TrinityCore
MotionMaster Class Reference

#include <MotionMaster.h>

Public Member Functions

 MotionMaster (Unit *unit)
 
 ~MotionMaster ()
 
bool empty () const
 
int size () const
 
MovementGeneratortop () const
 
void Initialize ()
 
void InitDefault ()
 
void UpdateMotion (uint32 diff)
 
void Clear (bool reset=true)
 
void Clear (MovementSlot slot)
 
void MovementExpired (bool reset=true)
 
MovementGeneratorType GetCurrentMovementGeneratorType () const
 
MovementGeneratorType GetMotionSlotType (MovementSlot slot) const
 
MovementGeneratorGetMotionSlot (MovementSlot slot) const
 
void PropagateSpeedChange ()
 
bool GetDestination (float &x, float &y, float &z)
 
void MoveIdle ()
 
void MoveTargetedHome ()
 
void MoveRandom (float spawndist=0.0f)
 
void MoveFollow (Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
 
void MoveChase (Unit *target, float dist=0.0f, float angle=0.0f)
 
void MoveConfused ()
 
void MoveFleeing (Unit *enemy, uint32 time=0)
 
void MovePoint (uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
 
void MovePoint (uint32 id, float x, float y, float z, bool generatePath=true, Optional< float > finalOrient={})
 
void MoveCloserAndStop (uint32 id, Unit *target, float distance)
 
void MoveLand (uint32 id, Position const &pos)
 
void MoveTakeoff (uint32 id, Position const &pos)
 
void MoveCharge (float x, float y, float z, float speed=SPEED_CHARGE, uint32 id=EVENT_CHARGE, bool generatePath=false, Unit const *target=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
 
void MoveCharge (PathGenerator const &path, float speed=SPEED_CHARGE, Unit const *target=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
 
void MoveKnockbackFrom (float srcX, float srcY, float speedXY, float speedZ, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
 
void MoveJumpTo (float angle, float speedXY, float speedZ)
 
void MoveJump (Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, JumpArrivalCastArgs const *arrivalCast=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
 
void MoveJump (float x, float y, float z, float o, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, JumpArrivalCastArgs const *arrivalCast=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
 
void MoveCirclePath (float x, float y, float z, float radius, bool clockwise, uint8 stepCount)
 
void MoveSmoothPath (uint32 pointId, Position const *pathPoints, size_t pathSize, bool walk=false, bool fly=false)
 
void MoveAlongSplineChain (uint32 pointId, uint16 dbChainId, bool walk)
 
void MoveAlongSplineChain (uint32 pointId, std::vector< SplineChainLink > const &chain, bool walk)
 
void ResumeSplineChain (SplineChainResumeInfo const &info)
 
void MoveFall (uint32 id=0)
 
void MoveSeekAssistance (float x, float y, float z)
 
void MoveSeekAssistanceDistract (uint32 timer)
 
void MoveTaxiFlight (uint32 path, uint32 pathnode)
 
void MoveDistract (uint32 time)
 
void MovePath (uint32 pathId, bool repeatable)
 
void MovePath (WaypointPath &path, bool repeatable)
 
void MoveRotate (uint32 time, RotateDirection direction)
 
void MoveFormation (uint32 id, Position destination, uint32 moveType, bool forceRun=false, bool forceOrientation=false)
 

Private Types

typedef std::vector< MovementGenerator * > MovementList
 

Private Member Functions

void pop ()
 
bool NeedInitTop () const
 
void InitTop ()
 
void Mutate (MovementGenerator *m, MovementSlot slot)
 
void DirectClean (bool reset)
 
void DelayedClean ()
 
void DirectClean (MovementSlot slot)
 
void DelayedClean (MovementSlot slot)
 
void DirectExpire (bool reset)
 
void DelayedExpire ()
 
void DirectDelete (MovementGenerator *curr)
 
void DelayedDelete (MovementGenerator *curr)
 
void ClearExpireList ()
 

Private Attributes

MovementGenerator_slot [MAX_MOTION_SLOT]
 
bool _initialize [MAX_MOTION_SLOT]
 
MovementList _expireList
 
Unit_owner
 
int _top
 
uint8 _cleanFlag
 

Member Typedef Documentation

◆ MovementList

typedef std::vector<MovementGenerator*> MotionMaster::MovementList
private

Constructor & Destructor Documentation

◆ MotionMaster()

MotionMaster::MotionMaster ( Unit unit)
inlineexplicit
105  : _owner(unit), _top(-1), _cleanFlag(MMCF_NONE)
106  {
107  for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
108  {
109  _slot[i] = nullptr;
110  _initialize[i] = true;
111  }
112  }
uint8 _cleanFlag
Definition: MotionMaster.h:211
MovementGenerator * _slot[MAX_MOTION_SLOT]
Definition: MotionMaster.h:206
Definition: MotionMaster.h:85
bool _initialize[MAX_MOTION_SLOT]
Definition: MotionMaster.h:207
Definition: MotionMaster.h:80
int _top
Definition: MotionMaster.h:210
uint8_t uint8
Definition: Define.h:154
Unit * _owner
Definition: MotionMaster.h:209

◆ ~MotionMaster()

MotionMaster::~MotionMaster ( )
53 {
54  // clear ALL movement generators (including default)
55  while (!empty())
56  {
57  MovementGenerator* movement = top();
58  pop();
59  if (movement && !IsStatic(movement))
60  delete movement;
61  }
62 
63  while (!_expireList.empty())
64  {
65  delete _expireList.back();
66  _expireList.pop_back();
67  }
68 }
void pop()
Definition: MotionMaster.cpp:736
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
MovementList _expireList
Definition: MotionMaster.h:208
bool IsStatic(MovementGenerator *movement)
Definition: MotionMaster.cpp:47
Definition: MovementGenerator.h:29
+ Here is the call graph for this function:

Member Function Documentation

◆ Clear() [1/2]

void MotionMaster::Clear ( bool  reset = true)
111 {
112  if (_cleanFlag & MMCF_UPDATE)
113  {
114  if (reset)
116  else
118  DelayedClean();
119  }
120  else
121  DirectClean(reset);
122 }
void DirectClean(bool reset)
Definition: MotionMaster.cpp:784
uint8 _cleanFlag
Definition: MotionMaster.h:211
Definition: MotionMaster.h:86
Definition: MotionMaster.h:87
void DelayedClean()
Definition: MotionMaster.cpp:803
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Clear() [2/2]

void MotionMaster::Clear ( MovementSlot  slot)
125 {
126  if (empty() || slot >= MAX_MOTION_SLOT)
127  return;
128 
129  if (_cleanFlag & MMCF_UPDATE)
130  DelayedClean(slot);
131  else
132  DirectClean(slot);
133 }
void DirectClean(bool reset)
Definition: MotionMaster.cpp:784
uint8 _cleanFlag
Definition: MotionMaster.h:211
bool empty() const
Definition: MotionMaster.h:115
Definition: MotionMaster.h:80
Definition: MotionMaster.h:86
void DelayedClean()
Definition: MotionMaster.cpp:803
+ Here is the call graph for this function:

◆ ClearExpireList()

void MotionMaster::ClearExpireList ( )
private
894 {
895  for (auto itr : _expireList)
896  DirectDelete(itr);
897 
898  _expireList.clear();
899 
900  if (empty())
901  Initialize();
902  else if (NeedInitTop())
903  InitTop();
904  else if (_cleanFlag & MMCF_RESET)
905  top()->Reset(_owner);
906 
907  _cleanFlag &= ~MMCF_RESET;
908 }
uint8 _cleanFlag
Definition: MotionMaster.h:211
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
bool NeedInitTop() const
Definition: MotionMaster.cpp:746
void InitTop()
Definition: MotionMaster.cpp:753
void DirectDelete(MovementGenerator *curr)
Definition: MotionMaster.cpp:876
MovementList _expireList
Definition: MotionMaster.h:208
Definition: MotionMaster.h:87
virtual void Reset(Unit *)=0
void Initialize()
Definition: MotionMaster.cpp:70
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DelayedClean() [1/2]

void MotionMaster::DelayedClean ( )
private
804 {
805  while (size() > 1)
806  {
807  MovementGenerator* curr = top();
808  pop();
809  if (curr)
810  DelayedDelete(curr);
811  }
812 }
void pop()
Definition: MotionMaster.cpp:736
MovementGenerator * top() const
Definition: MotionMaster.h:117
int size() const
Definition: MotionMaster.h:116
void DelayedDelete(MovementGenerator *curr)
Definition: MotionMaster.cpp:884
Definition: MovementGenerator.h:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DelayedClean() [2/2]

void MotionMaster::DelayedClean ( MovementSlot  slot)
private
832 {
833  if (MovementGenerator* motion = GetMotionSlot(slot))
834  {
835  _slot[slot] = nullptr;
836  DelayedDelete(motion);
837  }
838 
839  while (!empty() && !top())
840  --_top;
841 }
MovementGenerator * GetMotionSlot(MovementSlot slot) const
Definition: MotionMaster.cpp:165
MovementGenerator * _slot[MAX_MOTION_SLOT]
Definition: MotionMaster.h:206
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
void DelayedDelete(MovementGenerator *curr)
Definition: MotionMaster.cpp:884
int _top
Definition: MotionMaster.h:210
Definition: MovementGenerator.h:29
+ Here is the call graph for this function:

◆ DelayedDelete()

void MotionMaster::DelayedDelete ( MovementGenerator curr)
private
885 {
886  TC_LOG_DEBUG("misc", "MotionMaster::DelayedDelete: unit (%u) delayed deleting movement generator (type %u)", _owner->GetEntry(), curr->GetMovementGeneratorType());
887  if (IsStatic(curr))
888  return;
889 
890  _expireList.push_back(curr);
891 }
virtual MovementGeneratorType GetMovementGeneratorType() const =0
MovementList _expireList
Definition: MotionMaster.h:208
uint32 GetEntry() const
Definition: Object.h:155
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
bool IsStatic(MovementGenerator *movement)
Definition: MotionMaster.cpp:47
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DelayedExpire()

void MotionMaster::DelayedExpire ( )
private
864 {
865  if (size() > 1)
866  {
867  MovementGenerator* curr = top();
868  pop();
869  DelayedDelete(curr);
870  }
871 
872  while (!empty() && !top())
873  --_top;
874 }
void pop()
Definition: MotionMaster.cpp:736
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
int size() const
Definition: MotionMaster.h:116
void DelayedDelete(MovementGenerator *curr)
Definition: MotionMaster.cpp:884
int _top
Definition: MotionMaster.h:210
Definition: MovementGenerator.h:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DirectClean() [1/2]

void MotionMaster::DirectClean ( bool  reset)
private
785 {
786  while (size() > 1)
787  {
788  MovementGenerator* curr = top();
789  pop();
790  if (curr)
791  DirectDelete(curr);
792  }
793 
794  if (empty())
795  return;
796 
797  if (NeedInitTop())
798  InitTop();
799  else if (reset)
800  top()->Reset(_owner);
801 }
void pop()
Definition: MotionMaster.cpp:736
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
bool NeedInitTop() const
Definition: MotionMaster.cpp:746
int size() const
Definition: MotionMaster.h:116
void InitTop()
Definition: MotionMaster.cpp:753
void DirectDelete(MovementGenerator *curr)
Definition: MotionMaster.cpp:876
virtual void Reset(Unit *)=0
Definition: MovementGenerator.h:29
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DirectClean() [2/2]

void MotionMaster::DirectClean ( MovementSlot  slot)
private
815 {
816  if (MovementGenerator* motion = GetMotionSlot(slot))
817  {
818  _slot[slot] = nullptr;
819  DirectDelete(motion);
820  }
821 
822  while (!empty() && !top())
823  --_top;
824 
825  if (empty())
826  Initialize();
827  else if (NeedInitTop())
828  InitTop();
829 }
MovementGenerator * GetMotionSlot(MovementSlot slot) const
Definition: MotionMaster.cpp:165
MovementGenerator * _slot[MAX_MOTION_SLOT]
Definition: MotionMaster.h:206
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
bool NeedInitTop() const
Definition: MotionMaster.cpp:746
int _top
Definition: MotionMaster.h:210
void InitTop()
Definition: MotionMaster.cpp:753
void DirectDelete(MovementGenerator *curr)
Definition: MotionMaster.cpp:876
Definition: MovementGenerator.h:29
void Initialize()
Definition: MotionMaster.cpp:70
+ Here is the call graph for this function:

◆ DirectDelete()

void MotionMaster::DirectDelete ( MovementGenerator curr)
private
877 {
878  if (IsStatic(curr))
879  return;
880  curr->Finalize(_owner);
881  delete curr;
882 }
virtual void Finalize(Unit *)=0
bool IsStatic(MovementGenerator *movement)
Definition: MotionMaster.cpp:47
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DirectExpire()

void MotionMaster::DirectExpire ( bool  reset)
private
844 {
845  if (size() > 1)
846  {
847  MovementGenerator* curr = top();
848  pop();
849  DirectDelete(curr);
850  }
851 
852  while (!empty() && !top())
853  --_top;
854 
855  if (empty())
856  Initialize();
857  else if (NeedInitTop())
858  InitTop();
859  else if (reset)
860  top()->Reset(_owner);
861 }
void pop()
Definition: MotionMaster.cpp:736
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
bool NeedInitTop() const
Definition: MotionMaster.cpp:746
int size() const
Definition: MotionMaster.h:116
int _top
Definition: MotionMaster.h:210
void InitTop()
Definition: MotionMaster.cpp:753
void DirectDelete(MovementGenerator *curr)
Definition: MotionMaster.cpp:876
virtual void Reset(Unit *)=0
Definition: MovementGenerator.h:29
void Initialize()
Definition: MotionMaster.cpp:70
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ empty()

bool MotionMaster::empty ( ) const
inline
115 { return (_top < 0); }
int _top
Definition: MotionMaster.h:210
+ Here is the caller graph for this function:

◆ GetCurrentMovementGeneratorType()

MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType ( ) const
150 {
151  if (empty())
152  return IDLE_MOTION_TYPE;
153 
154  return top()->GetMovementGeneratorType();
155 }
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
Definition: MotionMaster.h:53
virtual MovementGeneratorType GetMovementGeneratorType() const =0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDestination()

bool MotionMaster::GetDestination ( float &  x,
float &  y,
float &  z 
)
186 {
187  if (_owner->movespline->Finalized())
188  return false;
189 
190  G3D::Vector3 const& dest = _owner->movespline->FinalDestination();
191  x = dest.x;
192  y = dest.y;
193  z = dest.z;
194  return true;
195 }
Movement::MoveSpline * movespline
Definition: Unit.h:1805
bool Finalized() const
Definition: MoveSpline.h:133
Vector3 const & FinalDestination() const
Definition: MoveSpline.h:136
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMotionSlot()

MovementGenerator * MotionMaster::GetMotionSlot ( MovementSlot  slot) const
166 {
167  if (empty() || slot >= MAX_MOTION_SLOT || !_slot[slot])
168  return nullptr;
169 
170  return _slot[slot];
171 }
MovementGenerator * _slot[MAX_MOTION_SLOT]
Definition: MotionMaster.h:206
bool empty() const
Definition: MotionMaster.h:115
Definition: MotionMaster.h:80
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMotionSlotType()

MovementGeneratorType MotionMaster::GetMotionSlotType ( MovementSlot  slot) const
158 {
159  if (empty() || slot >= MAX_MOTION_SLOT || !_slot[slot])
160  return MAX_MOTION_TYPE;
161 
162  return _slot[slot]->GetMovementGeneratorType();
163 }
MovementGenerator * _slot[MAX_MOTION_SLOT]
Definition: MotionMaster.h:206
bool empty() const
Definition: MotionMaster.h:115
virtual MovementGeneratorType GetMovementGeneratorType() const =0
Definition: MotionMaster.h:80
Definition: MotionMaster.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InitDefault()

void MotionMaster::InitDefault ( )
86 {
88 }
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
MovementGenerator * SelectMovementGenerator(Unit *unit)
Definition: CreatureAISelector.cpp:101
Definition: MotionMaster.h:77
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Initialize()

void MotionMaster::Initialize ( )
71 {
72  // clear ALL movement generators (including default)
73  while (!empty())
74  {
75  MovementGenerator* curr = top();
76  pop();
77  if (curr)
78  DirectDelete(curr);
79  }
80 
81  InitDefault();
82 }
void pop()
Definition: MotionMaster.cpp:736
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
void InitDefault()
Definition: MotionMaster.cpp:85
void DirectDelete(MovementGenerator *curr)
Definition: MotionMaster.cpp:876
Definition: MovementGenerator.h:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InitTop()

void MotionMaster::InitTop ( )
private
754 {
755  top()->Initialize(_owner);
756  _initialize[_top] = false;
757 }
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool _initialize[MAX_MOTION_SLOT]
Definition: MotionMaster.h:207
int _top
Definition: MotionMaster.h:210
Unit * _owner
Definition: MotionMaster.h:209
virtual void Initialize(Unit *)=0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveAlongSplineChain() [1/2]

void MotionMaster::MoveAlongSplineChain ( uint32  pointId,
uint16  dbChainId,
bool  walk 
)
562 {
563  Creature* owner = _owner->ToCreature();
564  if (!owner)
565  {
566  TC_LOG_ERROR("misc", "MotionMaster::MoveAlongSplineChain: non-creature %s tried to walk along DB spline chain. Ignoring.", _owner->GetGUID().ToString().c_str());
567  return;
568  }
569  std::vector<SplineChainLink> const* chain = sScriptSystemMgr->GetSplineChain(owner, dbChainId);
570  if (!chain)
571  {
572  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);
573  return;
574  }
575  MoveAlongSplineChain(pointId, *chain, walk);
576 }
void MoveAlongSplineChain(uint32 pointId, uint16 dbChainId, bool walk)
Definition: MotionMaster.cpp:561
std::string ToString() const
Definition: ObjectGuid.cpp:238
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
Definition: Creature.h:61
ObjectGuid const & GetGUID() const
Definition: Object.h:154
uint32 GetEntry() const
Definition: Object.h:155
Creature * ToCreature()
Definition: Object.h:196
#define sScriptSystemMgr
Definition: ScriptSystem.h:57
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveAlongSplineChain() [2/2]

void MotionMaster::MoveAlongSplineChain ( uint32  pointId,
std::vector< SplineChainLink > const &  chain,
bool  walk 
)
579 {
580  Mutate(new SplineChainMovementGenerator(pointId, chain, walk), MOTION_SLOT_ACTIVE);
581 }
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
Definition: MotionMaster.h:78
Definition: SplineChainMovementGenerator.h:24
+ Here is the call graph for this function:

◆ MoveCharge() [1/2]

void MotionMaster::MoveCharge ( float  x,
float  y,
float  z,
float  speed = SPEED_CHARGE,
uint32  id = EVENT_CHARGE,
bool  generatePath = false,
Unit const *  target = nullptr,
Movement::SpellEffectExtraData const *  spellEffectExtraData = nullptr 
)
386 {
387  if (_slot[MOTION_SLOT_CONTROLLED] && _slot[MOTION_SLOT_CONTROLLED]->GetMovementGeneratorType() != DISTRACT_MOTION_TYPE)
388  return;
389 
390  if (_owner->GetTypeId() == TYPEID_PLAYER)
391  {
392  TC_LOG_DEBUG("misc", "Player (%s) charged point (X: %f Y: %f Z: %f).", _owner->GetGUID().ToString().c_str(), x, y, z);
393  Mutate(new PointMovementGenerator<Player>(id, x, y, z, generatePath, speed, target, spellEffectExtraData), MOTION_SLOT_CONTROLLED);
394  }
395  else
396  {
397  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) charged point (X: %f Y: %f Z: %f).",
398  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), x, y, z);
399  Mutate(new PointMovementGenerator<Creature>(id, x, y, z, generatePath, speed, target, spellEffectExtraData), MOTION_SLOT_CONTROLLED);
400  }
401 }
TypeID GetTypeId() const
Definition: Object.h:167
MovementGenerator * _slot[MAX_MOTION_SLOT]
Definition: MotionMaster.h:206
std::string ToString() const
Definition: ObjectGuid.cpp:238
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Definition: PointMovementGenerator.h:31
Definition: MotionMaster.h:63
uint32 GetEntry() const
Definition: Object.h:155
Definition: ObjectGuid.h:40
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:79
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveCharge() [2/2]

void MotionMaster::MoveCharge ( PathGenerator const &  path,
float  speed = SPEED_CHARGE,
Unit const *  target = nullptr,
Movement::SpellEffectExtraData const *  spellEffectExtraData = nullptr 
)
405 {
406  G3D::Vector3 dest = path.GetActualEndPosition();
407 
408  MoveCharge(dest.x, dest.y, dest.z, speed, EVENT_CHARGE_PREPATH);
409 
410  // Charge movement is not started when using EVENT_CHARGE_PREPATH
412  init.MovebyPath(path.GetPath());
413  init.SetVelocity(speed);
414  if (target)
415  init.SetFacing(target);
416  if (spellEffectExtraData)
417  init.SetSpellEffectExtraData(*spellEffectExtraData);
418  init.Launch();
419 }
Definition: SharedDefines.h:5763
void MoveCharge(float x, float y, float z, float speed=SPEED_CHARGE, uint32 id=EVENT_CHARGE, bool generatePath=false, Unit const *target=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
Definition: MotionMaster.cpp:384
Definition: MoveSplineInit.h:50
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:

◆ MoveChase()

void MotionMaster::MoveChase ( Unit target,
float  dist = 0.0f,
float  angle = 0.0f 
)
258 {
259  // ignore movement request if target not exist
260  if (!target || target == _owner)
261  return;
262 
263  //_owner->ClearUnitState(UNIT_STATE_FOLLOW);
264  if (_owner->GetTypeId() == TYPEID_PLAYER)
265  {
266  TC_LOG_DEBUG("misc", "Player (%s) chase (%s)",
267  _owner->GetGUID().ToString().c_str(),
268  target->GetGUID().ToString().c_str());
269  Mutate(new ChaseMovementGenerator<Player>(target, dist, angle), MOTION_SLOT_ACTIVE);
270  }
271  else
272  {
273  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) chase %s",
274  _owner->GetEntry(),
275  _owner->GetGUID().ToString().c_str(),
276  target->GetGUID().ToString().c_str());
278  }
279 }
TypeID GetTypeId() const
Definition: Object.h:167
std::string ToString() const
Definition: ObjectGuid.cpp:238
Definition: TargetedMovementGenerator.h:77
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
uint32 GetEntry() const
Definition: Object.h:155
Definition: ObjectGuid.h:40
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:78
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveCirclePath()

void MotionMaster::MoveCirclePath ( float  x,
float  y,
float  z,
float  radius,
bool  clockwise,
uint8  stepCount 
)
497 {
498  float step = 2 * float(M_PI) / stepCount * (clockwise ? -1.0f : 1.0f);
499  Position const& pos = { x, y, z, 0.0f };
500  float angle = pos.GetAngle(_owner->GetPositionX(), _owner->GetPositionY());
501 
503 
504  for (uint8 i = 0; i < stepCount; angle += step, ++i)
505  {
506  G3D::Vector3 point;
507  point.x = x + radius * cosf(angle);
508  point.y = y + radius * sinf(angle);
509 
510  if (_owner->IsFlying())
511  point.z = z;
512  else
513  point.z = _owner->GetMapHeight(point.x, point.y, z) + _owner->GetHoverOffset();
514 
515  init.Path().push_back(point);
516  }
517 
518  if (_owner->IsFlying())
519  {
520  init.SetFly();
521  init.SetCyclic();
522  init.SetAnimation(Movement::ToFly);
523  }
524  else
525  {
526  init.SetWalk(true);
527  init.SetCyclic();
528  }
529 
530  init.Launch();
531 }
float GetMapHeight(float x, float y, float z, bool vmap=true, float distanceToSearch=50.0f) const
Definition: Object.cpp:3332
float GetAngle(Position const *pos) const
Definition: Position.cpp:85
Definition: MoveSplineInit.h:31
#define M_PI
Definition: Common.h:134
float GetPositionY() const
Definition: Position.h:102
float GetHoverOffset() const
Definition: Unit.h:1776
bool IsFlying() const
Definition: Unit.h:1772
float GetPositionX() const
Definition: Position.h:101
uint8_t uint8
Definition: Define.h:154
Definition: Position.h:28
Definition: MoveSplineInit.h:50
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:

◆ MoveCloserAndStop()

void MotionMaster::MoveCloserAndStop ( uint32  id,
Unit target,
float  distance 
)
336 {
337  float distanceToTravel = _owner->GetExactDist2d(target) - distance;
338  if (distanceToTravel > 0.0f)
339  {
340  float angle = _owner->GetAngle(target);
341  float destx = _owner->GetPositionX() + distanceToTravel * std::cos(angle);
342  float desty = _owner->GetPositionY() + distanceToTravel * std::sin(angle);
343  MovePoint(id, destx, desty, target->GetPositionZ());
344  }
345  else
346  {
347  // we are already close enough. We just need to turn toward the target without changing position.
349  init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
350  init.SetFacing(target);
351  init.Launch();
353  }
354 }
float GetAngle(Position const *pos) const
Definition: Position.cpp:85
float GetPositionY() const
Definition: Position.h:102
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
float GetPositionZ() const
Definition: Position.h:103
Definition: PointMovementGenerator.h:69
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
Definition: MotionMaster.h:143
float GetPositionX() const
Definition: Position.h:101
Definition: MotionMaster.h:78
Definition: MoveSplineInit.h:50
Unit * _owner
Definition: MotionMaster.h:209
float GetExactDist2d(const float x, const float y) const
Definition: Position.cpp:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveConfused()

void MotionMaster::MoveConfused ( )
282 {
283  if (_owner->GetTypeId() == TYPEID_PLAYER)
284  {
285  TC_LOG_DEBUG("misc", "Player (%s) move confused", _owner->GetGUID().ToString().c_str());
287  }
288  else
289  {
290  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) move confused",
291  _owner->GetEntry(), _owner->GetGUID().ToString().c_str());
293  }
294 }
TypeID GetTypeId() const
Definition: Object.h:167
std::string ToString() const
Definition: ObjectGuid.cpp:238
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
uint32 GetEntry() const
Definition: Object.h:155
Definition: ObjectGuid.h:40
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:79
Definition: ConfusedMovementGenerator.h:25
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:

