AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
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
 
uint8 GetCleanFlags () const
 
void DirectDelete (_Ty curr)
 
void DelayedDelete (_Ty curr)
 
void UpdateMotion (uint32 diff)
 
void Clear (bool reset=true)
 
void MovementExpired (bool reset=true)
 
void MovementExpiredOnSlot (MovementSlot slot, bool reset=true)
 
void MoveIdle ()
 
void MoveTargetedHome (bool walk=false)
 The unit will return this initial position (owner for pets and summoned creatures). Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveRandom (float wanderDistance=0.0f)
 Enable a random movement in desired range around the unit. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveFollow (Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE, bool inheritWalkState=true, bool inheritSpeed=true)
 The unit will follow this target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveFormation (Unit *leader, float dist, float angle, uint32 point1, uint32 point2)
 
void MoveChase (Unit *target, std::optional< ChaseRange > dist={}, std::optional< ChaseAngle > angle={})
 Force the unit to chase this target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveChase (Unit *target, float dist, float angle)
 
void MoveChase (Unit *target, float dist)
 
void MoveCircleTarget (Unit *target)
 
void MoveBackwards (Unit *target, float dist)
 
void MoveForwards (Unit *target, float dist)
 
void MoveConfused ()
 Enable the confusion movement. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveFleeing (Unit *enemy, uint32 time=0)
 Enable the target's fleeing movement. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MovePoint (uint32 id, Position const &pos, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE, float speed=0.f, bool generatePath=true, bool forceDestination=true, std::optional< AnimTier > animTier=std::nullopt)
 
void MovePoint (uint32 id, float x, float y, float z, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE, float speed=0.f, float orientation=0.0f, bool generatePath=true, bool forceDestination=true, MovementSlot slot=MOTION_SLOT_ACTIVE, std::optional< AnimTier > animTier=std::nullopt)
 The unit will move to a specific point. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveSplinePath (Movement::PointsArray *path, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE)
 
void MovePath (uint32 path_id, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE, PathSource pathSource=PathSource::WAYPOINT_MGR)
 
void MoveLand (uint32 id, Position const &pos, float speed=0.0f)
 Use to move the unit from the air to the ground. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveLand (uint32 id, float x, float y, float z, float speed=0.0f)
 Use to move the unit from the air to the ground. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveTakeoff (uint32 id, Position const &pos, float speed=0.0f, bool skipAnimation=false)
 Use to move the unit from the ground to the air. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveTakeoff (uint32 id, float x, float y, float z, float speed=0.0f, bool skipAnimation=false)
 Use to move the unit from the air to the ground. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveCharge (float x, float y, float z, float speed=SPEED_CHARGE, uint32 id=EVENT_CHARGE, Movement::PointsArray const *path=nullptr, bool generatePath=false, float orientation=0.0f, ObjectGuid targetGUID=ObjectGuid::Empty)
 The unit will charge the target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveCharge (PathGenerator const &path, float speed=SPEED_CHARGE, ObjectGuid targetGUID=ObjectGuid::Empty)
 The unit will charge the target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveKnockbackFrom (float srcX, float srcY, float speedXY, float speedZ, bool allowClientControlled=false)
 
void MoveJumpTo (float angle, float speedXY, float speedZ)
 The unit will jump in a specific direction.
 
void MoveJump (Position const &pos, float speedXY, float speedZ, uint32 id=0)
 
void MoveJump (float x, float y, float z, float speedXY, float speedZ, uint32 id=0, Unit const *target=nullptr)
 The unit will jump to a specific point.
 
void MoveCirclePath (float x, float y, float z, float radius, bool clockwise, uint8 stepCount, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE, float speed=0.0f)
 Makes the unit travel a closed, cyclic path around (x, y, z).
 
void MoveFall (uint32 id=0, bool addFlagForNPC=false)
 The unit will fall. Used when in the air. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveSeekAssistance (float x, float y, float z)
 
void MoveSeekAssistanceDistract (uint32 timer)
 
void MoveTaxiFlight (uint32 path, uint32 pathnode)
 
void MoveDistract (uint32 time)
 Enable the target's distract movement. Doesn't work with UNIT_FLAG_DISABLE_MOVE and if the unit has MOTION_SLOT_CONTROLLED (generaly apply when the unit is controlled).
 
void MoveWaypoint (uint32 path_id, bool repeatable, PathSource pathSource=PathSource::WAYPOINT_MGR)
 Move the unit following a specific path. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
 
void MoveRotate (uint32 time, RotateDirection direction)
 Rotate the unit. You can specify the time of the rotation.
 
void MovePointBackwards (uint32 id, float x, float y, float z, bool generatePath=true, bool forceDestination=true, MovementSlot slot=MOTION_SLOT_ACTIVE, float orientation=0.0f)
 
MovementGeneratorType GetCurrentMovementGeneratorType () const
 
MovementGeneratorType GetMotionSlotType (int slot) const
 
bool HasMovementGeneratorType (MovementGeneratorType type) const
 
uint32 GetCurrentSplineId () const
 
void propagateSpeedChange ()
 
void ReinitializeMovement ()
 
bool GetDestination (float &x, float &y, float &z)
 
void DistanceYourself (float range)
 

Private Types

typedef MovementGenerator * _Ty
 
typedef std::vector< _Ty > ExpireList
 

Private Member Functions

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

Private Attributes

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

Detailed Description

Member Typedef Documentation

◆ _Ty

◆ ExpireList

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

Constructor & Destructor Documentation

◆ MotionMaster()

MotionMaster::MotionMaster ( Unit *  unit)
inlineexplicit
162 : _expList(nullptr), _top(-1), _owner(unit), _cleanFlag(MMCF_NONE)
163 {
164 for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
165 {
166 Impl[i] = nullptr;
167 _needInit[i] = true;
168 }
169 }
std::uint8_t uint8
Definition Define.h:109
@ MMCF_NONE
Definition MotionMaster.h:72
@ MAX_MOTION_SLOT
Definition MotionMaster.h:67
int _top
Definition MotionMaster.h:297
Unit * _owner
Definition MotionMaster.h:298
bool _needInit[MAX_MOTION_SLOT]
Definition MotionMaster.h:299
ExpireList * _expList
Definition MotionMaster.h:295
_Ty Impl[MAX_MOTION_SLOT]
Definition MotionMaster.h:296
uint8 _cleanFlag
Definition MotionMaster.h:300

References _needInit, Impl, and MAX_MOTION_SLOT.

◆ ~MotionMaster()

MotionMaster::~MotionMaster ( )
96{
97 // clear ALL movement generators (including default)
98 while (!empty())
99 {
100 MovementGenerator* curr = top();
101 pop();
102 if (curr && !isStatic(curr))
103 delete curr; // Skip finalizing on delete, it might launch new movement
104 }
105}
bool isStatic(MovementGenerator *movement)
Definition MotionMaster.cpp:71
_Ty top() const
Definition MotionMaster.h:177
void pop()
Definition MotionMaster.h:144
bool empty() const
Definition MotionMaster.h:175
Definition MovementGenerator.h:28

References empty(), isStatic(), pop(), and top().

Member Function Documentation

◆ Clear()

void MotionMaster::Clear ( bool  reset = true)
inline
195 {
197 {
198 if (reset)
200 else
201 _cleanFlag &= ~MMCF_RESET;
202 DelayedClean();
203 }
204 else
205 DirectClean(reset);
206 }
@ MMCF_RESET
Definition MotionMaster.h:74
@ MMCF_UPDATE
Definition MotionMaster.h:73
void DelayedClean()
Definition MotionMaster.cpp:167
void DirectClean(bool reset)
Definition MotionMaster.cpp:149

References _cleanFlag, DelayedClean(), DirectClean(), MMCF_RESET, and MMCF_UPDATE.

Referenced by PetAI::_stopAttack(), SmartAI::AttackStart(), Pet::CastPendingSpell(), Unit::CleanupBeforeRemoveFromMap(), boss_julianne::DamageTaken(), boss_grand_champion::boss_grand_championAI::DamageTaken(), boss_bronjahm::DamageTaken(), boss_hodir::DamageTaken(), npc_ulduar_leviathan_mkii::DamageTaken(), npc_ulduar_aerial_command_unit::DamageTaken(), boss_essence_of_suffering::boss_essence_of_sufferingAI::DamageTaken(), boss_essence_of_desire::boss_essence_of_desireAI::DamageTaken(), npc_blistering_zombie::npc_blistering_zombieAI::DamageTaken(), npc_icc_ice_sphere::npc_icc_ice_sphereAI::DoAction(), npc_weegli_blastfuse::npc_weegli_blastfuseAI::DoAction(), npc_twilight_volunteer::DoAction(), boss_taldaram::DoAction(), npc_high_overlord_saurfang_icc::npc_high_overlord_saurfangAI::DoAction(), npc_muradin_bronzebeard_icc::npc_muradin_bronzebeard_iccAI::DoAction(), npc_ulduar_hodir_priest::DoAction(), npc_ulduar_hodir_druid::DoAction(), npc_ulduar_hodir_shaman::DoAction(), npc_ulduar_hodir_mage::DoAction(), npc_kalecgos_kj::DoAction(), boss_skadi_grauf::boss_skadi_graufAI::DoAction(), boss_illidan_stormrage::DoAction(), Spell::EffectSummonType(), npc_argent_captainAI::EnterEvadeMode(), brann_bronzebeard::EnterEvadeMode(), CreatureAI::EnterEvadeMode(), npc_pet_dk_ebon_gargoyle::EnterEvadeMode(), npc_pet_gen_argent_pony_bridle::EnterEvadeMode(), npc_pet_mage_mirror_image::EnterEvadeMode(), boss_halazzi::EnterPhase(), boss_zuljin::EnterPhase(), UtherBatteredHiltEvent::Execute(), npc_singularity::FindAndFollowTarget(), npc_hallows_end_soh::FinishEvent(), npc_pet_dk_ebon_gargoyle::FlyAway(), boss_nightbane::FlyToClosestPreFlyWayPoint(), spell_q6124_6129_apply_salve::HandleDummy(), spell_q11919_q11940_drake_hunt_aura::HandleEffectRemove(), boss_sartharion_dragonAI::HandleExtraEvent(), spell_item_toxic_wasteling::HandleJump(), AuraEffect::HandleModPossessPet(), spell_item_enchanted_broom_periodic::HandlePeriodicTick(), WorldSession::HandlePetActionHelper(), PetAI::HandleReturnMovement(), spell_gen_ayamiss_swarmer_loop::HandleScript(), npc_valkyr_shadowguard::npc_valkyr_shadowguardAI::HandleSpeedChangeIfNeeded(), boss_prince_keleseth_icc::boss_prince_kelesethAI::JustDied(), boss_prince_taldaram_icc::boss_prince_taldaramAI::JustDied(), boss_prince_valanar_icc::boss_prince_valanarAI::JustDied(), npc_zulian_prowler::npc_zulian_prowlerAI::JustEngagedWith(), boss_grandmaster_vorpil::JustEngagedWith(), boss_swamplord_muselek::JustEngagedWith(), boss_high_botanist_freywinn::JustEngagedWith(), boss_felmyst::JustEngagedWith(), boss_high_astromancer_solarian::JustEngagedWith(), boss_algalon_the_observer::JustSummoned(), boss_mennu_the_betrayer::JustSummoned(), FollowerAI::MoveInLineOfSight(), npc_escortAI::MoveInLineOfSight(), SmartAI::MoveInLineOfSight(), npc_aged_dying_ancient_kodo::MoveInLineOfSight(), PetAI::MovementInform(), boss_professor_putricide::boss_professor_putricideAI::MovementInform(), boss_four_horsemen::boss_four_horsemenAI::MovementInform(), npc_wild_wyrm::MovementInform(), boss_kaelthas::MovementInform(), boss_jedoga_shadowseeker::MovementInform(), MoveTargetedHome(), boss_leotheras_the_blind::MoveToTargetIfOutOfRange(), npc_pet_dk_ebon_gargoyle::MySelectNextTarget(), spell_halion_twilight_phasing_aura::OnApply(), spell_halion_twilight_phasing_aura::OnRemove(), NPCStaveQuestAI::PrepareForEncounter(), boss_felblood_kaelthas::Reset(), npc_valkyr_battle_maiden::Reset(), boss_janalai::Reset(), npc_janalai_hatcher::Reset(), npc_batrider::Reset(), boss_archimonde::Reset(), boss_taldaram::Reset(), npc_q24545_lich_king::npc_q24545_lich_kingAI::Reset(), boss_leotheras_the_blind::Reset(), boss_magtheridon::Reset(), npc_pet_gen_gnomish_flame_turret::Reset(), boss_magtheridon::ScheduleCombatEvents(), boss_felmyst::ScheduleGroundAbilities(), boss_nightbane::ScheduleLand(), boss_loken::ScheduleTasks(), boss_laj::ScheduleTasks(), npc_putricide_oozeAI::SelectNewTarget(), npc_icc_ice_sphere::npc_icc_ice_sphereAI::SelectNewTarget(), Unit::SetCharmedBy(), boss_grand_warlock_nethekurse::SetData(), Unit::setDeathState(), FollowerAI::SetFollowComplete(), FollowerAI::SetFollowPaused(), npc_scarlet_ghoul::SetGUID(), npc_tirion_fordring_tft::npc_tirion_fordringAI::SpellHit(), boss_urom::boss_uromAI::SpellHit(), boss_devourer_of_souls::SpellHitTarget(), FollowerAI::StartFollow(), SmartAI::StopFollow(), Spell::SummonGuardian(), boss_quartermaster_zigris::UpdateAI(), boss_mr_smite::boss_mr_smiteAI::UpdateAI(), npc_highlord_darion_mograine::UpdateAI(), npc_draenei_survivor::npc_draenei_survivorAI::UpdateAI(), npc_weegli_blastfuse::npc_weegli_blastfuseAI::UpdateAI(), boss_jedoga_shadowseeker::UpdateAI(), npc_twilight_volunteer::UpdateAI(), boss_hadronox::UpdateAI(), boss_jormungarAI::UpdateAI(), boss_icehowl::boss_icehowlAI::UpdateAI(), npc_saurfang_event::npc_saurfang_eventAI::UpdateAI(), npc_strangulate_vehicle::npc_strangulate_vehicleAI::UpdateAI(), npc_valithria_cloud::npc_valithria_cloudAI::UpdateAI(), boss_malygos::UpdateAI(), npc_spark_of_ionar::UpdateAI(), boss_algalon_the_observer::UpdateAI(), boss_mimiron::UpdateAI(), boss_ymiron::boss_ymironAI::UpdateAI(), npc_commander_eligor_dawnbringer::npc_commander_eligor_dawnbringerAI::UpdateAI(), boss_omor_the_unscarred::UpdateAI(), npc_pet_gen_plump_turkey::UpdateAI(), npc_pet_gen_toxic_wasteling::UpdateAI(), and PetAI::UpdateAI().

