Core/Spells: implement SpellInfo helper to filter for relevant mechanic immunities in spell_start packet
Port From (https://github.com/TrinityCore/TrinityCore/commit/60119ba8503e1b8e17d7163baf990022b2d25d41)
This commit is contained in:
@@ -3644,8 +3644,8 @@ namespace Game.Spells
|
|||||||
Unit unitCaster = m_caster.ToUnit();
|
Unit unitCaster = m_caster.ToUnit();
|
||||||
if (unitCaster != null)
|
if (unitCaster != null)
|
||||||
{
|
{
|
||||||
schoolImmunityMask = unitCaster.GetSchoolImmunityMask();
|
schoolImmunityMask = m_timer != 0 ? unitCaster.GetSchoolImmunityMask() : 0;
|
||||||
mechanicImmunityMask = unitCaster.GetMechanicImmunityMask();
|
mechanicImmunityMask = m_timer != 0 ? m_spellInfo.GetMechanicImmunityMask(unitCaster) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schoolImmunityMask != 0 || mechanicImmunityMask != 0)
|
if (schoolImmunityMask != 0 || mechanicImmunityMask != 0)
|
||||||
|
|||||||
@@ -2641,6 +2641,23 @@ namespace Game.Spells
|
|||||||
return _allowedMechanicMask;
|
return _allowedMechanicMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public uint GetMechanicImmunityMask(Unit caster)
|
||||||
|
{
|
||||||
|
uint casterMechanicImmunityMask = caster.GetMechanicImmunityMask();
|
||||||
|
uint mechanicImmunityMask = 0;
|
||||||
|
|
||||||
|
if (CanBeInterrupted(null, caster, true))
|
||||||
|
{
|
||||||
|
if ((casterMechanicImmunityMask & (1 << (int)Mechanics.Silence)) != 0)
|
||||||
|
mechanicImmunityMask |= (1 << (int)Mechanics.Silence);
|
||||||
|
|
||||||
|
if ((casterMechanicImmunityMask & (1 << (int)Mechanics.Interrupt)) != 0)
|
||||||
|
mechanicImmunityMask |= (1 << (int)Mechanics.Interrupt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mechanicImmunityMask;
|
||||||
|
}
|
||||||
|
|
||||||
public float GetMinRange(bool positive = false)
|
public float GetMinRange(bool positive = false)
|
||||||
{
|
{
|
||||||
if (RangeEntry == null)
|
if (RangeEntry == null)
|
||||||
@@ -3888,14 +3905,14 @@ namespace Game.Spells
|
|||||||
public bool HasAttribute(SpellAttr14 attribute) { return Convert.ToBoolean(AttributesEx14 & attribute); }
|
public bool HasAttribute(SpellAttr14 attribute) { return Convert.ToBoolean(AttributesEx14 & attribute); }
|
||||||
public bool HasAttribute(SpellCustomAttributes attribute) { return Convert.ToBoolean(AttributesCu & attribute); }
|
public bool HasAttribute(SpellCustomAttributes attribute) { return Convert.ToBoolean(AttributesCu & attribute); }
|
||||||
|
|
||||||
public bool CanBeInterrupted(WorldObject interruptCaster, Unit interruptTarget)
|
public bool CanBeInterrupted(WorldObject interruptCaster, Unit interruptTarget, bool ignoreImmunity = false)
|
||||||
{
|
{
|
||||||
return HasAttribute(SpellAttr7.CanAlwaysBeInterrupted)
|
return HasAttribute(SpellAttr7.CanAlwaysBeInterrupted)
|
||||||
|| HasChannelInterruptFlag(SpellAuraInterruptFlags.Damage | SpellAuraInterruptFlags.EnteringCombat)
|
|| HasChannelInterruptFlag(SpellAuraInterruptFlags.Damage | SpellAuraInterruptFlags.EnteringCombat)
|
||||||
|| (interruptTarget.IsPlayer() && InterruptFlags.HasFlag(SpellInterruptFlags.DamageCancelsPlayerOnly))
|
|| (interruptTarget.IsPlayer() && InterruptFlags.HasFlag(SpellInterruptFlags.DamageCancelsPlayerOnly))
|
||||||
|| InterruptFlags.HasFlag(SpellInterruptFlags.DamageCancels)
|
|| InterruptFlags.HasFlag(SpellInterruptFlags.DamageCancels)
|
||||||
|| interruptCaster.IsUnit() && interruptCaster.ToUnit().HasAuraTypeWithMiscvalue(AuraType.AllowInterruptSpell, (int)Id)
|
|| (interruptCaster != null && interruptCaster.IsUnit() && interruptCaster.ToUnit().HasAuraTypeWithMiscvalue(AuraType.AllowInterruptSpell, (int)Id))
|
||||||
|| ((interruptTarget.GetMechanicImmunityMask() & (1 << (int)Mechanics.Interrupt)) == 0
|
|| (((interruptTarget.GetMechanicImmunityMask() & (1 << (int)Mechanics.Interrupt)) == 0 || ignoreImmunity)
|
||||||
&& !interruptTarget.HasAuraTypeWithAffectMask(AuraType.PreventInterrupt, this)
|
&& !interruptTarget.HasAuraTypeWithAffectMask(AuraType.PreventInterrupt, this)
|
||||||
&& PreventionType.HasAnyFlag(SpellPreventionType.Silence));
|
&& PreventionType.HasAnyFlag(SpellPreventionType.Silence));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user