◆ MoveDistract()

void MotionMaster::MoveDistract ( uint32  time)
680 {
682  return;
683 
684  if (_owner->GetTypeId() == TYPEID_PLAYER)
685  {
686  TC_LOG_DEBUG("misc", "Player (%s) distracted (timer: %u).", _owner->GetGUID().ToString().c_str(), timer);
687  }
688  else
689  {
690  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) distracted (timer: %u)",
691  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), timer);
692  }
693 
695  Mutate(mgen, MOTION_SLOT_CONTROLLED);
696 }
TypeID GetTypeId() const
Definition: Object.h:167
Definition: IdleMovementGenerator.h:50
MovementGenerator * _slot[MAX_MOTION_SLOT]
Definition: MotionMaster.h:206
std::string ToString() const
Definition: ObjectGuid.cpp:238
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
uint32 GetEntry() const
Definition: Object.h:155
Definition: ObjectGuid.h:40
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:79
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveFall()

void MotionMaster::MoveFall ( uint32  id = 0)
594 {
595  // use larger distance for vmap height search than in most other cases
597  if (tz <= INVALID_HEIGHT)
598  {
599  TC_LOG_DEBUG("misc", "MotionMaster::MoveFall: unable to retrieve a proper height at map %u (x: %f, y: %f, z: %f).",
601  return;
602  }
603 
604  // Abort too if the ground is very near
605  if (std::fabs(_owner->GetPositionZ() - tz) < 0.1f)
606  return;
607 
608  _owner->SetFall(true);
609 
610  // don't run spline movement for players
611  if (_owner->GetTypeId() == TYPEID_PLAYER)
612  {
614  return;
615  }
616 
618  init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(), tz + _owner->GetHoverOffset(), false);
619  init.SetFall();
620  init.Launch();
622 }
float GetMapHeight(float x, float y, float z, bool vmap=true, float distanceToSearch=50.0f) const
Definition: Object.cpp:3332
TypeID GetTypeId() const
Definition: Object.h:167
#define MAX_FALL_DISTANCE
Definition: Map.h:210
uint32 GetId() const
Definition: Map.cpp:4230
Player * ToPlayer()
Definition: Object.h:192
float GetPositionY() const
Definition: Position.h:102
Map * GetMap() const
Definition: Object.h:535
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
float GetPositionZ() const
Definition: Position.h:103
Definition: PointMovementGenerator.h:69
float GetHoverOffset() const
Definition: Unit.h:1776
float GetPositionX() const
Definition: Position.h:101
Definition: ObjectGuid.h:40
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:79
void SetFallInformation(uint32 time, float z)
Definition: Player.cpp:26494
#define INVALID_HEIGHT
Definition: Map.h:209
Definition: MoveSplineInit.h:50
Unit * _owner
Definition: MotionMaster.h:209
bool SetFall(bool enable)
Definition: Unit.cpp:12393
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveFleeing()

