Core/Auras: Allow SPELL_AURA_MECHANIC_IMMUNITY_MASK to apply aoe/chain targeting immunity
Port From (https://github.com/TrinityCore/TrinityCore/commit/ed0b621d1569a14174a9802027b68dbe4329da69)
This commit is contained in:
@@ -2988,4 +2988,12 @@ namespace Framework.Constants
|
|||||||
Area,
|
Area,
|
||||||
Chain
|
Chain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum SpellOtherImmunity
|
||||||
|
{
|
||||||
|
None = 0x0,
|
||||||
|
AoETarget = 0x1,
|
||||||
|
ChainTarget = 0x2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ namespace Framework.Constants
|
|||||||
Dispel = 4, // enum DispelType
|
Dispel = 4, // enum DispelType
|
||||||
Mechanic = 5, // enum Mechanics
|
Mechanic = 5, // enum Mechanics
|
||||||
Id = 6,
|
Id = 6,
|
||||||
Max = 7
|
Other = 7, //enum SpellOtherImmunity
|
||||||
|
Max
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2218,6 +2218,9 @@ namespace Game.Entities
|
|||||||
|
|
||||||
foreach (AuraType aura in immunities.Aura)
|
foreach (AuraType aura in immunities.Aura)
|
||||||
ApplySpellImmune(placeholderSpellId, SpellImmunity.State, aura, apply);
|
ApplySpellImmune(placeholderSpellId, SpellImmunity.State, aura, apply);
|
||||||
|
|
||||||
|
if (immunities.Other != SpellOtherImmunity.None)
|
||||||
|
ApplySpellImmune(placeholderSpellId, SpellImmunity.Other, (byte)immunities.Other, apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unapply template immunities (in case we're updating entry)
|
// unapply template immunities (in case we're updating entry)
|
||||||
|
|||||||
@@ -1384,6 +1384,16 @@ namespace Game.Entities
|
|||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SpellOtherImmunity GetSpellOtherImmunityMask()
|
||||||
|
{
|
||||||
|
SpellOtherImmunity mask = 0;
|
||||||
|
var damageList = m_spellImmune[(int)SpellImmunity.Other];
|
||||||
|
foreach (var pair in damageList)
|
||||||
|
mask |= (SpellOtherImmunity)pair.Key;
|
||||||
|
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual bool IsImmunedToSpellEffect(SpellInfo spellInfo, SpellEffectInfo spellEffectInfo, WorldObject caster, bool requireImmunityPurgesEffectAttribute = false)
|
public virtual bool IsImmunedToSpellEffect(SpellInfo spellInfo, SpellEffectInfo spellEffectInfo, WorldObject caster, bool requireImmunityPurgesEffectAttribute = false)
|
||||||
{
|
{
|
||||||
if (spellInfo == null)
|
if (spellInfo == null)
|
||||||
|
|||||||
+13
-18
@@ -9185,26 +9185,21 @@ namespace Game.Spells
|
|||||||
if (!isInsideCylinder)
|
if (!isInsideCylinder)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Creature creatureTarget = target.ToCreature();
|
Unit unitTarget = target.ToUnit();
|
||||||
if (creatureTarget != null)
|
if (unitTarget != null)
|
||||||
{
|
{
|
||||||
CreatureImmunities immunities = Global.SpellMgr.GetCreatureImmunities(creatureTarget.GetCreatureTemplate().CreatureImmunitiesId);
|
switch (_searchReason)
|
||||||
if (immunities != null)
|
|
||||||
{
|
{
|
||||||
switch (_searchReason)
|
case WorldObjectSpellAreaTargetSearchReason.Area:
|
||||||
{
|
if (unitTarget.GetSpellOtherImmunityMask().HasFlag(SpellOtherImmunity.AoETarget))
|
||||||
case WorldObjectSpellAreaTargetSearchReason.Area:
|
return false;
|
||||||
if (immunities.ImmuneAoE)
|
break;
|
||||||
return false;
|
case WorldObjectSpellAreaTargetSearchReason.Chain:
|
||||||
break;
|
if (unitTarget.GetSpellOtherImmunityMask().HasFlag(SpellOtherImmunity.ChainTarget))
|
||||||
case WorldObjectSpellAreaTargetSearchReason.Chain:
|
return false;
|
||||||
if (immunities.ImmuneChain)
|
break;
|
||||||
return false;
|
default:
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1078,6 +1078,10 @@ namespace Game.Spells
|
|||||||
if (HasAttribute(SpellAttr8.OnlyTargetOwnSummons))
|
if (HasAttribute(SpellAttr8.OnlyTargetOwnSummons))
|
||||||
if (!unitTarget.IsSummon() || unitTarget.ToTempSummon().GetSummonerGUID() != caster.GetGUID())
|
if (!unitTarget.IsSummon() || unitTarget.ToTempSummon().GetSummonerGUID() != caster.GetGUID())
|
||||||
return SpellCastResult.BadTargets;
|
return SpellCastResult.BadTargets;
|
||||||
|
|
||||||
|
if (HasAttribute(SpellAttr3.NotOnAoeImmune))
|
||||||
|
if (unitTarget.GetSpellOtherImmunityMask().HasFlag(SpellOtherImmunity.AoETarget))
|
||||||
|
return SpellCastResult.BadTargets;
|
||||||
}
|
}
|
||||||
// corpse specific target checks
|
// corpse specific target checks
|
||||||
else if (target.IsTypeId(TypeId.Corpse))
|
else if (target.IsTypeId(TypeId.Corpse))
|
||||||
@@ -1106,13 +1110,6 @@ namespace Game.Spells
|
|||||||
|
|
||||||
if (HasAttribute(SpellAttr5.NotOnPlayerControlledNpc) && unitTarget.IsControlledByPlayer())
|
if (HasAttribute(SpellAttr5.NotOnPlayerControlledNpc) && unitTarget.IsControlledByPlayer())
|
||||||
return SpellCastResult.TargetIsPlayerControlled;
|
return SpellCastResult.TargetIsPlayerControlled;
|
||||||
|
|
||||||
if (HasAttribute(SpellAttr3.NotOnAoeImmune))
|
|
||||||
{
|
|
||||||
CreatureImmunities immunities = Global.SpellMgr.GetCreatureImmunities(unitTarget.ToCreature().GetCreatureTemplate().CreatureImmunitiesId);
|
|
||||||
if (immunities != null && immunities.ImmuneAoE)
|
|
||||||
return SpellCastResult.BadTargets;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (HasAttribute(SpellAttr5.NotOnPlayer))
|
else if (HasAttribute(SpellAttr5.NotOnPlayer))
|
||||||
return SpellCastResult.TargetIsPlayer;
|
return SpellCastResult.TargetIsPlayer;
|
||||||
@@ -2144,6 +2141,7 @@ namespace Game.Spells
|
|||||||
ulong mechanicImmunityMask = 0;
|
ulong mechanicImmunityMask = 0;
|
||||||
uint dispelImmunityMask = 0;
|
uint dispelImmunityMask = 0;
|
||||||
uint damageImmunityMask = 0;
|
uint damageImmunityMask = 0;
|
||||||
|
byte otherImmunityMask = 0;
|
||||||
|
|
||||||
int miscVal = effect.MiscValue;
|
int miscVal = effect.MiscValue;
|
||||||
|
|
||||||
@@ -2159,6 +2157,7 @@ namespace Game.Spells
|
|||||||
schoolImmunityMask |= creatureImmunities.School.ToUInt();
|
schoolImmunityMask |= creatureImmunities.School.ToUInt();
|
||||||
dispelImmunityMask |= creatureImmunities.DispelType.ToUInt();
|
dispelImmunityMask |= creatureImmunities.DispelType.ToUInt();
|
||||||
mechanicImmunityMask |= creatureImmunities.Mechanic.ToUInt();
|
mechanicImmunityMask |= creatureImmunities.Mechanic.ToUInt();
|
||||||
|
otherImmunityMask |= (byte)creatureImmunities.Other;
|
||||||
foreach (SpellEffectName effectType in creatureImmunities.Effect)
|
foreach (SpellEffectName effectType in creatureImmunities.Effect)
|
||||||
immuneInfo.SpellEffectImmune.Add(effectType);
|
immuneInfo.SpellEffectImmune.Add(effectType);
|
||||||
foreach (AuraType aura in creatureImmunities.Aura)
|
foreach (AuraType aura in creatureImmunities.Aura)
|
||||||
@@ -2237,6 +2236,7 @@ namespace Game.Spells
|
|||||||
immuneInfo.MechanicImmuneMask = mechanicImmunityMask;
|
immuneInfo.MechanicImmuneMask = mechanicImmunityMask;
|
||||||
immuneInfo.DispelImmuneMask = dispelImmunityMask;
|
immuneInfo.DispelImmuneMask = dispelImmunityMask;
|
||||||
immuneInfo.DamageSchoolMask = damageImmunityMask;
|
immuneInfo.DamageSchoolMask = damageImmunityMask;
|
||||||
|
immuneInfo.OtherImmuneMask = otherImmunityMask;
|
||||||
|
|
||||||
_allowedMechanicMask |= immuneInfo.MechanicImmuneMask;
|
_allowedMechanicMask |= immuneInfo.MechanicImmuneMask;
|
||||||
}
|
}
|
||||||
@@ -2413,6 +2413,10 @@ namespace Game.Spells
|
|||||||
|
|
||||||
foreach (SpellEffectName effectType in immuneInfo.SpellEffectImmune)
|
foreach (SpellEffectName effectType in immuneInfo.SpellEffectImmune)
|
||||||
target.ApplySpellImmune(Id, SpellImmunity.Effect, effectType, apply);
|
target.ApplySpellImmune(Id, SpellImmunity.Effect, effectType, apply);
|
||||||
|
|
||||||
|
byte otherImmuneMask = immuneInfo.OtherImmuneMask;
|
||||||
|
if (otherImmuneMask != 0)
|
||||||
|
target.ApplySpellImmune(Id, SpellImmunity.Other, otherImmuneMask, apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CanSpellProvideImmunityAgainstAura(SpellInfo auraSpellInfo)
|
bool CanSpellProvideImmunityAgainstAura(SpellInfo auraSpellInfo)
|
||||||
@@ -5154,6 +5158,7 @@ namespace Game.Spells
|
|||||||
public ulong MechanicImmuneMask;
|
public ulong MechanicImmuneMask;
|
||||||
public uint DispelImmuneMask;
|
public uint DispelImmuneMask;
|
||||||
public uint DamageSchoolMask;
|
public uint DamageSchoolMask;
|
||||||
|
public byte OtherImmuneMask;
|
||||||
|
|
||||||
public List<AuraType> AuraTypeImmune = new();
|
public List<AuraType> AuraTypeImmune = new();
|
||||||
public List<SpellEffectName> SpellEffectImmune = new();
|
public List<SpellEffectName> SpellEffectImmune = new();
|
||||||
|
|||||||
@@ -4513,8 +4513,10 @@ namespace Game.Entities
|
|||||||
immunities.School = new BitSet(new uint[] { school });
|
immunities.School = new BitSet(new uint[] { school });
|
||||||
immunities.DispelType = new BitSet(new uint[] { dispelType });
|
immunities.DispelType = new BitSet(new uint[] { dispelType });
|
||||||
immunities.Mechanic = new BitSet(mechanics);
|
immunities.Mechanic = new BitSet(mechanics);
|
||||||
immunities.ImmuneAoE = result.Read<bool>(6);
|
if (result.Read<bool>(6))
|
||||||
immunities.ImmuneChain = result.Read<bool>(7);
|
immunities.Other |= SpellOtherImmunity.AoETarget;
|
||||||
|
if (result.Read<bool>(7))
|
||||||
|
immunities.Other |= SpellOtherImmunity.ChainTarget;
|
||||||
|
|
||||||
if (immunities.School.ToUInt() != school)
|
if (immunities.School.ToUInt() != school)
|
||||||
Log.outError(LogFilter.Sql, $"Invalid value in `SchoolMask` {school} for creature immunities {id}, truncated");
|
Log.outError(LogFilter.Sql, $"Invalid value in `SchoolMask` {school} for creature immunities {id}, truncated");
|
||||||
@@ -5147,7 +5149,6 @@ namespace Game.Entities
|
|||||||
public BitSet Mechanic = new((int)Mechanics.Max);
|
public BitSet Mechanic = new((int)Mechanics.Max);
|
||||||
public List<SpellEffectName> Effect = new();
|
public List<SpellEffectName> Effect = new();
|
||||||
public List<AuraType> Aura = new();
|
public List<AuraType> Aura = new();
|
||||||
public bool ImmuneAoE; // NYI
|
public SpellOtherImmunity Other;
|
||||||
public bool ImmuneChain; // NYI
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user