mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Unit: Fix units on vehicles not dismounting on death (#25404)
* Core/Unit: Fix units on vehicles not dismounting on death
Closes #23095
Issue added in 982643cd96
* Remove leftovers from previous tries
This commit is contained in:
@@ -8663,6 +8663,8 @@ void Unit::setDeathState(DeathState s)
|
||||
// Death state needs to be updated before RemoveAllAurasOnDeath() is called, to prevent entering combat
|
||||
m_deathState = s;
|
||||
|
||||
bool isOnVehicle = GetVehicle() != nullptr;
|
||||
|
||||
if (s != ALIVE && s != JUST_RESPAWNED)
|
||||
{
|
||||
CombatStop();
|
||||
@@ -8684,18 +8686,25 @@ void Unit::setDeathState(DeathState s)
|
||||
// remove aurastates allowing special moves
|
||||
ClearAllReactives();
|
||||
ClearDiminishings();
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user