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 replace ff26027453
* 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>
This commit is contained in:
@@ -8722,19 +8722,8 @@ void Unit::setDeathState(DeathState s)
|
||||
// Don't clear the movement if the Unit was on a vehicle as we are exiting now
|
||||
if (!isOnVehicle)
|
||||
{
|
||||
if (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
|
||||
GetMotionMaster()->Clear();
|
||||
GetMotionMaster()->MoveIdle();
|
||||
}
|
||||
|
||||
StopMoving();
|
||||
DisableSpline();
|
||||
if (GetMotionMaster()->StopOnDeath())
|
||||
DisableSpline();
|
||||
}
|
||||
|
||||
// without this when removing IncreaseMaxHealth aura player may stuck with 1 hp
|
||||
|
||||
@@ -543,6 +543,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);
|
||||
@@ -757,6 +779,7 @@ void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, 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);
|
||||
}
|
||||
|
||||
@@ -801,6 +824,7 @@ void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, f
|
||||
GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id);
|
||||
movement->Priority = MOTION_PRIORITY_HIGHEST;
|
||||
movement->BaseUnitState = UNIT_STATE_JUMPING;
|
||||
movement->AddFlag(MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH);
|
||||
Add(movement);
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ class TC_GAME_API MotionMaster
|
||||
void Clear(MovementGeneratorPriority priority);
|
||||
void PropagateSpeedChange();
|
||||
bool GetDestination(float &x, float &y, float &z);
|
||||
bool StopOnDeath();
|
||||
|
||||
void MoveIdle();
|
||||
void MoveTargetedHome();
|
||||
|
||||
@@ -39,6 +39,7 @@ enum MovementGeneratorFlags : uint16
|
||||
MOVEMENTGENERATOR_FLAG_DEACTIVATED = 0x040,
|
||||
MOVEMENTGENERATOR_FLAG_INFORM_ENABLED = 0x080,
|
||||
MOVEMENTGENERATOR_FLAG_FINALIZED = 0x100,
|
||||
MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH = 0x200,
|
||||
|
||||
MOVEMENTGENERATOR_FLAG_TRANSITORY = MOVEMENTGENERATOR_FLAG_SPEED_UPDATE_PENDING | MOVEMENTGENERATOR_FLAG_INTERRUPTED
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user