aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp14
-rw-r--r--src/server/game/Spells/SpellInfo.cpp124
-rw-r--r--src/server/game/Spells/SpellInfo.h1
3 files changed, 61 insertions, 78 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 00287b1f4b7..b276156cf72 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -2528,6 +2528,13 @@ void UnitAura::FillTargetMap(std::unordered_map<Unit*, uint32>& targets, Unit* c
targets.emplace(target, targetPair.second);
}
+ // skip area update if owner is not in world!
+ if (!GetUnitOwner()->IsInWorld())
+ return;
+
+ if (GetUnitOwner()->HasAuraState(AURA_STATE_BANISHED, GetSpellInfo(), caster))
+ return;
+
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
{
if (!HasEffect(spellEffectInfo.EffectIndex))
@@ -2537,13 +2544,6 @@ void UnitAura::FillTargetMap(std::unordered_map<Unit*, uint32>& targets, Unit* c
if (spellEffectInfo.IsEffect(SPELL_EFFECT_APPLY_AURA))
continue;
- // skip area update if owner is not in world!
- if (!GetUnitOwner()->IsInWorld())
- continue;
-
- if (GetUnitOwner()->HasAuraState(AURA_STATE_BANISHED, GetSpellInfo(), caster))
- continue;
-
std::vector<WorldObject*> units;
ConditionContainer* condList = spellEffectInfo.ImplicitTargetConditions.get();
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 0d172cef5e6..5d653dc5a35 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -3608,11 +3608,9 @@ bool SpellInfo::CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInf
continue;
if (!auraSpellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES))
- {
if (uint32 schoolImmunity = immuneInfo->SchoolImmuneMask)
if ((auraSpellInfo->SchoolMask & schoolImmunity) != 0)
return true;
- }
if (uint64 mechanicImmunity = immuneInfo->MechanicImmuneMask)
if ((mechanicImmunity & (UI64LIT(1) << auraSpellInfo->Mechanic)) != 0)
@@ -3625,48 +3623,25 @@ bool SpellInfo::CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInf
bool immuneToAllEffects = true;
for (SpellEffectInfo const& auraSpellEffectInfo : auraSpellInfo->GetEffects())
{
- if (!auraSpellEffectInfo.IsEffect())
+ if (!auraSpellEffectInfo.IsAura())
continue;
- auto spellImmuneItr = immuneInfo->SpellEffectImmune.find(auraSpellEffectInfo.Effect);
- if (spellImmuneItr == immuneInfo->SpellEffectImmune.end())
- {
- immuneToAllEffects = false;
- break;
- }
-
- if (uint32 mechanic = auraSpellEffectInfo.Mechanic)
- {
- if (!(immuneInfo->MechanicImmuneMask & (UI64LIT(1) << mechanic)))
- {
- immuneToAllEffects = false;
- break;
- }
- }
+ if (uint64 mechanicImmunity = immuneInfo->MechanicImmuneMask)
+ if ((mechanicImmunity & (UI64LIT(1) << auraSpellEffectInfo.Mechanic)) != 0)
+ continue;
- if (!auraSpellInfo->HasAttribute(SPELL_ATTR3_ALWAYS_HIT))
+ if (AuraType auraName = auraSpellEffectInfo.ApplyAuraName)
{
- if (AuraType auraName = auraSpellEffectInfo.ApplyAuraName)
- {
- bool isImmuneToAuraEffectApply = false;
- auto auraImmuneItr = immuneInfo->AuraTypeImmune.find(auraName);
- if (auraImmuneItr != immuneInfo->AuraTypeImmune.end())
- isImmuneToAuraEffectApply = true;
-
- if (!isImmuneToAuraEffectApply && !auraSpellInfo->IsPositiveEffect(auraSpellEffectInfo.EffectIndex) && !auraSpellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES))
- {
- if (uint32 applyHarmfulAuraImmunityMask = immuneInfo->ApplyHarmfulAuraImmuneMask)
- if ((auraSpellInfo->GetSchoolMask() & applyHarmfulAuraImmunityMask) != 0)
- isImmuneToAuraEffectApply = true;
- }
+ if (immuneInfo->AuraTypeImmune.find(auraName) != immuneInfo->AuraTypeImmune.end())
+ continue;
- if (!isImmuneToAuraEffectApply)
- {
- immuneToAllEffects = false;
- break;
- }
- }
+ if (!auraSpellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES) && !auraSpellInfo->IsPositiveEffect(auraSpellEffectInfo.EffectIndex))
+ if (uint32 applyHarmfulAuraImmunityMask = immuneInfo->ApplyHarmfulAuraImmuneMask)
+ if ((auraSpellInfo->GetSchoolMask() & applyHarmfulAuraImmunityMask) != 0)
+ continue;
}
+
+ immuneToAllEffects = false;
}
if (immuneToAllEffects)
@@ -3676,6 +3651,41 @@ bool SpellInfo::CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInf
return false;
}
+bool SpellInfo::CanSpellEffectProvideImmunityAgainstAuraEffect(SpellEffectInfo const& immunityEffectInfo, SpellInfo const* auraSpellInfo, SpellEffectInfo const& auraEffectInfo) const
+{
+ SpellEffectInfo::ImmunityInfo const* immuneInfo = immunityEffectInfo.GetImmunityInfo();
+ if (!immuneInfo)
+ return false;
+
+ if (!auraSpellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES))
+ {
+ if (uint32 schoolImmunity = immuneInfo->SchoolImmuneMask)
+ if ((auraSpellInfo->SchoolMask & schoolImmunity) != 0)
+ return true;
+
+ if (uint32 applyHarmfulAuraImmunityMask = immuneInfo->ApplyHarmfulAuraImmuneMask)
+ if ((auraSpellInfo->GetSchoolMask() & applyHarmfulAuraImmunityMask) != 0)
+ return true;
+ }
+
+ if (uint64 mechanicImmunity = immuneInfo->MechanicImmuneMask)
+ {
+ if ((mechanicImmunity & (UI64LIT(1) << auraSpellInfo->Mechanic)) != 0)
+ return true;
+ if ((mechanicImmunity & (UI64LIT(1) << auraEffectInfo.Mechanic)) != 0)
+ return true;
+ }
+
+ if (uint32 dispelImmunity = immuneInfo->DispelImmuneMask)
+ if (auraSpellInfo->Dispel == dispelImmunity)
+ return true;
+
+ if (immuneInfo->AuraTypeImmune.find(auraEffectInfo.ApplyAuraName) != immuneInfo->AuraTypeImmune.end())
+ return true;
+
+ return false;
+}
+
// based on client Spell_C::CancelsAuraEffect
bool SpellInfo::SpellCancelsAuraEffect(AuraEffect const* aurEff) const
{
@@ -3685,40 +3695,12 @@ bool SpellInfo::SpellCancelsAuraEffect(AuraEffect const* aurEff) const
if (aurEff->GetSpellInfo()->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
return false;
- for (SpellEffectInfo const& effect : GetEffects())
- {
- if (!effect.IsEffect(SPELL_EFFECT_APPLY_AURA))
- continue;
-
- uint32 const miscValue = static_cast<uint32>(effect.MiscValue);
- switch (effect.ApplyAuraName)
- {
- case SPELL_AURA_STATE_IMMUNITY:
- if (miscValue != aurEff->GetAuraType())
- continue;
- break;
- case SPELL_AURA_SCHOOL_IMMUNITY:
- case SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL:
- if (aurEff->GetSpellInfo()->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES) || !(aurEff->GetSpellInfo()->SchoolMask & miscValue))
- continue;
- break;
- case SPELL_AURA_DISPEL_IMMUNITY:
- if (miscValue != aurEff->GetSpellInfo()->Dispel)
- continue;
- break;
- case SPELL_AURA_MECHANIC_IMMUNITY:
- if (miscValue != aurEff->GetSpellInfo()->Mechanic)
- {
- if (miscValue != aurEff->GetSpellEffectInfo().Mechanic)
- continue;
- }
- break;
- default:
- continue;
- }
+ if (aurEff->GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::NoImmunity))
+ return false;
- return true;
- }
+ for (SpellEffectInfo const& effect : GetEffects())
+ if (CanSpellEffectProvideImmunityAgainstAuraEffect(effect, aurEff->GetSpellInfo(), aurEff->GetSpellEffectInfo()))
+ return true;
return false;
}
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index c66da5ccad4..dea9d265b8e 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -585,6 +585,7 @@ class TC_GAME_API SpellInfo
// spell immunities
void ApplyAllSpellImmunitiesTo(Unit* target, SpellEffectInfo const& spellEffectInfo, bool apply) const;
bool CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInfo) const;
+ bool CanSpellEffectProvideImmunityAgainstAuraEffect(SpellEffectInfo const& immunityEffectInfo, SpellInfo const* auraSpellInfo, SpellEffectInfo const& auraEffectInfo) const;
bool SpellCancelsAuraEffect(AuraEffect const* aurEff) const;
uint64 GetAllowedMechanicMask() const;