[11375] Move holder-wide code from effect loop in immune cast checks.

This commit is contained in:
VladimirMangos 2011-04-17 05:43:06 +04:00
parent 79cd96af8a
commit c6dee6c2d6
2 changed files with 40 additions and 39 deletions

View file

@ -5714,46 +5714,47 @@ SpellCastResult Spell::CheckCasterAuras() const
Unit::SpellAuraHolderMap const& auras = m_caster->GetSpellAuraHolderMap(); Unit::SpellAuraHolderMap const& auras = m_caster->GetSpellAuraHolderMap();
for(Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) for(Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{ {
if (SpellAuraHolder *holder = itr->second) SpellAuraHolder *holder = itr->second;
SpellEntry const * pEntry = holder->GetSpellProto();
if ((GetSpellSchoolMask(pEntry) & school_immune) && !(pEntry->AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE))
continue;
if ((1<<(pEntry->Dispel)) & dispel_immune)
continue;
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{ {
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) Aura *aura = holder->GetAuraByEffectIndex(SpellEffectIndex(i));
if (!aura)
continue;
if (GetSpellMechanicMask(pEntry, 1 << i) & mechanic_immune)
continue;
// Make a second check for spell failed so the right SPELL_FAILED message is returned.
// That is needed when your casting is prevented by multiple states and you are only immune to some of them.
switch(aura->GetModifier()->m_auraname)
{ {
SpellEntry const * pEntry = holder->GetSpellProto(); case SPELL_AURA_MOD_STUN:
if (GetSpellMechanicMask(pEntry, 1 << i) & mechanic_immune) if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED) || !aura->HasMechanic(MECHANIC_STUN))
continue; return SPELL_FAILED_STUNNED;
if ((GetSpellSchoolMask(pEntry) & school_immune) && !(pEntry->AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE)) break;
continue; case SPELL_AURA_MOD_CONFUSE:
if ((1<<(pEntry->Dispel)) & dispel_immune) if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED))
continue; return SPELL_FAILED_CONFUSED;
Aura *aura = holder->GetAuraByEffectIndex(SpellEffectIndex(i)); break;
if (!aura) case SPELL_AURA_MOD_FEAR:
continue; if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED))
// Make a second check for spell failed so the right SPELL_FAILED message is returned. return SPELL_FAILED_FLEEING;
// That is needed when your casting is prevented by multiple states and you are only immune to some of them. break;
switch(aura->GetModifier()->m_auraname) case SPELL_AURA_MOD_SILENCE:
{ case SPELL_AURA_MOD_PACIFY:
case SPELL_AURA_MOD_STUN: case SPELL_AURA_MOD_PACIFY_SILENCE:
if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED) || !aura->HasMechanic(MECHANIC_STUN)) if( m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY)
return SPELL_FAILED_STUNNED; return SPELL_FAILED_PACIFIED;
break; else if ( m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
case SPELL_AURA_MOD_CONFUSE: return SPELL_FAILED_SILENCED;
if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) break;
return SPELL_FAILED_CONFUSED; default: break;
break;
case SPELL_AURA_MOD_FEAR:
if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED))
return SPELL_FAILED_FLEEING;
break;
case SPELL_AURA_MOD_SILENCE:
case SPELL_AURA_MOD_PACIFY:
case SPELL_AURA_MOD_PACIFY_SILENCE:
if( m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY)
return SPELL_FAILED_PACIFIED;
else if ( m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
return SPELL_FAILED_SILENCED;
break;
default: break;
}
} }
} }
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11374" #define REVISION_NR "11375"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__