mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Spells: Use spell positivity to determine immunities instead of caster-target faction reaction
This commit is contained in:
@@ -7810,23 +7810,23 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo, WorldObject const* caste
|
||||
{
|
||||
uint32 schoolImmunityMask = 0;
|
||||
SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
|
||||
for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr)
|
||||
for (auto [auraSchoolImmunityMask, immunityAuraId] : schoolList)
|
||||
{
|
||||
if ((itr->first & schoolMask) == 0)
|
||||
if ((auraSchoolImmunityMask & schoolMask) == 0)
|
||||
continue;
|
||||
|
||||
SpellInfo const* immuneSpellInfo = sSpellMgr->GetSpellInfo(itr->second, GetMap()->GetDifficultyID());
|
||||
SpellInfo const* immuneSpellInfo = sSpellMgr->GetSpellInfo(immunityAuraId, GetMap()->GetDifficultyID());
|
||||
if (requireImmunityPurgesEffectAttribute)
|
||||
if (!immuneSpellInfo || !immuneSpellInfo->HasAttribute(SPELL_ATTR1_IMMUNITY_PURGES_EFFECT))
|
||||
continue;
|
||||
|
||||
if (!(immuneSpellInfo && immuneSpellInfo->HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS)) && caster && caster->IsFriendlyTo(this))
|
||||
if (spellInfo->IsPositive() && !(immuneSpellInfo && immuneSpellInfo->HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS)))
|
||||
continue;
|
||||
|
||||
if (spellInfo->CanPierceImmuneAura(immuneSpellInfo))
|
||||
continue;
|
||||
|
||||
schoolImmunityMask |= itr->first;
|
||||
schoolImmunityMask |= auraSchoolImmunityMask;
|
||||
}
|
||||
if ((schoolImmunityMask & schoolMask) == schoolMask)
|
||||
return true;
|
||||
@@ -7893,7 +7893,7 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask schoolMask) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Unit::IsImmunedToDamage(WorldObject const* caster, SpellInfo const* spellInfo, SpellEffectInfo const* spellEffectInfo /*= nullptr*/) const
|
||||
bool Unit::IsImmunedToDamage(WorldObject const* /*caster*/, SpellInfo const* spellInfo, SpellEffectInfo const* spellEffectInfo /*= nullptr*/) const
|
||||
{
|
||||
if (!spellInfo)
|
||||
return false;
|
||||
@@ -7912,7 +7912,7 @@ bool Unit::IsImmunedToDamage(WorldObject const* caster, SpellInfo const* spellIn
|
||||
for (auto&& [immunitySchoolMask, immunityAuraId] : container)
|
||||
{
|
||||
SpellInfo const* immuneAuraInfo = sSpellMgr->GetSpellInfo(immunityAuraId, GetMap()->GetDifficultyID());
|
||||
if (immuneAuraInfo && !immuneAuraInfo->HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS) && caster && caster->IsFriendlyTo(this))
|
||||
if (spellInfo->IsPositive() && !(immuneAuraInfo && immuneAuraInfo->HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS)))
|
||||
continue;
|
||||
|
||||
if (immuneAuraInfo && spellInfo->CanPierceImmuneAura(immuneAuraInfo))
|
||||
@@ -7937,7 +7937,7 @@ bool Unit::IsImmunedToDamage(WorldObject const* caster, SpellInfo const* spellIn
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster,
|
||||
bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* /*caster*/,
|
||||
bool requireImmunityPurgesEffectAttribute /*= false*/) const
|
||||
{
|
||||
if (!spellInfo)
|
||||
@@ -7994,7 +7994,10 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo co
|
||||
if (!(immuneAuraApply->GetMiscValue() & spellInfo->GetSchoolMask())) // Check school
|
||||
continue;
|
||||
|
||||
if (immuneAuraApply->GetSpellInfo()->HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS) || (caster && !IsFriendlyTo(caster))) // Harmful
|
||||
if (!spellInfo->IsPositiveEffect(spellEffectInfo.EffectIndex)) // Harmful
|
||||
return true;
|
||||
|
||||
if (immuneAuraApply->GetSpellInfo()->HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS)) // Friendly
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8003,26 +8006,24 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo co
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Unit::IsImmunedToAuraPeriodicTick(WorldObject const* caster, SpellInfo const* spellInfo, SpellEffectInfo const* spellEffectInfo) const
|
||||
bool Unit::IsImmunedToAuraPeriodicTick(WorldObject const* /*caster*/, AuraEffect const* auraEffect) const
|
||||
{
|
||||
if (!spellInfo)
|
||||
if (auraEffect->GetSpellInfo()->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) || auraEffect->GetSpellInfo()->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES) /*only school immunities are checked in this function*/)
|
||||
return false;
|
||||
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) || spellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES) /*only school immunities are checked in this function*/)
|
||||
if (auraEffect->GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::NoImmunity))
|
||||
return false;
|
||||
|
||||
if (spellEffectInfo && spellEffectInfo->EffectAttributes.HasFlag(SpellEffectAttributes::NoImmunity))
|
||||
return false;
|
||||
|
||||
if (uint32 schoolMask = spellInfo->GetSchoolMask())
|
||||
if (uint32 schoolMask = auraEffect->GetSpellInfo()->GetSchoolMask())
|
||||
{
|
||||
auto hasImmunity = [&](SpellImmuneContainer const& container)
|
||||
{
|
||||
bool isPositive = auraEffect->GetBase()->GetApplicationOfTarget(GetGUID())->IsPositive();
|
||||
uint32 schoolImmunityMask = 0;
|
||||
for (auto&& [immunitySchoolMask, immunityAuraId] : container)
|
||||
{
|
||||
SpellInfo const* immuneAuraInfo = sSpellMgr->GetSpellInfo(immunityAuraId, GetMap()->GetDifficultyID());
|
||||
if (immuneAuraInfo && !immuneAuraInfo->HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS) && caster && caster->IsFriendlyTo(this))
|
||||
if (isPositive && !(immuneAuraInfo && immuneAuraInfo->HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS)))
|
||||
continue;
|
||||
|
||||
schoolImmunityMask |= immunitySchoolMask;
|
||||
|
||||
@@ -1687,7 +1687,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
bool IsImmunedToDamage(WorldObject const* caster, SpellInfo const* spellInfo, SpellEffectInfo const* spellEffectInfo = nullptr) const;
|
||||
virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster, bool requireImmunityPurgesEffectAttribute = false) const;
|
||||
|
||||
bool IsImmunedToAuraPeriodicTick(WorldObject const* caster, SpellInfo const* spellInfo, SpellEffectInfo const* spellEffectInfo = nullptr) const;
|
||||
bool IsImmunedToAuraPeriodicTick(WorldObject const* caster, AuraEffect const* auraEffect) const;
|
||||
|
||||
static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = nullptr);
|
||||
static uint32 CalcArmorReducedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = MAX_ATTACK, uint8 attackerLevel = 0);
|
||||
|
||||
@@ -5856,7 +5856,7 @@ void AuraEffect::HandlePeriodicHealthFunnelAuraTick(Unit* target, Unit* caster)
|
||||
if (!caster || !caster->IsAlive() || !target->IsAlive())
|
||||
return;
|
||||
|
||||
if (target->IsImmunedToAuraPeriodicTick(caster, GetSpellInfo(), &GetSpellEffectInfo()))
|
||||
if (target->IsImmunedToAuraPeriodicTick(caster, this))
|
||||
{
|
||||
SendTickImmune(target, caster);
|
||||
return;
|
||||
@@ -5886,7 +5886,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
|
||||
if (!target->IsAlive())
|
||||
return;
|
||||
|
||||
if (target->IsImmunedToAuraPeriodicTick(caster, GetSpellInfo(), &GetSpellEffectInfo()))
|
||||
if (target->IsImmunedToAuraPeriodicTick(caster, this))
|
||||
{
|
||||
SendTickImmune(target, caster);
|
||||
return;
|
||||
@@ -5946,7 +5946,7 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con
|
||||
if (!caster || !caster->IsAlive() || !target->IsAlive() || target->GetPowerType() != powerType)
|
||||
return;
|
||||
|
||||
if (target->IsImmunedToAuraPeriodicTick(caster, GetSpellInfo(), &GetSpellEffectInfo()))
|
||||
if (target->IsImmunedToAuraPeriodicTick(caster, this))
|
||||
{
|
||||
SendTickImmune(target, caster);
|
||||
return;
|
||||
@@ -6009,7 +6009,7 @@ void AuraEffect::HandleObsModPowerAuraTick(Unit* target, Unit* caster) const
|
||||
if (!target->IsAlive() || !target->GetMaxPower(powerType))
|
||||
return;
|
||||
|
||||
if (target->IsImmunedToAuraPeriodicTick(caster, GetSpellInfo(), &GetSpellEffectInfo()))
|
||||
if (target->IsImmunedToAuraPeriodicTick(caster, this))
|
||||
{
|
||||
SendTickImmune(target, caster);
|
||||
return;
|
||||
@@ -6047,7 +6047,7 @@ void AuraEffect::HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) cons
|
||||
if (!target->IsAlive() || !target->GetMaxPower(powerType))
|
||||
return;
|
||||
|
||||
if (target->IsImmunedToAuraPeriodicTick(caster, GetSpellInfo(), &GetSpellEffectInfo()))
|
||||
if (target->IsImmunedToAuraPeriodicTick(caster, this))
|
||||
{
|
||||
SendTickImmune(target, caster);
|
||||
return;
|
||||
|
||||
@@ -3649,7 +3649,7 @@ void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, SpellEffectInfo const& s
|
||||
|
||||
if (apply && HasAttribute(SPELL_ATTR1_IMMUNITY_PURGES_EFFECT))
|
||||
{
|
||||
target->RemoveAppliedAuras([this, target, schoolImmunity](AuraApplication const* aurApp) -> bool
|
||||
target->RemoveAppliedAuras([this, schoolImmunity](AuraApplication const* aurApp) -> bool
|
||||
{
|
||||
SpellInfo const* auraSpellInfo = aurApp->GetBase()->GetSpellInfo();
|
||||
if (auraSpellInfo->Id == Id) // Don't remove self
|
||||
@@ -3660,12 +3660,8 @@ void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, SpellEffectInfo const& s
|
||||
return false;
|
||||
if (!CanDispelAura(auraSpellInfo))
|
||||
return false;
|
||||
if (!HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS))
|
||||
{
|
||||
WorldObject const* existingAuraCaster = aurApp->GetBase()->GetWorldObjectCaster();
|
||||
if (existingAuraCaster && existingAuraCaster->IsFriendlyTo(target)) // Check spell vs aura possitivity
|
||||
return false;
|
||||
}
|
||||
if (aurApp->IsPositive() && !HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS)) // Check spell vs aura possitivity
|
||||
return false;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user