Skip to content

Commit

Permalink
Spells/Auras: Properly handle negative health modifiers on application.
Browse files Browse the repository at this point in the history
Closes #22211.
  • Loading branch information
Treeston committed Aug 12, 2018
1 parent 59edf6b commit 41982aa
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/server/game/Spells/Auras/SpellAuraEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3620,20 +3620,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
Expand Down

1 comment on commit 41982aa

@Killyana
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quest case works correctly, but I tested another case and the npc doesn't regen health it stays at 1 hp:

  • .go c id 33744
  • .mod hp 100000 (you char)
  • .mod fac 14 (on the npc)
  • .dam 40000 (on the npc)
  • .cast self 64498 (on the npc)
    The npc will stay at 1 HP

Please sign in to comment.