From 774f211f7a1651d0bda616c843ee483589681c85 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 30 Jan 2024 10:45:14 -0500 Subject: [PATCH] Core/Spells: Implemented NoImmunity spell effect attribute Port From (https://github.com/TrinityCore/TrinityCore/commit/e883b61094c3a5d2e80d2165e53921631e72e33e) --- Source/Framework/Constants/CliDBConst.cs | 2 +- Source/Game/Entities/Unit/Unit.Spells.cs | 8 +++++++- Source/Game/Spells/Auras/AuraEffect.cs | 10 +++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Source/Framework/Constants/CliDBConst.cs b/Source/Framework/Constants/CliDBConst.cs index a8542b962..478eaf86e 100644 --- a/Source/Framework/Constants/CliDBConst.cs +++ b/Source/Framework/Constants/CliDBConst.cs @@ -1973,7 +1973,7 @@ namespace Framework.Constants public enum SpellEffectAttributes { None = 0, - NoImmunity = 0x01, /*NYI*/ // not cancelled by immunities + NoImmunity = 0x01, // not cancelled by immunities PositionIsFacingRelative = 0x02, /*NYI*/ JumpChargeUnitMeleeRange = 0x04, /*NYI*/ JumpChargeUnitStrictPathCheck = 0x08, /*NYI*/ diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index f1c7c7d11..add7b2a0c 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -1373,6 +1373,9 @@ namespace Game.Entities if (spellInfo.HasAttribute(SpellAttr0.NoImmunities)) return false; + if (spellEffectInfo.EffectAttributes.HasFlag(SpellEffectAttributes.NoImmunity)) + return false; + bool hasImmunity(MultiMap container, uint key) { var range = container.LookupByKey(key); @@ -1445,7 +1448,7 @@ namespace Game.Entities return false; } - public bool IsImmunedToDamage(SpellInfo spellInfo) + public bool IsImmunedToDamage(SpellInfo spellInfo, SpellEffectInfo spellEffectInfo = null) { if (spellInfo == null) return false; @@ -1457,6 +1460,9 @@ namespace Game.Entities if (spellInfo.HasAttribute(SpellAttr1.ImmunityToHostileAndFriendlyEffects) || spellInfo.HasAttribute(SpellAttr2.NoSchoolImmunities)) return false; + if (spellEffectInfo != null && spellEffectInfo.EffectAttributes.HasFlag(SpellEffectAttributes.NoImmunity)) + return false; + uint schoolMask = (uint)spellInfo.GetSchoolMask(); if (schoolMask != 0) { diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index 32aadbecd..d52970ee3 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -5043,7 +5043,7 @@ namespace Game.Spells if (!target.IsAlive()) return; - if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo())) + if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo(), GetSpellEffectInfo())) { SendTickImmune(target, caster); return; @@ -5171,7 +5171,7 @@ namespace Game.Spells if (!target.IsAlive()) return; - if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo())) + if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo(), GetSpellEffectInfo())) { SendTickImmune(target, caster); return; @@ -5361,7 +5361,7 @@ namespace Game.Spells if (caster == null || !caster.IsAlive() || !target.IsAlive() || target.GetPowerType() != powerType) return; - if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo())) + if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo(), GetSpellEffectInfo())) { SendTickImmune(target, caster); return; @@ -5479,7 +5479,7 @@ namespace Game.Spells if (caster == null || !target.IsAlive() || target.GetPowerType() != powerType) return; - if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo())) + if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo(), GetSpellEffectInfo())) { SendTickImmune(target, caster); return; @@ -5605,7 +5605,7 @@ namespace Game.Spells { Unit target = aurApp.GetTarget(); Unit triggerTarget = eventInfo.GetProcTarget(); - if (triggerTarget.HasUnitState(UnitState.Isolated) || triggerTarget.IsImmunedToDamage(GetSpellInfo())) + if (triggerTarget.HasUnitState(UnitState.Isolated) || triggerTarget.IsImmunedToDamage(GetSpellInfo(), GetSpellEffectInfo())) { SendTickImmune(triggerTarget, target); return;