void MotionMaster::MoveFleeing ( Unit enemy,
uint32  time = 0 
)
297 {
298  if (!enemy)
299  return;
300 
301  if (_owner->GetTypeId() == TYPEID_PLAYER)
302  {
303  TC_LOG_DEBUG("misc", "Player (%s) flees from (%s).", _owner->GetGUID().ToString().c_str(),
304  enemy->GetGUID().ToString().c_str());
306  }
307  else
308  {
309  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) flees from (%s)%s.",
310  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(),
311  enemy->GetGUID().ToString().c_str(),
312  time ? " for a limited time" : "");
313  if (time)
315  else
317  }
318 }
Definition: FleeingMovementGenerator.h:50
TypeID GetTypeId() const
Definition: Object.h:167
std::string ToString() const
Definition: ObjectGuid.cpp:238
Definition: FleeingMovementGenerator.h:27
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
uint32 GetEntry() const
Definition: Object.h:155
Definition: ObjectGuid.h:40
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:79
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveFollow()

void MotionMaster::MoveFollow ( Unit target,
float  dist,
float  angle,
MovementSlot  slot = MOTION_SLOT_ACTIVE 
)
239 {
240  // ignore movement request if target not exist
241  if (!target || target == _owner)
242  return;
243 
244  //_owner->AddUnitState(UNIT_STATE_FOLLOW);
245  if (_owner->GetTypeId() == TYPEID_PLAYER)
246  {
247  TC_LOG_DEBUG("misc", "Player (%s) follows (%s)", _owner->GetGUID().ToString().c_str(), target->GetGUID().ToString().c_str());
248  Mutate(new FollowMovementGenerator<Player>(target, dist, angle), slot);
249  }
250  else
251  {
252  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) follows (%s)", _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), target->GetGUID().ToString().c_str());
253  Mutate(new FollowMovementGenerator<Creature>(target, dist, angle), slot);
254  }
255 }
TypeID GetTypeId() const
Definition: Object.h:167
std::string ToString() const
Definition: ObjectGuid.cpp:238
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
uint32 GetEntry() const
Definition: Object.h:155
Definition: TargetedMovementGenerator.h:97
Definition: ObjectGuid.h:40
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveFormation()

