TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MotionMaster Class Reference

#include <MotionMaster.h>

Public Member Functions

 MotionMaster (Unit *unit)
 
 ~MotionMaster ()
 
void Initialize ()
 
void InitDefault ()
 
bool empty () const
 
int size () const
 
_Ty top () const
 
_Ty GetMotionSlot (int slot) const
 
void DirectDelete (_Ty curr)
 
void DelayedDelete (_Ty curr)
 
void UpdateMotion (uint32 diff)
 
void Clear (bool reset=true)
 
void MovementExpired (bool reset=true)
 
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)
 
void MovePoint (uint32 id, float x, float y, float z, bool generatePath=true)
 
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)
 
void MoveCharge (PathGenerator const &path, float speed=SPEED_CHARGE)
 
void MoveKnockbackFrom (float srcX, float srcY, float speedXY, float speedZ)
 
void MoveJumpTo (float angle, float speedXY, float speedZ)
 
void MoveJump (Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, uint32 arrivalSpellId=0, ObjectGuid const &arrivalSpellTargetGuid=ObjectGuid::Empty)
 
void MoveJump (float x, float y, float z, float o, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, uint32 arrivalSpellId=0, ObjectGuid const &arrivalSpellTargetGuid=ObjectGuid::Empty)
 
void MoveCirclePath (float x, float y, float z, float radius, bool clockwise, uint8 stepCount)
 
void MoveSmoothPath (uint32 pointId, G3D::Vector3 const *pathPoints, size_t pathSize, bool walk)
 
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 path_id, bool repeatable)
 
void MoveRotate (uint32 time, RotateDirection direction)
 
MovementGeneratorType GetCurrentMovementGeneratorType () const
 
MovementGeneratorType GetMotionSlotType (int slot) const
 
void propagateSpeedChange ()
 
bool GetDestination (float &x, float &y, float &z)
 

Private Types

typedef MovementGenerator_Ty
 
typedef std::vector< _TyExpireList
 

Private Member Functions

void pop ()
 
void push (_Ty _Val)
 
bool needInitTop () const
 
void InitTop ()
 
void Mutate (MovementGenerator *m, MovementSlot slot)
 
void DirectClean (bool reset)
 
void DelayedClean ()
 
void DirectExpire (bool reset)
 
void DelayedExpire ()
 

Private Attributes

ExpireList_expList
 
_Ty Impl [MAX_MOTION_SLOT]
 
int _top
 
Unit_owner
 
bool _needInit [MAX_MOTION_SLOT]
 
uint8 _cleanFlag
 

Member Typedef Documentation

typedef std::vector<_Ty> MotionMaster::ExpireList
private

Constructor & Destructor Documentation

MotionMaster::MotionMaster ( Unit unit)
inlineexplicit
108  : _expList(NULL), _top(-1), _owner(unit), _cleanFlag(MMCF_NONE)
109  {
110  for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
111  {
112  Impl[i] = NULL;
113  _needInit[i] = true;
114  }
115  }
uint8 _cleanFlag
Definition: MotionMaster.h:221
Definition: MotionMaster.h:68
ExpireList * _expList
Definition: MotionMaster.h:216
arena_t NULL
Definition: jemalloc_internal.h:624
int _top
Definition: MotionMaster.h:218
bool _needInit[MAX_MOTION_SLOT]
Definition: MotionMaster.h:220
Definition: MotionMaster.h:63
uint8_t uint8
Definition: Define.h:152
_Ty Impl[MAX_MOTION_SLOT]
Definition: MotionMaster.h:217
Unit * _owner
Definition: MotionMaster.h:219
MotionMaster::~MotionMaster ( )
68 {
69  // clear ALL movement generators (including default)
70  while (!empty())
71  {
72  MovementGenerator *curr = top();
73  pop();
74  if (curr && !isStatic(curr))
75  delete curr; // Skip finalizing on delete, it might launch new movement
76  }
77 }
void pop()
Definition: MotionMaster.h:88
_Ty top() const
Definition: MotionMaster.h:123
bool isStatic(MovementGenerator *mv)
Definition: MotionMaster.cpp:34
Definition: MovementGenerator.h:30
bool empty() const
Definition: MotionMaster.h:121

+ Here is the call graph for this function:

Member Function Documentation

void MotionMaster::Clear ( bool  reset = true)
inline
139  {
140  if (_cleanFlag & MMCF_UPDATE)
141  {
142  if (reset)
144  else
146  DelayedClean();
147  }
148  else
149  DirectClean(reset);
150  }
void DirectClean(bool reset)
Definition: MotionMaster.cpp:123
uint8 _cleanFlag
Definition: MotionMaster.h:221
Definition: MotionMaster.h:69
Definition: MotionMaster.h:70
void DelayedClean()
Definition: MotionMaster.cpp:141
void MotionMaster::DelayedClean ( )
private
142 {
143  while (size() > 1)
144  {
145  MovementGenerator *curr = top();
146  pop();
147  if (curr)
148  DelayedDelete(curr);
149  }
150 }
void pop()
Definition: MotionMaster.h:88
_Ty top() const
Definition: MotionMaster.h:123
void DelayedDelete(_Ty curr)
Definition: MotionMaster.cpp:693
int size() const
Definition: MotionMaster.h:122
Definition: MovementGenerator.h:30

+ Here is the call graph for this function:

