mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[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:
parent
e3e39b5607
commit
83079e0b81
4 changed files with 24 additions and 53 deletions
|
|
@ -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)
|
void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
|
||||||
{
|
{
|
||||||
if (!pVictim->isAlive() || pVictim->IsTaxiFlying() || (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()))
|
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)
|
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)
|
// remove affects from attacker at any non-DoT damage (including 0 damage)
|
||||||
if( damagetype != DOT)
|
if( damagetype != DOT)
|
||||||
{
|
{
|
||||||
|
|
@ -492,11 +475,6 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
||||||
|
|
||||||
return 0;
|
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/
|
// no xp,health if type 8 /critters/
|
||||||
if (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->GetCreatureType() == CREATURE_TYPE_CRITTER)
|
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);
|
((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(damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE)
|
||||||
{
|
{
|
||||||
if (!spellProto || !(spellProto->AuraInterruptFlags&AURA_INTERRUPT_FLAG_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;
|
next = i; ++next;
|
||||||
if (spellProto && spellProto->Id == se->Id) // Not drop auras added by self
|
if (spellProto && spellProto->Id == se->Id) // Not drop auras added by self
|
||||||
continue;
|
continue;
|
||||||
if( se->AuraInterruptFlags & AURA_INTERRUPT_FLAG_DAMAGE )
|
if (!se->procFlags && (se->AuraInterruptFlags & AURA_INTERRUPT_FLAG_DAMAGE))
|
||||||
{
|
{
|
||||||
bool remove = true;
|
pVictim->RemoveAurasDueToSpell(i->second->GetId());
|
||||||
if (se->procFlags & (1<<3))
|
next = vAuras.begin();
|
||||||
{
|
|
||||||
if (!roll_chance_i(se->procChance))
|
|
||||||
remove = false;
|
|
||||||
}
|
|
||||||
if (remove)
|
|
||||||
{
|
|
||||||
pVictim->RemoveAurasDueToSpell(i->second->GetId());
|
|
||||||
next = vAuras.begin();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1433,8 +1433,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
bool isFrozen() const;
|
bool isFrozen() const;
|
||||||
bool IsIgnoreUnitState(SpellEntry const *spell, IgnoreUnitState ignoreState);
|
bool IsIgnoreUnitState(SpellEntry const *spell, IgnoreUnitState ignoreState);
|
||||||
|
|
||||||
void RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage);
|
|
||||||
|
|
||||||
bool isTargetableForAttack(bool inversAlive = false) const;
|
bool isTargetableForAttack(bool inversAlive = false) const;
|
||||||
bool isPassiveToHostile() { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE); }
|
bool isPassiveToHostile() { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE); }
|
||||||
|
|
||||||
|
|
@ -1852,6 +1850,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
SpellAuraProcResult HandleSpellMagnetAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
|
SpellAuraProcResult HandleSpellMagnetAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
|
||||||
SpellAuraProcResult HandleManaShieldAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
|
SpellAuraProcResult HandleManaShieldAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
|
||||||
SpellAuraProcResult HandleModResistanceAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
|
SpellAuraProcResult HandleModResistanceAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
|
||||||
|
SpellAuraProcResult HandleRemoveByDamageChanceProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
|
||||||
SpellAuraProcResult HandleNULLProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* /*triggeredByAura*/, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/)
|
SpellAuraProcResult HandleNULLProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* /*triggeredByAura*/, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/)
|
||||||
{
|
{
|
||||||
// no proc handler for this aura type
|
// no proc handler for this aura type
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ pAuraProcHandler AuraProcHandler[TOTAL_AURAS]=
|
||||||
&Unit::HandleDummyAuraProc, // 4 SPELL_AURA_DUMMY
|
&Unit::HandleDummyAuraProc, // 4 SPELL_AURA_DUMMY
|
||||||
&Unit::HandleNULLProc, // 5 SPELL_AURA_MOD_CONFUSE
|
&Unit::HandleNULLProc, // 5 SPELL_AURA_MOD_CONFUSE
|
||||||
&Unit::HandleNULLProc, // 6 SPELL_AURA_MOD_CHARM
|
&Unit::HandleNULLProc, // 6 SPELL_AURA_MOD_CHARM
|
||||||
&Unit::HandleNULLProc, // 7 SPELL_AURA_MOD_FEAR
|
&Unit::HandleRemoveByDamageChanceProc, // 7 SPELL_AURA_MOD_FEAR
|
||||||
&Unit::HandleNULLProc, // 8 SPELL_AURA_PERIODIC_HEAL
|
&Unit::HandleNULLProc, // 8 SPELL_AURA_PERIODIC_HEAL
|
||||||
&Unit::HandleNULLProc, // 9 SPELL_AURA_MOD_ATTACKSPEED
|
&Unit::HandleNULLProc, // 9 SPELL_AURA_MOD_ATTACKSPEED
|
||||||
&Unit::HandleNULLProc, // 10 SPELL_AURA_MOD_THREAT
|
&Unit::HandleNULLProc, // 10 SPELL_AURA_MOD_THREAT
|
||||||
|
|
@ -58,7 +58,7 @@ pAuraProcHandler AuraProcHandler[TOTAL_AURAS]=
|
||||||
&Unit::HandleNULLProc, // 23 SPELL_AURA_PERIODIC_TRIGGER_SPELL
|
&Unit::HandleNULLProc, // 23 SPELL_AURA_PERIODIC_TRIGGER_SPELL
|
||||||
&Unit::HandleNULLProc, // 24 SPELL_AURA_PERIODIC_ENERGIZE
|
&Unit::HandleNULLProc, // 24 SPELL_AURA_PERIODIC_ENERGIZE
|
||||||
&Unit::HandleNULLProc, // 25 SPELL_AURA_MOD_PACIFY
|
&Unit::HandleNULLProc, // 25 SPELL_AURA_MOD_PACIFY
|
||||||
&Unit::HandleNULLProc, // 26 SPELL_AURA_MOD_ROOT
|
&Unit::HandleRemoveByDamageChanceProc, // 26 SPELL_AURA_MOD_ROOT
|
||||||
&Unit::HandleNULLProc, // 27 SPELL_AURA_MOD_SILENCE
|
&Unit::HandleNULLProc, // 27 SPELL_AURA_MOD_SILENCE
|
||||||
&Unit::HandleNULLProc, // 28 SPELL_AURA_REFLECT_SPELLS
|
&Unit::HandleNULLProc, // 28 SPELL_AURA_REFLECT_SPELLS
|
||||||
&Unit::HandleNULLProc, // 29 SPELL_AURA_MOD_STAT
|
&Unit::HandleNULLProc, // 29 SPELL_AURA_MOD_STAT
|
||||||
|
|
@ -92,7 +92,7 @@ pAuraProcHandler AuraProcHandler[TOTAL_AURAS]=
|
||||||
&Unit::HandleSpellCritChanceAuraProc, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE
|
&Unit::HandleSpellCritChanceAuraProc, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE
|
||||||
&Unit::HandleNULLProc, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED
|
&Unit::HandleNULLProc, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED
|
||||||
&Unit::HandleNULLProc, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE
|
&Unit::HandleNULLProc, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE
|
||||||
&Unit::HandleNULLProc, // 60 SPELL_AURA_MOD_PACIFY_SILENCE
|
&Unit::HandleRemoveByDamageChanceProc, // 60 SPELL_AURA_MOD_PACIFY_SILENCE
|
||||||
&Unit::HandleNULLProc, // 61 SPELL_AURA_MOD_SCALE
|
&Unit::HandleNULLProc, // 61 SPELL_AURA_MOD_SCALE
|
||||||
&Unit::HandleNULLProc, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL
|
&Unit::HandleNULLProc, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL
|
||||||
&Unit::HandleNULLProc, // 63 unused (3.0.8a-3.2.2a) old SPELL_AURA_PERIODIC_MANA_FUNNEL
|
&Unit::HandleNULLProc, // 63 unused (3.0.8a-3.2.2a) old SPELL_AURA_PERIODIC_MANA_FUNNEL
|
||||||
|
|
@ -4059,3 +4059,19 @@ SpellAuraProcResult Unit::HandleModResistanceAuraProc(Unit* /*pVictim*/, uint32
|
||||||
|
|
||||||
return SPELL_AURA_PROC_OK;
|
return SPELL_AURA_PROC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SpellAuraProcResult Unit::HandleRemoveByDamageChanceProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
|
||||||
|
{
|
||||||
|
// 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))
|
||||||
|
{
|
||||||
|
triggeredByAura->SetInUse(true);
|
||||||
|
RemoveAurasByCasterSpell(triggeredByAura->GetId(), triggeredByAura->GetCasterGuid());
|
||||||
|
triggeredByAura->SetInUse(false);
|
||||||
|
return SPELL_AURA_PROC_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SPELL_AURA_PROC_FAILED;
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11777"
|
#define REVISION_NR "11778"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue