Core/Aura: fix SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE unapply case for dead players

Port From (https://github.com/TrinityCore/TrinityCore/commit/99a95c924181b1beab8cc8eb873eaade08f64a6c)
This commit is contained in:
hondacrx
2019-09-03 15:58:27 -04:00
parent a0fbf8e172
commit fff95df0e8
+8 -2
View File
@@ -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)]