mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Movement: Add new flag MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH (#26549)
* Core/Movement: Add new flag MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH Add new flag MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH to keep movement generators even after death. Fixes #23095 Could replaceff26027453* Core/Movement: reorder new method MotionMaster::StopOnDeath * Core/Movement: reorder new method MotionMaster::StopOnDeath * Keep MoveJump movement generator after death Co-authored-by: ccrs <ccrs@users.noreply.github.com> (cherry picked from commit9fe9dc087b)
This commit is contained in:
@@ -544,6 +544,28 @@ bool MotionMaster::GetDestination(float &x, float &y, float &z)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MotionMaster::StopOnDeath()
|
||||
{
|
||||
if (MovementGenerator* movementGenerator = GetCurrentMovementGenerator())
|
||||
if (movementGenerator->HasFlag(MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH))
|
||||
return false;
|
||||
|
||||
if (_owner->IsInWorld())
|
||||
{
|
||||
// Only clear MotionMaster for entities that exists in world
|
||||
// Avoids crashes in the following conditions :
|
||||
// * Using 'call pet' on dead pets
|
||||
// * Using 'call stabled pet'
|
||||
// * Logging in with dead pets
|
||||
Clear();
|
||||
MoveIdle();
|
||||
}
|
||||
|
||||
_owner->StopMoving();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MotionMaster::MoveIdle()
|
||||
{
|
||||
Add(GetIdleMovementGenerator(), MOTION_SLOT_DEFAULT);
|
||||
@@ -766,6 +788,7 @@ void MotionMaster::MoveKnockbackFrom(Position const& origin, float speedXY, floa
|
||||
|
||||
GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, 0);
|
||||
movement->Priority = MOTION_PRIORITY_HIGHEST;
|
||||
movement->AddFlag(MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH);
|
||||
Add(movement);
|
||||
}
|
||||
|
||||
@@ -853,6 +876,7 @@ void MotionMaster::MoveJumpWithGravity(Position const& pos, float speedXY, float
|
||||
GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id, arrivalSpellId, arrivalSpellTargetGuid);
|
||||
movement->Priority = MOTION_PRIORITY_HIGHEST;
|
||||
movement->BaseUnitState = UNIT_STATE_JUMPING;
|
||||
movement->AddFlag(MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH);
|
||||
Add(movement);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user