void MotionMaster::DelayedDelete ( _Ty  curr)
694 {
695  TC_LOG_FATAL("misc", "Unit (Entry %u) is trying to delete its updating Movement Generator (Type %u)!", _owner->GetEntry(), curr->GetMovementGeneratorType());
696  if (isStatic(curr))
697  return;
698  if (!_expList)
699  _expList = new ExpireList();
700  _expList->push_back(curr);
701 }
ExpireList * _expList
Definition: MotionMaster.h:216
bool isStatic(MovementGenerator *mv)
Definition: MotionMaster.cpp:34
std::vector< _Ty > ExpireList
Definition: MotionMaster.h:215
#define TC_LOG_FATAL(filterType__,...)
Definition: Log.h:210
uint32 GetEntry() const
Definition: Object.h:107
Unit * _owner
Definition: MotionMaster.h:219

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::DelayedExpire ( )
private
173 {
174  if (size() > 1)
175  {
176  MovementGenerator *curr = top();
177  pop();
178  DelayedDelete(curr);
179  }
180 
181  while (!empty() && !top())
182  --_top;
183 }
void pop()
Definition: MotionMaster.h:88
_Ty top() const
Definition: MotionMaster.h:123
void DelayedDelete(_Ty curr)
Definition: MotionMaster.cpp:693
int _top
Definition: MotionMaster.h:218
int size() const
Definition: MotionMaster.h:122
Definition: MovementGenerator.h:30
bool empty() const
Definition: MotionMaster.h:121

+ Here is the call graph for this function:

void MotionMaster::DirectClean ( bool  reset)
private
124 {
125  while (size() > 1)
126  {
127  MovementGenerator *curr = top();
128  pop();
129  if (curr) DirectDelete(curr);
130  }
131 
132  if (empty())
133  return;
134 
135  if (needInitTop())
136  InitTop();
137  else if (reset)
138  top()->Reset(_owner);
139 }
void pop()
Definition: MotionMaster.h:88
void DirectDelete(_Ty curr)
Definition: MotionMaster.cpp:685
_Ty top() const
Definition: MotionMaster.h:123
void InitTop()
Definition: MotionMaster.cpp:679
bool needInitTop() const
Definition: MotionMaster.h:99
int size() const
Definition: MotionMaster.h:122
virtual void Reset(Unit *)=0
Definition: MovementGenerator.h:30
Unit * _owner
Definition: MotionMaster.h:219
bool empty() const
Definition: MotionMaster.h:121

+ Here is the call graph for this function:

void MotionMaster::DirectDelete ( _Ty  curr)
686 {
687  if (isStatic(curr))
688  return;
689  curr->Finalize(_owner);
690  delete curr;
691 }
bool isStatic(MovementGenerator *mv)
Definition: MotionMaster.cpp:34
Unit * _owner
Definition: MotionMaster.h:219

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::DirectExpire ( bool  reset)
private
153 {
154  if (size() > 1)
155  {
156  MovementGenerator *curr = top();
157  pop();
158  DirectDelete(curr);
159  }
160 
161  while (!empty() && !top())
162  --_top;
163 
164  if (empty())
165  Initialize();
166  else if (needInitTop())
167  InitTop();
168  else if (reset)
169  top()->Reset(_owner);
170 }
void pop()
Definition: MotionMaster.h:88
void DirectDelete(_Ty curr)
Definition: MotionMaster.cpp:685
_Ty top() const
Definition: MotionMaster.h:123
int _top
Definition: MotionMaster.h:218
void InitTop()
Definition: MotionMaster.cpp:679
bool needInitTop() const
Definition: MotionMaster.h:99
int size() const
Definition: MotionMaster.h:122
virtual void Reset(Unit *)=0
Definition: MovementGenerator.h:30
void Initialize()
Definition: MotionMaster.cpp:39
Unit * _owner
Definition: MotionMaster.h:219
bool empty() const
Definition: MotionMaster.h:121

+ Here is the call graph for this function:

bool MotionMaster::empty ( ) const
inline
121 { return (_top < 0); }
int _top
Definition: MotionMaster.h:218

+ Here is the caller graph for this function:

MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType ( ) const
664 {
665  if (empty())
666  return IDLE_MOTION_TYPE;
667 
668  return top()->GetMovementGeneratorType();
669 }
Definition: MotionMaster.h:37
virtual MovementGeneratorType GetMovementGeneratorType() const =0
_Ty top() const
Definition: MotionMaster.h:123
bool empty() const
Definition: MotionMaster.h:121

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool MotionMaster::GetDestination ( float &  x,
float &  y,
float &  z 
)
704 {
705  if (_owner->movespline->Finalized())
706  return false;
707 
709  x = dest.x;
710  y = dest.y;
711  z = dest.z;
712  return true;
713 }
float x
Definition: Vector3.h:62
Movement::MoveSpline * movespline
Definition: Unit.h:2213
float y
Definition: Vector3.h:62
Definition: Vector3.h:58
G3D::int16 z
Definition: Vector3int16.h:46
bool Finalized() const
Definition: MoveSpline.h:129
G3D::int16 y
Definition: Vector2int16.h:38
Vector3 const & FinalDestination() const
Definition: MoveSpline.h:132
float z
Definition: Vector3.h:62
G3D::int16 x
Definition: Vector2int16.h:37
Unit * _owner
Definition: MotionMaster.h:219

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

_Ty MotionMaster::GetMotionSlot ( int  slot) const
inline
129  {
130  ASSERT(slot >= 0);
131  return Impl[slot];
132  }
#define ASSERT
Definition: Errors.h:55
_Ty Impl[MAX_MOTION_SLOT]
Definition: MotionMaster.h:217

+ Here is the caller graph for this function:

