From 55dc4a7da52a35a110fb14e0fb5d65511921c811 Mon Sep 17 00:00:00 2001 From: mark1145 Date: Fri, 28 Apr 2023 16:12:07 +1000 Subject: [PATCH] fix: Fixes casting by sending ParalyzeFlag to client while animating (#1397) --- Projects/Server/Interfaces.cs | 1 + Projects/Server/Mobiles/Mobile.cs | 2 +- .../Items/Weapons/Ranged/BaseRanged.cs | 3 +- Projects/UOContent/Spells/Base/Spell.cs | 42 ++++++++++++------- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Projects/Server/Interfaces.cs b/Projects/Server/Interfaces.cs index 9bd96f661..ffdb6bf33 100644 --- a/Projects/Server/Interfaces.cs +++ b/Projects/Server/Interfaces.cs @@ -33,6 +33,7 @@ public interface IHued public interface ISpell { + bool BlocksMovement { get; } bool IsCasting { get; } void OnCasterHurt(); void OnCasterKilled(); diff --git a/Projects/Server/Mobiles/Mobile.cs b/Projects/Server/Mobiles/Mobile.cs index 754f6540c..33504bed9 100644 --- a/Projects/Server/Mobiles/Mobile.cs +++ b/Projects/Server/Mobiles/Mobile.cs @@ -6959,7 +6959,7 @@ public class Mobile : IHued, IComparable, ISpawnable, IObjectPropertyLis { var flags = 0x0; - if (m_Paralyzed || m_Frozen) + if (m_Paralyzed || m_Frozen || m_Spell?.BlocksMovement == true) { flags |= 0x01; } diff --git a/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs b/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs index 884cd0657..b595448cc 100644 --- a/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs +++ b/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs @@ -54,7 +54,8 @@ namespace Server.Items if (canSwing) { - canSwing = attacker.Spell is not Spell sp || !sp.IsCasting || !sp.BlocksMovement; + // On OSI you can swing + hold a cast at the same time + canSwing = attacker.Spell is not Spell { IsCasting: true, BlocksMovement: true }; } } diff --git a/Projects/UOContent/Spells/Base/Spell.cs b/Projects/UOContent/Spells/Base/Spell.cs index f78d508b1..3f50ee9d4 100644 --- a/Projects/UOContent/Spells/Base/Spell.cs +++ b/Projects/UOContent/Spells/Base/Spell.cs @@ -64,7 +64,7 @@ namespace Server.Spells public virtual bool BlockedByHorrificBeast => true; public virtual bool BlockedByAnimalForm => true; - public virtual bool BlocksMovement => true; + public virtual bool BlocksMovement => IsCasting; public virtual bool CheckNextSpellTime => Scroll is not BaseWand; @@ -145,6 +145,8 @@ namespace Server.Spells { Caster.Spell = null; } + + Caster.Delta(MobileDelta.Flags); // Remove paralyze } public void StartDelayedDamageContext(Mobile m, Timer t) @@ -420,6 +422,8 @@ namespace Server.Spells { DoHurtFizzle(); } + + Caster.Delta(MobileDelta.Flags); // Remove paralyze } public virtual void DoHurtFizzle() @@ -554,6 +558,8 @@ namespace Server.Spells WeaponAbility.ClearCurrentAbility(Caster); } + Caster.Delta(MobileDelta.Flags); // Start paralyze + _castTimer = new CastTimer(this, castDelay); // m_CastTimer.Start(); @@ -885,21 +891,23 @@ namespace Server.Spells protected override void OnTick() { - if (m_Spell.State != SpellState.Casting || m_Spell.Caster.Spell != m_Spell) + var caster = m_Spell.Caster; + + if (m_Spell.State != SpellState.Casting || caster.Spell != m_Spell) { Stop(); return; } - if (!m_Spell.Caster.Mounted && m_Spell.Info.Action >= 0) + if (!caster.Mounted && m_Spell.Info.Action >= 0) { - if (m_Spell.Caster.Body.IsHuman) + if (caster.Body.IsHuman) { - m_Spell.Caster.Animate(m_Spell.Info.Action, 7, 1, true, false, 0); + caster.Animate(m_Spell.Info.Action, 7, 1, true, false, 0); } - else if (m_Spell.Caster.Player && m_Spell.Caster.Body.IsMonster) + else if (caster.Player && caster.Body.IsMonster) { - m_Spell.Caster.Animate(12, 7, 1, true, false, 0); + caster.Animate(12, 7, 1, true, false, 0); } } @@ -921,27 +929,31 @@ namespace Server.Spells protected override void OnTick() { - if (m_Spell?.Caster == null) + var caster = m_Spell?.Caster; + + if (caster == null) { return; } - if (m_Spell.State == SpellState.Casting && m_Spell.Caster.Spell == m_Spell) + if (m_Spell.State == SpellState.Casting && caster.Spell == m_Spell) { m_Spell.State = SpellState.Sequencing; m_Spell._castTimer = null; - m_Spell.Caster.OnSpellCast(m_Spell); - m_Spell.Caster.Region?.OnSpellCast(m_Spell.Caster, m_Spell); - m_Spell.Caster.NextSpellTime = + caster.OnSpellCast(m_Spell); + caster.Region?.OnSpellCast(caster, m_Spell); + caster.NextSpellTime = Core.TickCount + (int)m_Spell.GetCastRecovery().TotalMilliseconds; // Spell.NextSpellDelay; - var originalTarget = m_Spell.Caster.Target; + caster.Delta(MobileDelta.Flags); // Update paralyze + + var originalTarget = caster.Target; m_Spell.OnCast(); - if (m_Spell.Caster.Player && m_Spell.Caster.Target != originalTarget) + if (caster.Player && caster.Target != originalTarget) { - m_Spell.Caster.Target?.BeginTimeout(m_Spell.Caster, 30000); // 30 seconds + caster.Target?.BeginTimeout(caster, 30000); // 30 seconds } m_Spell._castTimer = null;