Core/Movement: Add new flag MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH
Port From (https://github.com/TrinityCore/TrinityCore/commit/8111f50d035c1915165cb8ecd4938ba97820ed10)
This commit is contained in:
@@ -97,6 +97,7 @@ namespace Framework.Constants
|
|||||||
Deactivated = 0x040,
|
Deactivated = 0x040,
|
||||||
InformEnabled = 0x080,
|
InformEnabled = 0x080,
|
||||||
Finalized = 0x100,
|
Finalized = 0x100,
|
||||||
|
PersistOnDeath = 0x200,
|
||||||
|
|
||||||
Transitory = SpeedUpdatePending | Interrupted
|
Transitory = SpeedUpdatePending | Interrupted
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1397,18 +1397,8 @@ namespace Game.Entities
|
|||||||
// Don't clear the movement if the Unit was on a vehicle as we are exiting now
|
// Don't clear the movement if the Unit was on a vehicle as we are exiting now
|
||||||
if (!isOnVehicle)
|
if (!isOnVehicle)
|
||||||
{
|
{
|
||||||
if (IsInWorld)
|
if (GetMotionMaster().StopOnDeath())
|
||||||
{
|
DisableSpline();
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// without this when removing IncreaseMaxHealth aura player may stuck with 1 hp
|
// without this when removing IncreaseMaxHealth aura player may stuck with 1 hp
|
||||||
|
|||||||
@@ -513,6 +513,29 @@ namespace Game.Movement
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool StopOnDeath()
|
||||||
|
{
|
||||||
|
MovementGenerator movementGenerator = GetCurrentMovementGenerator();
|
||||||
|
if (movementGenerator != null)
|
||||||
|
if (movementGenerator.HasFlag(MovementGeneratorFlags.PersistOnDeath))
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
public void MoveIdle()
|
public void MoveIdle()
|
||||||
{
|
{
|
||||||
Add(GetIdleMovementGenerator(), MovementSlot.Default);
|
Add(GetIdleMovementGenerator(), MovementSlot.Default);
|
||||||
@@ -710,6 +733,7 @@ namespace Game.Movement
|
|||||||
|
|
||||||
GenericMovementGenerator movement = new(init, MovementGeneratorType.Effect, 0);
|
GenericMovementGenerator movement = new(init, MovementGeneratorType.Effect, 0);
|
||||||
movement.Priority = MovementGeneratorPriority.Highest;
|
movement.Priority = MovementGeneratorPriority.Highest;
|
||||||
|
movement.AddFlag(MovementGeneratorFlags.PersistOnDeath);
|
||||||
Add(movement);
|
Add(movement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -793,6 +817,7 @@ namespace Game.Movement
|
|||||||
GenericMovementGenerator movement = new GenericMovementGenerator(init, MovementGeneratorType.Effect, id, arrivalSpellId, arrivalSpellTargetGuid);
|
GenericMovementGenerator movement = new GenericMovementGenerator(init, MovementGeneratorType.Effect, id, arrivalSpellId, arrivalSpellTargetGuid);
|
||||||
movement.Priority = MovementGeneratorPriority.Highest;
|
movement.Priority = MovementGeneratorPriority.Highest;
|
||||||
movement.BaseUnitState = UnitState.Jumping;
|
movement.BaseUnitState = UnitState.Jumping;
|
||||||
|
movement.AddFlag(MovementGeneratorFlags.PersistOnDeath);
|
||||||
Add(movement);
|
Add(movement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user