Skip to content

Commit

Permalink
fix(core/scripting) Calculate percent-based damage before `ModifyPeri…
Browse files Browse the repository at this point in the history
…odicDamageAurasTick` hook (#17387)

Moved damage calculation for `SPELL_AURA_PERIODIC_DAMAGE_PERCENT` to before the hook.

Co-authored-by: KJack <kjack@electricnightowl.com>
  • Loading branch information
kjack9 and KJack committed Oct 8, 2023
1 parent 2255f49 commit f127e58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/server/game/Spells/Auras/SpellAuraEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6298,6 +6298,13 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
// ignore non positive values (can be result apply spellmods to aura damage
uint32 damage = std::max(GetAmount(), 0);

// If the damage is percent-max-health based, calculate damage before the Modify hook
if (GetAuraType() == SPELL_AURA_PERIODIC_DAMAGE_PERCENT)
{
// xinef: ceil obtained value, it may happen that 10 ticks for 10% damage may not kill owner
damage = uint32(std::ceil(CalculatePct<float, float>(target->GetMaxHealth(), damage)));
}

// Script Hook For HandlePeriodicDamageAurasTick -- Allow scripts to change the Damage pre class mitigation calculations
sScriptMgr->ModifyPeriodicDamageAurasTick(target, caster, damage, GetSpellInfo());

Expand Down Expand Up @@ -6329,8 +6336,6 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
// 5..8 ticks have normal tick damage
}
}
else // xinef: ceil obtained value, it may happen that 10 ticks for 10% damage may not kill owner
damage = uint32(std::ceil(CalculatePct<float, float>(target->GetMaxHealth(), damage)));

// calculate crit chance
bool crit = false;
Expand Down

0 comments on commit f127e58

Please sign in to comment.