MovementGeneratorType MotionMaster::GetMotionSlotType ( int  slot) const
672 {
673  if (!Impl[slot])
674  return NULL_MOTION_TYPE;
675  else
676  return Impl[slot]->GetMovementGeneratorType();
677 }
virtual MovementGeneratorType GetMovementGeneratorType() const =0
Definition: MotionMaster.h:55
_Ty Impl[MAX_MOTION_SLOT]
Definition: MotionMaster.h:217

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::InitDefault ( )
55 {
56  if (_owner->GetTypeId() == TYPEID_UNIT)
57  {
59  Mutate(movement == NULL ? &si_idleMovement : movement, MOTION_SLOT_IDLE);
60  }
61  else
62  {
64  }
65 }
IdleMovementGenerator si_idleMovement
Definition: IdleMovementGenerator.cpp:24
MovementGenerator * selectMovementGenerator(Creature *creature)
Definition: CreatureAISelector.cpp:100
Definition: MotionMaster.h:60
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
Creature * ToCreature()
Definition: Object.h:194
Definition: MovementGenerator.h:30
Unit * _owner
Definition: MotionMaster.h:219

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::Initialize ( void  )
40 {
41  // clear ALL movement generators (including default)
42  while (!empty())
43  {
44  MovementGenerator *curr = top();
45  pop();
46  if (curr)
47  DirectDelete(curr);
48  }
49 
50  InitDefault();
51 }
void pop()
Definition: MotionMaster.h:88
void DirectDelete(_Ty curr)
Definition: MotionMaster.cpp:685
_Ty top() const
Definition: MotionMaster.h:123
void InitDefault()
Definition: MotionMaster.cpp:54
Definition: MovementGenerator.h:30
bool empty() const
Definition: MotionMaster.h:121

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::InitTop ( )
private
680 {
681  top()->Initialize(_owner);
682  _needInit[_top] = false;
683 }
_Ty top() const
Definition: MotionMaster.h:123
int _top
Definition: MotionMaster.h:218
bool _needInit[MAX_MOTION_SLOT]
Definition: MotionMaster.h:220
Unit * _owner
Definition: MotionMaster.h:219
virtual void Initialize(Unit *)=0

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveCharge ( float  x,
float  y,
float  z,
float  speed = SPEED_CHARGE,
uint32  id = EVENT_CHARGE,
bool  generatePath = false 
)
466 {
467  if (Impl[MOTION_SLOT_CONTROLLED] && Impl[MOTION_SLOT_CONTROLLED]->GetMovementGeneratorType() != DISTRACT_MOTION_TYPE)
468  return;
469 
470  if (_owner->GetTypeId() == TYPEID_PLAYER)
471  {
472  TC_LOG_DEBUG("misc", "Player (%s) charge point (X: %f Y: %f Z: %f)", _owner->GetGUID().ToString().c_str(), x, y, z);
473  Mutate(new PointMovementGenerator<Player>(id, x, y, z, generatePath, speed), MOTION_SLOT_CONTROLLED);
474  }
475  else
476  {
477  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) charge point (X: %f Y: %f Z: %f)",
478  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), x, y, z);
479  Mutate(new PointMovementGenerator<Creature>(id, x, y, z, generatePath, speed), MOTION_SLOT_CONTROLLED);
480  }
481 }
Definition: MotionMaster.h:62
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: MotionMaster.h:48
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
Definition: PointMovementGenerator.h:26
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
_Ty Impl[MAX_MOTION_SLOT]
Definition: MotionMaster.h:217
uint32 GetEntry() const
Definition: Object.h:107
G3D::int16 x
Definition: Vector2int16.h:37
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveCharge ( PathGenerator const path,
float  speed = SPEED_CHARGE 
)
484 {
485  G3D::Vector3 dest = path.GetActualEndPosition();
486 
487  MoveCharge(dest.x, dest.y, dest.z, speed, EVENT_CHARGE_PREPATH);
488 
489  // Charge movement is not started when using EVENT_CHARGE_PREPATH
491  init.MovebyPath(path.GetPath());
492  init.SetVelocity(speed);
493  init.Launch();
494 }
float x
Definition: Vector3.h:62
void MoveCharge(float x, float y, float z, float speed=SPEED_CHARGE, uint32 id=EVENT_CHARGE, bool generatePath=false)
Definition: MotionMaster.cpp:465
float y
Definition: Vector3.h:62
Definition: Vector3.h:58
Definition: SharedDefines.h:4419
float z
Definition: Vector3.h:62
Definition: MoveSplineInit.h:52
Unit * _owner
Definition: MotionMaster.h:219

+ Here is the call graph for this function:

