diff options
author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2020-09-05 22:07:17 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-02-05 13:08:34 +0100 |
commit | b45277f1cf52483f0471f4aa79ca6b288180ee7c (patch) | |
tree | 844e6ffa7b3bf834a9c5227baee99eacb64135f4 | |
parent | 341ef2c0dd5a15ecfe95450febdd41272f1e48d1 (diff) |
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 982643cd96790ffc54e7a3e507469649f3b074d2
* Remove leftovers from previous tries
(cherry picked from commit ff26027453179448bb972d88a51e565d71e95f3f)
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 16f616e5379..19c2e050bed 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -8216,6 +8216,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(); @@ -8236,18 +8238,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); |