aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-08-12 14:17:26 +0200
committerShauren <shauren.trinity@gmail.com>2021-10-19 23:41:07 +0200
commitd3f93bcc2632ed334ddf7acd1f068734bd507877 (patch)
treecdce2951173453f05871d601b40a5ddfdf52177c
parent5cafc211e623c2c6ad730302ea3313d931eb8bb5 (diff)
Spells/Auras: Properly handle negative health modifiers on application. Closes #22211.
(cherry picked from commit 41982aa300263b2c8faedfb88015d31e0ee3161a)
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 38a5ac9c563..a9532ff0823 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -3675,20 +3675,14 @@ void AuraEffect::HandleAuraModIncreaseHealth(AuraApplication const* aurApp, uint
Unit* target = aurApp->GetTarget();
- if (apply)
- {
- target->HandleStatFlatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(GetAmount()), apply);
- target->ModifyHealth(GetAmount());
- }
- else
- {
- if (target->GetHealth() > 0)
- {
- int32 value = std::min<int32>(target->GetHealth() - 1, GetAmount());
- target->ModifyHealth(-value);
- }
- target->HandleStatFlatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(GetAmount()), apply);
- }
+ int32 const amt = apply ? GetAmount() : -GetAmount();
+ if (amt < 0)
+ target->ModifyHealth(std::max<int32>(1 - target->GetHealth(), amt));
+
+ target->HandleStatFlatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, GetAmount(), apply);
+
+ if (amt > 0)
+ target->ModifyHealth(amt);
}
void AuraEffect::HandleAuraModIncreaseMaxHealth(AuraApplication const* aurApp, uint8 mode, bool apply) const