aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Movement/MotionMaster.cpp
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2018-04-23 20:33:14 +0200
committerGitHub <noreply@github.com>2018-04-23 20:33:14 +0200
commit2a45418032233bc8779cdb44f9be6057c4b417c5 (patch)
tree69e950abd81d8151512570df98354f5506950501 /src/server/game/Movement/MotionMaster.cpp
parentbeb333738db0d493bf95994eb5557e174e5dd3a6 (diff)
Core/Movement: move MoveSplineInit (#21857)
The number of edge cases in which weirdness is seen on "effect movements" will be kinda reduced, plus consistency, plus movementInform on custom movement spline initalizations.
Diffstat (limited to 'src/server/game/Movement/MotionMaster.cpp')
-rw-r--r--src/server/game/Movement/MotionMaster.cpp216
1 files changed, 89 insertions, 127 deletions
diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp
index 122b7399ff4..281393f379e 100644
--- a/src/server/game/Movement/MotionMaster.cpp
+++ b/src/server/game/Movement/MotionMaster.cpp
@@ -20,6 +20,7 @@
#include "Creature.h"
#include "CreatureAISelector.h"
#include "DBCStores.h"
+#include "G3DPosition.hpp"
#include "Log.h"
#include "Map.h"
#include "MovementGenerator.h"
@@ -37,6 +38,7 @@
#include "FlightPathMovementGenerator.h"
#include "FollowMovementGenerator.h"
#include "FormationMovementGenerator.h"
+#include "GenericMovementGenerator.h"
#include "HomeMovementGenerator.h"
#include "IdleMovementGenerator.h"
#include "PointMovementGenerator.h"
@@ -219,26 +221,25 @@ void MotionMaster::MoveIdle()
void MotionMaster::MoveTargetedHome()
{
+ Creature* owner = _owner->ToCreature();
+ if (!owner)
+ {
+ TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveTargetedHome: '%s', attempted to move towards target home.", _owner->GetGUID().ToString().c_str());
+ return;
+ }
+
Clear(false);
- if (_owner->GetTypeId() == TYPEID_UNIT && !_owner->ToCreature()->GetCharmerOrOwnerGUID())
+ Unit* target = owner->GetCharmerOrOwner();
+ if (!target)
{
- TC_LOG_DEBUG("misc", "Creature (Entry: %u GUID: %u) targeted home.", _owner->GetEntry(), _owner->GetGUID().GetCounter());
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTargetedHome: '%s', targeted home.", _owner->GetGUID().ToString().c_str());
Mutate(new HomeMovementGenerator<Creature>(), MOTION_SLOT_ACTIVE);
}
- else if (_owner->GetTypeId() == TYPEID_UNIT && _owner->ToCreature()->GetCharmerOrOwnerGUID())
- {
- TC_LOG_DEBUG("misc", "Pet or controlled creature (Entry: %u GUID: %u) is targeting home.", _owner->GetEntry(), _owner->GetGUID().GetCounter());
- Unit* target = _owner->ToCreature()->GetCharmerOrOwner();
- if (target)
- {
- TC_LOG_DEBUG("misc", "Following %s (GUID: %u).", target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetTypeId() == TYPEID_PLAYER ? target->GetGUID().GetCounter() : ((Creature*)target)->GetSpawnId());
- Mutate(new FollowMovementGenerator(target, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE), MOTION_SLOT_ACTIVE);
- }
- }
else
{
- TC_LOG_ERROR("misc", "Player (GUID: %u) attempted to move towards target home.", _owner->GetGUID().GetCounter());
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTargetedHome: '%s', starts following '%s'", _owner->GetGUID().ToString().c_str(), target->GetGUID().ToString().c_str());
+ Mutate(new FollowMovementGenerator(target, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE), MOTION_SLOT_ACTIVE);
}
}
@@ -246,7 +247,7 @@ void MotionMaster::MoveRandom(float spawndist)
{
if (_owner->GetTypeId() == TYPEID_UNIT)
{
- TC_LOG_DEBUG("misc", "Creature (GUID: %u) started random movement.", _owner->GetGUID().GetCounter());
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveRandom: '%s', started random movement (spawnDist: %f)", _owner->GetGUID().ToString().c_str(), spawndist);
Mutate(new RandomMovementGenerator<Creature>(spawndist), MOTION_SLOT_IDLE);
}
}
@@ -257,12 +258,7 @@ void MotionMaster::MoveFollow(Unit* target, float dist, ChaseAngle angle, Moveme
if (!target || target == _owner)
return;
- TC_LOG_DEBUG("misc", "%s (Entry: %u, GUID: %u) follows %s (Entry %u, GUID: %u).",
- _owner->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature",
- _owner->GetEntry(), _owner->GetGUID().GetCounter(),
- target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature",
- target->GetEntry(), target->GetGUID().GetCounter());
-
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFollow: '%s', starts following '%s'", _owner->GetGUID().ToString().c_str(), target->GetGUID().ToString().c_str());
Mutate(new FollowMovementGenerator(target, dist, angle), slot);
}
@@ -272,11 +268,7 @@ void MotionMaster::MoveChase(Unit* target, Optional<ChaseRange> dist, Optional<C
if (!target || target == _owner)
return;
- TC_LOG_DEBUG("misc", "%s (Entry: %u, GUID: %u) chase to %s (Entry: %u, GUID: %u)",
- _owner->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature",
- _owner->GetEntry(), _owner->GetGUID().GetCounter(),
- target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature",
- target->GetEntry(), target->GetGUID().GetCounter());
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveChase: '%s', starts chasing '%s'", _owner->GetGUID().ToString().c_str(), target->GetGUID().ToString().c_str());
Mutate(new ChaseMovementGenerator(target, dist, angle), MOTION_SLOT_ACTIVE);
}
@@ -284,13 +276,12 @@ void MotionMaster::MoveConfused()
{
if (_owner->GetTypeId() == TYPEID_PLAYER)
{
- TC_LOG_DEBUG("misc", "Player (GUID: %u) move confused", _owner->GetGUID().GetCounter());
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveConfused: '%s', started confused movement.", _owner->GetGUID().ToString().c_str());
Mutate(new ConfusedMovementGenerator<Player>(), MOTION_SLOT_CONTROLLED);
}
else
{
- TC_LOG_DEBUG("misc", "Creature (Entry: %u GUID: %u) move confused",
- _owner->GetEntry(), _owner->GetGUID().GetCounter());
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveConfused: '%s', started confused movement.", _owner->GetGUID().ToString().c_str());
Mutate(new ConfusedMovementGenerator<Creature>(), MOTION_SLOT_CONTROLLED);
}
}
@@ -300,25 +291,16 @@ void MotionMaster::MoveFleeing(Unit* enemy, uint32 time)
if (!enemy)
return;
- if (_owner->GetTypeId() == TYPEID_PLAYER)
- {
- TC_LOG_DEBUG("misc", "Player (GUID: %u) flees from %s (GUID: %u).", _owner->GetGUID().GetCounter(),
- enemy->GetTypeId() == TYPEID_PLAYER ? "player" : "creature",
- enemy->GetTypeId() == TYPEID_PLAYER ? enemy->GetGUID().GetCounter() : enemy->ToCreature()->GetSpawnId());
- Mutate(new FleeingMovementGenerator<Player>(enemy->GetGUID()), MOTION_SLOT_CONTROLLED);
- }
- else
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFleeing: '%s', flees from '%s' (time: %u)", _owner->GetGUID().ToString().c_str(), enemy->GetGUID().ToString().c_str(), time);
+ if (_owner->GetTypeId() == TYPEID_UNIT)
{
- TC_LOG_DEBUG("misc", "Creature (Entry: %u GUID: %u) flees from %s (GUID: %u)%s.",
- _owner->GetEntry(), _owner->GetGUID().GetCounter(),
- enemy->GetTypeId() == TYPEID_PLAYER ? "player" : "creature",
- enemy->GetTypeId() == TYPEID_PLAYER ? enemy->GetGUID().GetCounter() : enemy->ToCreature()->GetSpawnId(),
- time ? " for a limited time" : "");
if (time)
Mutate(new TimedFleeingMovementGenerator(enemy->GetGUID(), time), MOTION_SLOT_CONTROLLED);
else
Mutate(new FleeingMovementGenerator<Creature>(enemy->GetGUID()), MOTION_SLOT_CONTROLLED);
}
+ else
+ Mutate(new FleeingMovementGenerator<Player>(enemy->GetGUID()), MOTION_SLOT_CONTROLLED);
}
void MotionMaster::MovePoint(uint32 id, Position const& pos, bool generatePath/* = true*/, Optional<float> finalOrient/* = {}*/)
@@ -330,13 +312,12 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generate
{
if (_owner->GetTypeId() == TYPEID_PLAYER)
{
- TC_LOG_DEBUG("misc", "Player (GUID: %u) targeted point (Id: %u X: %f Y: %f Z: %f).", _owner->GetGUID().GetCounter(), id, x, y, z);
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePoint: '%s', targeted point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, x, y, z);
Mutate(new PointMovementGenerator<Player>(id, x, y, z, generatePath, 0.0f, finalOrient), MOTION_SLOT_ACTIVE);
}
else
{
- TC_LOG_DEBUG("misc", "Creature (Entry: %u GUID: %u) targeted point (ID: %u X: %f Y: %f Z: %f).",
- _owner->GetEntry(), _owner->GetGUID().GetCounter(), id, x, y, z);
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePoint: '%s', targeted point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, x, y, z);
Mutate(new PointMovementGenerator<Creature>(id, x, y, z, generatePath, 0.0f, finalOrient), MOTION_SLOT_ACTIVE);
}
}
@@ -357,37 +338,28 @@ void MotionMaster::MoveCloserAndStop(uint32 id, Unit* target, float distance)
Movement::MoveSplineInit init(_owner);
init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
init.SetFacing(target);
- init.Launch();
- Mutate(new EffectMovementGenerator(id), MOTION_SLOT_ACTIVE);
+ Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id), MOTION_SLOT_ACTIVE);
}
}
void MotionMaster::MoveLand(uint32 id, Position const& pos)
{
- float x, y, z;
- pos.GetPosition(x, y, z);
-
- TC_LOG_DEBUG("misc", "Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f).", _owner->GetEntry(), id, x, y, z);
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveLand: '%s', landing point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
Movement::MoveSplineInit init(_owner);
- init.MoveTo(x, y, z);
+ init.MoveTo(PositionToVector3(pos));
init.SetAnimation(Movement::ToGround);
- init.Launch();
- Mutate(new EffectMovementGenerator(id), MOTION_SLOT_ACTIVE);
+ Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id), MOTION_SLOT_ACTIVE);
}
void MotionMaster::MoveTakeoff(uint32 id, Position const& pos)
{
- float x, y, z;
- pos.GetPosition(x, y, z);
-
- TC_LOG_DEBUG("misc", "Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f).", _owner->GetEntry(), id, x, y, z);
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTakeoff: '%s', landing point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
Movement::MoveSplineInit init(_owner);
- init.MoveTo(x, y, z);
+ init.MoveTo(PositionToVector3(pos));
init.SetAnimation(Movement::ToFly);
- init.Launch();
- Mutate(new EffectMovementGenerator(id), MOTION_SLOT_ACTIVE);
+ Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id), MOTION_SLOT_ACTIVE);
}
void MotionMaster::MoveCharge(float x, float y, float z, float speed /*= SPEED_CHARGE*/, uint32 id /*= EVENT_CHARGE*/, bool generatePath /*= false*/)
@@ -397,13 +369,12 @@ void MotionMaster::MoveCharge(float x, float y, float z, float speed /*= SPEED_C
if (_owner->GetTypeId() == TYPEID_PLAYER)
{
- TC_LOG_DEBUG("misc", "Player (GUID: %u) charged point (X: %f Y: %f Z: %f).", _owner->GetGUID().GetCounter(), x, y, z);
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveCharge: '%s', charging point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, x, y, z);
Mutate(new PointMovementGenerator<Player>(id, x, y, z, generatePath, speed), MOTION_SLOT_CONTROLLED);
}
else
{
- TC_LOG_DEBUG("misc", "Creature (Entry: %u GUID: %u) charged point (X: %f Y: %f Z: %f).",
- _owner->GetEntry(), _owner->GetGUID().GetCounter(), x, y, z);
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveCharge: '%s', charging point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, x, y, z);
Mutate(new PointMovementGenerator<Creature>(id, x, y, z, generatePath, speed), MOTION_SLOT_CONTROLLED);
}
}
@@ -423,7 +394,7 @@ void MotionMaster::MoveCharge(PathGenerator const& path, float speed /*= SPEED_C
void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ)
{
- //this function may make players fall below map
+ // this function may make players fall below map
if (_owner->GetTypeId() == TYPEID_PLAYER)
return;
@@ -442,23 +413,24 @@ void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, floa
init.SetParabolic(max_height, 0);
init.SetOrientationFixed(true);
init.SetVelocity(speedXY);
- init.Launch();
- Mutate(new EffectMovementGenerator(0), MOTION_SLOT_CONTROLLED);
+
+ Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, 0), MOTION_SLOT_CONTROLLED);
}
void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ)
{
- //this function may make players fall below map
+ // this function may make players fall below map
if (_owner->GetTypeId() == TYPEID_PLAYER)
return;
- float x, y, z;
+ float x, y, z = _owner->GetPositionZ();
float moveTimeHalf = speedZ / Movement::gravity;
float dist = 2 * moveTimeHalf * speedXY;
+
_owner->GetNearPoint2D(nullptr, x, y, dist, _owner->GetOrientation() + angle);
- z = _owner->GetPositionZ();
_owner->UpdateAllowedPositionZ(x, y, z);
+
MoveJump(x, y, z, 0.0f, speedXY, speedZ);
}
@@ -469,7 +441,7 @@ void MotionMaster::MoveJump(Position const& pos, float speedXY, float speedZ, ui
void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, float speedZ, uint32 id, bool hasOrientation /* = false*/)
{
- TC_LOG_DEBUG("misc", "Unit (GUID: %u) jumps to point (X: %f Y: %f Z: %f).", _owner->GetGUID().GetCounter(), x, y, z);
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveJump: '%s', jumps to point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, x, y, z);
if (speedXY < 0.01f)
return;
@@ -482,8 +454,8 @@ void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, f
init.SetVelocity(speedXY);
if (hasOrientation)
init.SetFacing(o);
- init.Launch();
- Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED);
+
+ Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id), MOTION_SLOT_CONTROLLED);
}
void MotionMaster::MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount)
@@ -520,7 +492,7 @@ void MotionMaster::MoveCirclePath(float x, float y, float z, float radius, bool
init.SetCyclic();
}
- init.Launch();
+ Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, 0), MOTION_SLOT_ACTIVE);
}
void MotionMaster::MoveSmoothPath(uint32 pointId, Position const* pathPoints, size_t pathSize, bool walk)
@@ -536,14 +508,11 @@ void MotionMaster::MoveSmoothPath(uint32 pointId, Position const* pathPoints, si
init.MovebyPath(path);
init.SetSmooth();
init.SetWalk(walk);
- init.Launch();
// This code is not correct
- // EffectMovementGenerator does not affect UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE
+ // GenericMovementGenerator does not affect UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE
// need to call PointMovementGenerator with various pointIds
- Mutate(new EffectMovementGenerator(pointId), MOTION_SLOT_ACTIVE);
- //Position pos(pathPoints[pathSize - 1].x, pathPoints[pathSize - 1].y, pathPoints[pathSize - 1].z);
- //MovePoint(EVENT_CHARGE_PREPATH, pos, false);
+ Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, pointId), MOTION_SLOT_ACTIVE);
}
void MotionMaster::MoveAlongSplineChain(uint32 pointId, uint16 dbChainId, bool walk)
@@ -551,13 +520,13 @@ void MotionMaster::MoveAlongSplineChain(uint32 pointId, uint16 dbChainId, bool w
Creature* owner = _owner->ToCreature();
if (!owner)
{
- TC_LOG_ERROR("misc", "MotionMaster::MoveAlongSplineChain: non-creature %s tried to walk along DB spline chain. Ignoring.", _owner->GetGUID().ToString().c_str());
+ TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveAlongSplineChain: '%s', tried to walk along DB spline chain. Ignoring.", _owner->GetGUID().ToString().c_str());
return;
}
std::vector<SplineChainLink> const* chain = sScriptSystemMgr->GetSplineChain(owner, dbChainId);
if (!chain)
{
- TC_LOG_ERROR("misc", "MotionMaster::MoveAlongSplineChain: creature with entry %u tried to walk along non-existing spline chain with DB id %u.", owner->GetEntry(), dbChainId);
+ TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveAlongSplineChain: '%s', tried to walk along non-existing spline chain with DB Id: %u.", _owner->GetGUID().ToString().c_str(), dbChainId);
return;
}
MoveAlongSplineChain(pointId, *chain, walk);
@@ -572,20 +541,20 @@ void MotionMaster::ResumeSplineChain(SplineChainResumeInfo const& info)
{
if (info.Empty())
{
- TC_LOG_ERROR("misc", "MotionMaster::ResumeSplineChain: unit with entry %u tried to resume a spline chain from empty info.", _owner->GetEntry());
+ TC_LOG_ERROR("movement.motionmaster", "MotionMaster::ResumeSplineChain: '%s', tried to resume a spline chain from empty info.", _owner->GetGUID().ToString().c_str());
return;
}
Mutate(new SplineChainMovementGenerator(info), MOTION_SLOT_ACTIVE);
}
-void MotionMaster::MoveFall(uint32 id /*=0*/)
+void MotionMaster::MoveFall(uint32 id/* = 0*/)
{
// use larger distance for vmap height search than in most other cases
float tz = _owner->GetMapHeight(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ(), true, MAX_FALL_DISTANCE);
if (tz <= INVALID_HEIGHT)
{
- TC_LOG_DEBUG("misc", "MotionMaster::MoveFall: unable to retrieve a proper height at map %u (x: %f, y: %f, z: %f).",
- _owner->GetMap()->GetId(), _owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ() + _owner->GetPositionZ());
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFall: '%s', unable to retrieve a proper height at map Id: %u (X: %f, Y: %f, Z: %f)",
+ _owner->GetGUID().ToString().c_str(), _owner->GetMap()->GetId(), _owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
return;
}
@@ -606,39 +575,32 @@ void MotionMaster::MoveFall(uint32 id /*=0*/)
Movement::MoveSplineInit init(_owner);
init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(), tz + _owner->GetHoverOffset(), false);
init.SetFall();
- init.Launch();
- Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED);
+ Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id), MOTION_SLOT_CONTROLLED);
}
void MotionMaster::MoveSeekAssistance(float x, float y, float z)
{
- if (_owner->GetTypeId() == TYPEID_PLAYER)
- {
- TC_LOG_ERROR("misc", "Player (GUID: %u) attempted to seek assistance.", _owner->GetGUID().GetCounter());
- }
- else
+ if (_owner->GetTypeId() == TYPEID_UNIT)
{
- TC_LOG_DEBUG("misc", "Creature (Entry: %u GUID: %u) seek assistance (X: %f Y: %f Z: %f)",
- _owner->GetEntry(), _owner->GetGUID().GetCounter(), x, y, z);
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveSeekAssistance: '%s', seeks assistance (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), x, y, z);
_owner->AttackStop();
_owner->CastStop();
_owner->ToCreature()->SetReactState(REACT_PASSIVE);
Mutate(new AssistanceMovementGenerator(x, y, z), MOTION_SLOT_ACTIVE);
}
+ else
+ TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveSeekAssistance: '%s', attempted to seek assistance.", _owner->GetGUID().ToString().c_str());
}
void MotionMaster::MoveSeekAssistanceDistract(uint32 time)
{
- if (_owner->GetTypeId() == TYPEID_PLAYER)
- {
- TC_LOG_ERROR("misc", "Player (GUID: %u) attempted to call distract assistance.", _owner->GetGUID().GetCounter());
- }
- else
+ if (_owner->GetTypeId() == TYPEID_UNIT)
{
- TC_LOG_DEBUG("misc", "Creature (Entry: %u GUID: %u) is distracted after assistance call (Time: %u).",
- _owner->GetEntry(), _owner->GetGUID().GetCounter(), time);
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveSeekAssistanceDistract: '%s', is distracted after assistance call (Time: %u)", _owner->GetGUID().ToString().c_str(), time);
Mutate(new AssistanceDistractMovementGenerator(time), MOTION_SLOT_ACTIVE);
}
+ else
+ TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveSeekAssistanceDistract: '%s', attempted to call distract assistance.", _owner->GetGUID().ToString().c_str());
}
void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
@@ -647,22 +609,16 @@ void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
{
if (path < sTaxiPathNodesByPath.size())
{
- TC_LOG_DEBUG("misc", "%s taxi to (Path %u node %u).", _owner->GetName().c_str(), path, pathnode);
- FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(pathnode);
- mgen->LoadPath(_owner->ToPlayer());
- Mutate(mgen, MOTION_SLOT_CONTROLLED);
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTaxiFlight: '%s', taxi to path Id: %u (node %u)", _owner->GetGUID().ToString().c_str(), path, pathnode);
+ FlightPathMovementGenerator* movement = new FlightPathMovementGenerator(pathnode);
+ movement->LoadPath(_owner->ToPlayer());
+ Mutate(movement, MOTION_SLOT_CONTROLLED);
}
else
- {
- TC_LOG_ERROR("misc", "%s attempted taxi to (non-existing Path %u node %u).",
- _owner->GetName().c_str(), path, pathnode);
- }
+ TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveTaxiFlight: '%s', attempted taxi to non-existing path Id: %u (node: %u)", _owner->GetGUID().ToString().c_str(), path, pathnode);
}
else
- {
- TC_LOG_ERROR("misc", "Creature (Entry: %u GUID: %u) attempted taxi to (Path %u node %u).",
- _owner->GetEntry(), _owner->GetGUID().GetCounter(), path, pathnode);
- }
+ TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveTaxiFlight: '%s', attempted taxi to path Id: %u (node: %u)", _owner->GetGUID().ToString().c_str(), path, pathnode);
}
void MotionMaster::MoveDistract(uint32 timer)
@@ -671,17 +627,11 @@ void MotionMaster::MoveDistract(uint32 timer)
return;
if (_owner->GetTypeId() == TYPEID_PLAYER)
- {
- TC_LOG_DEBUG("misc", "Player (GUID: %u) distracted (timer: %u).", _owner->GetGUID().GetCounter(), timer);
- }
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveDistract: '%s', distracted (timer: %u)", _owner->GetGUID().ToString().c_str(), timer);
else
- {
- TC_LOG_DEBUG("misc", "Creature (Entry: %u GUID: %u) distracted (timer: %u)",
- _owner->GetEntry(), _owner->GetGUID().GetCounter(), timer);
- }
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveDistract: '%s', distracted (timer: %u)", _owner->GetGUID().ToString().c_str(), timer);
- DistractMovementGenerator* mgen = new DistractMovementGenerator(timer);
- Mutate(mgen, MOTION_SLOT_CONTROLLED);
+ Mutate(new DistractMovementGenerator(timer), MOTION_SLOT_CONTROLLED);
}
void MotionMaster::MovePath(uint32 pathId, bool repeatable)
@@ -689,16 +639,14 @@ void MotionMaster::MovePath(uint32 pathId, bool repeatable)
if (!pathId)
return;
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePath: '%s', starts moving over path Id: %u (repeatable: %s)", _owner->GetGUID().ToString().c_str(), pathId, repeatable ? "YES" : "NO");
Mutate(new WaypointMovementGenerator<Creature>(pathId, repeatable), MOTION_SLOT_IDLE);
-
- TC_LOG_DEBUG("misc", "%s (GUID: %u) starts moving over path(Id:%u, repeatable: %s).", _owner->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature", _owner->GetGUID().GetCounter(), pathId, repeatable ? "YES" : "NO");
}
void MotionMaster::MovePath(WaypointPath& path, bool repeatable)
{
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePath: '%s', starts moving over path Id: %u (repeatable: %s)", _owner->GetGUID().ToString().c_str(), path.id, repeatable ? "YES" : "NO");
Mutate(new WaypointMovementGenerator<Creature>(path, repeatable), MOTION_SLOT_IDLE);
-
- TC_LOG_DEBUG("misc", "%s (GUID: %u) start moving over path(repeatable: %s)", _owner->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature", _owner->GetGUID().GetCounter(), repeatable ? "YES" : "NO");
}
void MotionMaster::MoveRotate(uint32 time, RotateDirection direction)
@@ -706,6 +654,7 @@ void MotionMaster::MoveRotate(uint32 time, RotateDirection direction)
if (!time)
return;
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveRotate: '%s', starts rotate (time: %u, direction: %u)", _owner->GetGUID().ToString().c_str(), time, direction);
Mutate(new RotateMovementGenerator(time, direction), MOTION_SLOT_ACTIVE);
}
@@ -713,11 +662,23 @@ void MotionMaster::MoveFormation(uint32 id, Position destination, uint32 moveTyp
{
if (_owner->GetTypeId() == TYPEID_UNIT)
{
- TC_LOG_DEBUG("misc", "MotionMaster::MoveFormation: creature (GUID: %u) targeted point (Id: %u X: %f Y: %f Z: %f).", _owner->GetGUID().GetCounter(), id, destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ());
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFormation: '%s', targeted point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ());
Mutate(new FormationMovementGenerator(id, destination, moveType, forceRun, forceOrientation), MOTION_SLOT_ACTIVE);
}
}
+void MotionMaster::LaunchMoveSpline(Movement::MoveSplineInit&& init, uint32 id/*= 0*/, MovementSlot slot/*= MOTION_SLOT_ACTIVE*/, MovementGeneratorType type/*= EFFECT_MOTION_TYPE*/)
+{
+ if (IsInvalidMovementGeneratorType(type))
+ {
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::LaunchMoveSpline: '%s', tried to launch a spline with an invalid MovementGeneratorType: %u (Id: %u, Slot: %u)", _owner->GetGUID().ToString().c_str(), type, id, slot);
+ return;
+ }
+
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::LaunchMoveSpline: '%s', initiates spline Id: %u (Type: %u, Slot: %u)", _owner->GetGUID().ToString().c_str(), id, type, slot);
+ Mutate(new GenericMovementGenerator(std::move(init), type, id), slot);
+}
+
/******************** Private methods ********************/
void MotionMaster::pop()
@@ -864,13 +825,14 @@ void MotionMaster::DirectDelete(MovementGenerator* curr)
{
if (IsStatic(curr))
return;
+
curr->Finalize(_owner);
delete curr;
}
void MotionMaster::DelayedDelete(MovementGenerator* curr)
{
- TC_LOG_DEBUG("misc", "MotionMaster::DelayedDelete: unit (%u) delayed deleting movement generator (type %u)", _owner->GetEntry(), curr->GetMovementGeneratorType());
+ TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::DelayedDelete: '%s', delayed deleting movement generator (type: %u)", _owner->GetGUID().ToString().c_str(), curr->GetMovementGeneratorType());
if (IsStatic(curr))
return;