From a4d61a69882f63b50aeb6ab23f4e3eaf53fa5d6f Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 15 Oct 2009 20:44:30 +0400 Subject: [PATCH] [8649] Implement SPELL_AURA_MECHANIC_IMMUNITY_MASK (147) and related cleanups. * Always use machanic masks in form (1 << (mech-1)), fix all cases. * Imppement SPELL_AURA_MECHANIC_IMMUNITY_MASK (mostly boss/elite spells). Note: db stored mechannic masks already stored in proper format so not affected. --- src/game/SharedDefines.h | 31 ++++++++---- src/game/Spell.cpp | 34 +++++++------ src/game/SpellAuraDefines.h | 2 +- src/game/SpellAuras.cpp | 38 ++++++--------- src/game/SpellAuras.h | 1 + src/game/SpellEffects.cpp | 21 +------- src/game/SpellMgr.cpp | 42 ++++++++++------ src/game/SpellMgr.h | 8 +-- src/game/Unit.cpp | 97 ++++++++++++++++++++++++++----------- src/game/Unit.h | 1 + src/shared/revision_nr.h | 2 +- 11 files changed, 158 insertions(+), 119 deletions(-) diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 4acc06d20..37c38c742 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -956,18 +956,31 @@ enum Mechanics // Used for spell 42292 Immune Movement Impairment and Loss of Control (0x49967da6) #define IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK ( \ - (1<EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_IMMUNITY) + if (m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_IMMUNITY) school_immune |= uint32(m_spellInfo->EffectMiscValue[i]); - else if(m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MECHANIC_IMMUNITY) - mechanic_immune |= 1 << uint32(m_spellInfo->EffectMiscValue[i]); - else if(m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_DISPEL_IMMUNITY) + else if (m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MECHANIC_IMMUNITY) + mechanic_immune |= 1 << uint32(m_spellInfo->EffectMiscValue[i]-1); + else if (m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MECHANIC_IMMUNITY_MASK) + mechanic_immune |= uint32(m_spellInfo->EffectMiscValue[i]); + else if (m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_DISPEL_IMMUNITY) dispel_immune |= GetDispellMask(DispelType(m_spellInfo->EffectMiscValue[i])); } // immune movement impairment and loss of control - if(m_spellInfo->Id == 42292) + if (m_spellInfo->Id == 42292) mechanic_immune = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; } @@ -4889,33 +4891,33 @@ SpellCastResult Spell::CheckCasterAuras() const SpellCastResult prevented_reason = SPELL_CAST_OK; // Have to check if there is a stun aura. Otherwise will have problems with ghost aura apply while logging out uint32 unitflag = m_caster->GetUInt32Value(UNIT_FIELD_FLAGS); // Get unit state - if(unitflag & UNIT_FLAG_STUNNED && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED)) + if (unitflag & UNIT_FLAG_STUNNED && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED)) prevented_reason = SPELL_FAILED_STUNNED; - else if(unitflag & UNIT_FLAG_CONFUSED && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) + else if (unitflag & UNIT_FLAG_CONFUSED && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) prevented_reason = SPELL_FAILED_CONFUSED; - else if(unitflag & UNIT_FLAG_FLEEING && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) + else if (unitflag & UNIT_FLAG_FLEEING && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) prevented_reason = SPELL_FAILED_FLEEING; - else if(unitflag & UNIT_FLAG_SILENCED && m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) + else if (unitflag & UNIT_FLAG_SILENCED && m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) prevented_reason = SPELL_FAILED_SILENCED; - else if(unitflag & UNIT_FLAG_PACIFIED && m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY) + else if (unitflag & UNIT_FLAG_PACIFIED && m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY) prevented_reason = SPELL_FAILED_PACIFIED; // Attr must make flag drop spell totally immune from all effects - if(prevented_reason != SPELL_CAST_OK) + if (prevented_reason != SPELL_CAST_OK) { - if(school_immune || mechanic_immune || dispel_immune) + if (school_immune || mechanic_immune || dispel_immune) { //Checking auras is needed now, because you are prevented by some state but the spell grants immunity. Unit::AuraMap const& auras = m_caster->GetAuras(); for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { - if(itr->second) + if (itr->second) { - if( GetSpellMechanicMask(itr->second->GetSpellProto(), itr->second->GetEffIndex()) & mechanic_immune ) + if (GetSpellMechanicMask(itr->second->GetSpellProto(), itr->second->GetEffIndex()) & mechanic_immune) continue; - if( GetSpellSchoolMask(itr->second->GetSpellProto()) & school_immune ) + if (GetSpellSchoolMask(itr->second->GetSpellProto()) & school_immune) continue; - if( (1<<(itr->second->GetSpellProto()->Dispel)) & dispel_immune) + if ((1<<(itr->second->GetSpellProto()->Dispel)) & dispel_immune) continue; // Make a second check for spell failed so the right SPELL_FAILED message is returned. diff --git a/src/game/SpellAuraDefines.h b/src/game/SpellAuraDefines.h index 10b4fd3e5..2700d1d2f 100644 --- a/src/game/SpellAuraDefines.h +++ b/src/game/SpellAuraDefines.h @@ -189,7 +189,7 @@ enum AuraType SPELL_AURA_SAFE_FALL = 144, SPELL_AURA_MOD_PET_TALENT_POINTS = 145, SPELL_AURA_ALLOW_TAME_PET_TYPE = 146, - SPELL_AURA_ADD_CREATURE_IMMUNITY = 147, + SPELL_AURA_MECHANIC_IMMUNITY_MASK = 147, SPELL_AURA_RETAIN_COMBO_POINTS = 148, SPELL_AURA_REDUCE_PUSHBACK = 149, // Reduce Pushback SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT = 150, diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index a142e2423..43f9e5a5c 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -197,7 +197,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &Aura::HandleAuraSafeFall, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes &Aura::HandleAuraModPetTalentsPoints, //145 SPELL_AURA_MOD_PET_TALENT_POINTS &Aura::HandleNoImmediateEffect, //146 SPELL_AURA_ALLOW_TAME_PET_TYPE - &Aura::HandleNULL, //147 SPELL_AURA_ADD_CREATURE_IMMUNITY + &Aura::HandleModMechanicImmunityMask, //147 SPELL_AURA_ADD_CREATURE_IMMUNITY implemented in Unit::IsImmunedToSpell and Unit::IsImmunedToSpellEffect (check part) &Aura::HandleAuraRetainComboPoints, //148 SPELL_AURA_RETAIN_COMBO_POINTS &Aura::HandleNoImmediateEffect, //149 SPELL_AURA_REDUCE_PUSHBACK &Aura::HandleShieldBlockValue, //150 SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT @@ -2887,7 +2887,8 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real) // If spell that caused this aura has Croud Control or Daze effect if((aurMechMask & MECHANIC_NOT_REMOVED_BY_SHAPESHIFT) || // some Daze spells have these parameters instead of MECHANIC_DAZE (skip snare spells) - aurSpellInfo->SpellIconID == 15 && aurSpellInfo->Dispel == 0 && (aurMechMask & (1 << MECHANIC_SNARE))==0) + aurSpellInfo->SpellIconID == 15 && aurSpellInfo->Dispel == 0 && + (aurMechMask & (1 << (MECHANIC_SNARE-1)))==0) { ++iter; continue; @@ -4171,32 +4172,13 @@ void Aura::HandleModMechanicImmunity(bool apply, bool /*Real*/) if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) { - uint32 mechanic = 1 << misc; + uint32 mechanic = 1 << (misc-1); //immune movement impairment and loss of control if(GetId()==42292 || GetId()==59752) mechanic=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; - Unit::AuraMap& Auras = m_target->GetAuras(); - for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) - { - next = iter; - ++next; - SpellEntry const *spell = iter->second->GetSpellProto(); - if (!( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) && // spells unaffected by invulnerability - spell->Id != GetId()) - { - //check for mechanic mask - if(GetSpellMechanicMask(spell, iter->second->GetEffIndex()) & mechanic) - { - m_target->RemoveAurasDueToSpell(spell->Id); - if(Auras.empty()) - break; - else - next = Auras.begin(); - } - } - } + m_target->RemoveAurasAtMechanicImmunity(mechanic,GetId()); } m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,misc,apply); @@ -4224,6 +4206,16 @@ void Aura::HandleModMechanicImmunity(bool apply, bool /*Real*/) } } +void Aura::HandleModMechanicImmunityMask(bool apply, bool /*Real*/) +{ + uint32 mechanic = m_modifier.m_miscvalue; + + if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) + m_target->RemoveAurasAtMechanicImmunity(mechanic,GetId()); + + // check implemented in Unit::IsImmunedToSpell and Unit::IsImmunedToSpellEffect +} + //this method is called whenever we add / remove aura which gives m_target some imunity to some spell effect void Aura::HandleAuraModEffectImmunity(bool apply, bool /*Real*/) { diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index 397338227..0695271e7 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -159,6 +159,7 @@ class MANGOS_DLL_SPEC Aura void HandleFarSight(bool Apply, bool Real); void HandleModPossessPet(bool Apply, bool Real); void HandleModMechanicImmunity(bool Apply, bool Real); + void HandleModMechanicImmunityMask(bool Apply, bool Real); void HandleAuraModSkill(bool Apply, bool Real); void HandleModDamagePercentDone(bool Apply, bool Real); void HandleModPercentStat(bool Apply, bool Real); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 96b1e6252..db09186e1 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4989,26 +4989,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) if(!unitTarget) return; // Removes snares and roots. - uint32 mechanic_mask = (1<GetAuras(); - for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) - { - next = iter; - ++next; - Aura *aur = iter->second; - if (!aur->IsPositive()) //only remove negative spells - { - // check for mechanic mask - if(GetSpellMechanicMask(aur->GetSpellProto(), aur->GetEffIndex()) & mechanic_mask) - { - unitTarget->RemoveAurasDueToSpell(aur->GetId()); - if(Auras.empty()) - break; - else - next = Auras.begin(); - } - } - } + unitTarget->RemoveAurasAtMechanicImmunity(IMMUNE_TO_ROOT_AND_SNARE_MASK,30918,true); break; } // Flame Crash diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index a91ca0302..7fc30c697 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -3309,23 +3309,33 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto // Get by mechanic uint32 mechanic = GetAllSpellMechanicMask(spellproto); - if (mechanic == MECHANIC_NONE) return DIMINISHING_NONE; - if (mechanic & ((1<Mechanic) - mask |= 1<Mechanic; + mask |= 1 << (spellInfo->Mechanic - 1); if (spellInfo->EffectMechanic[effect]) - mask |= 1<EffectMechanic[effect]; + mask |= 1 << (spellInfo->EffectMechanic[effect] - 1); return mask; } @@ -398,10 +398,10 @@ inline uint32 GetAllSpellMechanicMask(SpellEntry const* spellInfo) { uint32 mask = 0; if (spellInfo->Mechanic) - mask |= 1<Mechanic; + mask |= 1 << (spellInfo->Mechanic - 1); for (int i=0; i< 3; ++i) if (spellInfo->EffectMechanic[i]) - mask |= 1<EffectMechanic[i]; + mask |= 1 << (spellInfo->EffectMechanic[i]-1); return mask; } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 23c0cac95..7e6f7f900 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -4078,10 +4078,13 @@ void Unit::RemoveArenaAuras(bool onleave) // used to remove positive visible auras in arenas for(AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();) { - if ( !(iter->second->GetSpellProto()->AttributesEx4 & (1<<21)) // don't remove stances, shadowform, pally/hunter auras - && !iter->second->IsPassive() // don't remove passive auras - && (!(iter->second->GetSpellProto()->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) || !(iter->second->GetSpellProto()->Attributes & SPELL_ATTR_UNK8)) // not unaffected by invulnerability auras or not having that unknown flag (that seemed the most probable) - && (iter->second->IsPositive() != onleave)) // remove positive buffs on enter, negative buffs on leave + if (!(iter->second->GetSpellProto()->AttributesEx4 & SPELL_ATTR_EX4_UNK21) && + // don't remove stances, shadowform, pally/hunter auras + !iter->second->IsPassive() && // don't remove passive auras + (!(iter->second->GetSpellProto()->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) || + !(iter->second->GetSpellProto()->Attributes & SPELL_ATTR_UNK8)) && + // not unaffected by invulnerability auras or not having that unknown flag (that seemed the most probable) + (iter->second->IsPositive() != onleave)) // remove positive buffs on enter, negative buffs on leave RemoveAura(iter); else ++iter; @@ -5191,7 +5194,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT|PROC_EX_CRITICAL_HIT)) || this == pVictim) return false; // Need stun or root mechanic - if (!(GetAllSpellMechanicMask(procSpell) & ((1<Id) @@ -6355,7 +6358,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT|PROC_EX_CRITICAL_HIT)) || this == pVictim) return false; // Need snare or root mechanic - if (!(GetAllSpellMechanicMask(procSpell) & ((1<GetAurasByType(SPELL_AURA_MOD_HEALING); for(AuraList::const_iterator i = mDamageTaken.begin();i != mDamageTaken.end(); ++i) - if(((*i)->GetModifier()->m_miscvalue & schoolMask) != 0) + if ((*i)->GetModifier()->m_miscvalue & schoolMask) AdvertisedBenefit += (*i)->GetModifier()->m_amount; + return AdvertisedBenefit; } @@ -8974,13 +8978,13 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask) //If m_immuneToSchool type contain this school type, IMMUNE damage. SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) - if(itr->type & shoolMask) + if (itr->type & shoolMask) return true; //If m_immuneToDamage type contain magic, IMMUNE damage. SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE]; for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr) - if(itr->type & shoolMask) + if (itr->type & shoolMask) return true; return false; @@ -8996,26 +9000,30 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo) SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL]; for(SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr) - if(itr->type == spellInfo->Dispel) + if (itr->type == spellInfo->Dispel) return true; - if( !(spellInfo->AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE) && // unaffected by school immunity + if (!(spellInfo->AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE) && // unaffected by school immunity !(spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) // can remove immune (by dispell or immune it) { SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; for(SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) - if( !(IsPositiveSpell(itr->spellId) && IsPositiveSpell(spellInfo->Id)) && - (itr->type & GetSpellSchoolMask(spellInfo)) ) + if (!(IsPositiveSpell(itr->spellId) && IsPositiveSpell(spellInfo->Id)) && + (itr->type & GetSpellSchoolMask(spellInfo))) return true; } - SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; - for(SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) + if(uint32 mechanic = spellInfo->Mechanic) { - if(itr->type == spellInfo->Mechanic) - { - return true; - } + SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; + for(SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) + if (itr->type == mechanic) + return true; + + AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MECHANIC_IMMUNITY_MASK); + for(AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) + if ((*iter)->GetModifier()->m_miscvalue & (1 << (mechanic-1))) + return true; } return false; @@ -9027,14 +9035,19 @@ bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) con uint32 effect = spellInfo->Effect[index]; SpellImmuneList const& effectList = m_spellImmune[IMMUNITY_EFFECT]; for (SpellImmuneList::const_iterator itr = effectList.begin(); itr != effectList.end(); ++itr) - if(itr->type == effect) + if (itr->type == effect) return true; if(uint32 mechanic = spellInfo->EffectMechanic[index]) { SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) - if(itr->type == mechanic) + if (itr->type == mechanic) + return true; + + AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MECHANIC_IMMUNITY_MASK); + for(AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) + if ((*iter)->GetModifier()->m_miscvalue & (1 << (mechanic-1))) return true; } @@ -9042,8 +9055,9 @@ bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) con { SpellImmuneList const& list = m_spellImmune[IMMUNITY_STATE]; for(SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr) - if(itr->type == aura) + if (itr->type == aura) return true; + // Check for immune to application of harmful magical effects AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL); for(AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) @@ -9058,13 +9072,13 @@ bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) con bool Unit::IsDamageToThreatSpell(SpellEntry const * spellInfo) const { - if(!spellInfo) + if (!spellInfo) return false; uint32 family = spellInfo->SpellFamilyName; uint64 flags = spellInfo->SpellFamilyFlags; - if((family == 5 && flags == 256) || //Searing Pain + if ((family == 5 && flags == 256) || //Searing Pain (family == 6 && flags == 8192) || //Mind Blast (family == 11 && flags == 1048576)) //Earth Shock return true; @@ -9074,10 +9088,10 @@ bool Unit::IsDamageToThreatSpell(SpellEntry const * spellInfo) const uint32 Unit::MeleeDamageBonus(Unit *pVictim, uint32 pdamage,WeaponAttackType attType, SpellEntry const *spellProto, DamageEffectType damagetype, uint32 stack) { - if(!pVictim) + if (!pVictim) return pdamage; - if(pdamage == 0) + if (pdamage == 0) return pdamage; // differentiate for weapon damage based spells @@ -9089,7 +9103,7 @@ uint32 Unit::MeleeDamageBonus(Unit *pVictim, uint32 pdamage,WeaponAttackType att // Shred also have bonus as MECHANIC_BLEED damages if (spellProto && spellProto->SpellFamilyName==SPELLFAMILY_DRUID && spellProto->SpellFamilyFlags & UI64LIT(0x00008000)) - mechanicMask |= (1 << MECHANIC_BLEED); + mechanicMask |= (1 << (MECHANIC_BLEED-1)); // FLAT damage bonus auras @@ -12416,6 +12430,31 @@ void Unit::RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo) } } +void Unit::RemoveAurasAtMechanicImmunity(uint32 mechMask, uint32 exceptSpellId, bool non_positive /*= false*/) +{ + Unit::AuraMap& auras = GetAuras(); + for(Unit::AuraMap::iterator iter = auras.begin(); iter != auras.end();) + { + SpellEntry const *spell = iter->second->GetSpellProto(); + if (spell->Id == exceptSpellId) + ++iter; + else if (non_positive && iter->second->IsPositive()) + ++iter; + else if (spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) + ++iter; + else if (GetSpellMechanicMask(spell, iter->second->GetEffIndex()) & mechMask) + { + RemoveAurasDueToSpell(spell->Id); + if(auras.empty()) + break; + else + iter = auras.begin(); + } + else + ++iter; + } +} + void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) { if(newPhaseMask==GetPhaseMask()) diff --git a/src/game/Unit.h b/src/game/Unit.h index 72017fc1b..b1787d6f7 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1214,6 +1214,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void RemoveAurasDueToSpellByCancel(uint32 spellId); void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo); void RemoveNotOwnSingleTargetAuras(uint32 newPhase = 0x0); + void RemoveAurasAtMechanicImmunity(uint32 mechMask, uint32 exceptSpellId, bool non_positive = false); void RemoveSpellsCausingAura(AuraType auraType); void RemoveRankAurasDueToSpell(uint32 spellId); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c221ea49d..15117dd98 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8648" + #define REVISION_NR "8649" #endif // __REVISION_NR_H__