void MotionMaster::MoveChase ( Unit target,
float  dist = 0.0f,
float  angle = 0.0f 
)
242 {
243  // ignore movement request if target not exist
244  if (!target || target == _owner || _owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
245  return;
246 
247  //_owner->ClearUnitState(UNIT_STATE_FOLLOW);
248  if (_owner->GetTypeId() == TYPEID_PLAYER)
249  {
250  TC_LOG_DEBUG("misc", "Player (%s) chase (%s)",
251  _owner->GetGUID().ToString().c_str(),
252  target->GetGUID().ToString().c_str());
253  Mutate(new ChaseMovementGenerator<Player>(target, dist, angle), MOTION_SLOT_ACTIVE);
254  }
255  else
256  {
257  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) chase %s",
258  _owner->GetEntry(),
259  _owner->GetGUID().ToString().c_str(),
260  target->GetGUID().ToString().c_str());
262  }
263 }
Definition: TargetedMovementGenerator.h:67
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Unit.h:675
Definition: MotionMaster.h:61
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
uint32 GetEntry() const
Definition: Object.h:107
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void MotionMaster::MoveCirclePath ( float  x,
float  y,
float  z,
float  radius,
bool  clockwise,
uint8  stepCount 
)
386 {
387  float step = 2 * float(M_PI) / stepCount * (clockwise ? -1.0f : 1.0f);
388  Position const& pos = { x, y, z, 0.0f };
389  float angle = pos.GetAngle(_owner->GetPositionX(), _owner->GetPositionY());
390 
392 
393  for (uint8 i = 0; i < stepCount; angle += step, ++i)
394  {
395  G3D::Vector3 point;
396  point.x = x + radius * cosf(angle);
397  point.y = y + radius * sinf(angle);
398 
399  if (_owner->IsFlying())
400  point.z = z;
401  else
402  point.z = _owner->GetMap()->GetHeight(_owner->GetPhaseMask(), point.x, point.y, z);
403 
404  init.Path().push_back(point);
405  }
406 
407  if (_owner->IsFlying())
408  {
409  init.SetFly();
410  init.SetCyclic();
411  init.SetAnimation(Movement::ToFly);
412  }
413  else
414  {
415  init.SetWalk(true);
416  init.SetCyclic();
417  }
418 
419  init.Launch();
420 }
float x
Definition: Vector3.h:62
bool IsFlying() const
Definition: Unit.h:2189
Map * GetMap() const
Definition: Object.h:543
#define M_PI
Definition: Common.h:163
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2314
Definition: MoveSplineInit.h:33
float y
Definition: Vector3.h:62
Definition: Vector3.h:58
uint32 GetPhaseMask() const
Definition: Object.h:461
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
float z
Definition: Vector3.h:62
uint8_t uint8
Definition: Define.h:152
Definition: Position.h:27
G3D::int16 x
Definition: Vector2int16.h:37
Definition: MoveSplineInit.h:52
float GetPositionX() const
Definition: Position.h:104
Unit * _owner
Definition: MotionMaster.h:219

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveConfused ( )
227 {
228  if (_owner->GetTypeId() == TYPEID_PLAYER)
229  {
230  TC_LOG_DEBUG("misc", "Player (%s) move confused", _owner->GetGUID().ToString().c_str());
232  }
233  else
234  {
235  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) move confused",
236  _owner->GetEntry(), _owner->GetGUID().ToString().c_str());
238  }
239 }
Definition: MotionMaster.h:62
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
uint32 GetEntry() const
Definition: Object.h:107
Definition: ConfusedMovementGenerator.h:26
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveDistract ( uint32  time)
575 {
577  return;
578 
579  if (_owner->GetTypeId() == TYPEID_PLAYER)
580  {
581  TC_LOG_DEBUG("misc", "Player (%s) distracted (timer: %u)", _owner->GetGUID().ToString().c_str(), timer);
582  }
583  else
584  {
585  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) (timer: %u)",
586  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), timer);
587  }
588 
590  Mutate(mgen, MOTION_SLOT_CONTROLLED);
591 }
Definition: IdleMovementGenerator.h:53
Definition: MotionMaster.h:62
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
_Ty Impl[MAX_MOTION_SLOT]
Definition: MotionMaster.h:217
uint32 GetEntry() const
Definition: Object.h:107
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveFall ( uint32  id = 0)
441 {
442  // use larger distance for vmap height search than in most other cases
444  if (tz <= INVALID_HEIGHT)
445  {
446  TC_LOG_DEBUG("misc", "MotionMaster::MoveFall: unable retrive a proper height at map %u (x: %f, y: %f, z: %f).",
448  return;
449  }
450 
451  // Abort too if the ground is very near
452  if (std::fabs(_owner->GetPositionZ() - tz) < 0.1f)
453  return;
454 
455  if (_owner->GetTypeId() == TYPEID_PLAYER)
456  _owner->SetFall(true);
457 
459  init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(), tz, false);
460  init.SetFall();
461  init.Launch();
463 }
Map * GetMap() const
Definition: Object.h:543
Definition: MotionMaster.h:62
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2314
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetId(void) const
Definition: Map.h:325
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
uint32 GetPhaseMask() const
Definition: Object.h:461
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
#define MAX_FALL_DISTANCE
Definition: Map.h:249
Definition: PointMovementGenerator.h:63
Definition: ObjectGuid.h:33
Definition: MoveSplineInit.h:52
float GetPositionX() const
Definition: Position.h:104
Unit * _owner
Definition: MotionMaster.h:219
#define INVALID_HEIGHT
Definition: Map.h:248
bool SetFall(bool enable)
Definition: Unit.cpp:15864

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveFleeing ( Unit enemy,
uint32  time = 0 
)
527 {
528  if (!enemy)
529  return;
530 
531  if (_owner->GetTypeId() == TYPEID_PLAYER)
532  {
533  TC_LOG_DEBUG("misc", "Player (%s) flee from (%s)", _owner->GetGUID().ToString().c_str(),
534  enemy->GetGUID().ToString().c_str());
536  }
537  else
538  {
539  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) flee from (%s)%s",
540  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(),
541  enemy->GetGUID().ToString().c_str(),
542  time ? " for a limited time" : "");
543  if (time)
545  else
547  }
548 }
Definition: FleeingMovementGenerator.h:45
Definition: FleeingMovementGenerator.h:25
Definition: MotionMaster.h:62
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
uint32 GetEntry() const
Definition: Object.h:107
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveFollow ( Unit target,
float  dist,
float  angle,
MovementSlot  slot = MOTION_SLOT_ACTIVE 
)
266 {
267  // ignore movement request if target not exist
268  if (!target || target == _owner || _owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
269  return;
270 
271  //_owner->AddUnitState(UNIT_STATE_FOLLOW);
272  if (_owner->GetTypeId() == TYPEID_PLAYER)
273  {
274  TC_LOG_DEBUG("misc", "Player (%s) follow (%s)", _owner->GetGUID().ToString().c_str(), target->GetGUID().ToString().c_str());
275  Mutate(new FollowMovementGenerator<Player>(target, dist, angle), slot);
276  }
277  else
278  {
279  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) follow (%s)", _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), target->GetGUID().ToString().c_str());
280  Mutate(new FollowMovementGenerator<Creature>(target, dist, angle), slot);
281  }
282 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Unit.h:675
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: TargetedMovementGenerator.h:91
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
uint32 GetEntry() const
Definition: Object.h:107
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveIdle ( )

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

186 {
188  if (empty() || !isStatic(top()))
190 }
IdleMovementGenerator si_idleMovement
Definition: IdleMovementGenerator.cpp:24
Definition: MotionMaster.h:60
_Ty top() const
Definition: MotionMaster.h:123
bool isStatic(MovementGenerator *mv)
Definition: MotionMaster.cpp:34
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
bool empty() const
Definition: MotionMaster.h:121

+ Here is the call graph for this function:

void MotionMaster::MoveJump ( Position const pos,
float  speedXY,
float  speedZ,
uint32  id = EVENT_JUMP,
bool  hasOrientation = false,
uint32  arrivalSpellId = 0,
ObjectGuid const arrivalSpellTargetGuid = ObjectGuid::Empty 
)
inline
185  {
186  MoveJump(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), speedXY, speedZ, id, hasOrientation, arrivalSpellId, arrivalSpellTargetGuid);
187  }
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, uint32 arrivalSpellId=0, ObjectGuid const &arrivalSpellTargetGuid=ObjectGuid::Empty)
Definition: MotionMaster.h:184

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveJump ( float  x,
float  y,
float  z,
float  o,
float  speedXY,
float  speedZ,
uint32  id = EVENT_JUMP,
bool  hasOrientation = false,
uint32  arrivalSpellId = 0,
ObjectGuid const arrivalSpellTargetGuid = ObjectGuid::Empty 
)
367 {
368  TC_LOG_DEBUG("misc", "Unit (%s) jump to point (X: %f Y: %f Z: %f)", _owner->GetGUID().ToString().c_str(), x, y, z);
369  if (speedXY <= 0.1f)
370  return;
371 
372  float moveTimeHalf = speedZ / Movement::gravity;
373  float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
374 
376  init.MoveTo(x, y, z, false);
377  init.SetParabolic(max_height, 0);
378  init.SetVelocity(speedXY);
379  if (hasOrientation)
380  init.SetFacing(o);
381  init.Launch();
382  Mutate(new EffectMovementGenerator(id, arrivalSpellId, arrivalSpellTargetGuid), MOTION_SLOT_CONTROLLED);
383 }
TC_GAME_API float gravity
Definition: MovementUtil.cpp:23
Definition: MotionMaster.h:62
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: PointMovementGenerator.h:63
ObjectGuid const & GetGUID() const
Definition: Object.h:105
float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity=0.0f)
Definition: MovementUtil.cpp:59
G3D::int16 x
Definition: Vector2int16.h:37
Definition: MoveSplineInit.h:52
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void MotionMaster::MoveJumpTo ( float  angle,
float  speedXY,
float  speedZ 
)
353 {
354  //this function may make players fall below map
355  if (_owner->GetTypeId() == TYPEID_PLAYER)
356  return;
357 
358  float x, y, z;
359 
360  float moveTimeHalf = speedZ / Movement::gravity;
361  float dist = 2 * moveTimeHalf * speedXY;
362  _owner->GetClosePoint(x, y, z, _owner->GetObjectSize(), dist, angle);
363  MoveJump(x, y, z, 0.0f, speedXY, speedZ);
364 }
TC_GAME_API float gravity
Definition: MovementUtil.cpp:23
TypeID GetTypeId() const
Definition: Object.h:113
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, uint32 arrivalSpellId=0, ObjectGuid const &arrivalSpellTargetGuid=ObjectGuid::Empty)
Definition: MotionMaster.h:184
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: ObjectGuid.h:33
G3D::int16 x
Definition: Vector2int16.h:37
Unit * _owner
Definition: MotionMaster.h:219
float GetObjectSize() const
Definition: Object.cpp:2656
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
Definition: Object.cpp:2623

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveKnockbackFrom ( float  srcX,
float  srcY,
float  speedXY,
float  speedZ 
)
328 {
329  //this function may make players fall below map
330  if (_owner->GetTypeId() == TYPEID_PLAYER)
331  return;
332 
333  if (speedXY <= 0.1f)
334  return;
335 
336  float x, y, z;
337  float moveTimeHalf = speedZ / Movement::gravity;
338  float dist = 2 * moveTimeHalf * speedXY;
339  float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
340 
341  _owner->GetNearPoint(_owner, x, y, z, _owner->GetObjectSize(), dist, _owner->GetAngle(srcX, srcY) + float(M_PI));
342 
344  init.MoveTo(x, y, z);
345  init.SetParabolic(max_height, 0);
346  init.SetOrientationFixed(true);
347  init.SetVelocity(speedXY);
348  init.Launch();
350 }
TC_GAME_API float gravity
Definition: MovementUtil.cpp:23
#define M_PI
Definition: Common.h:163
Definition: MotionMaster.h:62
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
G3D::int16 z
Definition: Vector3int16.h:46
float GetAngle(Position const *pos) const
Definition: Position.cpp:63
G3D::int16 y
Definition: Vector2int16.h:38
Definition: PointMovementGenerator.h:63
Definition: ObjectGuid.h:33
float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity=0.0f)
Definition: MovementUtil.cpp:59
G3D::int16 x
Definition: Vector2int16.h:37
Definition: MoveSplineInit.h:52
Unit * _owner
Definition: MotionMaster.h:219
float GetObjectSize() const
Definition: Object.cpp:2656
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
Definition: Object.cpp:2587

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveLand ( uint32  id,
Position const pos 
)
300 {
301  float x, y, z;
302  pos.GetPosition(x, y, z);
303 
304  TC_LOG_DEBUG("misc", "Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f)", _owner->GetEntry(), id, x, y, z);
305 
307  init.MoveTo(x, y, z);
308  init.SetAnimation(Movement::ToGround);
309  init.Launch();
311 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: MotionMaster.h:61
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
Definition: MoveSplineInit.h:31
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: PointMovementGenerator.h:63
uint32 GetEntry() const
Definition: Object.h:107
G3D::int16 x
Definition: Vector2int16.h:37
Definition: MoveSplineInit.h:52
Unit * _owner
Definition: MotionMaster.h:219

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MovementExpired ( bool  reset = true)
inline
152  {
153  if (_cleanFlag & MMCF_UPDATE)
154  {
155  if (reset)
157  else
159  DelayedExpire();
160  }
161  else
162  DirectExpire(reset);
163  }
uint8 _cleanFlag
Definition: MotionMaster.h:221
void DirectExpire(bool reset)
Definition: MotionMaster.cpp:152
Definition: MotionMaster.h:69
Definition: MotionMaster.h:70
void DelayedExpire()
Definition: MotionMaster.cpp:172

+ Here is the caller graph for this function:

void MotionMaster::MovePath ( uint32  path_id,
bool  repeatable 
)
619 {
620  if (!path_id)
621  return;
622  //We set waypoint movement as new default movement generator
623  // clear ALL movement generators (including default)
624  /*while (!empty())
625  {
626  MovementGenerator *curr = top();
627  curr->Finalize(*_owner);
628  pop();
629  if (!isStatic(curr))
630  delete curr;
631  }*/
632 
633  //_owner->GetTypeId() == TYPEID_PLAYER ?
634  //Mutate(new WaypointMovementGenerator<Player>(path_id, repeatable)):
636 
637  TC_LOG_DEBUG("misc", "%s start moving over path (Id:%u, repeatable: %s)",
638  _owner->GetGUID().ToString().c_str(), path_id, repeatable ? "YES" : "NO");
639 }
Definition: WaypointMovementGenerator.h:54
Definition: MotionMaster.h:60
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MovePoint ( uint32  id,
Position const pos,
bool  generatePath = true 
)
inline
173  { MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, generatePath); }
void MovePoint(uint32 id, Position const &pos, bool generatePath=true)
Definition: MotionMaster.h:172
void MotionMaster::MovePoint ( uint32  id,
float  x,
float  y,
float  z,
bool  generatePath = true 
)
285 {
286  if (_owner->GetTypeId() == TYPEID_PLAYER)
287  {
288  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);
289  Mutate(new PointMovementGenerator<Player>(id, x, y, z, generatePath), MOTION_SLOT_ACTIVE);
290  }
291  else
292  {
293  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) targeted point (ID: %u X: %f Y: %f Z: %f)",
294  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), id, x, y, z);
295  Mutate(new PointMovementGenerator<Creature>(id, x, y, z, generatePath), MOTION_SLOT_ACTIVE);
296  }
297 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: MotionMaster.h:61
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
Definition: PointMovementGenerator.h:26
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
uint32 GetEntry() const
Definition: Object.h:107
G3D::int16 x
Definition: Vector2int16.h:37
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void MotionMaster::MoveRandom ( float  spawndist = 0.0f)
193 {
194  if (_owner->GetTypeId() == TYPEID_UNIT)
195  {
196  TC_LOG_DEBUG("misc", "Creature (%s) start moving random", _owner->GetGUID().ToString().c_str());
198  }
199 }
Definition: MotionMaster.h:60
Definition: ObjectGuid.h:32
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: RandomMovementGenerator.h:25
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveRotate ( uint32  time,
RotateDirection  direction 
)
642 {
643  if (!time)
644  return;
645 
646  Mutate(new RotateMovementGenerator(time, direction), MOTION_SLOT_ACTIVE);
647 }
Definition: IdleMovementGenerator.h:37
Definition: MotionMaster.h:61
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveSeekAssistance ( float  x,
float  y,
float  z 
)
497 {
498  if (_owner->GetTypeId() == TYPEID_PLAYER)
499  {
500  TC_LOG_ERROR("misc", "Player (GUID: %s) attempt to seek assistance", _owner->GetGUID().ToString().c_str());
501  }
502  else
503  {
504  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) seek assistance (X: %f Y: %f Z: %f)",
505  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), x, y, z);
506  _owner->AttackStop();
509  }
510 }
bool AttackStop()
Definition: Unit.cpp:7337
Definition: Unit.h:1129
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: MotionMaster.h:61
Definition: PointMovementGenerator.h:52
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
Unit * _owner
Definition: MotionMaster.h:219
void SetReactState(ReactStates st)
Definition: Creature.h:502
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveSeekAssistanceDistract ( uint32  timer)
513 {
514  if (_owner->GetTypeId() == TYPEID_PLAYER)
515  {
516  TC_LOG_ERROR("misc", "Player (%s) attempt to call distract after assistance", _owner->GetGUID().ToString().c_str());
517  }
518  else
519  {
520  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) is distracted after assistance call (Time: %u)",
521  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), time);
523  }
524 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: MotionMaster.h:61
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: IdleMovementGenerator.h:68

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveSmoothPath ( uint32  pointId,
G3D::Vector3 const pathPoints,
size_t  pathSize,
bool  walk 
)
423 {
424  Movement::PointsArray path(pathPoints, pathPoints + pathSize);
425 
427  init.MovebyPath(path);
428  init.SetSmooth();
429  init.SetWalk(walk);
430  init.Launch();
431 
432  // This code is not correct
433  // EffectMovementGenerator does not affect UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE
434  // need to call PointMovementGenerator with various pointIds
436  //Position pos(pathPoints[pathSize - 1].x, pathPoints[pathSize - 1].y, pathPoints[pathSize - 1].z);
437  //MovePoint(EVENT_CHARGE_PREPATH, pos, false);
438 }
Definition: MotionMaster.h:61
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
std::vector< Vector3 > PointsArray
Definition: MoveSplineInitArgs.h:30
Definition: PointMovementGenerator.h:63
Definition: MoveSplineInit.h:52
Unit * _owner
Definition: MotionMaster.h:219

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveTakeoff ( uint32  id,
Position const pos 
)
314 {
315  float x, y, z;
316  pos.GetPosition(x, y, z);
317 
318  TC_LOG_DEBUG("misc", "Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f)", _owner->GetEntry(), id, x, y, z);
319 
321  init.MoveTo(x, y, z);
322  init.SetAnimation(Movement::ToFly);
323  init.Launch();
325 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: MoveSplineInit.h:33
Definition: MotionMaster.h:61
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: PointMovementGenerator.h:63
uint32 GetEntry() const
Definition: Object.h:107
G3D::int16 x
Definition: Vector2int16.h:37
Definition: MoveSplineInit.h:52
Unit * _owner
Definition: MotionMaster.h:219

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveTargetedHome ( )
202 {
203  Clear(false);
204 
206  {
207  TC_LOG_DEBUG("misc", "Creature (Entry: %u %s) targeted home", _owner->GetEntry(), _owner->GetGUID().ToString().c_str());
209  }
211  {
212  TC_LOG_DEBUG("misc", "Pet or controlled creature (Entry: %u %s) targeting home", _owner->GetEntry(), _owner->GetGUID().ToString().c_str());
213  Unit* target = _owner->ToCreature()->GetCharmerOrOwner();
214  if (target)
215  {
216  TC_LOG_DEBUG("misc", "Following %s", target->GetGUID().ToString().c_str());
218  }
219  }
220  else
221  {
222  TC_LOG_ERROR("misc", "Player (%s) attempt targeted home", _owner->GetGUID().ToString().c_str());
223  }
224 }
#define PET_FOLLOW_ANGLE
Definition: PetDefines.h:78
void Clear(bool reset=true)
Definition: MotionMaster.h:138
Definition: ObjectGuid.h:32
Definition: HomeMovementGenerator.h:30
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: MotionMaster.h:61
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Unit.cpp:12677
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: TargetedMovementGenerator.h:91
Creature * ToCreature()
Definition: Object.h:194
#define PET_FOLLOW_DIST
Definition: PetDefines.h:77
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Unit * _owner
Definition: MotionMaster.h:219
Definition: Unit.h:1305
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MotionMaster::MoveTaxiFlight ( uint32  path,
uint32  pathnode 
)
551 {
552  if (_owner->GetTypeId() == TYPEID_PLAYER)
553  {
554  if (path < sTaxiPathNodesByPath.size())
555  {
556  TC_LOG_DEBUG("misc", "%s taxi to (Path %u node %u)", _owner->GetName().c_str(), path, pathnode);
558  mgen->LoadPath(_owner->ToPlayer());
560  }
561  else
562  {
563  TC_LOG_ERROR("misc", "%s attempt taxi to (not existed Path %u node %u)",
564  _owner->GetName().c_str(), path, pathnode);
565  }
566  }
567  else
568  {
569  TC_LOG_ERROR("misc", "Creature (Entry: %u %s) attempt taxi to (Path %u node %u)",
570  _owner->GetEntry(), _owner->GetGUID().ToString().c_str(), path, pathnode);
571  }
572 }
Definition: WaypointMovementGenerator.h:105
Definition: MotionMaster.h:62
std::string const & GetName() const
Definition: Object.h:479
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition: DB2Stores.cpp:139
Player * ToPlayer()
Definition: Object.h:191
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition: MotionMaster.cpp:593
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Unit * _owner
Definition: MotionMaster.h:219
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void MotionMaster::Mutate ( MovementGenerator m,
MovementSlot  slot 
)
private
594 {
595  if (MovementGenerator *curr = Impl[slot])
596  {
597  Impl[slot] = NULL; // in case a new one is generated in this slot during directdelete
598  if (_top == slot && (_cleanFlag & MMCF_UPDATE))
599  DelayedDelete(curr);
600  else
601  DirectDelete(curr);
602  }
603  else if (_top < slot)
604  {
605  _top = slot;
606  }
607 
608  Impl[slot] = m;
609  if (_top > slot)
610  _needInit[slot] = true;
611  else
612  {
613  _needInit[slot] = false;
614  m->Initialize(_owner);
615  }
616 }
uint8 _cleanFlag
Definition: MotionMaster.h:221
arena_t NULL
Definition: jemalloc_internal.h:624
void DirectDelete(_Ty curr)
Definition: MotionMaster.cpp:685
void DelayedDelete(_Ty curr)
Definition: MotionMaster.cpp:693
int _top
Definition: MotionMaster.h:218
Definition: MotionMaster.h:69
bool _needInit[MAX_MOTION_SLOT]
Definition: MotionMaster.h:220
_Ty Impl[MAX_MOTION_SLOT]
Definition: MotionMaster.h:217
Definition: MovementGenerator.h:30
Unit * _owner
Definition: MotionMaster.h:219
virtual void Initialize(Unit *)=0

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool MotionMaster::needInitTop ( ) const
inlineprivate
100  {
101  if (empty())
102  return false;
103  return _needInit[_top];
104  }
int _top
Definition: MotionMaster.h:218
bool _needInit[MAX_MOTION_SLOT]
Definition: MotionMaster.h:220
bool empty() const
Definition: MotionMaster.h:121

+ Here is the caller graph for this function:

void MotionMaster::pop ( )
inlineprivate
89  {
90  if (empty())
91  return;
92 
93  Impl[_top] = NULL;
94  while (!empty() && !top())
95  --_top;
96  }
arena_t NULL
Definition: jemalloc_internal.h:624
_Ty top() const
Definition: MotionMaster.h:123
int _top
Definition: MotionMaster.h:218
_Ty Impl[MAX_MOTION_SLOT]
Definition: MotionMaster.h:217
bool empty() const
Definition: MotionMaster.h:121

+ Here is the caller graph for this function:

void MotionMaster::propagateSpeedChange ( )
650 {
651  /*Impl::container_type::iterator it = Impl::c.begin();
652  for (; it != end(); ++it)
653  {
654  (*it)->unitSpeedChanged();
655  }*/
656  for (int i = 0; i <= _top; ++i)
657  {
658  if (Impl[i])
659  Impl[i]->unitSpeedChanged();
660  }
661 }
int _top
Definition: MotionMaster.h:218
virtual void unitSpeedChanged()
Definition: MovementGenerator.h:44
_Ty Impl[MAX_MOTION_SLOT]
Definition: MotionMaster.h:217

+ Here is the call graph for this function:

void MotionMaster::push ( _Ty  _Val)
inlineprivate
97 { ++_top; Impl[_top] = _Val; }
int _top
Definition: MotionMaster.h:218
_Ty Impl[MAX_MOTION_SLOT]
Definition: MotionMaster.h:217
int MotionMaster::size ( ) const
inline
122 { return _top + 1; }
int _top
Definition: MotionMaster.h:218

+ Here is the caller graph for this function:

_Ty MotionMaster::top ( ) const
inline
124  {
125  ASSERT(!empty());
126  return Impl[_top];
127  }
int _top
Definition: MotionMaster.h:218
#define ASSERT
Definition: Errors.h:55
_Ty Impl[MAX_MOTION_SLOT]
Definition: MotionMaster.h:217
bool empty() const
Definition: MotionMaster.h:121

+ Here is the caller graph for this function:

void MotionMaster::UpdateMotion ( uint32  diff)
80 {
81  if (!_owner)
82  return;
83 
84  if (_owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED)) // what about UNIT_STATE_DISTRACTED? Why is this not included?
85  return;
86 
87  ASSERT(!empty());
88 
90  if (!top()->Update(_owner, diff))
91  {
94  }
95  else
97 
98  if (_expList)
99  {
100  for (size_t i = 0; i < _expList->size(); ++i)
101  {
102  MovementGenerator* mg = (*_expList)[i];
103  DirectDelete(mg);
104  }
105 
106  delete _expList;
107  _expList = NULL;
108 
109  if (empty())
110  Initialize();
111  else if (needInitTop())
112  InitTop();
113  else if (_cleanFlag & MMCF_RESET)
114  top()->Reset(_owner);
115 
116  _cleanFlag &= ~MMCF_RESET;
117  }
118 
119  // probably not the best place to pu this but im not really sure where else to put it.
121 }
uint8 _cleanFlag
Definition: MotionMaster.h:221
Map * GetMap() const
Definition: Object.h:543
ExpireList * _expList
Definition: MotionMaster.h:216
arena_t NULL
Definition: jemalloc_internal.h:624
void DirectDelete(_Ty curr)
Definition: MotionMaster.cpp:685
_Ty top() const
Definition: MotionMaster.h:123
Definition: MotionMaster.h:69
Definition: Unit.h:553
void InitTop()
Definition: MotionMaster.cpp:679
bool needInitTop() const
Definition: MotionMaster.h:99
float GetPositionY() const
Definition: Position.h:105
virtual void UpdateUnderwaterState(Map *m, float x, float y, float z)
Definition: Unit.cpp:2974
float GetPositionZ() const
Definition: Position.h:106
Definition: MotionMaster.h:70
Definition: Unit.h:560
virtual void Reset(Unit *)=0
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
#define ASSERT
Definition: Errors.h:55
Definition: MovementGenerator.h:30
void Initialize()
Definition: MotionMaster.cpp:39
float GetPositionX() const
Definition: Position.h:104
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:151
Unit * _owner
Definition: MotionMaster.h:219
void Update(uint32 diff)
Definition: WeatherMgr.cpp:150
bool empty() const
Definition: MotionMaster.h:121

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

uint8 MotionMaster::_cleanFlag
private
ExpireList* MotionMaster::_expList
private
bool MotionMaster::_needInit[MAX_MOTION_SLOT]
private
Unit* MotionMaster::_owner
private
int MotionMaster::_top
private
_Ty MotionMaster::Impl[MAX_MOTION_SLOT]
private

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