◆ DelayedClean()

void MotionMaster::DelayedClean ( )
private
168{
169 while (size() > 1)
170 {
171 MovementGenerator* curr = top();
172 pop();
173 if (curr) DelayedDelete(curr);
174 }
175}
int size() const
Definition MotionMaster.h:176
void DelayedDelete(_Ty curr)
Definition MotionMaster.cpp:1141

References DelayedDelete(), pop(), size(), and top().

Referenced by Clear().

◆ DelayedDelete()

void MotionMaster::DelayedDelete ( _Ty  curr)
1142{
1143 LOG_DEBUG("movement.motionmaster", "Unit (Entry {}) is trying to delete its updating MG (Type {})!", _owner->GetEntry(), curr->GetMovementGeneratorType());
1144 if (isStatic(curr))
1145 return;
1146 if (!_expList)
1147 _expList = new ExpireList();
1148 _expList->push_back(curr);
1149}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
std::vector< _Ty > ExpireList
Definition MotionMaster.h:294
uint32 GetEntry() const
Definition Object.h:123

References _expList, _owner, Object::GetEntry(), MovementGenerator::GetMovementGeneratorType(), isStatic(), and LOG_DEBUG.

Referenced by DelayedClean(), DelayedExpire(), and Mutate().

◆ DelayedExpire()

void MotionMaster::DelayedExpire ( )
private
198{
199 if (size() > 1)
200 {
201 MovementGenerator* curr = top();
202 pop();
203 if (curr) DelayedDelete(curr);
204 }
205
206 while (!empty() && !top())
207 --_top;
208}

References _top, DelayedDelete(), empty(), pop(), size(), and top().

Referenced by MovementExpired().

◆ DirectClean()

void MotionMaster::DirectClean ( bool  reset)
private
150{
151 while (size() > 1)
152 {
153 MovementGenerator* curr = top();
154 pop();
155 if (curr) DirectDelete(curr);
156 }
157
158 if (empty())
159 return;
160
161 if (needInitTop())
162 InitTop();
163 else if (reset)
164 top()->Reset(_owner);
165}
void InitTop()
Definition MotionMaster.cpp:1127
void DirectDelete(_Ty curr)
Definition MotionMaster.cpp:1133
bool needInitTop() const
Definition MotionMaster.h:154
virtual void Reset(Unit *)=0

References _owner, DirectDelete(), empty(), InitTop(), needInitTop(), pop(), MovementGenerator::Reset(), size(), and top().

Referenced by Clear().

◆ DirectDelete()

void MotionMaster::DirectDelete ( _Ty  curr)
1134{
1135 if (isStatic(curr))
1136 return;
1137 curr->Finalize(_owner);
1138 delete curr;
1139}

References _owner, MovementGenerator::Finalize(), and isStatic().

Referenced by DirectClean(), DirectExpire(), DirectExpireSlot(), Initialize(), Mutate(), and UpdateMotion().

◆ DirectExpire()

void MotionMaster::DirectExpire ( bool  reset)
private
178{
179 if (size() > 1)
180 {
181 MovementGenerator* curr = top();
182 pop();
183 if (curr) DirectDelete(curr);
184 }
185
186 while (!empty() && !top())
187 --_top;
188
189 if (empty())
190 Initialize();
191 else if (needInitTop())
192 InitTop();
193 else if (reset)
194 top()->Reset(_owner);
195}
void Initialize()
Definition MotionMaster.cpp:76

References _owner, _top, DirectDelete(), empty(), Initialize(), InitTop(), needInitTop(), pop(), MovementGenerator::Reset(), size(), and top().

Referenced by MovementExpired().

◆ DirectExpireSlot()

void MotionMaster::DirectExpireSlot ( MovementSlot  slot,
bool  reset 
)
private
211{
212 if (size() > 1)
213 {
214 MovementGenerator* curr = Impl[slot];
215
216 // pussywizard: clear slot AND decrease top immediately to avoid crashes when referencing null top in DirectDelete
217 Impl[slot] = nullptr;
218 while (!empty() && !top())
219 --_top;
220
221 if (curr) DirectDelete(curr);
222 }
223
224 while (!empty() && !top())
225 --_top;
226
227 if (empty())
228 Initialize();
229 else if (needInitTop())
230 InitTop();
231 else if (reset)
232 top()->Reset(_owner);
233}

References _owner, _top, DirectDelete(), empty(), Impl, Initialize(), InitTop(), needInitTop(), MovementGenerator::Reset(), size(), and top().

Referenced by MovementExpiredOnSlot().

◆ DistanceYourself()

void MotionMaster::DistanceYourself ( float  range)
355{
357 {
358 if (_owner->IsPlayer())
359 {
361 gen->DistanceYourself((Player*)_owner, dist);
362 }
363 else
364 {
366 gen->DistanceYourself((Creature*)_owner, dist);
367 }
368 return;
369 }
370}
@ CHASE_MOTION_TYPE
Definition MotionMaster.h:45
Definition TargetedMovementGenerator.h:38
void DistanceYourself(T *owner, float distance)
Definition TargetedMovementGenerator.cpp:83
Definition Creature.h:47
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition MotionMaster.cpp:1088
bool IsPlayer() const
Definition Object.h:207
Definition Player.h:1086

References _owner, CHASE_MOTION_TYPE, ChaseMovementGenerator< T >::DistanceYourself(), GetCurrentMovementGeneratorType(), Object::IsPlayer(), and top().

Referenced by SmartAI::DistanceYourself().

◆ empty()

◆ GetCleanFlags()

uint8 MotionMaster::GetCleanFlags ( ) const
inline
188{ return _cleanFlag; }

References _cleanFlag.

◆ GetCurrentMovementGeneratorType()

MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType ( ) const
1089{
1090 if (empty())
1091 return IDLE_MOTION_TYPE;
1092
1093 return top()->GetMovementGeneratorType();
1094}
@ IDLE_MOTION_TYPE
Definition MotionMaster.h:39
virtual MovementGeneratorType GetMovementGeneratorType()=0

References empty(), MovementGenerator::GetMovementGeneratorType(), IDLE_MOTION_TYPE, and top().

Referenced by Creature::AtEngage(), DistanceYourself(), GuardAI::EnterEvadeMode(), FollowerAI::EnterEvadeMode(), boss_volkhan::GoToAnvil(), WorldSession::HandleGossipHelloOpcode(), npc_commandscript::HandleNpcUnFollowCommand(), WorldSession::HandleQuestgiverHelloOpcode(), WorldSession::HandleSetRaidDifficultyOpcode(), IsMutualChase(), SmartAI::JustReachedHome(), MoveChase(), SmartAI::MovepointReached(), go_beacon::go_beaconAI::OnStateChanged(), SplineHandler::operator()(), WorldSession::SendListInventory(), SmartAI::SetCombatMovement(), Unit::SetSpeed(), npc_escortAI::Start(), FollowerAI::StartFollow(), npc_rabid_thistle_bear::npc_rabid_thistle_bearAI::UpdateAI(), boss_hadronox::UpdateAI(), boss_grand_champion::boss_grand_championAI::UpdateAI(), npc_anubarak_spike::npc_anubarak_spikeAI::UpdateAI(), npc_high_overlord_saurfang_igb::npc_high_overlord_saurfang_igbAI::UpdateAI(), npc_muradin_bronzebeard_igb::npc_muradin_bronzebeard_igbAI::UpdateAI(), boss_lord_marrowgar::UpdateAI(), boss_sindragosa::boss_sindragosaAI::UpdateAI(), boss_the_lich_king::boss_the_lich_kingAI::UpdateAI(), boss_flame_leviathan_safety_container::UpdateAI(), npc_infra_green_bomber_generic::npc_infra_green_bomber_genericAI::UpdateAI(), npc_fel_guard_hound::npc_fel_guard_houndAI::UpdateAI(), npc_mature_netherwing_drake::npc_mature_netherwing_drakeAI::UpdateAI(), npc_concentrated_ball::npc_concentrated_ballAI::UpdateAI(), and Player::UpdateCharmedAI().

◆ GetCurrentSplineId()

uint32 MotionMaster::GetCurrentSplineId ( ) const
1120{
1121 if (empty())
1122 return 0;
1123
1124 return top()->GetSplineId();
1125}
virtual uint32 GetSplineId() const
Definition MovementGenerator.h:41

References empty(), MovementGenerator::GetSplineId(), and top().

Referenced by SplineHandler::operator()().

◆ GetDestination()

bool MotionMaster::GetDestination ( float &  x,
float &  y,
float &  z 
)
1152{
1153 if (_owner->movespline->Finalized())
1154 return false;
1155
1156 G3D::Vector3 const& dest = _owner->movespline->FinalDestination();
1157 x = dest.x;
1158 y = dest.y;
1159 z = dest.z;
1160 return true;
1161}
bool Finalized() const
Definition MoveSpline.h:118
Vector3 FinalDestination() const
Definition MoveSpline.h:122
Movement::MoveSpline * movespline
Definition Unit.h:2121

References _owner, Movement::MoveSpline::FinalDestination(), Movement::MoveSpline::Finalized(), and Unit::movespline.

Referenced by misc_commandscript::HandleMovegensCommand().

◆ GetMotionSlot()

_Ty MotionMaster::GetMotionSlot ( int  slot) const
inline
183 {
184 ASSERT(slot >= 0);
185 return Impl[slot];
186 }
#define ASSERT
Definition Errors.h:68

References ASSERT, and Impl.

Referenced by HomeMovementGenerator< Creature >::_setTargetLocation(), Creature::CanCreatureAttack(), and misc_commandscript::HandleMovegensCommand().

◆ GetMotionSlotType()

◆ HasMovementGeneratorType()

bool MotionMaster::HasMovementGeneratorType ( MovementGeneratorType  type) const
1105{
1106 if (empty() && type == IDLE_MOTION_TYPE)
1107 return true;
1108
1109 for (int i = _top; i >= 0; --i)
1110 {
1111 if (Impl[i] && Impl[i]->GetMovementGeneratorType() == type)
1112 return true;
1113 }
1114
1115 return false;
1116}

References _top, empty(), IDLE_MOTION_TYPE, and Impl.

◆ InitDefault()

void MotionMaster::InitDefault ( )
91{
93}
@ MOTION_SLOT_IDLE
Definition MotionMaster.h:64
void Mutate(MovementGenerator *m, MovementSlot slot)
Definition MotionMaster.cpp:984
MovementGenerator * SelectMovementGenerator(Unit *unit)
Definition CreatureAISelector.cpp:91

References _owner, MOTION_SLOT_IDLE, Mutate(), and FactorySelector::SelectMovementGenerator().

Referenced by Initialize(), npc_mature_netherwing_drake::npc_mature_netherwing_drakeAI::JustReachedHome(), Unit::RemoveCharmedBy(), and Creature::Respawn().

◆ Initialize()

◆ InitTop()

void MotionMaster::InitTop ( )
private
1128{
1129 top()->Initialize(_owner);
1130 _needInit[_top] = false;
1131}
virtual void Initialize(Unit *)=0

References _needInit, _owner, _top, MovementGenerator::Initialize(), and top().

Referenced by DirectClean(), DirectExpire(), DirectExpireSlot(), and UpdateMotion().

◆ MoveBackwards()

