Core/Spells: Fixed implementation of SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS and removed banish special cases that were neccessary because that attribute wasn't correctly supported
Port From (https://github.com/TrinityCore/TrinityCore/commit/c968dedfee59db53fc912ac166309f3d87470821)
This commit is contained in:
@@ -1702,7 +1702,7 @@ namespace Framework.Constants
|
|||||||
ToggleFarSight = 0x2000, // Toggle Far Sight (Client Only)
|
ToggleFarSight = 0x2000, // Toggle Far Sight (Client Only)
|
||||||
TrackTargetInChannel = 0x4000, // Track Target In Channel Description While Channeling, Adjust Facing To Face Target
|
TrackTargetInChannel = 0x4000, // Track Target In Channel Description While Channeling, Adjust Facing To Face Target
|
||||||
ImmunityPurgesEffect = 0x8000, // Immunity Purges Effect Description For Immunity Spells, Cancel All Auras That This Spell Would Make You Immune To When The Spell Is Applied
|
ImmunityPurgesEffect = 0x8000, // Immunity Purges Effect Description For Immunity Spells, Cancel All Auras That This Spell Would Make You Immune To When The Spell Is Applied
|
||||||
ImmunityToHostileAndFriendlyEffects = 0x10000, /*Wrong Impl*/ // Immunity To Hostile & Friendly Effects Description Will Not Pierce Divine Shield, Ice Block And Other Full Invulnerabilities
|
ImmunityToHostileAndFriendlyEffects = 0x10000, // Immunity applied by this aura will also be checked for friendly spells (school immunity only) - used by Cyclone for example to cause friendly spells and healing over time to be immuned
|
||||||
NoAutocastAi = 0x20000, // No Autocast (Ai)
|
NoAutocastAi = 0x20000, // No Autocast (Ai)
|
||||||
PreventsAnim = 0x40000, /*Nyi*/ // Prevents Anim Description Auras Apply UnitFlagPreventEmotesFromChatText
|
PreventsAnim = 0x40000, /*Nyi*/ // Prevents Anim Description Auras Apply UnitFlagPreventEmotesFromChatText
|
||||||
ExcludeCaster = 0x80000, // Exclude Caster
|
ExcludeCaster = 0x80000, // Exclude Caster
|
||||||
@@ -2683,7 +2683,7 @@ namespace Framework.Constants
|
|||||||
Marked = 5, // C T| Nyi
|
Marked = 5, // C T| Nyi
|
||||||
Wounded25Percent = 6, // T |
|
Wounded25Percent = 6, // T |
|
||||||
Defensive2 = 7, // Cc | Nyi
|
Defensive2 = 7, // Cc | Nyi
|
||||||
Banished = 8, // C | Nyi
|
Banished = 8, // C |
|
||||||
Dazed = 9, // T|
|
Dazed = 9, // T|
|
||||||
Victorious = 10, // C |
|
Victorious = 10, // C |
|
||||||
Rampage = 11, // | Nyi
|
Rampage = 11, // | Nyi
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ namespace Framework.Constants
|
|||||||
Root = 0x400,
|
Root = 0x400,
|
||||||
Confused = 0x800,
|
Confused = 0x800,
|
||||||
Distracted = 0x1000,
|
Distracted = 0x1000,
|
||||||
Isolated = 0x2000, // Area Auras Do Not Affect Other Players
|
Isolated_Deprecated = 0x2000, // REUSE
|
||||||
AttackPlayer = 0x4000,
|
AttackPlayer = 0x4000,
|
||||||
Casting = 0x8000,
|
Casting = 0x8000,
|
||||||
Possessed = 0x10000, // being possessed by another unit
|
Possessed = 0x10000, // being possessed by another unit
|
||||||
@@ -494,7 +494,7 @@ namespace Framework.Constants
|
|||||||
|
|
||||||
AllStateSupported = Died | MeleeAttacking | Charmed | Stunned | Roaming | Chase
|
AllStateSupported = Died | MeleeAttacking | Charmed | Stunned | Roaming | Chase
|
||||||
| Focusing | Fleeing | InFlight | Follow | Root | Confused
|
| Focusing | Fleeing | InFlight | Follow | Root | Confused
|
||||||
| Distracted | Isolated | AttackPlayer | Casting
|
| Distracted | AttackPlayer | Casting
|
||||||
| Possessed | Charging | Jumping | Move | Rotating
|
| Possessed | Charging | Jumping | Move | Rotating
|
||||||
| Evade | RoamingMove | ConfusedMove | FleeingMove
|
| Evade | RoamingMove | ConfusedMove | FleeingMove
|
||||||
| ChaseMove | FollowMove | IgnorePathfinding | FollowFormationMove,
|
| ChaseMove | FollowMove | IgnorePathfinding | FollowFormationMove,
|
||||||
|
|||||||
@@ -2189,7 +2189,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
// Damage immunity is only checked if the spell has damage effects, this immunity must not prevent aura apply
|
// Damage immunity is only checked if the spell has damage effects, this immunity must not prevent aura apply
|
||||||
// returns SPELL_MISS_IMMUNE in that case, for other spells, the SMSG_SPELL_GO must show hit
|
// returns SPELL_MISS_IMMUNE in that case, for other spells, the SMSG_SPELL_GO must show hit
|
||||||
if (spellInfo.HasOnlyDamageEffects() && victim.IsImmunedToDamage(spellInfo))
|
if (spellInfo.HasOnlyDamageEffects() && victim.IsImmunedToDamage(this, spellInfo))
|
||||||
return SpellMissInfo.Immune;
|
return SpellMissInfo.Immune;
|
||||||
|
|
||||||
// All positive spells can`t miss
|
// All positive spells can`t miss
|
||||||
|
|||||||
@@ -1339,11 +1339,13 @@ namespace Game.Entities
|
|||||||
if (immuneSpellInfo == null || !immuneSpellInfo.HasAttribute(SpellAttr1.ImmunityPurgesEffect))
|
if (immuneSpellInfo == null || !immuneSpellInfo.HasAttribute(SpellAttr1.ImmunityPurgesEffect))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Consider the school immune if any of these conditions are not satisfied.
|
if (immuneSpellInfo != null && !immuneSpellInfo.HasAttribute(SpellAttr1.ImmunityToHostileAndFriendlyEffects) && caster != null && !caster.IsFriendlyTo(this))
|
||||||
// In case of no immuneSpellInfo, ignore that condition and check only the other conditions
|
continue;
|
||||||
if ((immuneSpellInfo != null && !immuneSpellInfo.IsPositive()) || !spellInfo.IsPositive() || caster == null || !IsFriendlyTo(caster))
|
|
||||||
if (!spellInfo.CanPierceImmuneAura(immuneSpellInfo))
|
if (spellInfo.CanPierceImmuneAura(immuneSpellInfo))
|
||||||
schoolImmunityMask |= pair.Key;
|
continue;
|
||||||
|
|
||||||
|
schoolImmunityMask |= pair.Key;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((schoolImmunityMask & schoolMask) == schoolMask)
|
if ((schoolImmunityMask & schoolMask) == schoolMask)
|
||||||
@@ -1392,6 +1394,69 @@ namespace Game.Entities
|
|||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsImmunedToDamage(SpellSchoolMask schoolMask)
|
||||||
|
{
|
||||||
|
if (schoolMask == SpellSchoolMask.None)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// If m_immuneToSchool type contain this school type, IMMUNE damage.
|
||||||
|
uint schoolImmunityMask = GetSchoolImmunityMask();
|
||||||
|
if (((SpellSchoolMask)schoolImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If m_immuneToDamage type contain magic, IMMUNE damage.
|
||||||
|
uint damageImmunityMask = GetDamageImmunityMask();
|
||||||
|
if (((SpellSchoolMask)damageImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsImmunedToDamage(WorldObject caster, SpellInfo spellInfo, SpellEffectInfo spellEffectInfo = null)
|
||||||
|
{
|
||||||
|
if (spellInfo == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (spellInfo.HasAttribute(SpellAttr0.NoImmunities) && spellInfo.HasAttribute(SpellAttr2.NoSchoolImmunities))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (spellEffectInfo != null && spellEffectInfo.EffectAttributes.HasFlag(SpellEffectAttributes.NoImmunity))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint schoolMask = (uint)spellInfo.GetSchoolMask();
|
||||||
|
if (schoolMask != 0)
|
||||||
|
{
|
||||||
|
bool hasImmunity(MultiMap<uint, uint> container)
|
||||||
|
{
|
||||||
|
uint schoolImmunityMask = 0;
|
||||||
|
foreach (var (immunitySchoolMask, immunityAuraId) in container)
|
||||||
|
{
|
||||||
|
SpellInfo immuneAuraInfo = Global.SpellMgr.GetSpellInfo(immunityAuraId, GetMap().GetDifficultyID());
|
||||||
|
if (immuneAuraInfo != null && !immuneAuraInfo.HasAttribute(SpellAttr1.ImmunityToHostileAndFriendlyEffects) && caster != null && caster.IsFriendlyTo(this))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (immuneAuraInfo != null && spellInfo.CanPierceImmuneAura(immuneAuraInfo))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
schoolImmunityMask |= immunitySchoolMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
// // We need to be immune to all types
|
||||||
|
return (schoolImmunityMask & schoolMask) == schoolMask;
|
||||||
|
};
|
||||||
|
|
||||||
|
// If m_immuneToSchool type contain this school type, IMMUNE damage.
|
||||||
|
if (hasImmunity(m_spellImmune[(int)SpellImmunity.School]))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If m_immuneToDamage type contain magic, IMMUNE damage.
|
||||||
|
if (hasImmunity(m_spellImmune[(int)SpellImmunity.Damage]))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
@@ -1445,46 +1510,26 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (!spellInfo.HasAttribute(SpellAttr2.NoSchoolImmunities))
|
if (!spellInfo.HasAttribute(SpellAttr2.NoSchoolImmunities))
|
||||||
{
|
{
|
||||||
// Check for immune to application of harmful magical effects
|
foreach (AuraEffect immuneAuraApply in GetAuraEffectsByType(AuraType.ModImmuneAuraApplySchool))
|
||||||
var immuneAuraApply = GetAuraEffectsByType(AuraType.ModImmuneAuraApplySchool);
|
{
|
||||||
foreach (var auraEffect in immuneAuraApply)
|
if ((immuneAuraApply.GetMiscValue() & (int)spellInfo.GetSchoolMask()) == 0) // Check school
|
||||||
if (Convert.ToBoolean(auraEffect.GetMiscValue() & (int)spellInfo.GetSchoolMask()) && // Check school
|
continue;
|
||||||
((caster != null && !IsFriendlyTo(caster)) || !spellInfo.IsPositiveEffect(spellEffectInfo.EffectIndex))) // Harmful
|
|
||||||
|
if (spellInfo.HasAttribute(SpellAttr1.ImmunityToHostileAndFriendlyEffects) || (caster != null && !IsFriendlyTo(caster))) // Harmful
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsImmunedToDamage(SpellSchoolMask schoolMask)
|
public bool IsImmunedToAuraPeriodicTick(WorldObject caster, SpellInfo spellInfo, SpellEffectInfo spellEffectInfo = null)
|
||||||
{
|
|
||||||
if (schoolMask == SpellSchoolMask.None)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// If m_immuneToSchool type contain this school type, IMMUNE damage.
|
|
||||||
uint schoolImmunityMask = GetSchoolImmunityMask();
|
|
||||||
if (((SpellSchoolMask)schoolImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// If m_immuneToDamage type contain magic, IMMUNE damage.
|
|
||||||
uint damageImmunityMask = GetDamageImmunityMask();
|
|
||||||
if (((SpellSchoolMask)damageImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsImmunedToDamage(SpellInfo spellInfo, SpellEffectInfo spellEffectInfo = null)
|
|
||||||
{
|
{
|
||||||
if (spellInfo == null)
|
if (spellInfo == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// for example 40175
|
if (spellInfo.HasAttribute(SpellAttr0.NoImmunities) || spellInfo.HasAttribute(SpellAttr2.NoSchoolImmunities) /*only school immunities are checked in this function*/)
|
||||||
if (spellInfo.HasAttribute(SpellAttr0.NoImmunities) && spellInfo.HasAttribute(SpellAttr3.AlwaysHit))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (spellInfo.HasAttribute(SpellAttr1.ImmunityToHostileAndFriendlyEffects) || spellInfo.HasAttribute(SpellAttr2.NoSchoolImmunities))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (spellEffectInfo != null && spellEffectInfo.EffectAttributes.HasFlag(SpellEffectAttributes.NoImmunity))
|
if (spellEffectInfo != null && spellEffectInfo.EffectAttributes.HasFlag(SpellEffectAttributes.NoImmunity))
|
||||||
@@ -1493,20 +1538,24 @@ namespace Game.Entities
|
|||||||
uint schoolMask = (uint)spellInfo.GetSchoolMask();
|
uint schoolMask = (uint)spellInfo.GetSchoolMask();
|
||||||
if (schoolMask != 0)
|
if (schoolMask != 0)
|
||||||
{
|
{
|
||||||
|
bool hasImmunity(MultiMap<uint, uint> container)
|
||||||
|
{
|
||||||
|
uint schoolImmunityMask = 0;
|
||||||
|
foreach (var (immunitySchoolMask, immunityAuraId) in container)
|
||||||
|
{
|
||||||
|
SpellInfo immuneAuraInfo = Global.SpellMgr.GetSpellInfo(immunityAuraId, GetMap().GetDifficultyID());
|
||||||
|
if (immuneAuraInfo != null && !immuneAuraInfo.HasAttribute(SpellAttr1.ImmunityToHostileAndFriendlyEffects) && caster != null && caster.IsFriendlyTo(this))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
schoolImmunityMask |= immunitySchoolMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
// // We need to be immune to all types
|
||||||
|
return (schoolImmunityMask & schoolMask) == schoolMask;
|
||||||
|
}
|
||||||
|
|
||||||
// If m_immuneToSchool type contain this school type, IMMUNE damage.
|
// If m_immuneToSchool type contain this school type, IMMUNE damage.
|
||||||
uint schoolImmunityMask = 0;
|
if (hasImmunity(m_spellImmune[(int)SpellImmunity.School]))
|
||||||
var schoolList = m_spellImmune[(int)SpellImmunity.School];
|
|
||||||
foreach (var pair in schoolList)
|
|
||||||
if (Convert.ToBoolean(pair.Key & schoolMask) && !spellInfo.CanPierceImmuneAura(Global.SpellMgr.GetSpellInfo(pair.Value, GetMap().GetDifficultyID())))
|
|
||||||
schoolImmunityMask |= pair.Key;
|
|
||||||
|
|
||||||
// // We need to be immune to all types
|
|
||||||
if ((schoolImmunityMask & schoolMask) == schoolMask)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// If m_immuneToDamage type contain magic, IMMUNE damage.
|
|
||||||
uint damageImmunityMask = GetDamageImmunityMask();
|
|
||||||
if ((damageImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3100,7 +3100,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...or immuned
|
// ...or immuned
|
||||||
if (IsImmunedToDamage(spellInfo))
|
if (IsImmunedToDamage(this, spellInfo))
|
||||||
{
|
{
|
||||||
victim.SendSpellDamageImmune(this, spellInfo.Id, false);
|
victim.SendSpellDamageImmune(this, spellInfo.Id, false);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ namespace Game.Spells
|
|||||||
return Global.ObjAccessor.GetUnit(m_owner, m_casterGuid);
|
return Global.ObjAccessor.GetUnit(m_owner, m_casterGuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldObject GetWorldObjectCaster()
|
public WorldObject GetWorldObjectCaster()
|
||||||
{
|
{
|
||||||
if (GetCasterGUID().IsUnit())
|
if (GetCasterGUID().IsUnit())
|
||||||
return GetCaster();
|
return GetCaster();
|
||||||
@@ -2785,7 +2785,7 @@ namespace Game.Spells
|
|||||||
if (!GetUnitOwner().IsInWorld)
|
if (!GetUnitOwner().IsInWorld)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (GetUnitOwner().HasUnitState(UnitState.Isolated))
|
if (GetUnitOwner().HasAuraState(AuraStateType.Banished, GetSpellInfo(), caster))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
List<WorldObject> units = new();
|
List<WorldObject> units = new();
|
||||||
|
|||||||
@@ -2933,28 +2933,6 @@ namespace Game.Spells
|
|||||||
Unit target = aurApp.GetTarget();
|
Unit target = aurApp.GetTarget();
|
||||||
m_spellInfo.ApplyAllSpellImmunitiesTo(target, GetSpellEffectInfo(), apply);
|
m_spellInfo.ApplyAllSpellImmunitiesTo(target, GetSpellEffectInfo(), apply);
|
||||||
|
|
||||||
if (GetSpellInfo().Mechanic == Mechanics.Banish)
|
|
||||||
{
|
|
||||||
if (apply)
|
|
||||||
target.AddUnitState(UnitState.Isolated);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool banishFound = false;
|
|
||||||
var banishAuras = target.GetAuraEffectsByType(GetAuraType());
|
|
||||||
foreach (var aurEff in banishAuras)
|
|
||||||
{
|
|
||||||
if (aurEff.GetSpellInfo().Mechanic == Mechanics.Banish)
|
|
||||||
{
|
|
||||||
banishFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!banishFound)
|
|
||||||
target.ClearUnitState(UnitState.Isolated);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: should be changed to a proc script on flag spell (they have "Taken positive" proc flags in db2)
|
// TODO: should be changed to a proc script on flag spell (they have "Taken positive" proc flags in db2)
|
||||||
{
|
{
|
||||||
if (apply && GetMiscValue() == (int)SpellSchoolMask.Normal)
|
if (apply && GetMiscValue() == (int)SpellSchoolMask.Normal)
|
||||||
@@ -5091,7 +5069,7 @@ namespace Game.Spells
|
|||||||
if (!target.IsAlive())
|
if (!target.IsAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo(), GetSpellEffectInfo()))
|
if (target.IsImmunedToDamage(caster, GetSpellInfo(), GetSpellEffectInfo()))
|
||||||
{
|
{
|
||||||
SendTickImmune(target, caster);
|
SendTickImmune(target, caster);
|
||||||
return;
|
return;
|
||||||
@@ -5219,7 +5197,7 @@ namespace Game.Spells
|
|||||||
if (!target.IsAlive())
|
if (!target.IsAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo(), GetSpellEffectInfo()))
|
if (target.IsImmunedToDamage(caster, GetSpellInfo(), GetSpellEffectInfo()))
|
||||||
{
|
{
|
||||||
SendTickImmune(target, caster);
|
SendTickImmune(target, caster);
|
||||||
return;
|
return;
|
||||||
@@ -5319,7 +5297,7 @@ namespace Game.Spells
|
|||||||
if (caster == null || !caster.IsAlive() || !target.IsAlive())
|
if (caster == null || !caster.IsAlive() || !target.IsAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target.HasUnitState(UnitState.Isolated))
|
if (target.IsImmunedToAuraPeriodicTick(caster, GetSpellInfo(), GetSpellEffectInfo()))
|
||||||
{
|
{
|
||||||
SendTickImmune(target, caster);
|
SendTickImmune(target, caster);
|
||||||
return;
|
return;
|
||||||
@@ -5349,7 +5327,7 @@ namespace Game.Spells
|
|||||||
if (!target.IsAlive())
|
if (!target.IsAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target.HasUnitState(UnitState.Isolated))
|
if (target.IsImmunedToAuraPeriodicTick(caster, GetSpellInfo(), GetSpellEffectInfo()))
|
||||||
{
|
{
|
||||||
SendTickImmune(target, caster);
|
SendTickImmune(target, caster);
|
||||||
return;
|
return;
|
||||||
@@ -5409,7 +5387,7 @@ namespace Game.Spells
|
|||||||
if (caster == null || !caster.IsAlive() || !target.IsAlive() || target.GetPowerType() != powerType)
|
if (caster == null || !caster.IsAlive() || !target.IsAlive() || target.GetPowerType() != powerType)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo(), GetSpellEffectInfo()))
|
if (target.IsImmunedToAuraPeriodicTick(caster, GetSpellInfo(), GetSpellEffectInfo()))
|
||||||
{
|
{
|
||||||
SendTickImmune(target, caster);
|
SendTickImmune(target, caster);
|
||||||
return;
|
return;
|
||||||
@@ -5469,7 +5447,7 @@ namespace Game.Spells
|
|||||||
if (!target.IsAlive() || target.GetMaxPower(powerType) == 0)
|
if (!target.IsAlive() || target.GetMaxPower(powerType) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target.HasUnitState(UnitState.Isolated))
|
if (target.IsImmunedToAuraPeriodicTick(caster, GetSpellInfo(), GetSpellEffectInfo()))
|
||||||
{
|
{
|
||||||
SendTickImmune(target, caster);
|
SendTickImmune(target, caster);
|
||||||
return;
|
return;
|
||||||
@@ -5498,7 +5476,7 @@ namespace Game.Spells
|
|||||||
if (!target.IsAlive() || target.GetMaxPower(powerType) == 0)
|
if (!target.IsAlive() || target.GetMaxPower(powerType) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target.HasUnitState(UnitState.Isolated))
|
if (target.IsImmunedToAuraPeriodicTick(caster, GetSpellInfo(), GetSpellEffectInfo()))
|
||||||
{
|
{
|
||||||
SendTickImmune(target, caster);
|
SendTickImmune(target, caster);
|
||||||
return;
|
return;
|
||||||
@@ -5527,7 +5505,7 @@ namespace Game.Spells
|
|||||||
if (caster == null || !target.IsAlive() || target.GetPowerType() != powerType)
|
if (caster == null || !target.IsAlive() || target.GetPowerType() != powerType)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target.HasUnitState(UnitState.Isolated) || target.IsImmunedToDamage(GetSpellInfo(), GetSpellEffectInfo()))
|
if (target.IsImmunedToDamage(caster, GetSpellInfo(), GetSpellEffectInfo()))
|
||||||
{
|
{
|
||||||
SendTickImmune(target, caster);
|
SendTickImmune(target, caster);
|
||||||
return;
|
return;
|
||||||
@@ -5657,7 +5635,7 @@ namespace Game.Spells
|
|||||||
{
|
{
|
||||||
Unit target = aurApp.GetTarget();
|
Unit target = aurApp.GetTarget();
|
||||||
Unit triggerTarget = eventInfo.GetProcTarget();
|
Unit triggerTarget = eventInfo.GetProcTarget();
|
||||||
if (triggerTarget.HasUnitState(UnitState.Isolated) || triggerTarget.IsImmunedToDamage(GetSpellInfo(), GetSpellEffectInfo()))
|
if (triggerTarget.IsImmunedToDamage(target, GetSpellInfo(), GetSpellEffectInfo()))
|
||||||
{
|
{
|
||||||
SendTickImmune(triggerTarget, target);
|
SendTickImmune(triggerTarget, target);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -9002,7 +9002,7 @@ namespace Game.Spells
|
|||||||
// Fill base damage struct (unitTarget - is real spell target)
|
// Fill base damage struct (unitTarget - is real spell target)
|
||||||
SpellNonMeleeDamage damageInfo = new(caster, spell.unitTarget, spell.m_spellInfo, spell.m_SpellVisual, spell.m_spellSchoolMask, spell.m_castId);
|
SpellNonMeleeDamage damageInfo = new(caster, spell.unitTarget, spell.m_spellInfo, spell.m_SpellVisual, spell.m_spellSchoolMask, spell.m_castId);
|
||||||
// Check damage immunity
|
// Check damage immunity
|
||||||
if (spell.unitTarget.IsImmunedToDamage(spell.m_spellInfo))
|
if (spell.unitTarget.IsImmunedToDamage(caster, spell.m_spellInfo))
|
||||||
{
|
{
|
||||||
hitMask = ProcFlagsHit.Immune;
|
hitMask = ProcFlagsHit.Immune;
|
||||||
spell.m_damage = 0;
|
spell.m_damage = 0;
|
||||||
|
|||||||
@@ -673,24 +673,6 @@ namespace Game.Spells
|
|||||||
|
|
||||||
public bool CanPierceImmuneAura(SpellInfo auraSpellInfo)
|
public bool CanPierceImmuneAura(SpellInfo auraSpellInfo)
|
||||||
{
|
{
|
||||||
// aura can't be pierced
|
|
||||||
if (auraSpellInfo == null || auraSpellInfo.HasAttribute(SpellAttr0.NoImmunities))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// these spells pierce all avalible spells (Resurrection Sickness for example)
|
|
||||||
if (HasAttribute(SpellAttr0.NoImmunities))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// these spells (Cyclone for example) can pierce all...
|
|
||||||
if (HasAttribute(SpellAttr1.ImmunityToHostileAndFriendlyEffects) || HasAttribute(SpellAttr2.NoSchoolImmunities))
|
|
||||||
{
|
|
||||||
// ...but not these (Divine shield, Ice block, Cyclone and Banish for example)
|
|
||||||
if (auraSpellInfo.Mechanic != Mechanics.ImmuneShield &&
|
|
||||||
auraSpellInfo.Mechanic != Mechanics.Invulnerability &&
|
|
||||||
(auraSpellInfo.Mechanic != Mechanics.Banish || (IsRankOf(auraSpellInfo) && auraSpellInfo.Dispel != DispelType.None))) // Banish shouldn't be immune to itself, but Cyclone should
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dispels other auras on immunity, check if this spell makes the unit immune to aura
|
// Dispels other auras on immunity, check if this spell makes the unit immune to aura
|
||||||
if (HasAttribute(SpellAttr1.ImmunityPurgesEffect) && CanSpellProvideImmunityAgainstAura(auraSpellInfo))
|
if (HasAttribute(SpellAttr1.ImmunityPurgesEffect) && CanSpellProvideImmunityAgainstAura(auraSpellInfo))
|
||||||
return true;
|
return true;
|
||||||
@@ -704,15 +686,6 @@ namespace Game.Spells
|
|||||||
if (auraSpellInfo.HasAttribute(SpellAttr0.NoImmunities))
|
if (auraSpellInfo.HasAttribute(SpellAttr0.NoImmunities))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// These spells (like Mass Dispel) can dispel all auras
|
|
||||||
if (HasAttribute(SpellAttr0.NoImmunities))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// These auras (Cyclone for example) are not dispelable
|
|
||||||
if ((auraSpellInfo.HasAttribute(SpellAttr1.ImmunityToHostileAndFriendlyEffects) && auraSpellInfo.Mechanic != Mechanics.None)
|
|
||||||
|| auraSpellInfo.HasAttribute(SpellAttr2.NoSchoolImmunities))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2331,11 +2304,21 @@ namespace Game.Spells
|
|||||||
target.RemoveAppliedAuras(aurApp =>
|
target.RemoveAppliedAuras(aurApp =>
|
||||||
{
|
{
|
||||||
SpellInfo auraSpellInfo = aurApp.GetBase().GetSpellInfo();
|
SpellInfo auraSpellInfo = aurApp.GetBase().GetSpellInfo();
|
||||||
return (((uint)auraSpellInfo.GetSchoolMask() & schoolImmunity) != 0 && // Check for school mask
|
if (auraSpellInfo.Id == Id) // Don't remove self
|
||||||
CanDispelAura(auraSpellInfo) &&
|
return false;
|
||||||
(IsPositive() != aurApp.IsPositive()) && // Check spell vs aura possitivity
|
if (auraSpellInfo.IsPassive()) // Don't remove passive auras
|
||||||
!auraSpellInfo.IsPassive() && // Don't remove passive auras
|
return false;
|
||||||
auraSpellInfo.Id != Id); // Don't remove self
|
if (((uint)auraSpellInfo.GetSchoolMask() & schoolImmunity) == 0) // Check for school mask
|
||||||
|
return false;
|
||||||
|
if (!CanDispelAura(auraSpellInfo))
|
||||||
|
return false;
|
||||||
|
if (!HasAttribute(SpellAttr1.ImmunityToHostileAndFriendlyEffects))
|
||||||
|
{
|
||||||
|
WorldObject existingAuraCaster = aurApp.GetBase().GetWorldObjectCaster();
|
||||||
|
if (existingAuraCaster != null && existingAuraCaster.IsFriendlyTo(target)) // Check spell vs aura possitivity
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2408,13 +2391,7 @@ namespace Game.Spells
|
|||||||
{
|
{
|
||||||
target.ApplySpellImmune(Id, SpellImmunity.State, auraType, apply);
|
target.ApplySpellImmune(Id, SpellImmunity.State, auraType, apply);
|
||||||
if (apply && HasAttribute(SpellAttr1.ImmunityPurgesEffect))
|
if (apply && HasAttribute(SpellAttr1.ImmunityPurgesEffect))
|
||||||
{
|
target.RemoveAurasByType(auraType, aurApp => CanDispelAura(aurApp.GetBase().GetSpellInfo()));
|
||||||
target.RemoveAurasByType(auraType, aurApp =>
|
|
||||||
{
|
|
||||||
// if the aura has SPELL_ATTR0_NO_IMMUNITIES, then it cannot be removed by immunity
|
|
||||||
return !aurApp.GetBase().GetSpellInfo().HasAttribute(SpellAttr0.NoImmunities);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (SpellEffectName effectType in immuneInfo.SpellEffectImmune)
|
foreach (SpellEffectName effectType in immuneInfo.SpellEffectImmune)
|
||||||
@@ -2437,7 +2414,7 @@ namespace Game.Spells
|
|||||||
|
|
||||||
ImmunityInfo immuneInfo = effectInfo.GetImmunityInfo();
|
ImmunityInfo immuneInfo = effectInfo.GetImmunityInfo();
|
||||||
|
|
||||||
if (!auraSpellInfo.HasAttribute(SpellAttr1.ImmunityToHostileAndFriendlyEffects) && !auraSpellInfo.HasAttribute(SpellAttr2.NoSchoolImmunities))
|
if (!auraSpellInfo.HasAttribute(SpellAttr2.NoSchoolImmunities))
|
||||||
{
|
{
|
||||||
uint schoolImmunity = immuneInfo.SchoolImmuneMask;
|
uint schoolImmunity = immuneInfo.SchoolImmuneMask;
|
||||||
if (schoolImmunity != 0)
|
if (schoolImmunity != 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user