void MotionMaster::MoveFormation ( uint32  id,
Position  destination,
uint32  moveType,
bool  forceRun = false,
bool  forceOrientation = false 
)
726 {
727  if (_owner->GetTypeId() == TYPEID_UNIT)
728  {
729  TC_LOG_DEBUG("misc", "MotionMaster::MoveFormation: Creature (Entry: %u %s) targeted point (Id: %u X: %f Y: %f Z: %f).", _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), id, destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ());
730  Mutate(new FormationMovementGenerator(id, destination, moveType, forceRun, forceOrientation), MOTION_SLOT_ACTIVE);
731  }
732 }
TypeID GetTypeId() const
Definition: Object.h:167
std::string ToString() const
Definition: ObjectGuid.cpp:238
Definition: FormationMovementGenerator.h:25
Definition: ObjectGuid.h:39
float GetPositionY() const
Definition: Position.h:102
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
float GetPositionZ() const
Definition: Position.h:103
float GetPositionX() const
Definition: Position.h:101
uint32 GetEntry() const
Definition: Object.h:155
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:78
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveIdle()

void MotionMaster::MoveIdle ( )

Should be preceded by MovementExpired or Clear if there's an overlying movementgenerator active

198 {
200  if (empty() || !IsStatic(top()))
202 }
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
Definition: MotionMaster.h:77
bool IsStatic(MovementGenerator *movement)
Definition: MotionMaster.cpp:47
MovementGenerator * GetIdleMovementGenerator()
Definition: MotionMaster.cpp:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveJump() [1/2]

