Core/Movement: Add new flag MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH

Port From (https://github.com/TrinityCore/TrinityCore/commit/8111f50d035c1915165cb8ecd4938ba97820ed10)
This commit is contained in:
hondacrx
2022-05-26 20:23:19 -04:00
parent ba87f08c37
commit 2703633af8
3 changed files with 28 additions and 12 deletions
@@ -97,6 +97,7 @@ namespace Framework.Constants
Deactivated = 0x040,
InformEnabled = 0x080,
Finalized = 0x100,
PersistOnDeath = 0x200,
Transitory = SpeedUpdatePending | Interrupted
}
+2 -12
View File
@@ -1397,18 +1397,8 @@ namespace Game.Entities
// 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
+25
View File
@@ -513,6 +513,29 @@ namespace Game.Movement
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()
{
Add(GetIdleMovementGenerator(), MovementSlot.Default);
@@ -710,6 +733,7 @@ namespace Game.Movement
GenericMovementGenerator movement = new(init, MovementGeneratorType.Effect, 0);
movement.Priority = MovementGeneratorPriority.Highest;
movement.AddFlag(MovementGeneratorFlags.PersistOnDeath);
Add(movement);
}
@@ -793,6 +817,7 @@ namespace Game.Movement
GenericMovementGenerator movement = new GenericMovementGenerator(init, MovementGeneratorType.Effect, id, arrivalSpellId, arrivalSpellTargetGuid);
movement.Priority = MovementGeneratorPriority.Highest;
movement.BaseUnitState = UnitState.Jumping;
movement.AddFlag(MovementGeneratorFlags.PersistOnDeath);
Add(movement);
}