mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/Spells: Fixed spell with SPELL_AURA_MECHANIC_IMMUNITY_MASK failing to cast if they were supposed to purge effect they are granting immunity to (CreatureImmunities was not checked)
(cherry picked from commit e1e4aa7980)
This commit is contained in:
@@ -2529,6 +2529,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))
|
||||
@@ -2538,13 +2545,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();
|
||||
|
||||
|
||||
@@ -3581,11 +3581,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)
|
||||
@@ -3598,48 +3596,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())
|
||||
if (uint64 mechanicImmunity = immuneInfo->MechanicImmuneMask)
|
||||
if ((mechanicImmunity & (UI64LIT(1) << auraSpellEffectInfo.Mechanic)) != 0)
|
||||
continue;
|
||||
|
||||
if (AuraType auraName = auraSpellEffectInfo.ApplyAuraName)
|
||||
{
|
||||
immuneToAllEffects = false;
|
||||
break;
|
||||
if (immuneInfo->AuraTypeImmune.find(auraName) != immuneInfo->AuraTypeImmune.end())
|
||||
continue;
|
||||
|
||||
if (!auraSpellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES) && !auraSpellInfo->IsPositiveEffect(auraSpellEffectInfo.EffectIndex))
|
||||
if (uint32 applyHarmfulAuraImmunityMask = immuneInfo->ApplyHarmfulAuraImmuneMask)
|
||||
if ((auraSpellInfo->GetSchoolMask() & applyHarmfulAuraImmunityMask) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (uint32 mechanic = auraSpellEffectInfo.Mechanic)
|
||||
{
|
||||
if (!(immuneInfo->MechanicImmuneMask & (UI64LIT(1) << mechanic)))
|
||||
{
|
||||
immuneToAllEffects = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!auraSpellInfo->HasAttribute(SPELL_ATTR3_ALWAYS_HIT))
|
||||
{
|
||||
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 (!isImmuneToAuraEffectApply)
|
||||
{
|
||||
immuneToAllEffects = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
immuneToAllEffects = false;
|
||||
}
|
||||
|
||||
if (immuneToAllEffects)
|
||||
@@ -3649,6 +3624,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
|
||||
{
|
||||
@@ -3658,40 +3668,12 @@ bool SpellInfo::SpellCancelsAuraEffect(AuraEffect const* aurEff) const
|
||||
if (aurEff->GetSpellInfo()->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
|
||||
return false;
|
||||
|
||||
if (aurEff->GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::NoImmunity))
|
||||
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;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
if (CanSpellEffectProvideImmunityAgainstAuraEffect(effect, aurEff->GetSpellInfo(), aurEff->GetSpellEffectInfo()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -587,6 +587,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;
|
||||
|
||||
Reference in New Issue
Block a user