[11505] Clarify check cases "health drops below" in spell proc code.

Avoid repeating triggering at health exactly at bound and 0 damage apply.

Thank you to boxa for pointing to problem.
This commit is contained in:
VladimirMangos 2011-05-18 18:29:36 +04:00
parent 61f82dc5fc
commit f3e3e53634
2 changed files with 10 additions and 8 deletions

View file

@ -2848,8 +2848,8 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d
//case 44819: break; // Hate Monster (Spar Buddy) (>30% Health)
//case 44820: break; // Hate Monster (Spar) (<30%)
case 45057: // Evasive Maneuvers (Commendation of Kael`thas trinket)
// reduce you below $s1% health
if (GetHealth() - damage > GetMaxHealth() * triggerAmount / 100)
// reduce you below $s1% health (in fact in this specific case can proc from any attack while health in result less $s1%)
if (int32(GetHealth()) - int32(damage) >= GetMaxHealth() * triggerAmount / 100)
return SPELL_AURA_PROC_FAILED;
break;
//case 45903: break: // Offensive State
@ -2913,8 +2913,8 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d
case 64568: // Blood Reserve
{
// When your health drops below 35% ....
uint32 health35 = uint32(GetMaxHealth() * 0.35);
if (GetHealth() - damage > health35 || GetHealth() < health35)
int32 health35 = int32(GetMaxHealth() * 35 / 100);
if (int32(GetHealth()) - int32(damage) >= health35 || int32(GetHealth()) < health35)
return SPELL_AURA_PROC_FAILED;
trigger_spell_id = 64569;
@ -3050,7 +3050,8 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d
else if (auraSpellInfo->Id == 28845)
{
// When your health drops below 20% ....
if (GetHealth() - damage > GetMaxHealth() / 5 || GetHealth() < GetMaxHealth() / 5)
int32 health20 = int32(GetMaxHealth()) / 5;
if (int32(GetHealth()) - int32(damage) >= health20 || int32(GetHealth()) < health20)
return SPELL_AURA_PROC_FAILED;
}
// Decimation
@ -3321,8 +3322,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d
// Nature's Guardian
else if (auraSpellInfo->SpellIconID == 2013)
{
// Check health condition - should drop to less 30% (damage deal after this!)
if (!(10*(int32(GetHealth() - damage)) < int32(3 * GetMaxHealth())))
// Check health condition - should drop to less 30% (trigger at any attack with result health less 30%, independent original health state)
int32 health30 = int32(GetMaxHealth()) * 3 / 10;
if (int32(GetHealth()) - int32(damage) >= health30)
return SPELL_AURA_PROC_FAILED;
if(pVictim && pVictim->isAlive())