From 23ae7a3c26b4bc898fbe754b5427ae0ce3a51fd6 Mon Sep 17 00:00:00 2001 From: mark1145 Date: Wed, 17 Aug 2022 15:17:39 +1000 Subject: [PATCH] fix: Players casting is sometimes not disturbed (#1138) --- .../Mobiles/Animals/Mounts/Ethereals.cs | 11 ++------ Projects/UOContent/Skills/SpiritSpeak.cs | 11 ++------ Projects/UOContent/Spells/Base/Spell.cs | 27 +++++++------------ Projects/UOContent/Spells/Base/SpellState.cs | 17 ++++++------ 4 files changed, 22 insertions(+), 44 deletions(-) diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs b/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs index 079736046..2689dc4c8 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs @@ -386,15 +386,8 @@ namespace Server.Mobiles Disturb(DisturbType.Hurt, false); } - public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable) - { - if (type is DisturbType.EquipRequest or DisturbType.UseRequest /* || type == DisturbType.Hurt*/) - { - return false; - } - - return true; - } + public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable) => + type != DisturbType.EquipRequest && type != DisturbType.UseRequest; public override void DoHurtFizzle() { diff --git a/Projects/UOContent/Skills/SpiritSpeak.cs b/Projects/UOContent/Skills/SpiritSpeak.cs index 4a2ac0ab0..40932abf2 100644 --- a/Projects/UOContent/Skills/SpiritSpeak.cs +++ b/Projects/UOContent/Skills/SpiritSpeak.cs @@ -113,15 +113,8 @@ namespace Server.SkillHandlers base.OnDisturb(type, message); } - public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable) - { - if (type is DisturbType.EquipRequest or DisturbType.UseRequest) - { - return false; - } - - return true; - } + public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable) => + type != DisturbType.EquipRequest && type != DisturbType.UseRequest; public override void SayMantra() { diff --git a/Projects/UOContent/Spells/Base/Spell.cs b/Projects/UOContent/Spells/Base/Spell.cs index c7631a7ee..04da7be38 100644 --- a/Projects/UOContent/Spells/Base/Spell.cs +++ b/Projects/UOContent/Spells/Base/Spell.cs @@ -395,38 +395,31 @@ namespace Server.Spells return; } - if (!firstCircle && !Core.AOS && (this as MagerySpell)?.Circle == SpellCircle.First) + if (State == SpellState.None || !firstCircle && !Core.AOS && (this as MagerySpell)?.Circle == SpellCircle.First) { return; } + var wasCasting = IsCasting; // Copy SpellState before resetting it to none State = SpellState.None; Caster.Spell = null; - if (State == SpellState.Casting) - { - OnDisturb(type, true); + OnDisturb(type, wasCasting); + if (wasCasting) + { _castTimer?.Stop(); _animTimer?.Stop(); - - if (Core.AOS && Caster.Player && type == DisturbType.Hurt) - { - DoHurtFizzle(); - } - Caster.NextSpellTime = Core.TickCount + (int)GetDisturbRecovery().TotalMilliseconds; } - else if (State == SpellState.Sequencing) + else { - OnDisturb(type, false); - Target.Cancel(Caster); + } - if (Core.AOS && Caster.Player && type == DisturbType.Hurt) - { - DoHurtFizzle(); - } + if (Core.AOS && Caster.Player && type == DisturbType.Hurt) + { + DoHurtFizzle(); } } diff --git a/Projects/UOContent/Spells/Base/SpellState.cs b/Projects/UOContent/Spells/Base/SpellState.cs index f2f79dc91..f2262c3e7 100644 --- a/Projects/UOContent/Spells/Base/SpellState.cs +++ b/Projects/UOContent/Spells/Base/SpellState.cs @@ -1,13 +1,12 @@ -namespace Server.Spells +namespace Server.Spells; + +public enum SpellState { - public enum SpellState - { - None = 0, + None = 0, - Casting = - 1, // We are in the process of casting (that is, waiting GetCastTime() and doing animations). Spell casting may be interupted in this state. + // We are in the process of casting (that is, waiting GetCastTime() and doing animations). Spell casting may be interupted in this state. + Casting = 1, - Sequencing = - 2 // Casting completed, but the full spell sequence isn't. Usually waiting for a target response. Some actions are restricted in this state (using skills for example). - } + // Casting completed, but the full spell sequence isn't. Usually waiting for a target response. Some actions are restricted in this state (using skills for example). + Sequencing = 2 }