From 51f0c70b7ea7eca2b0fcc05a38fa155b7378741f Mon Sep 17 00:00:00 2001 From: "shadowu@mail.bg" Date: Fri, 19 Dec 2008 00:37:40 +0200 Subject: *Movement Generators standardization. - bool GetDestination(&x,&y,&z) added to all movement generators.(it is used by update of players view distance) - Fixed when creature entering in combat not count this as StoppedByPlayer. - Random Movement Generator - added support for creating custom spawndist during the game. - Random Movement Generator - Db spawndist is checked only at initialize(NOT in each sellect of random location). - Added Random Movement to motion master - it can be called now by MoveRandom(spawndist) e.g. for use in SD2. - Home and Random movements no more using RespawnCoords(Home Position has implemented) - Fixed bug when creature is moving on path and enter combat, after that returns to spawn position. -Typo fix in Confused Movement Generator --HG-- branch : trunk --- src/game/RandomMovementGenerator.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/game/RandomMovementGenerator.cpp') diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp index 311cc7c6e17..db4f6bf5b42 100644 --- a/src/game/RandomMovementGenerator.cpp +++ b/src/game/RandomMovementGenerator.cpp @@ -21,6 +21,8 @@ #include "Creature.h" #include "MapManager.h" #include "RandomMovementGenerator.h" +#include "Traveller.h" +#include "ObjectAccessor.h" #include "DestinationHolderImp.h" #include "Map.h" #include "Util.h" @@ -42,9 +44,9 @@ template<> void RandomMovementGenerator::_setRandomLocation(Creature &creature) { - float X,Y,Z,z,nx,ny,nz,wander_distance,ori,dist; + float X,Y,Z,z,nx,ny,nz,ori,dist; - creature.GetRespawnCoord(X, Y, Z, &ori, &wander_distance); + creature.GetHomePosition(X, Y, Z, ori); z = creature.GetPositionZ(); uint32 mapid=creature.GetMapId(); @@ -120,8 +122,10 @@ RandomMovementGenerator::Initialize(Creature &creature) { if(!creature.isAlive()) return; - - if (creature.canFly()) + + wander_distance = creature.GetRespawnRadius(); + + if (creature.canFly()) creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); else creature.SetUnitMovementFlags(irand(0,RUNNING_CHANCE_RANDOMMV) > 0 ? MOVEMENTFLAG_WALK_MODE : MOVEMENTFLAG_NONE ); @@ -135,6 +139,10 @@ RandomMovementGenerator::Reset(Creature &creature) Initialize(creature); } +template<> +void +RandomMovementGenerator::Finalize(Creature &creature){} + template<> bool RandomMovementGenerator::Update(Creature &creature, const uint32 &diff) -- cgit v1.2.3