From fff95df0e8656fc260034d4ecd36a6fc42c29bd2 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 3 Sep 2019 15:58:27 -0400 Subject: [PATCH] Core/Aura: fix SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE unapply case for dead players Port From (https://github.com/TrinityCore/TrinityCore/commit/99a95c924181b1beab8cc8eb873eaade08f64a6c) --- Source/Game/Spells/Auras/AuraEffect.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index 11ab55778..65e1d6820 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -3121,7 +3121,13 @@ namespace Game.Spells // save current health state float healthPct = target.GetHealthPct(); - bool alive = target.IsAlive(); + bool zeroHealth = !target.IsAlive(); + + // players in corpse state may mean two different states: + /// 1. player just died but did not release (in this case health == 0) + /// 2. player is corpse running (ie ghost) (in this case health == 1) + if (target.getDeathState() == DeathState.Corpse) + zeroHealth = target.GetHealth() == 0; for (int i = (int)Stats.Strength; i < (int)Stats.Max; i++) { @@ -3147,7 +3153,7 @@ namespace Game.Spells // recalculate current HP/MP after applying aura modifications (only for spells with SPELL_ATTR0_UNK4 0x00000010 flag) // this check is total bullshit i think if (Convert.ToBoolean(GetMiscValueB() & 1 << (int)Stats.Stamina) && m_spellInfo.HasAttribute(SpellAttr0.Ability)) - target.SetHealth((uint)Math.Max((healthPct * target.GetMaxHealth() * 0.01f), (alive ? 1 : 0))); + target.SetHealth(Math.Max(MathFunctions.CalculatePct(target.GetMaxHealth(), healthPct), (zeroHealth ? 0 : 1ul))); } [AuraEffectHandler(AuraType.ModResistanceOfStatPercent)]