Core/Spells: Updated silence flags for 9.0 and rename unit flag to its new meaning

Port From (https://github.com/TrinityCore/TrinityCore/commit/3400c5a52c8ea35e56d57326f904dc0127c33048)
This commit is contained in:
hondacrx
2023-03-13 02:36:50 -04:00
parent 1e8a62fb26
commit cd249ac67a
6 changed files with 19 additions and 10 deletions
+2 -2
View File
@@ -48,7 +48,7 @@ namespace Framework.Constants
Looting = 0x400,
PetInCombat = 0x800,
PvpEnabling = 0x1000,
Silenced = 0x2000,
ForceNameplate = 0x2000,
CantSwim = 0x4000,
CanSwim = 0x8000, // shows swim animation in water
NonAttackable2 = 0x10000,
@@ -71,7 +71,7 @@ namespace Framework.Constants
Disallowed = (ServerControlled | NonAttackable | RemoveClientControl |
PlayerControlled | Rename | Preparation | /* UNIT_FLAG_UNK_6 | */
NotAttackable1 | Looting | PetInCombat | PvpEnabling |
Silenced | NonAttackable2 | Pacified | Stunned |
NonAttackable2 | Pacified | Stunned |
InCombat | OnTaxi | Disarmed | Confused | Fleeing |
Possessed | Skinnable | Mount | Unk28 |
PreventEmotesFromChatText | Sheathe | Immune),
+1 -1
View File
@@ -258,7 +258,7 @@ namespace Game.AI
return null;
//Silenced so we can't cast
if (me.HasUnitFlag(UnitFlags.Silenced))
if (me.IsSilenced(school != 0 ? school : SpellSchoolMask.Magic))
return null;
//Using the extended script system we first create a list of viable spells
+1 -1
View File
@@ -5569,7 +5569,7 @@ namespace Game.Entities
// cleanup unit flags (will be re-applied if need at aura load).
RemoveUnitFlag(UnitFlags.NonAttackable | UnitFlags.RemoveClientControl | UnitFlags.NotAttackable1 |
UnitFlags.ImmuneToPc | UnitFlags.ImmuneToNpc | UnitFlags.Looting |
UnitFlags.PetInCombat | UnitFlags.Silenced | UnitFlags.Pacified |
UnitFlags.PetInCombat | UnitFlags.Pacified |
UnitFlags.Stunned | UnitFlags.InCombat | UnitFlags.Disarmed |
UnitFlags.Confused | UnitFlags.Fleeing | UnitFlags.Uninteractible |
UnitFlags.Skinnable | UnitFlags.Mount | UnitFlags.OnTaxi);
+6
View File
@@ -923,6 +923,12 @@ namespace Game.Entities
return base.GetCastSpellXSpellVisualId(spellInfo);
}
public bool IsSilenced(SpellSchoolMask schoolMask) { return (m_unitData.SilencedSchoolMask & (uint)schoolMask) != 0; }
public void SetSilencedSchoolMask(SpellSchoolMask schoolMask) { SetUpdateFieldFlagValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.SilencedSchoolMask), (uint)schoolMask); }
public void ReplaceAllSilencedSchoolMask(SpellSchoolMask schoolMask) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.SilencedSchoolMask), (uint)schoolMask); }
public SpellHistory GetSpellHistory() { return _spellHistory; }
public static ProcFlagsHit CreateProcHitMask(SpellNonMeleeDamage damageInfo, SpellMissInfo missCondition)
+8 -5
View File
@@ -1832,7 +1832,7 @@ namespace Game.Spells
if (apply)
{
target.SetUnitFlag(UnitFlags.Silenced);
target.SetSilencedSchoolMask((SpellSchoolMask)GetMiscValue());
// call functions which may have additional effects after changing state of unit
// Stop cast only spells vs PreventionType & SPELL_PREVENTION_TYPE_SILENCE
@@ -1847,11 +1847,14 @@ namespace Game.Spells
}
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target.HasAuraType(AuraType.ModSilence) || target.HasAuraType(AuraType.ModPacifySilence))
return;
int silencedSchoolMask = 0;
foreach (AuraEffect auraEffect in target.GetAuraEffectsByType(AuraType.ModSilence))
silencedSchoolMask |= auraEffect.GetMiscValue();
target.RemoveUnitFlag(UnitFlags.Silenced);
foreach (AuraEffect auraEffect in target.GetAuraEffectsByType(AuraType.ModPacifySilence))
silencedSchoolMask |= auraEffect.GetMiscValue();
target.ReplaceAllSilencedSchoolMask((SpellSchoolMask)silencedSchoolMask);
}
}
+1 -1
View File
@@ -5909,7 +5909,7 @@ namespace Game.Spells
else if ((m_spellInfo.Mechanic & Mechanics.ImmuneShield) != 0 && m_caster.IsUnit() && m_caster.ToUnit().HasAuraWithMechanic(1 << (int)Mechanics.Banish))
result = SpellCastResult.Stunned;
}
else if (unitflag.HasAnyFlag(UnitFlags.Silenced) && m_spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Silence) && !CheckSpellCancelsSilence(ref param1))
else if (unitCaster.IsSilenced(m_spellSchoolMask) && (m_spellInfo.PreventionType & SpellPreventionType.Silence) != 0 && !CheckSpellCancelsSilence(ref param1))
result = SpellCastResult.Silenced;
else if (unitflag.HasAnyFlag(UnitFlags.Pacified) && m_spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Pacify) && !CheckSpellCancelsPacify(ref param1))
result = SpellCastResult.Pacified;