rendered paste bodyIndex: src/game/CreatureAI.h
===================================================================
--- src/game/CreatureAI.h (revision 5626)
+++ src/game/CreatureAI.h (working copy)
@@ -81,6 +81,9 @@
// Called when creature is spawned or respawned (for reseting variables)
virtual void JustRespawned() {}
+
+ // Called at waypoint reached or point movement finished
+ virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {}
};
struct SelectableAI : public FactoryHolder<CreatureAI>, public Permissible<Creature>
Index: src/game/Makefile.am
===================================================================
--- src/game/Makefile.am (revision 5626)
+++ src/game/Makefile.am (working copy)
@@ -185,6 +185,8 @@
Player.h \
PlayerDump.cpp \
PlayerDump.h \
+ PointMovementGenerator.cpp \
+ PointMovementGenerator.h \
QueryHandler.cpp \
QuestDef.cpp \
QuestDef.h \
Index: src/game/MotionMaster.h
===================================================================
--- src/game/MotionMaster.h (revision 5626)
+++ 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,61 @@
+/*
+* 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>
+void PointMovementGenerator<T>::Initialize(T &unit)
+{
+ unit.StopMoving();
+ Traveller<T> traveller(unit);
+ i_destinationHolder.SetDestination(traveller,x,y,z);
+}
+
+void PointMovementGenerator<Creature>::MovementInform(Creature &unit)
+{
+ unit.AI()->MovementInform(POINT_MOTION_TYPE, id);
+}
+
+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;
+}
\ No newline at end of file
Property changes on: src\game\PointMovementGenerator.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Index: src/game/PointMovementGenerator.h
===================================================================
--- src/game/PointMovementGenerator.h (revision 0)
+++ src/game/PointMovementGenerator.h (revision 0)
@@ -0,0 +1,55 @@
+/*
+* 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;
+};
+
+//template<>
+void MANGOS_DLL_SPEC PointMovementGenerator<Creature>::Initialize(Creature &unit);
+//template<>
+bool MANGOS_DLL_SPEC PointMovementGenerator<Creature>::Update(Creature &unit, const uint32 &diff);
+#endif
Property changes on: src\game\PointMovementGenerator.h
___________________________________________________________________
Name: svn:eol-style
+ native
Index: src/game/WaypointMovementGenerator.cpp
===================================================================
--- src/game/WaypointMovementGenerator.cpp (revision 5626)
+++ src/game/WaypointMovementGenerator.cpp (working copy)
@@ -37,6 +37,7 @@
#include "ObjectMgr.h"
#include "Creature.h"
#include "DestinationHolderImp.h"
+#include "CreatureAI.h"
#include <cassert>
@@ -98,7 +99,6 @@
tmpWPB->text[2] = text3;
tmpWPB->text[3] = text4;
tmpWPB->text[4] = text5;
- tmpWPB->aiscript = aiscript;
tmpWPB->orientation = orientation;
tmpWPB->emote = emote;
tmpWPB->spell = spell;
@@ -218,10 +218,6 @@
{
creature.SetUInt32Value(UNIT_NPC_EMOTESTATE,tmpBehavior->emote);
}
- if(!tmpBehavior->aiscript.empty())
- {
- WPAIScript(creature, tmpBehavior->aiscript);
- }
//sLog.outDebug("DEBUG: tmpBehavior->text[0] TEST");
if(!tmpBehavior->text[0].empty())
{
@@ -262,6 +258,7 @@
creature.SetDisplayId(tmpBehavior->model1);
}
tmpBehavior->HasDone = true;
+ MovementInform(creature);
} // HasDone == false
} // wpBehaviour found
} // i_creature.IsStopped()
@@ -304,49 +301,11 @@
return true;
}
-void
-WaypointMovementGenerator<Creature>::WPAIScript(Creature &pCreature, std::string pAiscript)
+void WaypointMovementGenerator<Creature>::MovementInform(Creature &unit)
{
- time_t curr;
- tm local;
- time(&curr); // get current time_t value
- local=*(localtime(&curr)); //
- int cT = ((local.tm_hour*100)+local.tm_min);
+ unit.AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode);
+}
- sLog.outDebug("WPAIScript: %s", pAiscript.c_str());
-
- if( pAiscript == "guard-sw") //demo script for WP-AI System
- {
- // 1423 - SW guard
- // 68 - SW city guard
- if((pCreature.GetEntry() == 68) || (pCreature.GetEntry() == 1423) )
- {
- if(!( (cT < 1800) && (cT > 800) )) //If time not smaller than 1800 and not bigger than 800 (24 hour format)
- { //try to set model of Off-hand (shield) to 0 (imo it doesn't work...)
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0);
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 2, 234948100);
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 2 + 1, 4);
-
- //set new Off-Hand Item as lamp
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 7557);
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 2, 385941508);
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 2 + 1, 7);
- } //else do it in other direction...
- else
- {
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0);
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 2, 385941508);
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 2 + 1, 7);
-
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 2080);
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 2, 234948100);
- pCreature.SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 2 + 1, 4);
- }
- }
- sLog.outDebug("guard-sw");
- } // guard-sw
-} // WPAIScript
-
std::set<uint32> WaypointMovementGenerator<Creature>::si_waypointHolders;
//----------------------------------------------------//
Index: src/game/WaypointMovementGenerator.h
===================================================================
--- src/game/WaypointMovementGenerator.h (revision 5626)
+++ src/game/WaypointMovementGenerator.h (working copy)
@@ -47,7 +47,6 @@
float orientation;
uint32 model1;
uint32 model2;
- std::string aiscript;
bool HasDone;
};
@@ -90,7 +89,6 @@
public:
WaypointMovementGenerator(Creature &) : i_nextMoveTime(0) {}
~WaypointMovementGenerator() { ClearWaypoints(); }
- void WPAIScript(Creature &pCreature, std::string pAiscript);
void Initialize(Creature &u)
{
i_nextMoveTime.Reset(0); // TODO: check the lower bound (0 is probably too small)
@@ -100,6 +98,9 @@
void Finalize(Creature &) {}
void Reset(Creature &u) { ReloadPath(u); }
bool Update(Creature &u, const uint32 &diff);
+
+ void MovementInform(Creature &);
+
MovementGeneratorType GetMovementGeneratorType() { return WAYPOINT_MOTION_TYPE; }
// now path movement implmementation
Index: win/VC71/game.vcproj
===================================================================
--- win/VC71/game.vcproj (revision 5626)
+++ win/VC71/game.vcproj (working copy)
@@ -640,6 +640,12 @@
RelativePath="..\..\src\game\Player.h">
</File>
<File
+ RelativePath="..\..\src\game\PointMovementGenerator.cpp">
+ </File>
+ <File
+ RelativePath="..\..\src\game\PointMovementGenerator.h">
+ </File>
+ <File
RelativePath="..\..\src\game\RandomMovementGenerator.cpp">
</File>
<File
Index: win/VC80/game.vcproj
===================================================================
--- win/VC80/game.vcproj (revision 5626)
+++ win/VC80/game.vcproj (working copy)
@@ -1027,6 +1027,14 @@
>
</File>
<File
+ RelativePath="..\..\src\game\PointMovementGenerator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\game\PointMovementGenerator.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\game\RandomMovementGenerator.cpp"
>
</File>
Index: win/VC90/game.vcproj
===================================================================
--- win/VC90/game.vcproj (revision 5626)
+++ 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>