void MotionMaster::MoveBackwards ( Unit *  target,
float  dist 
)
373{
374 if (!target)
375 {
376 return;
377 }
378
379 Position const& pos = target->GetPosition();
380 float angle = target->GetAngle(_owner);
381 G3D::Vector3 point;
382 point.x = pos.m_positionX + dist * cosf(angle);
383 point.y = pos.m_positionY + dist * sinf(angle);
384 point.z = pos.m_positionZ;
385
386 if (!_owner->GetMap()->CanReachPositionAndGetValidCoords(_owner, point.x, point.y, point.z, true, true))
387 {
388 return;
389 }
390
392 init.MoveTo(point.x, point.y, point.z, false);
393 init.SetWalk(true);
394 init.SetFacing(target);
395 init.SetOrientationInversed();
396 init.Launch();
397}
bool CanReachPositionAndGetValidCoords(WorldObject const *source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
Check if a given source can reach a specific point following a path and normalize the coords....
Definition Map.cpp:3381
Definition MoveSplineInit.h:63
Map * GetMap() const
Definition Object.h:637
Definition Position.h:27
float GetAngle(Position const *pos) const
Definition Position.cpp:85
float m_positionZ
Definition Position.h:57
float m_positionX
Definition Position.h:55
float m_positionY
Definition Position.h:56
void GetPosition(float &x, float &y) const
Definition Position.h:126

References _owner, Map::CanReachPositionAndGetValidCoords(), Position::GetAngle(), WorldObject::GetMap(), Position::GetPosition(), Movement::MoveSplineInit::Launch(), Position::m_positionX, Position::m_positionY, Position::m_positionZ, Movement::MoveSplineInit::MoveTo(), Movement::MoveSplineInit::SetFacing(), Movement::MoveSplineInit::SetOrientationInversed(), and Movement::MoveSplineInit::SetWalk().

Referenced by CreatureAI::MoveBackwardsChecks().

◆ MoveCharge() [1/2]

void MotionMaster::MoveCharge ( float  x,
float  y,
float  z,
float  speed = SPEED_CHARGE,
uint32  id = EVENT_CHARGE,
Movement::PointsArray const *  path = nullptr,
bool  generatePath = false,
float  orientation = 0.0f,
ObjectGuid  targetGUID = ObjectGuid::Empty 
)

The unit will charge the target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

826{
828 return;
829
830 if (Impl[MOTION_SLOT_CONTROLLED] && Impl[MOTION_SLOT_CONTROLLED]->GetMovementGeneratorType() != DISTRACT_MOTION_TYPE)
831 return;
832
833 if (_owner->IsPlayer())
834 {
835 LOG_DEBUG("movement.motionmaster", "Player ({}) charge point (X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), x, y, z);
836 Mutate(new PointMovementGenerator<Player>(id, x, y, z, FORCED_MOVEMENT_NONE, speed, orientation, path, generatePath, generatePath, std::nullopt, targetGUID), MOTION_SLOT_CONTROLLED);
837 }
838 else
839 {
840 LOG_DEBUG("movement.motionmaster", "Creature ({}) charge point (X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), x, y, z);
841 Mutate(new PointMovementGenerator<Creature>(id, x, y, z, FORCED_MOVEMENT_NONE, speed, orientation, path, generatePath, generatePath, std::nullopt, targetGUID), MOTION_SLOT_CONTROLLED);
842 }
843}
@ MOTION_SLOT_CONTROLLED
Definition MotionMaster.h:66
@ DISTRACT_MOTION_TYPE
Definition MotionMaster.h:50
@ FORCED_MOVEMENT_NONE
Definition MotionMaster.h:86
@ UNIT_FLAG_DISABLE_MOVE
Definition UnitDefines.h:259
std::string ToString() const
Definition ObjectGuid.cpp:48
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:120
Definition PointMovementGenerator.h:28
bool HasUnitFlag(UnitFlags flags) const
Definition Unit.h:750

References _owner, DISTRACT_MOTION_TYPE, FORCED_MOVEMENT_NONE, Object::GetGUID(), Unit::HasUnitFlag(), Impl, Object::IsPlayer(), LOG_DEBUG, MOTION_SLOT_CONTROLLED, Mutate(), ObjectGuid::ToString(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by boss_professor_putricide::boss_professor_putricideAI::ChangePhase(), npc_frost_sphere::npc_frost_sphereAI::DamageTaken(), npc_ulduar_leviathan_mkii::DamageTaken(), npc_kinetic_bomb::npc_kinetic_bombAI::DoAction(), npc_saurfang_event::npc_saurfang_eventAI::DoAction(), boss_professor_putricide::boss_professor_putricideAI::DoAction(), npc_living_mojo::npc_living_mojoAI::DoAction(), Spell::EffectCharge(), Spell::EffectChargeDest(), boss_professor_putricide::boss_professor_putricideAI::EnterEvadeMode(), npc_pet_dk_ebon_gargoyle::FlyAway(), npc_anachronos_the_ancient::npc_anachronos_the_ancientAI::HandleAnimation(), spell_the_lich_king_valkyr_target_search::HandleScript(), npc_pet_dk_ebon_gargoyle::InitializeAI(), npc_highlord_darion_mograine::JustSummoned(), MoveCharge(), npc_kinetic_bomb::npc_kinetic_bombAI::Reset(), npc_bh_thalorien_dawnseeker::npc_bh_thalorien_dawnseekerAI::SummonedCreatureDespawn(), npc_highlord_darion_mograine::UpdateAI(), boss_icehowl::boss_icehowlAI::UpdateAI(), npc_kinetic_bomb::npc_kinetic_bombAI::UpdateAI(), npc_high_overlord_saurfang_icc::npc_high_overlord_saurfangAI::UpdateAI(), npc_muradin_bronzebeard_icc::npc_muradin_bronzebeard_iccAI::UpdateAI(), boss_lord_marrowgar::UpdateAI(), boss_professor_putricide::boss_professor_putricideAI::UpdateAI(), boss_sindragosa::boss_sindragosaAI::UpdateAI(), boss_the_lich_king::boss_the_lich_kingAI::UpdateAI(), boss_mimiron::UpdateAI(), and npc_iron_watcher::npc_iron_watcherAI::UpdateAI().

◆ MoveCharge() [2/2]

void MotionMaster::MoveCharge ( PathGenerator const &  path,
float  speed = SPEED_CHARGE,
ObjectGuid  targetGUID = ObjectGuid::Empty 
)

The unit will charge the target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

849{
850 G3D::Vector3 dest = path.GetActualEndPosition();
851
852 MoveCharge(dest.x, dest.y, dest.z, speed, EVENT_CHARGE_PREPATH, nullptr, false, 0.0f, targetGUID);
853
854 // Charge movement is not started when using EVENT_CHARGE_PREPATH
856 init.MovebyPath(path.GetPath());
857 init.SetVelocity(speed);
858 init.Launch();
859}
#define EVENT_CHARGE_PREPATH
Definition boss_icecrown_gunship_battle.cpp:108
void MoveCharge(float x, float y, float z, float speed=SPEED_CHARGE, uint32 id=EVENT_CHARGE, Movement::PointsArray const *path=nullptr, bool generatePath=false, float orientation=0.0f, ObjectGuid targetGUID=ObjectGuid::Empty)
The unit will charge the target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:825

References _owner, EVENT_CHARGE_PREPATH, PathGenerator::GetActualEndPosition(), PathGenerator::GetPath(), Movement::MoveSplineInit::Launch(), Movement::MoveSplineInit::MovebyPath(), MoveCharge(), and Movement::MoveSplineInit::SetVelocity().

◆ MoveChase() [1/3]

void MotionMaster::MoveChase ( Unit *  target,
float  dist 
)
inline
235{ MoveChase(target, ChaseRange(dist)); }
void MoveChase(Unit *target, std::optional< ChaseRange > dist={}, std::optional< ChaseAngle > angle={})
Force the unit to chase this target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:316
Definition MotionMaster.h:111

References MoveChase().

Referenced by MoveChase().

◆ MoveChase() [2/3]

void MotionMaster::MoveChase ( Unit *  target,
float  dist,
float  angle 
)
inline
234{ MoveChase(target, ChaseRange(dist), ChaseAngle(angle)); }
Definition MotionMaster.h:124

References MoveChase().

Referenced by MoveChase().

◆ MoveChase() [3/3]

void MotionMaster::MoveChase ( Unit *  target,
std::optional< ChaseRange >  dist = {},
std::optional< ChaseAngle >  angle = {} 
)

Force the unit to chase this target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

317{
318 // ignore movement request if target not exist
319 if (!target || target == _owner || _owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
320 return;
321
323 {
324 if (_owner->IsPlayer())
325 {
327 gen->SetOffsetAndAngle(dist, angle);
328 gen->SetNewTarget(target);
329 }
330 else
331 {
333 gen->SetOffsetAndAngle(dist, angle);
334 gen->SetNewTarget(target);
335 }
336 return;
337 }
338
339 //_owner->ClearUnitState(UNIT_STATE_FOLLOW);
340 if (_owner->IsPlayer())
341 {
342 LOG_DEBUG("movement.motionmaster", "Player ({}) chase to {} ({})",
343 _owner->GetGUID().ToString(), target->IsPlayer() ? "player" : "creature", target->GetGUID().ToString());
345 }
346 else
347 {
348 LOG_DEBUG("movement.motionmaster", "Creature ({}) chase to {} ({})",
349 _owner->GetGUID().ToString(), target->IsPlayer() ? "player" : "creature", target->GetGUID().ToString());
351 }
352}
@ MOTION_SLOT_ACTIVE
Definition MotionMaster.h:65
void SetNewTarget(Unit *target)
Definition TargetedMovementGenerator.cpp:75
void SetOffsetAndAngle(std::optional< ChaseRange > dist, std::optional< ChaseAngle > angle)
Definition TargetedMovementGenerator.cpp:66
std::string ToString(Type &&val, Params &&... params)
Definition StringConvert.h:250

References _owner, CHASE_MOTION_TYPE, GetCurrentMovementGeneratorType(), Object::GetGUID(), Unit::HasUnitFlag(), Object::IsPlayer(), LOG_DEBUG, MOTION_SLOT_ACTIVE, Mutate(), ChaseMovementGenerator< T >::SetNewTarget(), ChaseMovementGenerator< T >::SetOffsetAndAngle(), top(), ObjectGuid::ToString(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by UnitAI::AttackStart(), FollowerAI::AttackStart(), boss_priestess_lackey_commonAI::AttackStart(), npc_high_overlord_saurfang_igb::npc_high_overlord_saurfang_igbAI::AttackStart(), npc_muradin_bronzebeard_igb::npc_muradin_bronzebeard_igbAI::AttackStart(), boss_lady_deathwhisper::boss_lady_deathwhisperAI::AttackStart(), boss_malygos::AttackStart(), boss_swamplord_muselek::AttackStart(), ArcherAI::AttackStart(), npc_escortAI::AttackStart(), SmartAI::AttackStart(), boss_shade_of_aran::AttackStart(), npc_hyjal_ground_trash::AttackStart(), npc_hyjal_gargoyle::AttackStart(), npc_hyjal_frost_wyrm::AttackStart(), boss_magus_telestra::AttackStart(), boss_lady_malande::AttackStart(), boss_kiggler_the_crazed::AttackStart(), boss_krosh_firehand::AttackStart(), npc_millhouse_manastorm::npc_millhouse_manastormAI::AttackStart(), boss_high_astromancer_solarian::AttackStart(), npc_capernian::AttackStart(), UnitAI::AttackStartCaster(), boss_thorim::DamageTaken(), ScriptedAI::DoStartMovement(), RestoreAttack::Execute(), boss_kologarn_eyebeam::IsSummonedBy(), boss_shade_of_aran::JustEngagedWith(), boss_swamplord_muselek::JustEngagedWith(), boss_high_astromancer_solarian::JustEngagedWith(), npc_daphne_stilwell::npc_daphne_stilwellAI::JustSummoned(), boss_algalon_the_observer::JustSummoned(), boss_lady_vashj::MovementInform(), boss_nazan::MovementInform(), boss_kaelthas::MovementInform(), boss_leotheras_the_blind::MoveToTargetIfOutOfRange(), Unit::PetSpellFail(), Unit::RemoveCharmedBy(), boss_magtheridon::Reset(), Creature::ResumeChasingVictim(), boss_high_botanist_freywinn::ResumeEncounter(), Resurrect(), npc_anubarak_spike::npc_anubarak_spikeAI::SelectNewTarget(), SmartAI::SetCombatMovement(), SmartAI::SetCurrentRangeMode(), boss_volkhan::SpellHitTarget(), npc_nerubian_burrower::npc_nerubian_burrowerAI::SpellHitTarget(), PetAI::StartChase(), boss_drakkari_colossus::boss_drakkari_colossusAI::SummonedCreatureDespawn(), boss_quartermaster_zigris::UpdateAI(), boss_mr_smite::boss_mr_smiteAI::UpdateAI(), boss_headless_horseman::UpdateAI(), boss_saviana_ragefire::boss_saviana_ragefireAI::UpdateAI(), npc_nerubian_burrower::npc_nerubian_burrowerAI::UpdateAI(), boss_jormungarAI::UpdateAI(), npc_high_overlord_saurfang_igb::npc_high_overlord_saurfang_igbAI::UpdateAI(), npc_muradin_bronzebeard_igb::npc_muradin_bronzebeard_igbAI::UpdateAI(), boss_kelthuzad::boss_kelthuzadAI::UpdateAI(), boss_malygos::UpdateAI(), boss_urom::boss_uromAI::UpdateAI(), boss_razorscale::UpdateAI(), boss_ingvar_the_plunderer::UpdateAI(), npc_vrykul_skeleton::UpdateAI(), boss_svala::boss_svalaAI::UpdateAI(), boss_ymiron::boss_ymironAI::UpdateAI(), boss_omor_the_unscarred::UpdateAI(), npc_pet_dk_ebon_gargoyle::UpdateAI(), and Player::UpdateCharmedAI().

◆ MoveCirclePath()

void MotionMaster::MoveCirclePath ( float  x,
float  y,
float  z,
float  radius,
bool  clockwise,
uint8  stepCount,
ForcedMovement  forcedMovement = FORCED_MOVEMENT_NONE,
float  speed = 0.0f 
)

Makes the unit travel a closed, cyclic path around (x, y, z).

The path starts at the unit's bearing from the centre. Flight state decides whether z pins to the argument or follows the terrain, raised by the unit's hover height, and which speed is used; forcedMovement overrides the walk/run choice, and FORCED_MOVEMENT_FLY flies a unit that is not fly-flagged.

Parameters
stepCountNumber of points the path is built from, must be at least 2: a lower count yields an empty or single-point path, which Launch() refuses, leaving the unit idle with neither spline nor movement generator.
speedFixed velocity; 0.0f keeps the speed the movement flags select.
711{
712 if (stepCount < 2)
713 {
714 LOG_ERROR("movement.motionmaster", "MotionMaster::MoveCirclePath: stepCount {} for unit ({}), no path launched",
715 stepCount, _owner->GetGUID().ToString());
716 return;
717 }
718
719 // FORCED_MOVEMENT_FLY flies units that are not fly-flagged, so z and the spline flags have to
720 // key off the same value.
721 bool const flying = _owner->IsFlying() || forcedMovement == FORCED_MOVEMENT_FLY;
722
723 float step = 2 * float(M_PI) / stepCount * (clockwise ? -1.0f : 1.0f);
724 Position const pos = { x, y, z, 0.0f };
725 float angle = pos.GetAngle(_owner->GetPositionX(), _owner->GetPositionY());
726
728
729 for (uint8 i = 0; i < stepCount; angle += step, ++i)
730 {
731 G3D::Vector3 point;
732 point.x = x + radius * cosf(angle);
733 point.y = y + radius * sinf(angle);
734
735 if (flying)
736 point.z = z;
737 else
738 {
739 point.z = _owner->GetMapHeight(point.x, point.y, z);
740
741 if (point.z <= INVALID_HEIGHT)
742 {
743 LOG_ERROR("movement.motionmaster",
744 "MotionMaster::MoveCirclePath: no ground below ({}, {}) for unit ({}), no path launched",
745 point.x, point.y, _owner->GetGUID().ToString());
746 return;
747 }
748
749 point.z += _owner->GetHoverHeight();
750 }
751
752 init.Path().push_back(point);
753 }
754
755 if (flying)
756 {
757 init.SetFly();
758 init.SetCyclic();
759 init.SetAnimation(AnimTier::Fly);
760 }
761 else
762 {
763 init.SetWalk(true);
764 init.SetSmooth();
765 init.SetCyclic();
766 }
767
768 if (forcedMovement == FORCED_MOVEMENT_WALK)
769 init.SetWalk(true);
770 else if (forcedMovement == FORCED_MOVEMENT_RUN)
771 init.SetWalk(false);
772
773 if (speed > 0.0f)
774 init.SetVelocity(speed);
775
776 init.Launch();
777}
#define INVALID_HEIGHT
Definition GridTerrainData.h:27
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
@ FORCED_MOVEMENT_WALK
Definition MotionMaster.h:87
@ FORCED_MOVEMENT_FLY
Definition MotionMaster.h:89
@ FORCED_MOVEMENT_RUN
Definition MotionMaster.h:88
float GetHoverHeight() const
Definition Unit.h:1726
bool IsFlying() const
Definition Unit.h:1722
float GetMapHeight(float x, float y, float z, bool vmap=true, float distanceToSearch=50.0f) const
Definition Object.cpp:3145
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122

References _owner, Fly, FORCED_MOVEMENT_FLY, FORCED_MOVEMENT_RUN, FORCED_MOVEMENT_WALK, Position::GetAngle(), Object::GetGUID(), Unit::GetHoverHeight(), WorldObject::GetMapHeight(), Position::GetPositionX(), Position::GetPositionY(), INVALID_HEIGHT, Unit::IsFlying(), Movement::MoveSplineInit::Launch(), LOG_ERROR, Movement::MoveSplineInit::Path(), Movement::MoveSplineInit::SetAnimation(), Movement::MoveSplineInit::SetCyclic(), Movement::MoveSplineInit::SetFly(), Movement::MoveSplineInit::SetSmooth(), Movement::MoveSplineInit::SetVelocity(), Movement::MoveSplineInit::SetWalk(), and ObjectGuid::ToString().

Referenced by npc_medivh_bm::JustSummoned(), and boss_yoggsaron_cloud::MoveCircle().

◆ MoveCircleTarget()

void MotionMaster::MoveCircleTarget ( Unit *  target)
426{
427 if (!target)
428 {
429 return;
430 }
431
432 Position pos;
433 if (!target->GetMeleeAttackPoint(_owner, pos))
434 {
435 return;
436 }
437
439 init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), false);
440 init.SetWalk(true);
441 init.SetFacing(target);
442 init.Launch();
443}
bool GetMeleeAttackPoint(Unit *attacker, Position &pos)
Definition Unit.cpp:2859
float GetPositionZ() const
Definition Position.h:123

References _owner, Unit::GetMeleeAttackPoint(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Movement::MoveSplineInit::Launch(), Movement::MoveSplineInit::MoveTo(), Movement::MoveSplineInit::SetFacing(), and Movement::MoveSplineInit::SetWalk().

Referenced by CreatureAI::MoveCircleChecks().

◆ MoveConfused()

void MotionMaster::MoveConfused ( )

Enable the confusion movement. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

296{
297 // Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
299 return;
300
301 if (_owner->IsPlayer())
302 {
303 LOG_DEBUG("movement.motionmaster", "Player ({}) move confused", _owner->GetGUID().ToString());
305 }
306 else
307 {
308 LOG_DEBUG("movement.motionmaster", "Creature ({}) move confused", _owner->GetGUID().ToString());
310 }
311}
Definition ConfusedMovementGenerator.h:28

References _owner, Object::GetGUID(), Unit::HasUnitFlag(), Object::IsPlayer(), LOG_DEBUG, MOTION_SLOT_CONTROLLED, Mutate(), ObjectGuid::ToString(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by Unit::SetConfused().

◆ MoveDistract()

void MotionMaster::MoveDistract ( uint32  time)

Enable the target's distract movement. Doesn't work with UNIT_FLAG_DISABLE_MOVE and if the unit has MOTION_SLOT_CONTROLLED (generaly apply when the unit is controlled).

964{
966 return;
967
969 return;
970
971 /*if (_owner->IsPlayer())
972 {
973 LOG_DEBUG("movement.motionmaster", "Player ({}) distracted (timer: {})", _owner->GetGUID().ToString(), timer);
974 }
975 else
976 {
977 LOG_DEBUG("movement.motionmaster", "Creature ({}) (timer: {})", _owner->GetGUID().ToString(), timer);
978 }*/
979
982}
Definition IdleMovementGenerator.h:50

References _owner, Unit::HasUnitFlag(), Impl, MOTION_SLOT_CONTROLLED, Mutate(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by Spell::EffectDistract(), and CreatureAI::TriggerAlert().

◆ MoveFall()

void MotionMaster::MoveFall ( uint32  id = 0,
bool  addFlagForNPC = false 
)

The unit will fall. Used when in the air. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

783{
785 return;
786
787 // use larger distance for vmap height search than in most other cases
789 if (tz <= INVALID_HEIGHT)
790 {
791 LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFall: unable retrive a proper height at map {} (x: {}, y: {}, z: {}).",
793 return;
794 }
795
796 // Abort too if the ground is very near
797 if (std::fabs(_owner->GetPositionZ() - tz) < 0.1f)
798 return;
799
800 if (_owner->IsPlayer())
801 {
805 }
806 else if (_owner->IsCreature() && addFlagForNPC) // pussywizard
807 {
813 }
814
816 init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(), tz + _owner->GetHoverHeight());
817 init.SetFall();
818
820}
#define MAX_FALL_DISTANCE
Definition GridTerrainData.h:28
@ MOVEMENTFLAG_MASK_MOVING
Definition UnitDefines.h:405
@ MOVEMENTFLAG_FLYING
Definition UnitDefines.h:397
@ MOVEMENTFLAG_CAN_FLY
Definition UnitDefines.h:396
@ MOVEMENTFLAG_FALLING
Definition UnitDefines.h:384
Definition PointMovementGenerator.h:86
uint32 GetId() const
Definition Map.h:234
Player * ToPlayer()
Definition Object.h:208
bool IsCreature() const
Definition Object.h:211
void SetFallInformation(uint32 time, float z)
Definition Player.h:2384
void AddUnitMovementFlag(uint32 f)
Definition Unit.h:775
void SendMovementFlagUpdate(bool self=false)
Definition Unit.cpp:12697
void RemoveUnitMovementFlag(uint32 f)
Definition Unit.h:776
MovementInfo m_movementInfo
Definition Object.h:711
Seconds GetGameTime()
Definition GameTime.cpp:38
void SetFallTime(uint32 newFallTime)
Definition Object.h:362

References _owner, Unit::AddUnitMovementFlag(), GameTime::GetGameTime(), Unit::GetHoverHeight(), Map::GetId(), WorldObject::GetMap(), WorldObject::GetMapHeight(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Unit::HasUnitFlag(), INVALID_HEIGHT, Object::IsCreature(), Object::IsPlayer(), LOG_DEBUG, WorldObject::m_movementInfo, MAX_FALL_DISTANCE, MOTION_SLOT_CONTROLLED, MOVEMENTFLAG_CAN_FLY, MOVEMENTFLAG_FALLING, MOVEMENTFLAG_FLYING, MOVEMENTFLAG_MASK_MOVING, Movement::MoveSplineInit::MoveTo(), Mutate(), Unit::RemoveUnitMovementFlag(), Unit::SendMovementFlagUpdate(), Movement::MoveSplineInit::SetFall(), Player::SetFallInformation(), MovementInfo::SetFallTime(), Object::ToPlayer(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by Unit::_ExitVehicle(), npc_wild_wyrm::DamageTaken(), boss_the_lich_king::boss_the_lich_kingAI::DamageTaken(), npc_ulduar_aerial_command_unit::DoAction(), AuraEffect::HandleAuraAllowFlight(), AuraEffect::HandleAuraDummy(), AuraEffect::HandleAuraModIncreaseFlightSpeed(), Totem::InitSummon(), boss_yoggsaron_death_ray::IsSummonedBy(), boss_ayamiss::JustDied(), Player::KillPlayer(), spell_chapter5_light_of_dawn_aura::OnRemove(), Creature::setDeathState(), boss_krick::boss_krickAI::UpdateAI(), boss_svala::boss_svalaAI::UpdateAI(), and npc_pet_gen_wind_rider_cub::UpdateAI().

◆ MoveFleeing()

void MotionMaster::MoveFleeing ( Unit *  enemy,
uint32  time = 0 
)

Enable the target's fleeing movement. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

902{
903 if (!enemy)
904 return;
905
907 return;
908
909 if (_owner->IsPlayer())
910 {
911 LOG_DEBUG("movement.motionmaster", "Player ({}) flee from {} ({})",
912 _owner->GetGUID().ToString(), enemy->IsPlayer() ? "player" : "creature", enemy->GetGUID().ToString());
914 }
915 else
916 {
917 LOG_DEBUG("movement.motionmaster", "Creature ({}) flee from {} ({}) {}",
918 _owner->GetGUID().ToString(), enemy->IsPlayer() ? "player" : "creature", enemy->GetGUID().ToString(), time ? " for a limited time" : "");
919 if (time)
921 else
923 }
924}
Definition FleeingMovementGenerator.h:27
Definition FleeingMovementGenerator.h:50

References _owner, Object::GetGUID(), Unit::HasUnitFlag(), Object::IsPlayer(), LOG_DEBUG, MOTION_SLOT_CONTROLLED, Mutate(), ObjectGuid::ToString(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by Unit::SetFeared(), and boss_headless_horseman_head::SpellHit().

◆ MoveFollow()

void MotionMaster::MoveFollow ( Unit *  target,
float  dist,
float  angle,
MovementSlot  slot = MOTION_SLOT_ACTIVE,
bool  inheritWalkState = true,
bool  inheritSpeed = true 
)

The unit will follow this target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

449{
450 // ignore movement request if target not exist
451 if (!target || target == _owner || _owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
452 {
453 return;
454 }
455
456 //_owner->AddUnitState(UNIT_STATE_FOLLOW);
457 if (_owner->IsPlayer())
458 {
459 LOG_DEBUG("movement.motionmaster", "Player ({}) follow to {} ({})",
460 _owner->GetGUID().ToString(), target->IsPlayer() ? "player" : "creature", target->GetGUID().ToString());
461 Mutate(new FollowMovementGenerator<Player>(target, dist, angle, inheritWalkState, inheritSpeed), slot);
462 }
463 else
464 {
465 LOG_DEBUG("movement.motionmaster", "Creature ({}) follow to {} ({})",
466 _owner->GetGUID().ToString(), target->IsPlayer() ? "player" : "creature", target->GetGUID().ToString());
467 Mutate(new FollowMovementGenerator<Creature>(target, dist, angle, inheritWalkState, inheritSpeed), slot);
468 }
469}
Definition TargetedMovementGenerator.h:83

References _owner, Object::GetGUID(), Unit::HasUnitFlag(), Object::IsPlayer(), LOG_DEBUG, Mutate(), ObjectGuid::ToString(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by Pet::CastPendingSpell(), npc_argent_captainAI::DoAction(), Spell::EffectSummonType(), npc_argent_captainAI::EnterEvadeMode(), CreatureAI::EnterEvadeMode(), SmartAI::EnterEvadeMode(), npc_burning_spirit::EnterEvadeMode(), npc_mrfloppy::npc_mrfloppyAI::EnterEvadeMode(), npc_pet_dk_ebon_gargoyle::EnterEvadeMode(), npc_pet_gen_argent_pony_bridle::EnterEvadeMode(), npc_pet_mage_mirror_image::EnterEvadeMode(), boss_halazzi::EnterPhase(), npc_singularity::FindAndFollowTarget(), npc_dark_iron_guzzler::FindNextKeg(), spell_q11919_q11940_drake_hunt_aura::HandleEffectRemove(), AuraEffect::HandleModPossessPet(), npc_commandscript::HandleNpcFollowCommand(), spell_item_enchanted_broom_periodic::HandlePeriodicTick(), WorldSession::HandlePetActionHelper(), PetAI::HandleReturnMovement(), spell_item_draenic_pale_ale::HandleSummon(), npc_troll_volunteer::npc_troll_volunteerAI::InitializeAI(), npc_pet_dk_dancing_rune_weapon::InitializeAI(), npc_pet_mage_mirror_image::InitializeAI(), npc_burning_spirit::IsSummonedBy(), npc_supremus_punch_invisible_stalker::IsSummonedBy(), npc_spirit_shade::npc_spirit_shadeAI::IsSummonedBy(), npc_sunblade_scout::JustEngagedWith(), npc_amanishi_scout::JustEngagedWith(), boss_warlord_kalithresh::JustEngagedWith(), npc_frosthound::JustSummoned(), boss_mekgineer_steamrigger::JustSummoned(), npc_ulduar_storm_tempered_keeper::JustSummoned(), boss_vexallus::JustSummoned(), boss_lady_vashj::JustSummoned(), boss_ichoron::JustSummoned(), boss_xevozz::JustSummoned(), npc_fel_guard_hound::npc_fel_guard_houndAI::MovementInform(), npc_pet_dk_ebon_gargoyle::MySelectNextTarget(), SmartAI::OnCharmed(), npc_kernobee::OnQuestAccept(), Unit::PetSpellFail(), npc_jungle_punch_target::npc_jungle_punch_targetAI::proceedCwEvent(), SmartScript::ProcessAction(), npc_lake_frog::npc_lake_frogAI::ReceiveEmote(), npc_assembly_lightning::Reset(), npc_scrapbot::Reset(), npc_boombot::Reset(), npc_voidtraveler::Reset(), npc_icc_ice_sphere::npc_icc_ice_sphereAI::SelectNewTarget(), Unit::SetCharmedBy(), SmartAI::SetFollow(), FollowerAI::SetFollowPaused(), boss_attumen::SpellHit(), npc_rabid_thistle_bear::npc_rabid_thistle_bearAI::SpellHit(), npc_aged_dying_ancient_kodo::SpellHit(), FollowerAI::StartFollow(), Spell::SummonGuardian(), SimpleCharmedAI::UpdateAI(), npc_scarlet_ghoul::UpdateAI(), npc_winterfin_playmate::UpdateAI(), npc_snowfall_glade_playmate::UpdateAI(), npc_the_biggest_tree::UpdateAI(), npc_high_oracle_soo_roo::UpdateAI(), npc_elder_kekek::UpdateAI(), npc_the_etymidian::UpdateAI(), npc_alexstraza_the_lifebinder::UpdateAI(), npc_spark_of_ionar::UpdateAI(), npc_hodirs_fury::UpdateAI(), npc_pet_gen_target_following_bomb::UpdateAI(), npc_pet_gen_toxic_wasteling::UpdateAI(), FollowerAI::UpdateAI(), and Player::UpdateCharmedAI().

◆ MoveFormation()

void MotionMaster::MoveFormation ( Unit *  leader,
float  dist,
float  angle,
uint32  point1,
uint32  point2 
)
472{
473 if (!leader || leader == _owner || _owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
474 return;
475
476 if (!_owner->IsCreature())
477 return;
478
479 Mutate(new FormationMovementGenerator(leader, dist, angle, point1, point2), MOTION_SLOT_IDLE);
480}
Definition FormationMovementGenerator.h:29

References _owner, Unit::HasUnitFlag(), Object::IsCreature(), MOTION_SLOT_IDLE, Mutate(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by CreatureGroup::LeaderStartedMoving(), and SmartScript::ProcessAction().

◆ MoveForwards()

void MotionMaster::MoveForwards ( Unit *  target,
float  dist 
)
400{
401 //like movebackwards, but without the inversion
402 if (!target)
403 {
404 return;
405 }
406
407 Position const& pos = target->GetPosition();
408 float angle = target->GetAngle(_owner);
409 G3D::Vector3 point;
410 point.x = pos.m_positionX + dist * cosf(angle);
411 point.y = pos.m_positionY + dist * sinf(angle);
412 point.z = pos.m_positionZ;
413
414 if (!_owner->GetMap()->CanReachPositionAndGetValidCoords(_owner, point.x, point.y, point.z, true, true))
415 {
416 return;
417 }
418
420 init.MoveTo(point.x, point.y, point.z, false);
421 init.SetFacing(target);
422 init.Launch();
423}

References _owner, Map::CanReachPositionAndGetValidCoords(), Position::GetAngle(), WorldObject::GetMap(), Position::GetPosition(), Movement::MoveSplineInit::Launch(), Position::m_positionX, Position::m_positionY, Position::m_positionZ, Movement::MoveSplineInit::MoveTo(), and Movement::MoveSplineInit::SetFacing().

◆ MoveIdle()

void MotionMaster::MoveIdle ( )

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

236{
238 if (empty() || !isStatic(top()))
240}
MovementGenerator * GetIdleMovementGenerator()
Definition MotionMaster.cpp:39

References empty(), GetIdleMovementGenerator(), isStatic(), MOTION_SLOT_IDLE, Mutate(), and top().

Referenced by PetAI::_stopAttack(), npc_time_lost_proto_drake::npc_time_lost_proto_drakeAI::ArmHiddenState(), npc_nexus_lord::AttackStart(), boss_swamplord_muselek::AttackStart(), ArcherAI::AttackStart(), Pet::CastPendingSpell(), npc_frost_sphere::npc_frost_sphereAI::DamageTaken(), boss_bronjahm::DamageTaken(), npc_power_spark::DamageTaken(), boss_ingvar_the_plunderer::DamageTaken(), npc_vrykul_skeleton::DamageTaken(), npc_blistering_zombie::npc_blistering_zombieAI::DamageTaken(), npc_twilight_volunteer::DoAction(), npc_spinestalker::npc_spinestalkerAI::DoAction(), npc_rimefang::npc_rimefangAI::DoAction(), npc_kalecgos_kj::DoAction(), npc_anubarak_spike::npc_anubarak_spikeAI::DoAction(), npc_power_spark::DoAction(), npc_spark_of_ionar::DoAction(), PetAI::DoAttack(), npc_taskmaster_fizzule::npc_taskmaster_fizzuleAI::DoFriend(), ScriptedAI::DoStartNoMovement(), GuardAI::EnterEvadeMode(), npc_hallows_end_soh::FinishEvent(), CreatureGroup::FormationReset(), boss_blood_queen_lana_thel::boss_blood_queen_lana_thelAI::GoToMinchar(), spell_chapter2_persuasive_strike::HandleHit(), spell_item_toxic_wasteling::HandleJump(), WorldSession::HandlePetActionHelper(), boss_prince_keleseth_icc::boss_prince_kelesethAI::JustDied(), boss_prince_taldaram_icc::boss_prince_taldaramAI::JustDied(), boss_prince_valanar_icc::boss_prince_valanarAI::JustDied(), boss_high_botanist_freywinn::JustEngagedWith(), Creature::Motion_Initialize(), npc_aged_dying_ancient_kodo::MoveInLineOfSight(), PetAI::MovementInform(), boss_bug_trio::MovementInform(), boss_professor_putricide::boss_professor_putricideAI::MovementInform(), boss_four_horsemen::boss_four_horsemenAI::MovementInform(), boss_malygos::MovementInform(), boss_felmyst::MovementInform(), npc_escortAI::MovementInform(), SmartAI::MovepointReached(), boss_nefarian::PathEndReached(), SmartAI::PausePath(), NPCStaveQuestAI::PrepareForEncounter(), PretendToDie(), boss_alar::PretendToDie(), SmartScript::ProcessAction(), npc_lake_frog::npc_lake_frogAI::ReceiveEmote(), boss_felblood_kaelthas::Reset(), boss_archimonde::Reset(), boss_felmyst::ScheduleGroundAbilities(), boss_loken::ScheduleTasks(), Unit::SetCharmedBy(), boss_grand_warlock_nethekurse::SetData(), Unit::setDeathState(), FollowerAI::SetFollowComplete(), FollowerAI::SetFollowPaused(), npc_cult_fanatic::npc_cult_fanaticAI::SpellHit(), npc_cult_adherent::npc_cult_adherentAI::SpellHit(), boss_urom::boss_uromAI::SpellHit(), npc_forest_frog::SpellHit(), boss_devourer_of_souls::SpellHitTarget(), npc_escortAI::Start(), FollowerAI::StartFollow(), SmartAI::StopFollow(), SmartAI::StopPath(), boss_jedoga_shadowseeker::SummonedCreatureDies(), boss_headless_horseman::UpdateAI(), boss_onyxia::UpdateAI(), boss_grand_champion::boss_grand_championAI::UpdateAI(), npc_nerubian_burrower::npc_nerubian_burrowerAI::UpdateAI(), boss_jormungarAI::UpdateAI(), boss_icehowl::boss_icehowlAI::UpdateAI(), npc_fos_corrupted_soul_fragment::UpdateAI(), boss_blood_queen_lana_thel::boss_blood_queen_lana_thelAI::UpdateAI(), boss_lord_marrowgar::UpdateAI(), boss_sindragosa::boss_sindragosaAI::UpdateAI(), npc_rimefang::npc_rimefangAI::UpdateAI(), npc_strangulate_vehicle::npc_strangulate_vehicleAI::UpdateAI(), npc_valithria_cloud::npc_valithria_cloudAI::UpdateAI(), boss_sapphiron::boss_sapphironAI::UpdateAI(), boss_malygos::UpdateAI(), npc_power_spark::UpdateAI(), npc_oculus_unstable_sphere::npc_oculus_unstable_sphereAI::UpdateAI(), boss_urom::boss_uromAI::UpdateAI(), boss_algalon_the_observer::UpdateAI(), boss_svala::boss_svalaAI::UpdateAI(), npc_minigob_manabonk::UpdateAI(), and npc_mature_netherwing_drake::npc_mature_netherwing_drakeAI::UpdateAI().

◆ MoveJump() [1/2]

void MotionMaster::MoveJump ( float  x,
float  y,
float  z,
float  speedXY,
float  speedZ,
uint32  id = 0,
Unit const *  target = nullptr 
)

The unit will jump to a specific point.

677{
678 LOG_DEBUG("movement.motionmaster", "Unit ({}) jump to point (X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), x, y, z);
679
680 if (speedXY <= 0.1f)
681 return;
682
683 float moveTimeHalf = speedZ / Movement::gravity;
684 float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
685
687 init.MoveTo(x, y, z);
688 init.SetParabolic(max_height, 0);
689 init.SetVelocity(speedXY);
690 if (target)
691 init.SetFacing(target);
692
694}
double gravity
Definition MovementUtil.cpp:24
float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity=0.0f)
Definition MovementUtil.cpp:60

References _owner, Movement::computeFallElevation(), Object::GetGUID(), Movement::gravity, LOG_DEBUG, MOTION_SLOT_CONTROLLED, Movement::MoveSplineInit::MoveTo(), Mutate(), Movement::MoveSplineInit::SetFacing(), Movement::MoveSplineInit::SetParabolic(), Movement::MoveSplineInit::SetVelocity(), and ObjectGuid::ToString().

◆ MoveJump() [2/2]

◆ MoveJumpTo()

void MotionMaster::MoveJumpTo ( float  angle,
float  speedXY,
float  speedZ 
)

The unit will jump in a specific direction.

660{
661 //this function may make players fall below map
662 if (_owner->IsPlayer())
663 return;
664
665 float x, y, z;
666
667 float moveTimeHalf = speedZ / Movement::gravity;
668 float dist = 2 * moveTimeHalf * speedXY;
669 _owner->GetClosePoint(x, y, z, _owner->GetObjectSize(), dist, angle);
670 MoveJump(x, y, z, speedXY, speedZ);
671}
bool GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0, WorldObject const *forWho=nullptr, bool force=false) const
Definition Object.cpp:2825
float GetObjectSize() const
Definition Object.cpp:2897

References _owner, WorldObject::GetClosePoint(), WorldObject::GetObjectSize(), Movement::gravity, Object::IsPlayer(), and MoveJump().

Referenced by Unit::JumpTo(), and npc_engineer_helice::OnQuestAccept().

◆ MoveKnockbackFrom()

void MotionMaster::MoveKnockbackFrom ( float  srcX,
float  srcY,
float  speedXY,
float  speedZ,
bool  allowClientControlled = false 
)
622{
623 //this function may make players fall below map
624 if (!allowClientControlled && _owner->IsPlayer() && _owner->IsClientControlled())
625 return;
626
627 if (speedXY <= 0.1f)
628 return;
629
630 Position dest = _owner->GetPosition();
631 float moveTimeHalf = speedZ / Movement::gravity;
632 float dist = 2 * moveTimeHalf * speedXY;
633 float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
634
635 // Use a mmap raycast to get a valid destination.
636 _owner->MovePositionToFirstCollision(dest, dist, _owner->GetRelativeAngle(srcX, srcY) + float(M_PI));
637
639 init.MoveTo(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
640 init.SetParabolic(max_height, 0);
641 init.SetOrientationFixed(true);
642 init.SetVelocity(speedXY);
643
644 // Do not mutate an active fleeing/confused movement generator,
645 // doing so breaks the movement upon landing from the knockback
647 if (slotType == FLEEING_MOTION_TYPE || slotType == CONFUSED_MOTION_TYPE)
648 {
649 init.Launch();
650 return;
651 }
652
654}
MovementGeneratorType
Definition MotionMaster.h:38
@ FLEEING_MOTION_TYPE
Definition MotionMaster.h:49
@ CONFUSED_MOTION_TYPE
Definition MotionMaster.h:44
MovementGeneratorType GetMotionSlotType(int slot) const
Definition MotionMaster.cpp:1096
bool IsClientControlled(Player const *exactClient=nullptr) const
Definition Unit.cpp:17009
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
Definition Object.cpp:2984
float GetRelativeAngle(Position const *pos) const
Definition Position.h:201

References _owner, Movement::computeFallElevation(), CONFUSED_MOTION_TYPE, FLEEING_MOTION_TYPE, GetMotionSlotType(), Position::GetPosition(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Position::GetRelativeAngle(), Movement::gravity, Unit::IsClientControlled(), Object::IsPlayer(), Movement::MoveSplineInit::Launch(), MOTION_SLOT_CONTROLLED, WorldObject::MovePositionToFirstCollision(), Movement::MoveSplineInit::MoveTo(), Mutate(), Movement::MoveSplineInit::SetOrientationFixed(), Movement::MoveSplineInit::SetParabolic(), and Movement::MoveSplineInit::SetVelocity().

Referenced by Unit::KnockbackFrom().

◆ MoveLand() [1/2]

void MotionMaster::MoveLand ( uint32  id,
float  x,
float  y,
float  z,
float  speed = 0.0f 
)

Use to move the unit from the air to the ground. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

581{
582 Position pos = {x, y, z, 0.0f};
583 MoveLand(id, pos, speed);
584}
void MoveLand(uint32 id, Position const &pos, float speed=0.0f)
Use to move the unit from the air to the ground. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:554

References MoveLand().

◆ MoveLand() [2/2]

void MotionMaster::MoveLand ( uint32  id,
Position const &  pos,
float  speed = 0.0f 
)

◆ MovementExpired()

void MotionMaster::MovementExpired ( bool  reset = true)
inline
208 {
210 {
211 if (reset)
213 else
214 _cleanFlag &= ~MMCF_RESET;
216 }
217 else
218 DirectExpire(reset);
219 }
void DirectExpire(bool reset)
Definition MotionMaster.cpp:177
void DelayedExpire()
Definition MotionMaster.cpp:197

References _cleanFlag, DelayedExpire(), DirectExpire(), MMCF_RESET, and MMCF_UPDATE.

Referenced by npc_escortAI::AttackStart(), SmartAI::AttackStart(), boss_ingvar_the_plunderer::DamageTaken(), npc_vrykul_skeleton::DamageTaken(), npc_kinetic_bomb::npc_kinetic_bombAI::DoAction(), go_commandscript::DoTeleport(), go_commandscript::DoTeleportToTransport(), boss_volkhan::GoToAnvil(), misc_commandscript::HandleAppearCommand(), go_commandscript::HandleGoGraveyardCommand(), go_commandscript::HandleGoGridCommand(), go_commandscript::HandleGoTicketCommand(), go_commandscript::HandleGoZoneXYCommand(), misc_commandscript::HandleGroupSummonCommand(), WorldSession::HandleMoveWorldportAck(), npc_commandscript::HandleNpcUnFollowCommand(), tele_commandscript::HandleTeleCommand(), tele_commandscript::HandleTeleGroupCommand(), Player::LeaveBattleground(), npc_escortAI::MovementInform(), SmartAI::MovepointReached(), SmartAI::PausePath(), PretendToDie(), boss_alar::PretendToDie(), Unit::RemoveCharmedBy(), WorldSession::SendDoFlight(), Unit::SetConfused(), Unit::SetFeared(), npc_cult_fanatic::npc_cult_fanaticAI::SpellHit(), npc_cult_adherent::npc_cult_adherentAI::SpellHit(), npc_vengeful_shade::npc_vengeful_shadeAI::SpellHitTarget(), npc_escortAI::Start(), SmartAI::StopPath(), Player::TeleportTo(), boss_grand_champion::boss_grand_championAI::UpdateAI(), boss_icehowl::boss_icehowlAI::UpdateAI(), npc_hor_lich_king::UpdateAI(), npc_kinetic_bomb::npc_kinetic_bombAI::UpdateAI(), boss_lord_marrowgar::UpdateAI(), npc_mature_netherwing_drake::npc_mature_netherwing_drakeAI::UpdateAI(), npc_pet_gen_toxic_wasteling::UpdateAI(), and UpdateMotion().

◆ MovementExpiredOnSlot()

void MotionMaster::MovementExpiredOnSlot ( MovementSlot  slot,
bool  reset = true 
)
inline
222 {
223 // xinef: cannot be used during motion update!
224 if (!(_cleanFlag & MMCF_UPDATE))
225 DirectExpireSlot(slot, reset);
226 }
void DirectExpireSlot(MovementSlot slot, bool reset)
Definition MotionMaster.cpp:210

References _cleanFlag, DirectExpireSlot(), and MMCF_UPDATE.

Referenced by Unit::AtEngage(), PetAI::DoAttack(), CreatureGroup::FormationReset(), Unit::RemoveCharmedBy(), and CreatureGroup::RemoveFormationMovement().

◆ MovePath()

void MotionMaster::MovePath ( uint32  path_id,
ForcedMovement  forcedMovement = FORCED_MOVEMENT_NONE,
PathSource  pathSource = PathSource::WAYPOINT_MGR 
)
521{
522 WaypointPath const* path;
523 switch (pathSource)
524 {
525 default:
527 path = sWaypointMgr->GetPath(path_id);
528 break;
530 path = sSmartWaypointMgr->GetPath(path_id);
531 break;
532 }
533
534 if (path == nullptr)
535 {
536 LOG_ERROR("sql.sql", "WaypointMovementGenerator::LoadPath: creature {} ({}) doesn't have waypoint path id: {} pathSource: {}",
537 _owner->GetName(), _owner->GetGUID().ToString(), path_id, pathSource);
538 return;
539 }
540
542 for (auto const& node : path->Nodes)
543 {
544 points.push_back(G3D::Vector3(node.X, node.Y, node.Z));
545 }
546
547 // pass the new PointsArray* to the appropriate MoveSplinePath function
548 MoveSplinePath(&points, forcedMovement);
549}
@ SMART_WAYPOINT_MGR
#define sSmartWaypointMgr
Definition SmartScriptMgr.h:2282
#define sWaypointMgr
Definition WaypointMgr.h:54
void MoveSplinePath(Movement::PointsArray *path, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE)
Definition MotionMaster.cpp:504
std::string const & GetName() const
Definition Object.h:535
std::vector< Vector3 > PointsArray
Definition MoveSplineInitArgs.h:28
Definition WaypointDefines.h:60

References _owner, Object::GetGUID(), WorldObject::GetName(), LOG_ERROR, MoveSplinePath(), WaypointPath::Nodes, SMART_WAYPOINT_MGR, sSmartWaypointMgr, sWaypointMgr, ObjectGuid::ToString(), and WAYPOINT_MGR.

Referenced by boss_alar::ConstructWaypointsAndMove(), brann_bronzebeard::DoAction(), boss_skadi_grauf::boss_skadi_graufAI::DoAction(), npc_batrider::npc_batrider(), npc_vehicle_d16_propelled_delivery::npc_vehicle_d16_propelled_deliveryAI::PassengerBoarded(), npc_preparations_for_war_vehicle::PassengerBoarded(), instance_ulduar::instance_ulduar_InstanceMapScript::StartLeviathanOutroSequence(), boss_skadi_grauf::boss_skadi_graufAI::UpdateAI(), npc_infra_green_bomber_generic::npc_infra_green_bomber_genericAI::UpdateAI(), npc_freed_protodrake::npc_freed_protodrakeAI::UpdateAI(), and npc_batrider::UpdateAI().

◆ MovePoint() [1/2]

void MotionMaster::MovePoint ( uint32  id,
float  x,
float  y,
float  z,
ForcedMovement  forcedMovement = FORCED_MOVEMENT_NONE,
float  speed = 0.f,
float  orientation = 0.0f,
bool  generatePath = true,
bool  forceDestination = true,
MovementSlot  slot = MOTION_SLOT_ACTIVE,
std::optional< AnimTier >  animTier = std::nullopt 
)

The unit will move to a specific point. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

For transition movement between the ground and the air, use MoveLand or MoveTakeoff instead.

488{
490 return;
491
492 if (_owner->IsPlayer())
493 {
494 LOG_DEBUG("movement.motionmaster", "Player ({}) targeted point (Id: {} X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
495 Mutate(new PointMovementGenerator<Player>(id, x, y, z, forcedMovement, speed, orientation, nullptr, generatePath, forceDestination, animTier), slot);
496 }
497 else
498 {
499 LOG_DEBUG("movement.motionmaster", "Creature ({}) targeted point (ID: {} X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
500 Mutate(new PointMovementGenerator<Creature>(id, x, y, z, forcedMovement, speed, orientation, nullptr, generatePath, forceDestination, animTier), slot);
501 }
502}

References _owner, Object::GetGUID(), Unit::HasUnitFlag(), Object::IsPlayer(), LOG_DEBUG, Mutate(), ObjectGuid::ToString(), and UNIT_FLAG_DISABLE_MOVE.

◆ MovePoint() [2/2]

void MotionMaster::MovePoint ( uint32  id,
Position const &  pos,
ForcedMovement  forcedMovement = FORCED_MOVEMENT_NONE,
float  speed = 0.f,
bool  generatePath = true,
bool  forceDestination = true,
std::optional< AnimTier >  animTier = std::nullopt 
)
inline
242 { MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, forcedMovement, speed, pos.GetOrientation(), generatePath, forceDestination, MOTION_SLOT_ACTIVE, animTier); }
void MovePoint(uint32 id, Position const &pos, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE, float speed=0.f, bool generatePath=true, bool forceDestination=true, std::optional< AnimTier > animTier=std::nullopt)
Definition MotionMaster.h:241

References Position::GetOrientation(), Position::m_positionX, Position::m_positionY, Position::m_positionZ, MOTION_SLOT_ACTIVE, and MovePoint().

Referenced by npc_high_overlord_saurfang_igb::npc_high_overlord_saurfang_igbAI::AttackStart(), npc_muradin_bronzebeard_igb::npc_muradin_bronzebeard_igbAI::AttackStart(), boss_isalien::DamageTaken(), boss_grand_champion::boss_grand_championAI::DamageTaken(), npc_power_spark::DamageTaken(), npc_ulduar_aerial_command_unit::DamageTaken(), boss_essence_of_suffering::boss_essence_of_sufferingAI::DamageTaken(), boss_essence_of_desire::boss_essence_of_desireAI::DamageTaken(), boss_the_lich_king::boss_the_lich_kingAI::DamageTaken(), npc_apothecary_genericAI::DoAction(), npc_chained_spirit::DoAction(), npc_weegli_blastfuse::npc_weegli_blastfuseAI::DoAction(), npc_hadronox_crusherPackAI::DoAction(), npc_high_overlord_saurfang_icc::npc_high_overlord_saurfangAI::DoAction(), npc_muradin_bronzebeard_icc::npc_muradin_bronzebeard_iccAI::DoAction(), npc_saurfang_event::npc_saurfang_eventAI::DoAction(), boss_sindragosa::boss_sindragosaAI::DoAction(), npc_spinestalker::npc_spinestalkerAI::DoAction(), npc_rimefang::npc_rimefangAI::DoAction(), npc_icc_spire_frostwyrm::DoAction(), brann_bronzebeard::DoAction(), boss_algalon_the_observer::DoAction(), npc_brann_bronzebeard_algalon::DoAction(), boss_razorscale::DoAction(), npc_expedition_defender::DoAction(), npc_expedition_trapper::DoAction(), npc_ahune_bunny::DoAction(), npc_pos_martin_or_gorkun_second::npc_pos_martin_or_gorkun_secondAI::DoAction(), npc_power_spark::DoAction(), npc_hover_disk::DoAction(), npc_ulduar_aerial_command_unit::DoAction(), boss_illidan_stormrage::DoAction(), npc_akama_illidan::DoAction(), npc_maiev_illidan::DoAction(), npc_akama_shade::DoAction(), boss_nazan::DoAction(), brann_bronzebeard::DoMarnakDarkMatter(), brann_bronzebeard::EndTribunalFight(), FollowerAI::EnterEvadeMode(), VehicleDespawnEvent::Execute(), OrcMoveEvent::Execute(), UtherBatteredHiltEvent::Execute(), SlaveRunEvent::Execute(), DelayedMovementEvent::Execute(), DaranavanMoveEvent::Execute(), npc_hallows_end_soh::FinishEvent(), boss_nightbane::FlyToClosestPreFlyWayPoint(), boss_volkhan::GoToAnvil(), boss_blood_queen_lana_thel::boss_blood_queen_lana_thelAI::GoToMinchar(), spell_apothecary_lingering_fumes::HandleAfterCast(), npc_torloth_the_magnificent::npc_torloth_the_magnificentAI::HandleAnimation(), misc_commandscript::HandleComeToMeCommand(), spell_q12589_shoot_rjr::HandleDummy(), spell_q11520_discovering_your_roots::HandleDummy(), boss_sartharion_dragonAI::HandleExtraEvent(), boss_malygos::HandleIntroSpeech(), PetAI::HandleReturnMovement(), boss_eck::InitializeAI(), npc_bushwhacker::npc_bushwhackerAI::InitializeAI(), npc_lk_spirit_bomb::npc_lk_spirit_bombAI::IsSummonedBy(), npc_oculus_drake::npc_oculus_drakeAI::IsSummonedBy(), npc_wintergarde_gryphon::IsSummonedBy(), npc_frostbrood_skytalon::npc_frostbrood_skytalonAI::IsSummonedBy(), npc_enraged_spirit::npc_enraged_spiritAI::JustDied(), boss_ayamiss::JustEngagedWith(), boss_alar::JustEngagedWith(), npc_eris_hevenfire::npc_eris_hevenfireAI::JustSummoned(), npc_daphne_stilwell::npc_daphne_stilwellAI::JustSummoned(), npc_hor_lich_king::JustSummoned(), boss_ingvar_the_plunderer::JustSummoned(), npc_kalecgos_kj::JustSummoned(), boss_janalai::JustSummoned(), boss_captain_skarloc::JustSummoned(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::JustSummoned(), boss_novos::JustSummoned(), npc_tirions_gambit_tirion::npc_tirions_gambit_tirionAI::JustSummoned(), npc_overlord_drakuru_betrayal::JustSummoned(), npc_akama_shade::JustSummoned(), npc_creature_generator_akama::JustSummoned(), boss_lady_vashj::JustSummoned(), npc_rinji::npc_rinjiAI::JustSummoned(), npc_lady_sylvanas_windrunner::npc_lady_sylvanas_windrunnerAI::JustSummoned(), npc_maghar_captive::npc_maghar_captiveAI::JustSummoned(), boss_ayamiss::JustSummoned(), boss_volkhan::MovementInform(), npc_akama_illidan::MovementInform(), boss_felmyst::MovementInform(), boss_jedoga_shadowseeker::MovementInform(), boss_razorscale::MovementInform(), MovePoint(), npc_cameron::MoveTheChildren(), boss_four_horsemen::boss_four_horsemenAI::MoveToCorner(), npc_sorlof::MoveToNextNode(), npc_concentrated_ball::npc_concentrated_ballAI::MoveToNextPoint(), boss_onyxia::MoveToWaypoint(), npc_attracted_reef_bull::npc_attracted_reef_bullAI::npc_attracted_reef_bullAI(), npc_omen::npc_omenAI::npc_omenAI(), npc_pos_after_first_boss::npc_pos_after_first_bossAI::npc_pos_after_first_bossAI(), go_beacon::go_beaconAI::OnStateChanged(), npc_oculus_drake::npc_oculus_drakeAI::PassengerBoarded(), boss_nightbane::PathEndReached(), npc_oculus_unstable_sphere::npc_oculus_unstable_sphereAI::PickNewLocation(), npc_jungle_punch_target::npc_jungle_punch_targetAI::proceedCwEvent(), SmartScript::ProcessAction(), npc_janalai_hatcher::Reset(), npc_zulian_prowler::npc_zulian_prowlerAI::Reset(), boss_jedoga_shadowseeker::Reset(), npc_released_offspring_harkoa::npc_released_offspring_harkoaAI::Reset(), boss_lady_vashj::Reset(), SmartAI::ReturnToLastOOCPos(), npc_escortAI::ReturnToLastPoint(), boss_illidan_stormrage::ScheduleAbilities(), boss_felmyst::ScheduleGroundAbilities(), boss_nightbane::ScheduleLand(), Map::ScriptsProcess(), boss_sartharion::SendLavaWaves(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SendSaurfangCampWorkerOut(), gunship_npc_AI::SetData(), npc_tirion_fordring_tft::npc_tirion_fordringAI::sGossipSelect(), npc_akama_illidan::sGossipSelect(), npc_akama_shade::sGossipSelect(), npc_varian_wrynn::npc_varian_wrynnAI::SpawnWave(), npc_high_overlord_saurfang_icc::npc_high_overlord_saurfangAI::SpellHit(), npc_muradin_bronzebeard_icc::npc_muradin_bronzebeard_iccAI::SpellHit(), npc_saurfang_event::npc_saurfang_eventAI::SpellHit(), npc_forest_frog::SpellHit(), npc_troll_volunteer::npc_troll_volunteerAI::SpellHit(), npc_enslaved_netherwing_drake::SpellHit(), npc_injured_patient::npc_injured_patientAI::SpellHit(), npc_attracted_reef_bull::npc_attracted_reef_bullAI::SpellHit(), npc_wild_wyrm::SpellHit(), boss_quartermaster_zigris::SpellHitTarget(), npc_chesspiece::SpellHitTarget(), npc_pet_gen_fetch_ball::SpellHitTarget(), instance_violet_hold::instance_violet_hold_InstanceMapScript::StartBossEncounter(), npc_stillpine_capitive::npc_stillpine_capitiveAI::StartMoving(), boss_vazruden_the_herald::SummonedCreatureDies(), boss_jedoga_shadowseeker::SummonedCreatureDies(), npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI::SummonNextWave(), npc_escortAI::UpdateAI(), npc_rookery_hatcher::UpdateAI(), boss_majordomo::UpdateAI(), boss_mr_smite::boss_mr_smiteAI::UpdateAI(), boss_kirtonos_the_herald::boss_kirtonos_the_heraldAI::UpdateAI(), npc_bh_thalorien_dawnseeker::npc_bh_thalorien_dawnseekerAI::UpdateAI(), npc_grand_magister_rommath::npc_grand_magister_rommathAI::UpdateAI(), npc_scarlet_ghoul::UpdateAI(), npc_acherus_necromancer::UpdateAI(), npc_gothik_the_harvester::UpdateAI(), npc_highlord_darion_mograine::UpdateAI(), npc_valkyr_battle_maiden::UpdateAI(), npc_highborne_lamenter::npc_highborne_lamenterAI::UpdateAI(), npc_akilzon_eagle::UpdateAI(), npc_forest_frog::UpdateAI(), boss_arlokk::boss_arlokkAI::UpdateAI(), boss_mandokir::boss_mandokirAI::UpdateAI(), npc_winterfin_playmate::UpdateAI(), npc_snowfall_glade_playmate::UpdateAI(), npc_the_biggest_tree::UpdateAI(), npc_high_oracle_soo_roo::UpdateAI(), npc_elder_kekek::UpdateAI(), npc_the_etymidian::UpdateAI(), npc_alexstraza_the_lifebinder::UpdateAI(), npc_arthas::npc_arthasAI::UpdateAI(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::UpdateAI(), boss_onyxia::UpdateAI(), npc_draenei_survivor::npc_draenei_survivorAI::UpdateAI(), boss_jedoga_shadowseeker::UpdateAI(), npc_twilight_volunteer::UpdateAI(), npc_taldaram_flamesphere::UpdateAI(), boss_hadronox::UpdateAI(), npc_xerestrasza::npc_xerestraszaAI::UpdateAI(), boss_saviana_ragefire::boss_saviana_ragefireAI::UpdateAI(), boss_grand_champion::boss_grand_championAI::UpdateAI(), npc_fos_corrupted_soul_fragment::UpdateAI(), npc_hor_leader::npc_hor_leaderAI::UpdateAI(), npc_hor_leader_second::npc_hor_leader_secondAI::UpdateAI(), npc_pos_leader::npc_pos_leaderAI::UpdateAI(), npc_pos_after_first_boss::npc_pos_after_first_bossAI::UpdateAI(), npc_pos_tyrannus_events::npc_pos_tyrannus_eventsAI::UpdateAI(), npc_blood_queen_lana_thel::npc_blood_queen_lana_thelAI::UpdateAI(), boss_blood_queen_lana_thel::boss_blood_queen_lana_thelAI::UpdateAI(), npc_high_overlord_saurfang_icc::npc_high_overlord_saurfangAI::UpdateAI(), npc_muradin_bronzebeard_icc::npc_muradin_bronzebeard_iccAI::UpdateAI(), npc_high_overlord_saurfang_igb::npc_high_overlord_saurfang_igbAI::UpdateAI(), npc_muradin_bronzebeard_igb::npc_muradin_bronzebeard_igbAI::UpdateAI(), boss_sindragosa::boss_sindragosaAI::UpdateAI(), npc_tirion_fordring_tft::npc_tirion_fordringAI::UpdateAI(), npc_valkyr_shadowguard::npc_valkyr_shadowguardAI::UpdateAI(), npc_icc_vengeful_fleshreaper::npc_icc_vengeful_fleshreaperAI::UpdateAI(), boss_four_horsemen::boss_four_horsemenAI::UpdateAI(), boss_sapphiron::boss_sapphironAI::UpdateAI(), boss_malygos::UpdateAI(), npc_power_spark::UpdateAI(), npc_oculus_drakegiver::npc_oculus_drakegiverAI::UpdateAI(), npc_oculus_drake::npc_oculus_drakeAI::UpdateAI(), boss_algalon_the_observer::UpdateAI(), npc_brann_bronzebeard_algalon::UpdateAI(), boss_stormcaller_brundir::UpdateAI(), boss_flame_leviathan::UpdateAI(), boss_flame_leviathan_safety_container::UpdateAI(), npc_ulduar_emergency_fire_bot::UpdateAI(), boss_razorscale::UpdateAI(), npc_expedition_engineer::UpdateAI(), boss_yoggsaron_death_ray::UpdateAI(), boss_ymiron::boss_ymironAI::UpdateAI(), npc_preparations_for_war_vehicle::UpdateAI(), npc_shandy_dalaran::npc_shandy_dalaranAI::UpdateAI(), npc_minigob_manabonk::UpdateAI(), npc_conversing_with_the_depths_trigger::npc_conversing_with_the_depths_triggerAI::UpdateAI(), npc_wintergarde_gryphon::UpdateAI(), npc_commander_eligor_dawnbringer::npc_commander_eligor_dawnbringerAI::UpdateAI(), npc_venture_co_straggler::npc_venture_co_stragglerAI::UpdateAI(), npc_battle_at_valhalas::npc_battle_at_valhalasAI::UpdateAI(), npc_lord_arete::npc_lord_areteAI::UpdateAI(), npc_frostbrood_skytalon::npc_frostbrood_skytalonAI::UpdateAI(), npc_crusade_recruit::npc_crusade_recruitAI::UpdateAI(), npc_millhouse_manastorm::npc_millhouse_manastormAI::UpdateAI(), npc_nether_drake::npc_nether_drakeAI::UpdateAI(), npc_fel_guard_hound::npc_fel_guard_houndAI::UpdateAI(), npc_mature_netherwing_drake::npc_mature_netherwing_drakeAI::UpdateAI(), npc_dragonmaw_peon::npc_dragonmaw_peonAI::UpdateAI(), npc_tirions_gambit_tirion::npc_tirions_gambit_tirionAI::UpdateEscortAI(), npc_tooga::npc_toogaAI::UpdateFollowerAI(), npc_jenny::UpdateFollowerAI(), npc_dusk::WaypointReached(), npc_emily::npc_emilyAI::WaypointReached(), and npc_ancestral_wolf::npc_ancestral_wolfAI::WaypointReached().

◆ MovePointBackwards()

void MotionMaster::MovePointBackwards ( uint32  id,
float  x,
float  y,
float  z,
bool  generatePath = true,
bool  forceDestination = true,
MovementSlot  slot = MOTION_SLOT_ACTIVE,
float  orientation = 0.0f 
)
1045{
1047 return;
1048
1049 if (_owner->IsPlayer())
1050 {
1051 LOG_DEBUG("movement.motionmaster", "Player ({}) targeted point backwards (Id: {} X: {} Y: {} Z: {})",
1052 _owner->GetGUID().ToString(), id, x, y, z);
1053 Mutate(new PointMovementGenerator<Player>(id, x, y, z, FORCED_MOVEMENT_NONE, 0.0f, orientation, nullptr,
1054 generatePath, forceDestination, std::nullopt, ObjectGuid::Empty, true), slot);
1055 }
1056 else
1057 {
1058 LOG_DEBUG("movement.motionmaster", "Creature ({}) targeted point backwards (ID: {} X: {} Y: {} Z: {})",
1059 _owner->GetGUID().ToString(), id, x, y, z);
1060 Mutate(new PointMovementGenerator<Creature>(id, x, y, z, FORCED_MOVEMENT_NONE, 0.0f, orientation, nullptr,
1061 generatePath, forceDestination, std::nullopt, ObjectGuid::Empty, true), slot);
1062 }
1063}
static ObjectGuid const Empty
Definition ObjectGuid.h:123

References _owner, ObjectGuid::Empty, FORCED_MOVEMENT_NONE, Object::GetGUID(), Unit::HasUnitFlag(), Object::IsPlayer(), LOG_DEBUG, Mutate(), ObjectGuid::ToString(), and UNIT_FLAG_DISABLE_MOVE.

◆ MoveRandom()

void MotionMaster::MoveRandom ( float  wanderDistance = 0.0f)

Enable a random movement in desired range around the unit. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

246{
248 return;
249
250 if (_owner->IsCreature())
251 {
252 LOG_DEBUG("movement.motionmaster", "Creature ({}) start moving random", _owner->GetGUID().ToString());
254 }
255}
Definition RandomMovementGenerator.h:33

References _owner, Object::GetGUID(), Unit::HasUnitFlag(), Object::IsCreature(), LOG_DEBUG, MOTION_SLOT_IDLE, Mutate(), ObjectGuid::ToString(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by SACActivateEvent::Execute(), spell_item_enchanted_broom_periodic::HandlePeriodicTick(), boss_ghazan::JustReachedHome(), boss_kelthuzad::boss_kelthuzadAI::JustSummoned(), boss_sartharion::JustSummoned(), boss_the_lich_king::boss_the_lich_kingAI::JustSummoned(), boss_lady_vashj::JustSummoned(), boss_kaelthas::JustSummoned(), boss_mechano_lord_capacitus::JustSummoned(), npc_crystalline_frayer::LeaveSeedPod(), boss_ebonroc::MovementInform(), npc_sorlof::MoveToNextNode(), npc_collapsing_star::npc_collapsing_star(), npc_frost_sphere::npc_frost_sphereAI::npc_frost_sphereAI(), npc_ulduar_saronite_vapors::npc_ulduar_saronite_vapors(), instance_serpent_shrine::instance_serpentshrine_cavern_InstanceMapScript::OnCreatureCreate(), SmartScript::ProcessAction(), npc_brew_bubble::Reset(), npc_crystalline_frayer::Reset(), npc_infernal_attacker::npc_infernal_attackerAI::Reset(), npc_cameron::UpdateAI(), boss_sapphiron::boss_sapphironAI::UpdateAI(), and npc_minigob_manabonk::UpdateAI().

◆ MoveRotate()

void MotionMaster::MoveRotate ( uint32  time,
RotateDirection  direction 
)

Rotate the unit. You can specify the time of the rotation.

1035{
1036 if (!time)
1037 return;
1038
1039 Mutate(new RotateMovementGenerator(time, direction), MOTION_SLOT_ACTIVE);
1040}
Definition IdleMovementGenerator.h:34

References MOTION_SLOT_ACTIVE, and Mutate().

◆ MoveSeekAssistance()

void MotionMaster::MoveSeekAssistance ( float  x,
float  y,
float  z 
)
862{
863 // Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
865 return;
866
867 if (_owner->IsPlayer())
868 {
869 LOG_ERROR("movement.motionmaster", "Player ({}) attempt to seek assistance", _owner->GetGUID().ToString());
870 }
871 else
872 {
873 LOG_DEBUG("movement.motionmaster", "Creature ({}) seek assistance (X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), x, y, z);
875 _owner->CastStop(0, false);
878 }
879}
@ REACT_PASSIVE
Definition Unit.h:569
Definition PointMovementGenerator.h:75
void SetReactState(ReactStates state)
A creature can have 3 ReactStates : Agressive, Passive, Neutral.
Definition Creature.h:100
Creature * ToCreature()
Definition Object.h:212
void CastStop(uint32 except_spellid=0, bool withInstant=true)
Interrupt the unit cast for all the current spells.
Definition Unit.cpp:1365
bool AttackStop()
Force the unit to stop attacking. This will clear UNIT_STATE_MELEE_ATTACKING, Interrupt current spell...
Definition Unit.cpp:7240

References _owner, Unit::AttackStop(), Unit::CastStop(), Object::GetGUID(), Unit::HasUnitFlag(), Object::IsPlayer(), LOG_DEBUG, LOG_ERROR, MOTION_SLOT_ACTIVE, Mutate(), REACT_PASSIVE, Creature::SetReactState(), Object::ToCreature(), ObjectGuid::ToString(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by Creature::DoFleeToGetAssistance().

◆ MoveSeekAssistanceDistract()

void MotionMaster::MoveSeekAssistanceDistract ( uint32  timer)
882{
883 // Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
885 return;
886
887 if (_owner->IsPlayer())
888 {
889 LOG_ERROR("movement.motionmaster", "Player ({}) attempt to call distract after assistance", _owner->GetGUID().ToString());
890 }
891 else
892 {
893 LOG_DEBUG("movement.motionmaster", "Creature ({}) is distracted after assistance call (Time: {})", _owner->GetGUID().ToString(), time);
895 }
896}
Definition IdleMovementGenerator.h:65

References _owner, Object::GetGUID(), Unit::HasUnitFlag(), Object::IsPlayer(), LOG_DEBUG, LOG_ERROR, MOTION_SLOT_ACTIVE, Mutate(), ObjectGuid::ToString(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by AssistanceMovementGenerator::Finalize().

◆ MoveSplinePath()

◆ MoveTakeoff() [1/2]

void MotionMaster::MoveTakeoff ( uint32  id,
float  x,
float  y,
float  z,
float  speed = 0.0f,
bool  skipAnimation = false 
)

Use to move the unit from the air to the ground. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

615{
616 Position pos = {x, y, z, 0.0f};
617 MoveTakeoff(id, pos, speed, skipAnimation);
618}
void MoveTakeoff(uint32 id, Position const &pos, float speed=0.0f, bool skipAnimation=false)
Use to move the unit from the ground to the air. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:589

References MoveTakeoff().

◆ MoveTakeoff() [2/2]

void MotionMaster::MoveTakeoff ( uint32  id,
Position const &  pos,
float  speed = 0.0f,
bool  skipAnimation = false 
)

Use to move the unit from the ground to the air. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

590{
592 return;
593
594 float x, y, z;
595 pos.GetPosition(x, y, z);
596
597 LOG_DEBUG("movement.motionmaster", "Creature (Entry: {}) landing point (ID: {} X: {} Y: {} Z: {})", _owner->GetEntry(), id, x, y, z);
598
600 init.MoveTo(x, y, z);
601
602 if (speed > 0.0f)
603 init.SetVelocity(speed);
604
605 if (!skipAnimation)
606 init.SetAnimation(AnimTier::Hover);
607
609}

References _owner, Object::GetEntry(), Position::GetPosition(), Unit::HasUnitFlag(), Hover, LOG_DEBUG, MOTION_SLOT_ACTIVE, Movement::MoveSplineInit::MoveTo(), Mutate(), Movement::MoveSplineInit::SetAnimation(), Movement::MoveSplineInit::SetVelocity(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by boss_kaelthas::ExecuteMiddleEvent(), MoveTakeoff(), npc_enslaved_proto_drake::SetData(), npc_madrigosa::UpdateAI(), boss_onyxia::UpdateAI(), boss_jedoga_shadowseeker::UpdateAI(), boss_krick::boss_krickAI::UpdateAI(), npc_pos_tyrannus_events::npc_pos_tyrannus_eventsAI::UpdateAI(), boss_blood_queen_lana_thel::boss_blood_queen_lana_thelAI::UpdateAI(), boss_sindragosa::boss_sindragosaAI::UpdateAI(), and npc_rimefang::npc_rimefangAI::UpdateAI().

◆ MoveTargetedHome()

void MotionMaster::MoveTargetedHome ( bool  walk = false)

The unit will return this initial position (owner for pets and summoned creatures). Doesn't work with UNIT_FLAG_DISABLE_MOVE.

Parameters
walkThe unit will run by default, but you can set it to walk
263{
264 Clear(false);
265
267 {
268 LOG_DEBUG("movement.motionmaster", "Creature ({}) targeted home", _owner->GetGUID().ToString());
270 }
272 {
274
276 return;
277
278 LOG_DEBUG("movement.motionmaster", "Pet or controlled creature ({}) targeting home", _owner->GetGUID().ToString());
279 Unit* target = _owner->ToCreature()->GetCharmerOrOwner();
280 if (target)
281 {
282 LOG_DEBUG("movement.motionmaster", "Following {} ({})", target->IsPlayer() ? "player" : "creature", target->GetGUID().ToString());
284 }
285 }
286 else
287 {
288 LOG_ERROR("movement.motionmaster", "Player ({}) attempt targeted home", _owner->GetGUID().ToString());
289 }
290}
constexpr float PET_FOLLOW_DIST
Definition PetDefines.h:206
@ UNIT_STATE_EVADE
Definition UnitDefines.h:194
Definition HomeMovementGenerator.h:26
void Clear(bool reset=true)
Definition MotionMaster.h:194
Definition Unit.h:667
void ClearUnitState(uint32 f)
Definition Unit.h:740
ObjectGuid GetCharmerOrOwnerGUID() const override
Definition Unit.h:1302
Unit * GetCharmerOrOwner() const
Definition Unit.h:1293
virtual float GetFollowAngle() const
Definition Unit.h:1903

References _owner, Clear(), Unit::ClearUnitState(), Unit::GetCharmerOrOwner(), Unit::GetCharmerOrOwnerGUID(), Unit::GetFollowAngle(), Object::GetGUID(), Unit::HasUnitFlag(), Object::IsCreature(), Object::IsPlayer(), LOG_DEBUG, LOG_ERROR, MOTION_SLOT_ACTIVE, Mutate(), PET_FOLLOW_DIST, Object::ToCreature(), ObjectGuid::ToString(), UNIT_FLAG_DISABLE_MOVE, and UNIT_STATE_EVADE.

Referenced by npc_expedition_engineer::DoAction(), npc_spark_of_ionar::DoAction(), npc_battle_at_valhalas::npc_battle_at_valhalasAI::EndBattle(), npc_black_morass_summoned_add::EnterEvadeMode(), npc_argent_captainAI::EnterEvadeMode(), CreatureAI::EnterEvadeMode(), SmartAI::EnterEvadeMode(), GuardAI::EnterEvadeMode(), boss_doomrel::EnterEvadeMode(), npc_varian_wrynn::npc_varian_wrynnAI::EnterEvadeMode(), npc_thrall_bfu::npc_thrall_bfuAI::EnterEvadeMode(), npc_high_overlord_saurfang_igb::npc_high_overlord_saurfang_igbAI::EnterEvadeMode(), npc_muradin_bronzebeard_igb::npc_muradin_bronzebeard_igbAI::EnterEvadeMode(), gunship_npc_AI::EnterEvadeMode(), npc_gunship_boarding_addAI::EnterEvadeMode(), violet_hold_trashAI::EnterEvadeMode(), npc_escortAI::EnterEvadeMode(), FollowerAI::EnterEvadeMode(), NpcRunToHome::Execute(), wp_commandscript::HandleWpUnLoadCommand(), boss_aeonus::IsSummonedBy(), boss_blood_queen_lana_thel::boss_blood_queen_lana_thelAI::MovementInform(), go_beacon::go_beaconAI::OnStateChanged(), boss_arlokk::boss_arlokkAI::Reset(), boss_kologarn::Reset(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::UpdateAI(), npc_expedition_engineer::UpdateAI(), npc_shandy_dalaran::npc_shandy_dalaranAI::UpdateAI(), and npc_mature_netherwing_drake::npc_mature_netherwing_drakeAI::UpdateAI().

◆ MoveTaxiFlight()

void MotionMaster::MoveTaxiFlight ( uint32  path,
uint32  pathnode 
)
927{
928 if (_owner->IsPlayer())
929 {
930 if (path < sTaxiPathNodesByPath.size())
931 {
932 LOG_DEBUG("movement.motionmaster", "{} taxi to (Path {} node {})", _owner->GetName(), path, pathnode);
934 Player* player = _owner->ToPlayer();
935 if (!mgen->LoadPath(player))
936 {
937 LOG_ERROR("movement.motionmaster", "{} failed to build taxi path (Path {} node {}), clearing taxi destinations",
938 _owner->GetName(), path, pathnode);
940 player->Dismount();
941 delete mgen;
942 return;
943 }
944
946 }
947 else
948 {
949 LOG_ERROR("movement.motionmaster", "{} attempt taxi to (not existed Path {} node {})",
950 _owner->GetName(), path, pathnode);
951 }
952 }
953 else
954 {
955 LOG_ERROR("movement.motionmaster", "Creature ({}) attempt taxi to (Path {} node {})", _owner->GetGUID().ToString(), path, pathnode);
956 }
957}
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition DBCStores.cpp:191
Definition WaypointMovementGenerator.h:101
bool LoadPath(Player *player)
Definition WaypointMovementGenerator.cpp:579
void ClearTaxiDestinations()
Definition PlayerTaxi.h:61
PlayerTaxi m_taxi
Definition Player.h:1160
void Dismount()
Definition Unit.cpp:10323

References _owner, PlayerTaxi::ClearTaxiDestinations(), Unit::Dismount(), Object::GetGUID(), WorldObject::GetName(), Object::IsPlayer(), FlightPathMovementGenerator::LoadPath(), LOG_DEBUG, LOG_ERROR, Player::m_taxi, MOTION_SLOT_CONTROLLED, Mutate(), sTaxiPathNodesByPath, Object::ToPlayer(), and ObjectGuid::ToString().

Referenced by WorldSession::SendDoFlight().

◆ MoveWaypoint()

void MotionMaster::MoveWaypoint ( uint32  path_id,
bool  repeatable,
PathSource  pathSource = PathSource::WAYPOINT_MGR 
)

Move the unit following a specific path. Doesn't work with UNIT_FLAG_DISABLE_MOVE.

1018{
1019 if (!path_id)
1020 return;
1021
1023 return;
1024
1025 Mutate(new WaypointMovementGenerator<Creature>(path_id, repeatable, pathSource), MOTION_SLOT_IDLE);
1026
1027 LOG_DEBUG("movement.motionmaster", "{} ({}) start moving over path(Id:{}, repeatable: {})",
1028 _owner->IsPlayer() ? "Player" : "Creature", _owner->GetGUID().ToString(), path_id, repeatable ? "YES" : "NO");
1029}
Definition WaypointMovementGenerator.h:50

References _owner, Object::GetGUID(), Unit::HasUnitFlag(), Object::IsPlayer(), LOG_DEBUG, MOTION_SLOT_IDLE, Mutate(), ObjectGuid::ToString(), and UNIT_FLAG_DISABLE_MOVE.

Referenced by boss_nightbane::DoAction(), npc_amanishi_lookout::DoAction(), boss_anetheron::DoAction(), boss_azgalor::DoAction(), boss_kazrogal::DoAction(), boss_rage_winterchill::DoAction(), npc_hyjal_ground_trash::DoAction(), npc_hyjal_gargoyle::DoAction(), npc_hyjal_frost_wyrm::DoAction(), brann_bronzebeard::DoAction(), npc_time_lost_proto_drake::npc_time_lost_proto_drakeAI::DoAction(), boss_ambassador_hellmaw::DoAction(), npc_akama_illidan::DoAction(), boss_ghazan::DoAction(), spell_gen_ayamiss_swarmer_loop::HandleScript(), boss_felmyst::InitializeAI(), boss_lieutenant_drake::InitializeAI(), boss_ambassador_hellmaw::InitializeAI(), boss_gahzranka::IsSummonedBy(), boss_jeklik::JustEngagedWith(), SmartAI::JustReachedHome(), npc_akama_illidan::JustReachedHome(), npc_kiljaeden_controller::JustSummoned(), boss_hadronox::JustSummoned(), boss_skadi::boss_skadiAI::JustSummoned(), boss_hydross_the_unstable::JustSummoned(), boss_nalorakk::MoveInLineOfSight(), npc_shattered_hand_scout::MoveInLineOfSight(), npc_harrison_jones::MovementInform(), npc_hyjal_jaina::OnGossipSelect(), npc_akama_illidan::PathEndReached(), boss_the_beast::Reset(), npc_acherus_necromancer::Reset(), npc_gothik_the_harvester::Reset(), boss_bug_trio::Reset(), npc_injured_7th_legion_soldier::npc_injured_7th_legion_soldierAI::Reset(), boss_the_beast::SetData(), npc_eastvale_peasent::SetData(), npc_akama_illidan::sGossipSelect(), npc_varian_wrynn::npc_varian_wrynnAI::SpawnWave(), npc_belnistrasz::npc_belnistraszAI::sQuestAccept(), boss_felmyst::StartIntro(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SummonSaurfangCampVendor(), boss_gyth::UpdateAI(), boss_rend_blackhand::UpdateAI(), boss_victor_nefarius::UpdateAI(), boss_kirtonos_the_herald::boss_kirtonos_the_heraldAI::UpdateAI(), npc_cameron::UpdateAI(), npc_eastvale_peasent::UpdateAI(), npc_partygoer_pather::UpdateAI(), npc_grand_magister_rommath::npc_grand_magister_rommathAI::UpdateAI(), boss_headless_horseman::UpdateAI(), boss_lieutenant_drake::UpdateAI(), npc_weegli_blastfuse::npc_weegli_blastfuseAI::UpdateAI(), npc_pos_leader_second::npc_pos_leader_secondAI::UpdateAI(), and npc_wounded_skirmisher::UpdateAI().

◆ Mutate()

void MotionMaster::Mutate ( MovementGenerator *  m,
MovementSlot  slot 
)
private
985{
986 bool const delayed = (_cleanFlag & MMCF_UPDATE);
987
988 while (MovementGenerator* curr = Impl[slot])
989 {
990 // clear slot AND decrease top immediately to avoid crashes when referencing null top in DirectDelete
991 Impl[slot] = nullptr;
992 while (!empty() && !top())
993 --_top;
994
995 if (delayed)
996 DelayedDelete(curr);
997 else
998 DirectDelete(curr);
999 }
1000
1001 if (_top < slot)
1002 _top = slot;
1003
1004 Impl[slot] = m;
1005 if (_top > slot)
1006 _needInit[slot] = true;
1007 else
1008 {
1009 _needInit[slot] = false;
1010 m->Initialize(_owner);
1011 }
1012}

References _cleanFlag, _needInit, _owner, _top, DelayedDelete(), DirectDelete(), empty(), Impl, MovementGenerator::Initialize(), MMCF_UPDATE, and top().

Referenced by InitDefault(), MoveCharge(), MoveChase(), MoveConfused(), MoveDistract(), MoveFall(), MoveFleeing(), MoveFollow(), MoveFormation(), MoveIdle(), MoveJump(), MoveKnockbackFrom(), MoveLand(), MovePoint(), MovePointBackwards(), MoveRandom(), MoveRotate(), MoveSeekAssistance(), MoveSeekAssistanceDistract(), MoveSplinePath(), MoveTakeoff(), MoveTargetedHome(), MoveTaxiFlight(), and MoveWaypoint().

◆ needInitTop()

bool MotionMaster::needInitTop ( ) const
inlineprivate
155 {
156 if (empty())
157 return false;
158 return _needInit[_top];
159 }

References _needInit, _top, and empty().

Referenced by DirectClean(), DirectExpire(), DirectExpireSlot(), and UpdateMotion().

◆ pop()

void MotionMaster::pop ( )
inlineprivate
145 {
146 if (empty())
147 return;
148
149 Impl[_top] = nullptr;
150 while (!empty() && !top())
151 --_top;
152 }

References _top, empty(), Impl, and top().

Referenced by DelayedClean(), DelayedExpire(), DirectClean(), DirectExpire(), Initialize(), and ~MotionMaster().

◆ propagateSpeedChange()

void MotionMaster::propagateSpeedChange ( )
1066{
1067 /*Impl::container_type::iterator it = Impl::c.begin();
1068 for (; it != end(); ++it)
1069 {
1070 (*it)->unitSpeedChanged();
1071 }*/
1072 for (int i = 0; i <= _top; ++i)
1073 {
1074 if (Impl[i])
1075 Impl[i]->unitSpeedChanged();
1076 }
1077}
virtual void unitSpeedChanged()
Definition MovementGenerator.h:43

References _top, Impl, and MovementGenerator::unitSpeedChanged().

Referenced by Unit::propagateSpeedChange(), and npc_hor_lich_king::UpdateAI().

◆ ReinitializeMovement()

void MotionMaster::ReinitializeMovement ( )
1080{
1081 for (int i = 0; i <= _top; ++i)
1082 {
1083 if (Impl[i])
1084 Impl[i]->Reset(_owner);
1085 }
1086}

References _owner, _top, Impl, and MovementGenerator::Reset().

Referenced by WorldSession::HandleMoveTeleportAck(), and Unit::NearTeleportTo().

◆ size()

int MotionMaster::size ( ) const
inline
176{ return _top + 1; }

References _top.

Referenced by DelayedClean(), DelayedExpire(), DirectClean(), DirectExpire(), and DirectExpireSlot().

◆ top()

◆ UpdateMotion()

void MotionMaster::UpdateMotion ( uint32  diff)
108{
109 if (!_owner)
110 return;
111
112 ASSERT(!empty());
113
115
117 if (!top()->Update(_owner, diff))
118 {
119 _cleanFlag &= ~MMCF_UPDATE;
121 }
122 else
123 _cleanFlag &= ~MMCF_UPDATE;
124
125 if (_expList)
126 {
127 for (std::size_t i = 0; i < _expList->size(); ++i)
128 {
129 MovementGenerator* mg = (*_expList)[i];
130 DirectDelete(mg);
131 }
132
133 delete _expList;
134 _expList = nullptr;
135
136 if (empty())
137 Initialize();
138 else if (needInitTop())
139 InitTop();
140 else if (_cleanFlag & MMCF_RESET)
141 top()->Reset(_owner);
142
143 _cleanFlag &= ~MMCF_RESET;
144 }
145
146 _cleanFlag &= ~MMCF_INUSE;
147}
@ MMCF_INUSE
Definition MotionMaster.h:75
void MovementExpired(bool reset=true)
Definition MotionMaster.h:207

References _cleanFlag, _expList, _owner, ASSERT, DirectDelete(), empty(), Initialize(), InitTop(), MMCF_INUSE, MMCF_RESET, MMCF_UPDATE, MovementExpired(), needInitTop(), MovementGenerator::Reset(), and top().

Referenced by Unit::Update().

Member Data Documentation

◆ _cleanFlag

uint8 MotionMaster::_cleanFlag
private

◆ _expList

ExpireList* MotionMaster::_expList
private

Referenced by DelayedDelete(), and UpdateMotion().

◆ _needInit

bool MotionMaster::_needInit[MAX_MOTION_SLOT]
private

◆ _owner

◆ _top

◆ Impl


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