diff options
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 92bf97e9e02..b31eab7572c 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -47,6 +47,7 @@ #include "CellImpl.h" #include "Path.h" #include "CreatureGroups.h" +#include "Traveller.h" #include <math.h> @@ -276,28 +277,23 @@ void Unit::SendMonsterMoveWithSpeedToCurrentDestination(Player* player) { float x, y, z; if(GetMotionMaster()->GetDestination(x, y, z)) - SendMonsterMoveWithSpeed(x, y, z, GetUnitMovementFlags(), 0, player); + SendMonsterMoveWithSpeed(x, y, z, 0, player); } -void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 MovementFlags, uint32 transitTime, Player* player) +void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime, Player* player) { if (!transitTime) { - float dx = x - GetPositionX(); - float dy = y - GetPositionY(); - float dz = z - GetPositionZ(); - - float dist = ((dx*dx) + (dy*dy) + (dz*dz)); - if(dist<0) - dist = 0; + if(GetTypeId()==TYPEID_PLAYER) + { + Traveller<Player> traveller(*(Player*)this); + transitTime = traveller.GetTotalTrevelTimeTo(x,y,z); + } else - dist = sqrt(dist); - - double speed = GetSpeed((MovementFlags & MOVEMENTFLAG_WALK_MODE) ? MOVE_WALK : MOVE_RUN); - if(speed<=0) - speed = 2.5f; - speed *= 0.001f; - transitTime = static_cast<uint32>(dist / speed + 0.5); + { + Traveller<Creature> traveller(*(Creature*)this); + transitTime = traveller.GetTotalTrevelTimeTo(x,y,z); + } } //float orientation = (float)atan2((double)dy, (double)dx); SendMonsterMove(x, y, z, transitTime, player); |