All pastes #982881 Raw Edit

Someone

public text v1 · immutable
·published 2008-04-12 22:00 UTC
rendered paste body
Index: src/game/AggressorAI.cpp
===================================================================
--- src/game/AggressorAI.cpp	(revision 5609)
+++ src/game/AggressorAI.cpp	(working copy)
@@ -21,6 +21,7 @@
 #include "Creature.h"
 #include "Player.h"
 #include "TargetedMovementGenerator.h"
+#include "PointMovementGenerator.h"
 #include "ObjectAccessor.h"
 #include "VMapFactory.h"
 #include "World.h"
Index: src/game/CreatureAI.h
===================================================================
--- src/game/CreatureAI.h	(revision 5609)
+++ src/game/CreatureAI.h	(working copy)
@@ -81,6 +81,8 @@
 
         // Called when creature is spawned or respawned (for reseting variables)
         virtual void JustRespawned() {}
+
+        virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {}
 };
 
 struct SelectableAI : public FactoryHolder<CreatureAI>, public Permissible<Creature>
Index: src/game/MotionMaster.h
===================================================================
--- src/game/MotionMaster.h	(revision 5609)
+++ src/game/MotionMaster.h	(working copy)
@@ -38,7 +38,8 @@
     CONFUSED_MOTION_TYPE  = 4,                              // ConfusedMovementGenerator.h
     TARGETED_MOTION_TYPE  = 5,                              // TargetedMovementGenerator.h
     HOME_MOTION_TYPE      = 6,                              // HomeMovementGenerator.h
-    FLIGHT_MOTION_TYPE    = 7                               // WaypointMovementGenerator.h
+    FLIGHT_MOTION_TYPE    = 7,                              // WaypointMovementGenerator.h
+    POINT_MOTION_TYPE     = 8,                              // PointMovementGenerator.h
 };
 
 class MANGOS_DLL_SPEC MotionMaster : private std::stack<MovementGenerator *>
Index: src/game/PointMovementGenerator.cpp
===================================================================
--- src/game/PointMovementGenerator.cpp	(revision 0)
+++ src/game/PointMovementGenerator.cpp	(revision 0)
@@ -0,0 +1,96 @@
+/* 
+* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include "PointMovementGenerator.h"
+#include "Errors.h"
+#include "Creature.h"
+#include "CreatureAI.h"
+#include "MapManager.h"
+#include "DestinationHolderImp.h"
+
+//----- Point Movement Generator
+template<class T>
+bool PointMovementGenerator<T>::Update(T &unit, const uint32 &diff)
+{
+    if(!&unit)
+        return false;
+
+    if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED))
+        return true;
+
+    Traveller<T> traveller(unit);
+
+    i_destinationHolder.UpdateTraveller(traveller, diff, false);
+
+    if(i_destinationHolder.HasArrived())
+    {
+        unit.StopMoving();
+        MovementInform(unit);
+        return false;    
+    }
+
+    return true;
+}
+
+template<class T>
+void PointMovementGenerator<T>::Initialize(T &unit)
+{
+    unit.StopMoving();
+    Traveller<T> traveller(unit);
+    i_destinationHolder.SetDestination(traveller,x,y,z);
+}
+
+template<class T>
+void PointMovementGenerator<T>::MovementInform(T &unit)
+{
+
+}
+
+void PointMovementGenerator<Creature>::MovementInform(Creature &unit)
+{
+    unit.AI()->MovementInform(POINT_MOTION_TYPE, id);
+}
+
+bool PointMovementGenerator<Creature>::Update(Creature &unit, const uint32 &diff)
+{
+    if(!&unit)
+        return false;
+
+    if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED))
+        return true;
+
+    Traveller<Creature> traveller(unit);
+
+    i_destinationHolder.UpdateTraveller(traveller, diff, false);
+
+    if(i_destinationHolder.HasArrived())
+    {
+        unit.StopMoving();
+        MovementInform(unit);
+        return false;    
+    }
+
+    return true;
+}
+
+void PointMovementGenerator<Creature>::Initialize(Creature &unit)
+{
+    unit.StopMoving();
+    Traveller<Creature> traveller(unit);
+    i_destinationHolder.SetDestination(traveller,x,y,z);
+}
\ No newline at end of file
Index: src/game/PointMovementGenerator.h
===================================================================
--- src/game/PointMovementGenerator.h	(revision 0)
+++ src/game/PointMovementGenerator.h	(revision 0)
@@ -0,0 +1,50 @@
+/* 
+* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#ifndef MANGOS_POINTMOVEMENTGENERATOR_H
+#define MANGOS_POINTMOVEMENTGENERATOR_H
+
+#include "MovementGenerator.h"
+#include "DestinationHolder.h"
+#include "Traveller.h"
+#include "FollowerReference.h"
+
+template<class T>
+class MANGOS_DLL_SPEC PointMovementGenerator
+    : public MovementGeneratorMedium< T, PointMovementGenerator<T> >
+{
+public:
+    PointMovementGenerator(uint32 _id, float _x, float _y, float _z) : id(_id), 
+        x(_x), y(_y), z(_z), i_nextMoveTime(0) {}
+
+    void Initialize(T &);
+    void Finalize(T &) {}
+    void Reset(T &unit) { unit.StopMoving(); }
+    bool Update(T &, const uint32 &diff);
+
+    void MovementInform(T &);
+
+    MovementGeneratorType GetMovementGeneratorType() { return POINT_MOTION_TYPE; }
+
+private:
+    TimeTracker i_nextMoveTime;
+    float x,y,z;
+    uint32 id;
+    DestinationHolder< Traveller<T> > i_destinationHolder;
+};
+#endif
Index: win/VC90/game.vcproj
===================================================================
--- win/VC90/game.vcproj	(revision 5609)
+++ win/VC90/game.vcproj	(working copy)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9,00"
+	Version="9.00"
 	Name="game"
 	ProjectGUID="{1DC6C4DA-A028-41F3-877D-D5400C594F88}"
 	RootNamespace="game"
@@ -1032,6 +1032,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\game\PointMovementGenerator.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\game\PointMovementGenerator.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\game\RandomMovementGenerator.cpp"
 				>
 			</File>