aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Movement/MotionMaster.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Movement/MotionMaster.cpp')
-rwxr-xr-xsrc/server/game/Movement/MotionMaster.cpp106
1 files changed, 70 insertions, 36 deletions
diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp
index 6ef2e71d907..2a15eb58452 100755
--- a/src/server/game/Movement/MotionMaster.cpp
+++ b/src/server/game/Movement/MotionMaster.cpp
@@ -37,8 +37,7 @@ inline bool isStatic(MovementGenerator *mv)
return (mv == &si_idleMovement);
}
-void
-MotionMaster::Initialize()
+void MotionMaster::Initialize()
{
// clear ALL movement generators (including default)
while (!empty())
@@ -76,8 +75,7 @@ MotionMaster::~MotionMaster()
}
}
-void
-MotionMaster::UpdateMotion(uint32 diff)
+void MotionMaster::UpdateMotion(uint32 diff)
{
if (i_owner->HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED)) // what about UNIT_STAT_DISTRACTED? Why is this not included?
return;
@@ -113,8 +111,7 @@ MotionMaster::UpdateMotion(uint32 diff)
}
}
-void
-MotionMaster::DirectClean(bool reset)
+void MotionMaster::DirectClean(bool reset)
{
while (size() > 1)
{
@@ -129,8 +126,7 @@ MotionMaster::DirectClean(bool reset)
top()->Reset(*i_owner);
}
-void
-MotionMaster::DelayedClean()
+void MotionMaster::DelayedClean()
{
while (size() > 1)
{
@@ -141,8 +137,7 @@ MotionMaster::DelayedClean()
}
}
-void
-MotionMaster::DirectExpire(bool reset)
+void MotionMaster::DirectExpire(bool reset)
{
if (size() > 1)
{
@@ -162,8 +157,7 @@ MotionMaster::DirectExpire(bool reset)
top()->Reset(*i_owner);
}
-void
-MotionMaster::DelayedExpire()
+void MotionMaster::DelayedExpire()
{
if (size() > 1)
{
@@ -184,8 +178,7 @@ void MotionMaster::MoveIdle(MovementSlot slot)
Mutate(&si_idleMovement, slot);
}
-void
-MotionMaster::MoveRandom(float spawndist)
+void MotionMaster::MoveRandom(float spawndist)
{
if (i_owner->GetTypeId() == TYPEID_UNIT)
{
@@ -194,8 +187,7 @@ MotionMaster::MoveRandom(float spawndist)
}
}
-void
-MotionMaster::MoveTargetedHome()
+void MotionMaster::MoveTargetedHome()
{
//if (i_owner->HasUnitState(UNIT_STAT_FLEEING))
// return;
@@ -213,8 +205,7 @@ MotionMaster::MoveTargetedHome()
}
}
-void
-MotionMaster::MoveConfused()
+void MotionMaster::MoveConfused()
{
if (i_owner->GetTypeId() == TYPEID_PLAYER)
{
@@ -229,8 +220,7 @@ MotionMaster::MoveConfused()
}
}
-void
-MotionMaster::MoveChase(Unit* target, float dist, float angle)
+void MotionMaster::MoveChase(Unit* target, float dist, float angle)
{
// ignore movement request if target not exist
if (!target || target == i_owner || i_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
@@ -255,8 +245,7 @@ MotionMaster::MoveChase(Unit* target, float dist, float angle)
}
}
-void
-MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlot slot)
+void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlot slot)
{
// ignore movement request if target not exist
if (!target || target == i_owner || i_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
@@ -280,8 +269,7 @@ MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlot slo
}
}
-void
-MotionMaster::MovePoint(uint32 id, float x, float y, float z)
+void MotionMaster::MovePoint(uint32 id, float x, float y, float z)
{
if (i_owner->GetTypeId() == TYPEID_PLAYER)
{
@@ -296,6 +284,58 @@ MotionMaster::MovePoint(uint32 id, float x, float y, float z)
}
}
+void MotionMaster::MoveLand(uint32 id, Position const& pos, float speed)
+{
+ if (i_owner->GetTypeId() != TYPEID_UNIT)
+ return;
+
+ uint32 moveFlag = SPLINEFLAG_FLYING | SPLINEFLAG_ANIMATIONTIER;
+ uint32 moveTime = uint32(i_owner->GetExactDist(&pos) / speed) * IN_MILLISECONDS;
+
+ // CHARGING state makes the unit use m_TempSpeed and JUMPING prevents sending movement packet in PointMovementGenerator
+ i_owner->AddUnitState(UNIT_STAT_CHARGING | UNIT_STAT_JUMPING);
+ i_owner->m_TempSpeed = speed;
+
+ float x, y, z;
+ pos.GetPosition(x, y, z);
+ sLog->outStaticDebug("Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f)", i_owner->GetEntry(), id, x, y, z);
+ Mutate(new PointMovementGenerator<Creature>(id, x, y, z), MOTION_SLOT_ACTIVE);
+
+ MonsterMoveData data;
+ data.DestLocation.Relocate(pos);
+ data.SplineFlag = moveFlag;
+ data.Time = moveTime;
+ data.AnimationState = ANIMATION_ON_GROUND;
+
+ i_owner->SendMonsterMove(data);
+}
+
+void MotionMaster::MoveTakeoff(uint32 id, Position const& pos, float speed)
+{
+ if (i_owner->GetTypeId() != TYPEID_UNIT)
+ return;
+
+ uint32 moveFlag = SPLINEFLAG_FLYING | SPLINEFLAG_ANIMATIONTIER;
+ uint32 moveTime = uint32(i_owner->GetExactDist(&pos) / speed) * IN_MILLISECONDS;
+
+ // CHARGING state makes the unit use m_TempSpeed and JUMPING prevents sending movement packet in PointMovementGenerator
+ i_owner->AddUnitState(UNIT_STAT_CHARGING | UNIT_STAT_JUMPING);
+ i_owner->m_TempSpeed = speed;
+
+ float x, y, z;
+ pos.GetPosition(x, y, z);
+ sLog->outStaticDebug("Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f)", i_owner->GetEntry(), id, x, y, z);
+ Mutate(new PointMovementGenerator<Creature>(id, x, y, z), MOTION_SLOT_ACTIVE);
+
+ MonsterMoveData data;
+ data.DestLocation.Relocate(pos);
+ data.SplineFlag = moveFlag;
+ data.Time = moveTime;
+ data.AnimationState = ANIMATION_FLYING;
+
+ i_owner->SendMonsterMove(data);
+}
+
void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ)
{
//this function may make players fall below map
@@ -346,8 +386,7 @@ void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float spee
i_owner->SendMonsterMove(x, y, z, moveFlag, time, speedZ);
}
-void
-MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id)
+void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id)
{
if (Impl[MOTION_SLOT_CONTROLLED] && Impl[MOTION_SLOT_CONTROLLED]->GetMovementGeneratorType() != DISTRACT_MOTION_TYPE)
return;
@@ -375,8 +414,7 @@ void MotionMaster::MoveFall(float z, uint32 id)
MoveCharge(i_owner->GetPositionX(), i_owner->GetPositionY(), z, SPEED_CHARGE, id);
}
-void
-MotionMaster::MoveSeekAssistance(float x, float y, float z)
+void MotionMaster::MoveSeekAssistance(float x, float y, float z)
{
if (i_owner->GetTypeId() == TYPEID_PLAYER)
{
@@ -392,8 +430,7 @@ MotionMaster::MoveSeekAssistance(float x, float y, float z)
}
}
-void
-MotionMaster::MoveSeekAssistanceDistract(uint32 time)
+void MotionMaster::MoveSeekAssistanceDistract(uint32 time)
{
if (i_owner->GetTypeId() == TYPEID_PLAYER)
{
@@ -407,8 +444,7 @@ MotionMaster::MoveSeekAssistanceDistract(uint32 time)
}
}
-void
-MotionMaster::MoveFleeing(Unit* enemy, uint32 time)
+void MotionMaster::MoveFleeing(Unit* enemy, uint32 time)
{
if (!enemy)
return;
@@ -437,8 +473,7 @@ MotionMaster::MoveFleeing(Unit* enemy, uint32 time)
}
}
-void
-MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
+void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
{
if (i_owner->GetTypeId() == TYPEID_PLAYER)
{
@@ -461,8 +496,7 @@ MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
}
}
-void
-MotionMaster::MoveDistract(uint32 timer)
+void MotionMaster::MoveDistract(uint32 timer)
{
if (Impl[MOTION_SLOT_CONTROLLED])
return;