[11778] Implement removal of spells that don't have appropriate SpellAuraInterruptFlags using proc system

Signed-off-by: Laise <fenrisse@gmail.com>
This commit is contained in:
Schmoozerd 2011-08-10 16:05:54 +03:00 committed by Laise
parent e3e39b5607
commit 83079e0b81
4 changed files with 24 additions and 53 deletions

View file

@ -420,19 +420,6 @@ void Unit::RemoveSpellsCausingAura(AuraType auraType, SpellAuraHolder* except)
}
}
/* Called by DealDamage for auras that have a chance to be dispelled on damage taken. */
void Unit::RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage)
{
if(!HasAuraType(auraType))
return;
// The chance to dispel an aura depends on the damage taken with respect to the casters level.
uint32 max_dmg = getLevel() > 8 ? 25 * getLevel() - 150 : 50;
float chance = float(damage) / max_dmg * 100.0f;
if (roll_chance_f(chance))
RemoveSpellsCausingAura(auraType);
}
void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
{
if (!pVictim->isAlive() || pVictim->IsTaxiFlying() || (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()))
@ -467,10 +454,6 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss)
{
// remove affects from victim (including from 0 damage and DoTs)
if(pVictim != this)
pVictim->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
// remove affects from attacker at any non-DoT damage (including 0 damage)
if( damagetype != DOT)
{
@ -492,11 +475,6 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
return 0;
}
if (!spellProto || !IsSpellHaveAura(spellProto,SPELL_AURA_MOD_FEAR))
pVictim->RemoveSpellbyDamageTaken(SPELL_AURA_MOD_FEAR, damage);
// root type spells do not dispel the root effect
if (!spellProto || !(spellProto->Mechanic == MECHANIC_ROOT || IsSpellHaveAura(spellProto,SPELL_AURA_MOD_ROOT)))
pVictim->RemoveSpellbyDamageTaken(SPELL_AURA_MOD_ROOT, damage);
// no xp,health if type 8 /critters/
if (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->GetCreatureType() == CREATURE_TYPE_CRITTER)
@ -871,19 +849,6 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
((Creature*)pVictim)->AI()->AttackedBy(this);
}
// polymorphed, hex and other negative transformed cases
uint32 morphSpell = pVictim->getTransForm();
if (morphSpell && !IsPositiveSpell(morphSpell))
{
if (SpellEntry const* morphEntry = sSpellStore.LookupEntry(morphSpell))
{
if (IsSpellHaveAura(morphEntry, SPELL_AURA_MOD_CONFUSE))
pVictim->RemoveAurasDueToSpell(morphSpell);
else if (IsSpellHaveAura(morphEntry, SPELL_AURA_MOD_PACIFY_SILENCE))
pVictim->RemoveSpellbyDamageTaken(SPELL_AURA_MOD_PACIFY_SILENCE, damage);
}
}
if(damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE)
{
if (!spellProto || !(spellProto->AuraInterruptFlags&AURA_INTERRUPT_FLAG_DIRECT_DAMAGE))
@ -929,19 +894,10 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
next = i; ++next;
if (spellProto && spellProto->Id == se->Id) // Not drop auras added by self
continue;
if( se->AuraInterruptFlags & AURA_INTERRUPT_FLAG_DAMAGE )
if (!se->procFlags && (se->AuraInterruptFlags & AURA_INTERRUPT_FLAG_DAMAGE))
{
bool remove = true;
if (se->procFlags & (1<<3))
{
if (!roll_chance_i(se->procChance))
remove = false;
}
if (remove)
{
pVictim->RemoveAurasDueToSpell(i->second->GetId());
next = vAuras.begin();
}
pVictim->RemoveAurasDueToSpell(i->second->GetId());
next = vAuras.begin();
}
}