void MotionMaster::MoveJump ( Position const &  pos,
float  speedXY,
float  speedZ,
uint32  id = EVENT_JUMP,
bool  hasOrientation = false,
JumpArrivalCastArgs const *  arrivalCast = nullptr,
Movement::SpellEffectExtraData const *  spellEffectExtraData = nullptr 
)
inline
164  {
165  MoveJump(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), speedXY, speedZ, id, hasOrientation, arrivalCast, spellEffectExtraData);
166  }
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, JumpArrivalCastArgs const *arrivalCast=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
Definition: MotionMaster.h:163
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveJump() [2/2]

void MotionMaster::MoveJump ( float  x,
float  y,
float  z,
float  o,
float  speedXY,
float  speedZ,
uint32  id = EVENT_JUMP,
bool  hasOrientation = false,
JumpArrivalCastArgs const *  arrivalCast = nullptr,
Movement::SpellEffectExtraData const *  spellEffectExtraData = nullptr 
)
467 {
468  TC_LOG_DEBUG("misc", "Unit (%s) jumps to point (X: %f Y: %f Z: %f).", _owner->GetGUID().ToString().c_str(), x, y, z);
469  if (speedXY < 0.01f)
470  return;
471 
472  float moveTimeHalf = speedZ / Movement::gravity;
473  float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
474 
476  init.MoveTo(x, y, z, false);
477  init.SetParabolic(max_height, 0);
478  init.SetVelocity(speedXY);
479  if (hasOrientation)
480  init.SetFacing(o);
481  if (spellEffectExtraData)
482  init.SetSpellEffectExtraData(*spellEffectExtraData);
483  init.Launch();
484 
485  uint32 arrivalSpellId = 0;
486  ObjectGuid arrivalSpellTargetGuid;
487  if (arrivalCast)
488  {
489  arrivalSpellId = arrivalCast->SpellId;
490  arrivalSpellTargetGuid = arrivalCast->Target;
491  }
492 
493  Mutate(new EffectMovementGenerator(id, arrivalSpellId, arrivalSpellTargetGuid), MOTION_SLOT_CONTROLLED);
494 }
std::string ToString() const
Definition: ObjectGuid.cpp:238
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
float constexpr gravity
Definition: MovementTypedefs.h:79
uint32_t uint32
Definition: Define.h:152
Definition: PointMovementGenerator.h:69
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:79
Definition: ObjectGuid.h:248
float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity=0.0f)
Definition: MovementUtil.cpp:58
Definition: MoveSplineInit.h:50
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:

