Core/Unit: Fix units on vehicles not dismounting on death

Port From (https://github.com/TrinityCore/TrinityCore/commit/b45277f1cf52483f0471f4aa79ca6b288180ee7c)
This commit is contained in:
hondacrx
2022-04-28 10:25:11 -04:00
parent 258c3c489f
commit e271ca1981
+18 -10
View File
@@ -1363,6 +1363,8 @@ namespace Game.Entities
// Death state needs to be updated before RemoveAllAurasOnDeath() is called, to prevent entering combat
m_deathState = s;
bool isOnVehicle = GetVehicle() != null;
if (s != DeathState.Alive && s != DeathState.JustRespawned)
{
CombatStop();
@@ -1383,18 +1385,24 @@ namespace Game.Entities
// remove aurastates allowing special moves
ClearAllReactives();
m_Diminishing.Clear();
if (IsInWorld)
// Don't clear the movement if the Unit was on a vehicle as we are exiting now
if (!isOnVehicle)
{
// 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();
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();
}
StopMoving();
DisableSpline();
// without this when removing IncreaseMaxHealth aura player may stuck with 1 hp
// do not why since in IncreaseMaxHealth currenthealth is checked
SetHealth(0);