From c9ea1484907b916b4fdb7ec42975b87366f14dee Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 20 Oct 2021 22:27:36 -0400 Subject: [PATCH] Spells/Auras: Properly handle negative health modifiers on application. Port From (https://github.com/TrinityCore/TrinityCore/commit/d3f93bcc2632ed334ddf7acd1f068734bd507877) --- Source/Game/Spells/Auras/AuraEffect.cs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index 1a0ee2845..5dad78503 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -3315,21 +3315,14 @@ namespace Game.Spells Unit target = aurApp.GetTarget(); - if (apply) - { - target.HandleStatFlatModifier(UnitMods.Health, UnitModifierFlatType.Total, GetAmount(), apply); - target.ModifyHealth(GetAmount()); - } - else - { - if (target.GetHealth() > 0) - { - int value = (int)Math.Min(target.GetHealth() - 1, (ulong)GetAmount()); - target.ModifyHealth(-value); - } + int amt = apply ? GetAmount() : -GetAmount(); + if (amt < 0) + target.ModifyHealth(Math.Max((int)(1 - target.GetHealth()), amt)); - target.HandleStatFlatModifier(UnitMods.Health, UnitModifierFlatType.Total, GetAmount(), apply); - } + target.HandleStatFlatModifier(UnitMods.Health, UnitModifierFlatType.Total, GetAmount(), apply); + + if (amt > 0) + target.ModifyHealth(amt); } void HandleAuraModIncreaseMaxHealth(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)