fix(core/scripting) Calculate percent-based damage before ModifyPeriodicDamageAurasTick hook (#17387)

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

Co-authored-by: KJack <kjack@electricnightowl.com>
This commit is contained in:
KJack
2023-10-08 14:38:07 -04:00
committed by GitHub
parent 2255f492b5
commit f127e583aa

View File

@@ -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());
@@ -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;