◆ MoveJumpTo()

void MotionMaster::MoveJumpTo ( float  angle,
float  speedXY,
float  speedZ 
)
450 {
451  //this function may make players fall below map
452  if (_owner->GetTypeId() == TYPEID_PLAYER)
453  return;
454 
455  float x, y, z;
456 
457  float moveTimeHalf = speedZ / Movement::gravity;
458  float dist = 2 * moveTimeHalf * speedXY;
459  _owner->GetNearPoint2D(x, y, dist, _owner->GetOrientation() + angle);
460  z = _owner->GetPositionZ();
461  _owner->UpdateAllowedPositionZ(x, y, z);
462  MoveJump(x, y, z, 0.0f, speedXY, speedZ);
463 }
TypeID GetTypeId() const
Definition: Object.h:167
float GetOrientation() const
Definition: Position.h:104
void UpdateAllowedPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1314
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, JumpArrivalCastArgs const *arrivalCast=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
Definition: MotionMaster.h:163
float constexpr gravity
Definition: MovementTypedefs.h:79
void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const
Definition: Object.cpp:2975
float GetPositionZ() const
Definition: Position.h:103
Definition: ObjectGuid.h:40
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveKnockbackFrom()

void MotionMaster::MoveKnockbackFrom ( float  srcX,
float  srcY,
float  speedXY,
float  speedZ,
Movement::SpellEffectExtraData const *  spellEffectExtraData = nullptr 
)
422 {
423  //this function may make players fall below map
424  if (_owner->GetTypeId() == TYPEID_PLAYER)
425  return;
426 
427  if (speedXY < 0.01f)
428  return;
429 
430  float x, y, z;
431  float moveTimeHalf = speedZ / Movement::gravity;
432  float dist = 2 * moveTimeHalf * speedXY;
433  float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
434 
435  _owner->GetNearPoint(_owner, x, y, z, _owner->GetCombatReach(), dist, _owner->GetAngle(srcX, srcY) + float(M_PI));
436 
438  init.MoveTo(x, y, z);
439  init.SetParabolic(max_height, 0);
440  init.SetOrientationFixed(true);
441  init.SetVelocity(speedXY);
442  if (spellEffectExtraData)
443  init.SetSpellEffectExtraData(*spellEffectExtraData);
444 
445  init.Launch();
447 }
float GetCombatReach() const override
Definition: Unit.h:791
TypeID GetTypeId() const
Definition: Object.h:167
float GetAngle(Position const *pos) const
Definition: Position.cpp:85
#define M_PI
Definition: Common.h:134
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
float constexpr gravity
Definition: MovementTypedefs.h:79
Definition: PointMovementGenerator.h:69
Definition: ObjectGuid.h:40
Definition: MotionMaster.h:79
float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity=0.0f)
Definition: MovementUtil.cpp:58
Definition: MoveSplineInit.h:50
Unit * _owner
Definition: MotionMaster.h:209
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
Definition: Object.cpp:2984
+ Here is the call graph for this function:

◆ MoveLand()

void MotionMaster::MoveLand ( uint32  id,
Position const &  pos 
)
357 {
358  float x, y, z;
359  pos.GetPosition(x, y, z);
360 
361  TC_LOG_DEBUG("misc", "Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f).", _owner->GetEntry(), id, x, y, z);
362 
364  init.MoveTo(x, y, z);
365  init.SetAnimation(Movement::ToGround);
366  init.Launch();
368 }
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
Definition: MoveSplineInit.h:29
Definition: PointMovementGenerator.h:69
uint32 GetEntry() const
Definition: Object.h:155
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:78
Definition: MoveSplineInit.h:50
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MovementExpired()

void MotionMaster::MovementExpired ( bool  reset = true)
136 {
137  if (_cleanFlag & MMCF_UPDATE)
138  {
139  if (reset)
141  else
143  DelayedExpire();
144  }
145  else
146  DirectExpire(reset);
147 }
uint8 _cleanFlag
Definition: MotionMaster.h:211
void DirectExpire(bool reset)
Definition: MotionMaster.cpp:843
Definition: MotionMaster.h:86
Definition: MotionMaster.h:87
void DelayedExpire()
Definition: MotionMaster.cpp:863
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MovePath() [1/2]

void MotionMaster::MovePath ( uint32  pathId,
bool  repeatable 
)
699 {
700  if (!pathId)
701  return;
702 
704 
705  TC_LOG_DEBUG("misc", "%s starts moving over path (Id:%u, repeatable: %s).",
706  _owner->GetGUID().ToString().c_str(), pathId, repeatable ? "YES" : "NO");
707 }
Definition: WaypointMovementGenerator.h:40
std::string ToString() const
Definition: ObjectGuid.cpp:238
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:77
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MovePath() [2/2]

void MotionMaster::MovePath ( WaypointPath path,
bool  repeatable 
)
710 {
712 
713  TC_LOG_DEBUG("misc", "%s start moving over path (repeatable: %s)",
714  _owner->GetGUID().ToString().c_str(), repeatable ? "YES" : "NO");
715 }
Definition: WaypointMovementGenerator.h:40
std::string ToString() const
Definition: ObjectGuid.cpp:238
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:77
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:

◆ MovePoint() [1/2]

void MotionMaster::MovePoint ( uint32  id,
Position const &  pos,
bool  generatePath = true,
Optional< float >  finalOrient = {} 
)
inline
143  {})
144  {
145  MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, generatePath, finalOrient);
146  }
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
Definition: MotionMaster.h:143

◆ MovePoint() [2/2]

void MotionMaster::MovePoint ( uint32  id,
float  x,
float  y,
float  z,
bool  generatePath = true,
Optional< float >  finalOrient = {} 
)
321 {
322  if (_owner->GetTypeId() == TYPEID_PLAYER)
323  {
324  TC_LOG_DEBUG("misc", "Player (%s) targeted point (Id: %u X: %f Y: %f Z: %f).", _owner->GetGUID().ToString().c_str(), id, x, y, z);
325  Mutate(new PointMovementGenerator<Player>(id, x, y, z, generatePath, 0.0f, nullptr, nullptr, finalOrient), MOTION_SLOT_ACTIVE);
326  }
327  else
328  {
329  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) targeted point (ID: %u X: %f Y: %f Z: %f).",
330  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), id, x, y, z);
331  Mutate(new PointMovementGenerator<Creature>(id, x, y, z, generatePath, 0.0f, nullptr, nullptr, finalOrient), MOTION_SLOT_ACTIVE);
332  }
333 }
TypeID GetTypeId() const
Definition: Object.h:167
std::string ToString() const
Definition: ObjectGuid.cpp:238
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Definition: PointMovementGenerator.h:31
uint32 GetEntry() const
Definition: Object.h:155
Definition: ObjectGuid.h:40
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:78
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:

◆ MoveRandom()

void MotionMaster::MoveRandom ( float  spawndist = 0.0f)
230 {
231  if (_owner->GetTypeId() == TYPEID_UNIT)
232  {
233  TC_LOG_DEBUG("misc", "Creature (%s) started random movement.", _owner->GetGUID().ToString().c_str());
235  }
236 }
TypeID GetTypeId() const
Definition: Object.h:167
std::string ToString() const
Definition: ObjectGuid.cpp:238
Definition: ObjectGuid.h:39
Definition: RandomMovementGenerator.h:25
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:77
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveRotate()

void MotionMaster::MoveRotate ( uint32  time,
RotateDirection  direction 
)
718 {
719  if (!time)
720  return;
721 
722  Mutate(new RotateMovementGenerator(time, direction), MOTION_SLOT_ACTIVE);
723 }
Definition: IdleMovementGenerator.h:34
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
Definition: MotionMaster.h:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveSeekAssistance()

void MotionMaster::MoveSeekAssistance ( float  x,
float  y,
float  z 
)
625 {
626  if (_owner->GetTypeId() == TYPEID_PLAYER)
627  {
628  TC_LOG_ERROR("misc", "Player (GUID: %s) attempted to seek assistance.", _owner->GetGUID().ToString().c_str());
629  }
630  else
631  {
632  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) seek assistance (X: %f Y: %f Z: %f)",
633  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), x, y, z);
634  _owner->AttackStop();
635  _owner->CastStop();
638  }
639 }
bool AttackStop()
Definition: Unit.cpp:5516
TypeID GetTypeId() const
Definition: Object.h:167
std::string ToString() const
Definition: ObjectGuid.cpp:238
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
void CastStop(uint32 except_spellid=0)
Definition: Unit.cpp:1016
Definition: PointMovementGenerator.h:60
Definition: UnitDefines.h:370
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
uint32 GetEntry() const
Definition: Object.h:155
Definition: ObjectGuid.h:40
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Creature * ToCreature()
Definition: Object.h:196
Definition: MotionMaster.h:78
Unit * _owner
Definition: MotionMaster.h:209
void SetReactState(ReactStates st)
Definition: Creature.h:110
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveSeekAssistanceDistract()

void MotionMaster::MoveSeekAssistanceDistract ( uint32  timer)
642 {
643  if (_owner->GetTypeId() == TYPEID_PLAYER)
644  {
645  TC_LOG_ERROR("misc", "Player (%s) attempedt to call distract after assistance.", _owner->GetGUID().ToString().c_str());
646  }
647  else
648  {
649  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) is distracted after assistance call (Time: %u).",
650  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), time);
652  }
653 }
TypeID GetTypeId() const
Definition: Object.h:167
std::string ToString() const
Definition: ObjectGuid.cpp:238
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
uint32 GetEntry() const
Definition: Object.h:155
Definition: ObjectGuid.h:40
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:78
Unit * _owner
Definition: MotionMaster.h:209
Definition: IdleMovementGenerator.h:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveSmoothPath()

void MotionMaster::MoveSmoothPath ( uint32  pointId,
Position const *  pathPoints,
size_t  pathSize,
bool  walk = false,
bool  fly = false 
)
534 {
536  if (fly)
537  {
538  init.SetFly();
539  init.SetUncompressed();
540  init.SetSmooth();
541  }
542 
544  path.reserve(pathSize);
545  std::transform(pathPoints, pathPoints + pathSize, std::back_inserter(path), [](Position const& point)
546  {
547  return G3D::Vector3(point.GetPositionX(), point.GetPositionY(), point.GetPositionZ());
548  });
549  init.MovebyPath(path);
550  init.SetWalk(walk);
551  init.Launch();
552 
553  // This code is not correct
554  // EffectMovementGenerator does not affect UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE
555  // need to call PointMovementGenerator with various pointIds
557  //Position pos(pathPoints[pathSize - 1].x, pathPoints[pathSize - 1].y, pathPoints[pathSize - 1].z);
558  //MovePoint(EVENT_CHARGE_PREPATH, pos, false);
559 }
float GetPositionY() const
Definition: Position.h:102
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
size_t const pathSize
Definition: zone_dun_morogh_area_coldridge_valley.cpp:253
std::vector< Vector3 > PointsArray
Definition: MoveSplineInitArgs.h:29
float GetPositionZ() const
Definition: Position.h:103
Definition: PointMovementGenerator.h:69
float GetPositionX() const
Definition: Position.h:101
Definition: Position.h:28
Definition: MotionMaster.h:78
Definition: MoveSplineInit.h:50
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveTakeoff()

void MotionMaster::MoveTakeoff ( uint32  id,
Position const &  pos 
)
371 {
372  float x, y, z;
373  pos.GetPosition(x, y, z);
374 
375  TC_LOG_DEBUG("misc", "Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f).", _owner->GetEntry(), id, x, y, z);
376 
378  init.MoveTo(x, y, z);
379  init.SetAnimation(Movement::ToFly);
380  init.Launch();
382 }
Definition: MoveSplineInit.h:31
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
Definition: PointMovementGenerator.h:69
uint32 GetEntry() const
Definition: Object.h:155
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:78
Definition: MoveSplineInit.h:50
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveTargetedHome()

void MotionMaster::MoveTargetedHome ( )
205 {
206  Clear(false);
207 
209  {
210  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) targeted home.", _owner->GetEntry(), _owner->GetGUID().ToString().c_str());
212  }
214  {
215  TC_LOG_DEBUG("misc", "Pet or controlled creature (Entry: %u %s) is targeting home", _owner->GetEntry(), _owner->GetGUID().ToString().c_str());
216  Unit* target = _owner->ToCreature()->GetCharmerOrOwner();
217  if (target)
218  {
219  TC_LOG_DEBUG("misc", "Following %s", target->GetGUID().ToString().c_str());
221  }
222  }
223  else
224  {
225  TC_LOG_ERROR("misc", "Player (%s) attempted to move towards target home.", _owner->GetGUID().ToString().c_str());
226  }
227 }
#define PET_FOLLOW_ANGLE
Definition: PetDefines.h:80
TypeID GetTypeId() const
Definition: Object.h:167
std::string ToString() const
Definition: ObjectGuid.cpp:238
void Clear(bool reset=true)
Definition: MotionMaster.cpp:110
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
Definition: ObjectGuid.h:39
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Definition: HomeMovementGenerator.h:24
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:5795
uint32 GetEntry() const
Definition: Object.h:155
Definition: TargetedMovementGenerator.h:97
bool IsEmpty() const
Definition: ObjectGuid.h:299
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Creature * ToCreature()
Definition: Object.h:196
ObjectGuid GetCharmerOrOwnerGUID() const override
Definition: Unit.cpp:9739
#define PET_FOLLOW_DIST
Definition: PetDefines.h:79
Definition: MotionMaster.h:78
Unit * _owner
Definition: MotionMaster.h:209
Definition: Unit.h:736
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MoveTaxiFlight()

void MotionMaster::MoveTaxiFlight ( uint32  path,
uint32  pathnode 
)
656 {
657  if (_owner->GetTypeId() == TYPEID_PLAYER)
658  {
659  if (path < sTaxiPathNodesByPath.size())
660  {
661  TC_LOG_DEBUG("misc", "%s taxi to (Path %u node %u).", _owner->GetName().c_str(), path, pathnode);
663  mgen->LoadPath(_owner->ToPlayer());
665  }
666  else
667  {
668  TC_LOG_ERROR("misc", "%s attempted taxi to (non-existing Path %u node %u).",
669  _owner->GetName().c_str(), path, pathnode);
670  }
671  }
672  else
673  {
674  TC_LOG_ERROR("misc", "Creature (Entry: %u %s) attempted taxi to (Path %u node %u).",
675  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), path, pathnode);
676  }
677 }
TypeID GetTypeId() const
Definition: Object.h:167
Definition: FlightPathMovementGenerator.h:31
std::string ToString() const
Definition: ObjectGuid.cpp:238
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition: DB2Stores.cpp:326
Player * ToPlayer()
Definition: Object.h:192
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
ObjectGuid const & GetGUID() const
Definition: Object.h:154
std::string const & GetName() const
Definition: Object.h:467
uint32 GetEntry() const
Definition: Object.h:155
Definition: ObjectGuid.h:40
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
Definition: MotionMaster.h:79
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Mutate()

void MotionMaster::Mutate ( MovementGenerator m,
MovementSlot  slot 
)
private
760 {
761  if (MovementGenerator* curr = _slot[slot])
762  {
763  _slot[slot] = nullptr; // in case a new one is generated in this slot during directdelete
764  if (_top == slot && (_cleanFlag & MMCF_UPDATE))
765  DelayedDelete(curr);
766  else
767  DirectDelete(curr);
768  }
769  else if (_top < slot)
770  {
771  _top = slot;
772  }
773 
774  _slot[slot] = m;
775  if (_top > slot)
776  _initialize[slot] = true;
777  else
778  {
779  _initialize[slot] = false;
780  m->Initialize(_owner);
781  }
782 }
uint8 _cleanFlag
Definition: MotionMaster.h:211
MovementGenerator * _slot[MAX_MOTION_SLOT]
Definition: MotionMaster.h:206
bool _initialize[MAX_MOTION_SLOT]
Definition: MotionMaster.h:207
void DelayedDelete(MovementGenerator *curr)
Definition: MotionMaster.cpp:884
int _top
Definition: MotionMaster.h:210
Definition: MotionMaster.h:86
void DirectDelete(MovementGenerator *curr)
Definition: MotionMaster.cpp:876
Definition: MovementGenerator.h:29
Unit * _owner
Definition: MotionMaster.h:209
virtual void Initialize(Unit *)=0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NeedInitTop()

bool MotionMaster::NeedInitTop ( ) const
private
747 {
748  if (empty())
749  return false;
750  return _initialize[_top];
751 }
bool empty() const
Definition: MotionMaster.h:115
bool _initialize[MAX_MOTION_SLOT]
Definition: MotionMaster.h:207
int _top
Definition: MotionMaster.h:210
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop()

void MotionMaster::pop ( )
private
737 {
738  if (empty())
739  return;
740 
741  _slot[_top] = nullptr;
742  while (!empty() && !top())
743  --_top;
744 }
MovementGenerator * _slot[MAX_MOTION_SLOT]
Definition: MotionMaster.h:206
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
int _top
Definition: MotionMaster.h:210
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PropagateSpeedChange()

void MotionMaster::PropagateSpeedChange ( )
174 {
175  if (empty())
176  return;
177 
178  MovementGenerator* movement = top();
179  if (!movement)
180  return;
181 
182  movement->UnitSpeedChanged();
183 }
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
Definition: MovementGenerator.h:29
virtual void UnitSpeedChanged()
Definition: MovementGenerator.h:40
+ Here is the call graph for this function:

◆ ResumeSplineChain()

void MotionMaster::ResumeSplineChain ( SplineChainResumeInfo const &  info)
584 {
585  if (info.Empty())
586  {
587  TC_LOG_ERROR("misc", "MotionMaster::ResumeSplineChain: unit with entry %u tried to resume a spline chain from empty info.", _owner->GetEntry());
588  return;
589  }
591 }
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:759
uint32 GetEntry() const
Definition: Object.h:155
Definition: MotionMaster.h:78
Unit * _owner
Definition: MotionMaster.h:209
Definition: SplineChainMovementGenerator.h:24
+ Here is the call graph for this function:

◆ size()

int MotionMaster::size ( ) const
inline
116 { return _top + 1; }
int _top
Definition: MotionMaster.h:210
+ Here is the caller graph for this function:

◆ top()

MovementGenerator* MotionMaster::top ( ) const
inline
117 { ASSERT(!empty()); return _slot[_top]; }
MovementGenerator * _slot[MAX_MOTION_SLOT]
Definition: MotionMaster.h:206
bool empty() const
Definition: MotionMaster.h:115
int _top
Definition: MotionMaster.h:210
#define ASSERT
Definition: Errors.h:57
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateMotion()

void MotionMaster::UpdateMotion ( uint32  diff)
91 {
92  if (!_owner)
93  return;
94 
95  ASSERT(!empty());
96 
98  if (!top()->Update(_owner, diff))
99  {
101  MovementExpired();
102  }
103  else
105 
106  if (!_expireList.empty())
107  ClearExpireList();
108 }
uint8 _cleanFlag
Definition: MotionMaster.h:211
MovementGenerator * top() const
Definition: MotionMaster.h:117
bool empty() const
Definition: MotionMaster.h:115
Definition: MotionMaster.h:86
virtual void Update(uint32)
Definition: Map.cpp:817
MovementList _expireList
Definition: MotionMaster.h:208
void ClearExpireList()
Definition: MotionMaster.cpp:893
#define ASSERT
Definition: Errors.h:57
void MovementExpired(bool reset=true)
Definition: MotionMaster.cpp:135
Unit * _owner
Definition: MotionMaster.h:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _cleanFlag

uint8 MotionMaster::_cleanFlag
private

◆ _expireList

MovementList MotionMaster::_expireList
private

◆ _initialize

bool MotionMaster::_initialize[MAX_MOTION_SLOT]
private

◆ _owner

Unit* MotionMaster::_owner
private

◆ _slot

MovementGenerator* MotionMaster::_slot[MAX_MOTION_SLOT]
private

◆ _top

int MotionMaster::_top
private

The documentation for this class was generated from the following files: