From b8ad5c671dc427ef4b9c4bf47357d2f25cdea96e Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:19:06 -0700 Subject: [PATCH] fix: Fixes double calls with Target cancel and spell sequences (#1840) ### Summary - Cleans up target cancellation being called incorrectly. - An invalid target type (which should never happen), now calls `OnTargetUntargetable` instead of `OnTargetCanceled` - Removes double calls to `FinishSequence` in Spells. --- Projects/Server/Targeting/Target.cs | 37 +++--- .../Skill Items/Tailor Items/Misc/Scissors.cs | 20 +-- .../Spells/Chivalry/CleanseByFire.cs | 2 - .../UOContent/Spells/Chivalry/CloseWounds.cs | 2 - .../UOContent/Spells/Chivalry/RemoveCurse.cs | 2 - .../Spells/Chivalry/SacredJourney.cs | 3 +- .../UOContent/Spells/Eighth/EnergyVortex.cs | 2 - .../UOContent/Spells/Eighth/Resurrection.cs | 2 - .../UOContent/Spells/Fifth/BladeSpirits.cs | 2 - .../UOContent/Spells/Fifth/DispelField.cs | 2 - .../UOContent/Spells/Fifth/MagicReflect.cs | 6 +- Projects/UOContent/Spells/Fifth/MindBlast.cs | 2 - Projects/UOContent/Spells/Fifth/Paralyze.cs | 2 - .../UOContent/Spells/Fifth/PoisonField.cs | 2 - Projects/UOContent/Spells/First/Clumsy.cs | 2 - Projects/UOContent/Spells/First/Feeblemind.cs | 2 - Projects/UOContent/Spells/First/Heal.cs | 2 - Projects/UOContent/Spells/First/MagicArrow.cs | 2 - Projects/UOContent/Spells/First/NightSight.cs | 102 ++++++-------- Projects/UOContent/Spells/First/Weaken.cs | 2 - Projects/UOContent/Spells/Fourth/ArchCure.cs | 2 - .../UOContent/Spells/Fourth/ArchProtection.cs | 14 +- Projects/UOContent/Spells/Fourth/Curse.cs | 2 - Projects/UOContent/Spells/Fourth/FireField.cs | 2 - .../UOContent/Spells/Fourth/GreaterHeal.cs | 2 - Projects/UOContent/Spells/Fourth/Lightning.cs | 2 - Projects/UOContent/Spells/Fourth/ManaDrain.cs | 2 - Projects/UOContent/Spells/Fourth/Recall.cs | 3 +- .../Spells/Mysticism/AnimatedWeaponSpell.cs | 4 +- .../Spells/Mysticism/BombardSpell.cs | 98 +++++++------- .../Spells/Mysticism/CleansingWindsSpell.cs | 4 +- .../Spells/Mysticism/EagleStrikeSpell.cs | 4 +- .../Spells/Mysticism/HailStormSpell.cs | 4 +- .../Spells/Mysticism/NetherCycloneSpell.cs | 4 +- .../Spells/Mysticism/SpellPlagueSpell.cs | 22 ++- .../Spells/Necromancy/BloodOathSpell.cs | 4 +- .../UOContent/Spells/Necromancy/CorpseSkin.cs | 4 +- .../UOContent/Spells/Necromancy/EvilOmen.cs | 4 +- .../UOContent/Spells/Necromancy/MindRot.cs | 4 +- .../UOContent/Spells/Necromancy/PainSpike.cs | 4 +- .../Spells/Necromancy/PoisonStrike.cs | 4 +- .../UOContent/Spells/Necromancy/Strangle.cs | 4 +- .../Spells/Necromancy/VengefulSpirit.cs | 4 +- .../UOContent/Spells/Ninjitsu/ShadowJump.cs | 4 +- Projects/UOContent/Spells/Second/Agility.cs | 2 - Projects/UOContent/Spells/Second/Cunning.cs | 2 - Projects/UOContent/Spells/Second/Cure.cs | 2 - Projects/UOContent/Spells/Second/Harm.cs | 2 - Projects/UOContent/Spells/Second/MagicTrap.cs | 2 - .../UOContent/Spells/Second/RemoveTrap.cs | 2 - Projects/UOContent/Spells/Second/Strength.cs | 2 - .../Spells/Seventh/ChainLightning.cs | 2 - .../UOContent/Spells/Seventh/EnergyField.cs | 2 - .../UOContent/Spells/Seventh/FlameStrike.cs | 2 - .../UOContent/Spells/Seventh/GateTravel.cs | 3 +- .../UOContent/Spells/Seventh/ManaVampire.cs | 2 - .../UOContent/Spells/Seventh/MassDispel.cs | 2 - .../UOContent/Spells/Seventh/MeteorSwarm.cs | 2 - Projects/UOContent/Spells/Sixth/Dispel.cs | 2 - Projects/UOContent/Spells/Sixth/EnergyBolt.cs | 2 - Projects/UOContent/Spells/Sixth/Explosion.cs | 4 +- .../UOContent/Spells/Sixth/Invisibility.cs | 2 - Projects/UOContent/Spells/Sixth/Mark.cs | 2 - Projects/UOContent/Spells/Sixth/MassCurse.cs | 2 - .../UOContent/Spells/Sixth/ParalyzeField.cs | 2 - Projects/UOContent/Spells/Sixth/Reveal.cs | 2 - .../Spells/Spellweaving/GiftOfLife.cs | 2 - .../Spells/Spellweaving/GiftOfRenewal.cs | 2 - .../Spells/Spellweaving/NatureFury.cs | 2 - .../Spells/Spellweaving/WordOfDeath.cs | 2 - .../Spells/Targeting/RecallSpellTarget.cs | 125 ++++++++---------- .../Spells/Targeting/SpellTargetMobile.cs | 2 +- Projects/UOContent/Spells/Third/Bless.cs | 2 - Projects/UOContent/Spells/Third/Fireball.cs | 2 - Projects/UOContent/Spells/Third/MagicLock.cs | 2 - Projects/UOContent/Spells/Third/Poison.cs | 2 - .../UOContent/Spells/Third/Telekinesis.cs | 2 - Projects/UOContent/Spells/Third/Teleport.cs | 2 - Projects/UOContent/Spells/Third/Unlock.cs | 2 - .../UOContent/Spells/Third/WallOfStone.cs | 8 +- 80 files changed, 201 insertions(+), 406 deletions(-) diff --git a/Projects/Server/Targeting/Target.cs b/Projects/Server/Targeting/Target.cs index 728300827..bf263b156 100644 --- a/Projects/Server/Targeting/Target.cs +++ b/Projects/Server/Targeting/Target.cs @@ -38,7 +38,7 @@ public abstract class Target public static void Cancel(Mobile m) { m.NetState.SendCancelTarget(); - m.Target?.OnTargetCancel(m, TargetCancelType.Canceled); + m.Target?.Cancel(m, TargetCancelType.Canceled); } public void BeginTimeout(Mobile from, long delay) @@ -57,15 +57,14 @@ public abstract class Target m_TimeoutTimer = null; } - public void Timeout(Mobile from) + public void Timeout(Mobile m) { + m.NetState.SendCancelTarget(); CancelTimeout(); - from.ClearTarget(); + m.ClearTarget(); - Cancel(from); - - OnTargetCancel(from, TargetCancelType.Timeout); - OnTargetFinish(from); + OnTargetCancel(m, TargetCancelType.Timeout); + OnTargetFinish(m); } public virtual void SendTargetTo(NetState ns) => ns.SendTargetReq(this); @@ -84,7 +83,6 @@ public abstract class Target if (!AllowGround) { // We should actually never get here. If we do, it's probably a misbehaving client/macro. - OnTargetCancel(from, TargetCancelType.Canceled); return false; } @@ -161,7 +159,7 @@ public abstract class Target Map map = null; Item item = null; Mobile mobile = null; - bool isValidTargetType = true; + var isValidTargetType = true; bool valid = targeted switch { @@ -176,13 +174,10 @@ public abstract class Target { if (!isValidTargetType) { - OnTargetCancel(from, TargetCancelType.Canceled); + OnTargetUntargetable(from, targeted); } - - OnTargetFinish(from); } - - if (map == null || map != from.Map || Range >= 0 && !from.InRange(loc, Range)) + else if (map == null || map != from.Map || Range >= 0 && !from.InRange(loc, Range)) { OnTargetOutOfRange(from, targeted); } @@ -206,7 +201,7 @@ public abstract class Target { OnTargetUntargetable(from, targeted); } - else if (mobile?.CheckTarget(from, this, mobile) == false) + else if (mobile?.CheckTarget(from, this, targeted) == false) { OnTargetUntargetable(from, mobile); } @@ -271,20 +266,20 @@ public abstract class Target private class TimeoutTimer : Timer { - private readonly Mobile m_Mobile; - private readonly Target m_Target; + private readonly Mobile _mobile; + private readonly Target _target; public TimeoutTimer(Target target, Mobile m, TimeSpan delay) : base(delay) { - m_Target = target; - m_Mobile = m; + _target = target; + _mobile = m; } protected override void OnTick() { - if (m_Mobile.Target == m_Target) + if (_mobile.Target == _target) { - m_Target.Timeout(m_Mobile); + _target.Timeout(_mobile); } } } diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs index 8880cdc60..afd5b9e23 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs @@ -59,19 +59,9 @@ public partial class Scissors : Item // Didn't your parents ever tell you not to run with scissors in your hand?! from.SendLocalizedMessage(1063305); } - else if (targeted is Item item && !item.Movable) + else if (targeted is Item item and IScissorable scissorable && (targeted is PlagueBeastInnard or PlagueBeastMutationCore || item.Movable)) { - if (item is IScissorable obj && obj is PlagueBeastInnard or PlagueBeastMutationCore) - { - if (CanScissor(from, obj) && obj.Scissor(from, m_Item)) - { - from.PlaySound(0x248); - } - } - } - else if (targeted is IScissorable obj) - { - if (CanScissor(from, obj) && obj.Scissor(from, m_Item)) + if (CanScissor(from, scissorable) && scissorable.Scissor(from, m_Item)) { from.PlaySound(0x248); } @@ -84,13 +74,15 @@ public partial class Scissors : Item protected override void OnNonlocalTarget(Mobile from, object targeted) { - if (targeted is not (IScissorable obj and (PlagueBeastInnard or PlagueBeastMutationCore))) + if (targeted is not PlagueBeastInnard and not PlagueBeastMutationCore) { base.OnNonlocalTarget(from, targeted); return; } - if (CanScissor(from, obj) && obj.Scissor(from, m_Item)) + var scissorable = (IScissorable)targeted; + + if (CanScissor(from, scissorable) && scissorable.Scissor(from, m_Item)) { from.PlaySound(0x248); } diff --git a/Projects/UOContent/Spells/Chivalry/CleanseByFire.cs b/Projects/UOContent/Spells/Chivalry/CleanseByFire.cs index e184d2b9e..20f7add6c 100644 --- a/Projects/UOContent/Spells/Chivalry/CleanseByFire.cs +++ b/Projects/UOContent/Spells/Chivalry/CleanseByFire.cs @@ -98,8 +98,6 @@ namespace Server.Spells.Chivalry AOS.Damage(Caster, Caster, damage, 0, 100, 0, 0, 0, true); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Chivalry/CloseWounds.cs b/Projects/UOContent/Spells/Chivalry/CloseWounds.cs index 0316d8db6..4e5fb00b5 100644 --- a/Projects/UOContent/Spells/Chivalry/CloseWounds.cs +++ b/Projects/UOContent/Spells/Chivalry/CloseWounds.cs @@ -78,8 +78,6 @@ namespace Server.Spells.Chivalry m.FixedParticles(0x376A, 1, 62, 9923, 3, 3, EffectLayer.Waist); m.FixedParticles(0x3779, 1, 46, 9502, 5, 3, EffectLayer.Waist); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Chivalry/RemoveCurse.cs b/Projects/UOContent/Spells/Chivalry/RemoveCurse.cs index 43c582331..667470005 100644 --- a/Projects/UOContent/Spells/Chivalry/RemoveCurse.cs +++ b/Projects/UOContent/Spells/Chivalry/RemoveCurse.cs @@ -124,8 +124,6 @@ namespace Server.Spells.Chivalry m.PlaySound(0x1DF); } } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Chivalry/SacredJourney.cs b/Projects/UOContent/Spells/Chivalry/SacredJourney.cs index ef3d71bc5..38dd6ff2c 100644 --- a/Projects/UOContent/Spells/Chivalry/SacredJourney.cs +++ b/Projects/UOContent/Spells/Chivalry/SacredJourney.cs @@ -109,8 +109,6 @@ namespace Server.Spells.Chivalry Caster.MoveToWorld(loc, map); Caster.PlaySound(0x1FC); } - - FinishSequence(); } public override void OnCast() @@ -122,6 +120,7 @@ namespace Server.Spells.Chivalry else { Effect(m_Entry.Location, m_Entry.Map, true); + FinishSequence(); } } diff --git a/Projects/UOContent/Spells/Eighth/EnergyVortex.cs b/Projects/UOContent/Spells/Eighth/EnergyVortex.cs index 7225a511c..13b20ea74 100644 --- a/Projects/UOContent/Spells/Eighth/EnergyVortex.cs +++ b/Projects/UOContent/Spells/Eighth/EnergyVortex.cs @@ -40,8 +40,6 @@ namespace Server.Spells.Eighth BaseCreature.Summon(new EnergyVortex(), false, Caster, new Point3D(p), 0x212, duration); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Eighth/Resurrection.cs b/Projects/UOContent/Spells/Eighth/Resurrection.cs index 2bda277a0..96f7dd2be 100644 --- a/Projects/UOContent/Spells/Eighth/Resurrection.cs +++ b/Projects/UOContent/Spells/Eighth/Resurrection.cs @@ -64,8 +64,6 @@ namespace Server.Spells.Eighth m.CloseGump(); m.SendGump(new ResurrectGump(m, Caster)); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Fifth/BladeSpirits.cs b/Projects/UOContent/Spells/Fifth/BladeSpirits.cs index 82e94f9b7..2a6716664 100644 --- a/Projects/UOContent/Spells/Fifth/BladeSpirits.cs +++ b/Projects/UOContent/Spells/Fifth/BladeSpirits.cs @@ -37,8 +37,6 @@ namespace Server.Spells.Fifth var duration = TimeSpan.FromSeconds(Core.AOS ? 120 : Utility.Random(80, 40)); BaseCreature.Summon(new BladeSpirits(), false, Caster, new Point3D(p), 0x212, duration); } - - FinishSequence(); } public override TimeSpan GetCastDelay() diff --git a/Projects/UOContent/Spells/Fifth/DispelField.cs b/Projects/UOContent/Spells/Fifth/DispelField.cs index 2db3e4f5b..5b544c636 100644 --- a/Projects/UOContent/Spells/Fifth/DispelField.cs +++ b/Projects/UOContent/Spells/Fifth/DispelField.cs @@ -47,8 +47,6 @@ namespace Server.Spells.Fifth item.Delete(); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Fifth/MagicReflect.cs b/Projects/UOContent/Spells/Fifth/MagicReflect.cs index 17ae14a83..d7f56b3ab 100644 --- a/Projects/UOContent/Spells/Fifth/MagicReflect.cs +++ b/Projects/UOContent/Spells/Fifth/MagicReflect.cs @@ -99,8 +99,6 @@ namespace Server.Spells.Fifth BuffInfo.AddBuff(Caster, new BuffInfo(BuffIcon.MagicReflection, 1075817, buffFormat, true)); } } - - FinishSequence(); } else { @@ -129,9 +127,9 @@ namespace Server.Spells.Fifth Caster.SendLocalizedMessage(1005385); // The spell will not adhere to you at this time. } } - - FinishSequence(); } + + FinishSequence(); } public static void EndReflect(Mobile m) diff --git a/Projects/UOContent/Spells/Fifth/MindBlast.cs b/Projects/UOContent/Spells/Fifth/MindBlast.cs index a5e2644e0..2f980f65f 100644 --- a/Projects/UOContent/Spells/Fifth/MindBlast.cs +++ b/Projects/UOContent/Spells/Fifth/MindBlast.cs @@ -106,8 +106,6 @@ namespace Server.Spells.Fifth SpellHelper.Damage(this, target, damage, 0, 0, 100, 0, 0); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Fifth/Paralyze.cs b/Projects/UOContent/Spells/Fifth/Paralyze.cs index aa323e3c2..bb99cdb17 100644 --- a/Projects/UOContent/Spells/Fifth/Paralyze.cs +++ b/Projects/UOContent/Spells/Fifth/Paralyze.cs @@ -78,8 +78,6 @@ namespace Server.Spells.Fifth HarmfulSpell(m); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Fifth/PoisonField.cs b/Projects/UOContent/Spells/Fifth/PoisonField.cs index 65225dbaf..6bd9fc417 100644 --- a/Projects/UOContent/Spells/Fifth/PoisonField.cs +++ b/Projects/UOContent/Spells/Fifth/PoisonField.cs @@ -53,8 +53,6 @@ public class PoisonFieldSpell : MagerySpell, ISpellTargetingPoint3D new PoisonField(itemID, targetLoc, Caster, Caster.Map, duration, i); } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/First/Clumsy.cs b/Projects/UOContent/Spells/First/Clumsy.cs index 0626ce762..96632e0a4 100644 --- a/Projects/UOContent/Spells/First/Clumsy.cs +++ b/Projects/UOContent/Spells/First/Clumsy.cs @@ -43,8 +43,6 @@ namespace Server.Spells.First HarmfulSpell(m); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/First/Feeblemind.cs b/Projects/UOContent/Spells/First/Feeblemind.cs index ab0f8aa24..175aeeaff 100644 --- a/Projects/UOContent/Spells/First/Feeblemind.cs +++ b/Projects/UOContent/Spells/First/Feeblemind.cs @@ -45,8 +45,6 @@ namespace Server.Spells.First HarmfulSpell(m); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/First/Heal.cs b/Projects/UOContent/Spells/First/Heal.cs index b591a280e..024e899fc 100644 --- a/Projects/UOContent/Spells/First/Heal.cs +++ b/Projects/UOContent/Spells/First/Heal.cs @@ -69,8 +69,6 @@ namespace Server.Spells.First m.FixedParticles(0x376A, 9, 32, 5005, EffectLayer.Waist); m.PlaySound(0x1F2); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/First/MagicArrow.cs b/Projects/UOContent/Spells/First/MagicArrow.cs index 1461e3548..3ccff9163 100644 --- a/Projects/UOContent/Spells/First/MagicArrow.cs +++ b/Projects/UOContent/Spells/First/MagicArrow.cs @@ -64,8 +64,6 @@ namespace Server.Spells.First SpellHelper.Damage(this, m, damage, 0, 100, 0, 0, 0); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/First/NightSight.cs b/Projects/UOContent/Spells/First/NightSight.cs index d4aaffc65..1f47337bd 100644 --- a/Projects/UOContent/Spells/First/NightSight.cs +++ b/Projects/UOContent/Spells/First/NightSight.cs @@ -1,80 +1,58 @@ using System; using Server.Targeting; -namespace Server.Spells.First +namespace Server.Spells.First; + +public class NightSightSpell : MagerySpell, ISpellTargetingMobile { - public class NightSightSpell : MagerySpell + private static readonly SpellInfo _info = new( + "Night Sight", + "In Lor", + 236, + 9031, + Reagent.SulfurousAsh, + Reagent.SpidersSilk + ); + + public NightSightSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info) { - private static readonly SpellInfo _info = new( - "Night Sight", - "In Lor", - 236, - 9031, - Reagent.SulfurousAsh, - Reagent.SpidersSilk - ); + } - public NightSightSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info) + public override SpellCircle Circle => SpellCircle.First; + + public override void OnCast() + { + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, 12); + } + + public void Target(Mobile m) + { + if (CheckBSequence(m)) { - } + SpellHelper.Turn(Caster, m); - public override SpellCircle Circle => SpellCircle.First; - - public override void OnCast() - { - Caster.Target = new NightSightTarget(this); - } - - private class NightSightTarget : Target - { - private readonly Spell m_Spell; - - public NightSightTarget(Spell spell) : base(12, false, TargetFlags.Beneficial) => m_Spell = spell; - - protected override void OnTarget(Mobile from, object targeted) + if (m.BeginAction()) { - if (targeted is Mobile targ && m_Spell.CheckBSequence(targ)) - { - SpellHelper.Turn(m_Spell.Caster, targ); + new LightCycle.NightSightTimer(m).Start(); - if (targ.BeginAction()) - { - new LightCycle.NightSightTimer(targ).Start(); - var level = - (int)(LightCycle.DungeonLevel * - ((Core.AOS - ? targ.Skills.Magery.Value - : from.Skills.Magery.Value) / 100)); + var skill = (Core.AOS ? m.Skills.Magery.Value : Caster.Skills.Magery.Value) / 100; + var level = (int)(LightCycle.DungeonLevel * skill); - targ.LightLevel = Math.Max(level, 0); + m.LightLevel = Math.Max(level, 0); - targ.FixedParticles(0x376A, 9, 32, 5007, EffectLayer.Waist); - targ.PlaySound(0x1E3); + m.FixedParticles(0x376A, 9, 32, 5007, EffectLayer.Waist); + m.PlaySound(0x1E3); - BuffInfo.AddBuff( - targ, - new BuffInfo(BuffIcon.NightSight, 1075643) - ); // Night Sight/You ignore lighting effects - } - else - { - if (from == targ) - { - from.SendMessage("You already have nightsight."); - } - else - { - from.SendMessage("They already have nightsight."); - } - } - } - - m_Spell.FinishSequence(); + // Night Sight/You ignore lighting effects + BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.NightSight, 1075643)); } - - protected override void OnTargetFinish(Mobile from) + else if (m == Caster) { - m_Spell.FinishSequence(); + m.SendMessage("You already have nightsight."); + } + else + { + m.SendMessage("They already have nightsight."); } } } diff --git a/Projects/UOContent/Spells/First/Weaken.cs b/Projects/UOContent/Spells/First/Weaken.cs index 5af8168f5..2379b0fe0 100644 --- a/Projects/UOContent/Spells/First/Weaken.cs +++ b/Projects/UOContent/Spells/First/Weaken.cs @@ -43,8 +43,6 @@ namespace Server.Spells.First HarmfulSpell(m); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Fourth/ArchCure.cs b/Projects/UOContent/Spells/Fourth/ArchCure.cs index 1ae41eb84..116eb3c09 100644 --- a/Projects/UOContent/Spells/Fourth/ArchCure.cs +++ b/Projects/UOContent/Spells/Fourth/ArchCure.cs @@ -91,8 +91,6 @@ namespace Server.Spells.Fourth } } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Fourth/ArchProtection.cs b/Projects/UOContent/Spells/Fourth/ArchProtection.cs index 38247f2dc..d16c47c6e 100644 --- a/Projects/UOContent/Spells/Fourth/ArchProtection.cs +++ b/Projects/UOContent/Spells/Fourth/ArchProtection.cs @@ -29,10 +29,14 @@ namespace Server.Spells.Fourth public void Target(IPoint3D p) { + if (Caster.Map == null) + { + return; + } + if (CheckSequence()) { SpellHelper.Turn(Caster, p); - SpellHelper.GetSurfaceTop(ref p); var loc = new Point3D(p); @@ -42,12 +46,6 @@ namespace Server.Spells.Fourth Effects.PlaySound(loc, Caster.Map, 0x299); } - if (Caster.Map == null) - { - FinishSequence(); - return; - } - using var targets = PooledRefQueue.Create(); foreach (var m in Caster.Map.GetMobilesInRange(loc, Core.AOS ? 2 : 3)) { @@ -92,8 +90,6 @@ namespace Server.Spells.Fourth } } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Fourth/Curse.cs b/Projects/UOContent/Spells/Fourth/Curse.cs index 1eae9f935..5443057fc 100644 --- a/Projects/UOContent/Spells/Fourth/Curse.cs +++ b/Projects/UOContent/Spells/Fourth/Curse.cs @@ -101,8 +101,6 @@ namespace Server.Spells.Fourth DoHurtFizzle(); } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Fourth/FireField.cs b/Projects/UOContent/Spells/Fourth/FireField.cs index 9899f5291..efd172183 100644 --- a/Projects/UOContent/Spells/Fourth/FireField.cs +++ b/Projects/UOContent/Spells/Fourth/FireField.cs @@ -56,8 +56,6 @@ public class FireFieldSpell : MagerySpell, ISpellTargetingPoint3D new FireFieldItem(itemID, targetLoc, Caster, Caster.Map, duration, i); } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Fourth/GreaterHeal.cs b/Projects/UOContent/Spells/Fourth/GreaterHeal.cs index a7e969347..d030f9739 100644 --- a/Projects/UOContent/Spells/Fourth/GreaterHeal.cs +++ b/Projects/UOContent/Spells/Fourth/GreaterHeal.cs @@ -57,8 +57,6 @@ namespace Server.Spells.Fourth m.FixedParticles(0x376A, 9, 32, 5030, EffectLayer.Waist); m.PlaySound(0x202); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Fourth/Lightning.cs b/Projects/UOContent/Spells/Fourth/Lightning.cs index 63eb3455c..07f40d73a 100644 --- a/Projects/UOContent/Spells/Fourth/Lightning.cs +++ b/Projects/UOContent/Spells/Fourth/Lightning.cs @@ -53,8 +53,6 @@ namespace Server.Spells.Fourth SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 100); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Fourth/ManaDrain.cs b/Projects/UOContent/Spells/Fourth/ManaDrain.cs index 05c48c197..3164e69f9 100644 --- a/Projects/UOContent/Spells/Fourth/ManaDrain.cs +++ b/Projects/UOContent/Spells/Fourth/ManaDrain.cs @@ -73,8 +73,6 @@ namespace Server.Spells.Fourth HarmfulSpell(m); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Fourth/Recall.cs b/Projects/UOContent/Spells/Fourth/Recall.cs index 37887a64e..5bd59340a 100644 --- a/Projects/UOContent/Spells/Fourth/Recall.cs +++ b/Projects/UOContent/Spells/Fourth/Recall.cs @@ -101,8 +101,6 @@ namespace Server.Spells.Fourth Caster.MoveToWorld(loc, map); Caster.PlaySound(0x1FC); } - - FinishSequence(); } public override void GetCastSkills(out double min, out double max) @@ -130,6 +128,7 @@ namespace Server.Spells.Fourth else { Effect(m_Entry.Location, m_Entry.Map, true); + FinishSequence(); } } diff --git a/Projects/UOContent/Spells/Mysticism/AnimatedWeaponSpell.cs b/Projects/UOContent/Spells/Mysticism/AnimatedWeaponSpell.cs index 5d39f1bfc..8bfed5c94 100644 --- a/Projects/UOContent/Spells/Mysticism/AnimatedWeaponSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/AnimatedWeaponSpell.cs @@ -51,12 +51,10 @@ public class AnimatedWeaponSpell : MysticSpell, ISpellTargetingPoint3D Effects.SendTargetParticles(summon, 0x3728, 10, 10, 0x13AA, (EffectLayer)255); } - - FinishSequence(); } public override void OnCast() { Caster.Target = new SpellTargetPoint3D(this); } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Mysticism/BombardSpell.cs b/Projects/UOContent/Spells/Mysticism/BombardSpell.cs index 89b8d45fc..1ec7e8fd2 100644 --- a/Projects/UOContent/Spells/Mysticism/BombardSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/BombardSpell.cs @@ -26,63 +26,61 @@ public class BombardSpell : MysticSpell, ISpellTargetingMobile public override void OnCast() { - Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful); - } + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful); + } public void Target(Mobile m) { - if (CheckHSequence(m)) + if (CheckHSequence(m)) + { + SpellHelper.Turn(Caster, m); + + if (HasDelayedDamageContext(m)) { - SpellHelper.Turn(Caster, m); + DoHurtFizzle(); + return; + } - if (HasDelayedDamageContext(m)) + var source = Caster; + + if (SpellHelper.CheckReflect(6, ref source, ref m)) + { + Timer.StartTimer(TimeSpan.FromSeconds(0.5), () => { - DoHurtFizzle(); - return; - } - - var source = Caster; - - if (SpellHelper.CheckReflect(6, ref source, ref m)) - { - Timer.StartTimer(TimeSpan.FromSeconds(0.5), () => - { - source.MovingEffect(m, 0x1363, 12, 1, false, true, 0, 0); - source.PlaySound(0x64B); - }); - } - - Caster.MovingEffect(m, 0x1363, 12, 1, false, true, 0, 0); - Caster.PlaySound(0x64B); - - SpellHelper.Damage(this, m, GetNewAosDamage(40, 1, 5, m), 100, 0, 0, 0, 0); - - Timer.StartTimer(TimeSpan.FromSeconds(1.2), () => - { - if (CheckResisted(m)) - { - return; - } - - var damageSkill = GetDamageSkill(Caster); - var resist = GetResistSkill(m); - - int secs = Math.Max(0, (int)(damageSkill / 10 - resist / 10)); - - if (secs > 0) - { - m.Paralyze(TimeSpan.FromSeconds(secs)); - } - - // Up to 12% chance by checking mysticism + imbuing/focus against resist - var knockBackChance = (GetBaseSkill(Caster) + damageSkill - resist) / 20; - if (knockBackChance > 0 && Utility.RandomDouble() < knockBackChance) - { - m.Move(Caster.GetDirectionTo(m)); - } + source.MovingEffect(m, 0x1363, 12, 1, false, true, 0, 0); + source.PlaySound(0x64B); }); } - FinishSequence(); + Caster.MovingEffect(m, 0x1363, 12, 1, false, true, 0, 0); + Caster.PlaySound(0x64B); + + SpellHelper.Damage(this, m, GetNewAosDamage(40, 1, 5, m), 100, 0, 0, 0, 0); + + Timer.StartTimer(TimeSpan.FromSeconds(1.2), () => + { + if (CheckResisted(m)) + { + return; + } + + var damageSkill = GetDamageSkill(Caster); + var resist = GetResistSkill(m); + + int secs = Math.Max(0, (int)(damageSkill / 10 - resist / 10)); + + if (secs > 0) + { + m.Paralyze(TimeSpan.FromSeconds(secs)); + } + + // Up to 12% chance by checking mysticism + imbuing/focus against resist + var knockBackChance = (GetBaseSkill(Caster) + damageSkill - resist) / 20; + if (knockBackChance > 0 && Utility.RandomDouble() < knockBackChance) + { + m.Move(Caster.GetDirectionTo(m)); + } + }); } -} \ No newline at end of file + } +} diff --git a/Projects/UOContent/Spells/Mysticism/CleansingWindsSpell.cs b/Projects/UOContent/Spells/Mysticism/CleansingWindsSpell.cs index b888bc6fb..ebfe79f69 100644 --- a/Projects/UOContent/Spells/Mysticism/CleansingWindsSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/CleansingWindsSpell.cs @@ -129,8 +129,6 @@ public class CleansingWindsSpell : MysticSpell, ISpellTargetingMobile } } } - - FinishSequence(); } public static int RemoveCurses(Mobile m) @@ -212,4 +210,4 @@ public class CleansingWindsSpell : MysticSpell, ISpellTargetingMobile return curseLevel; } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs b/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs index 054e784f1..b541e22de 100644 --- a/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs @@ -51,8 +51,6 @@ public class EagleStrikeSpell : MysticSpell, ISpellTargetingMobile Timer.StartTimer(TimeSpan.FromSeconds(1.0), () => Damage(m)); } - - FinishSequence(); } public override void OnCast() @@ -73,4 +71,4 @@ public class EagleStrikeSpell : MysticSpell, ISpellTargetingMobile to.PlaySound(0x64D); } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs b/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs index bd89e9f44..c5327893c 100644 --- a/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs @@ -69,8 +69,6 @@ public class HailStormSpell : MysticSpell, ISpellTargetingPoint3D } } } - - FinishSequence(); } public override void OnCast() @@ -122,4 +120,4 @@ public class HailStormSpell : MysticSpell, ISpellTargetingPoint3D 0x4 ); } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs b/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs index 1a25e6e9b..9c193462c 100644 --- a/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs @@ -85,8 +85,6 @@ public class NetherCycloneSpell : MysticSpell, ISpellTargetingPoint3D } } } - - FinishSequence(); } public override void OnCast() @@ -136,4 +134,4 @@ public class NetherCycloneSpell : MysticSpell, ISpellTargetingPoint3D 0x4 ); } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs b/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs index 1b8126d9b..4dd0a7b2d 100644 --- a/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs @@ -35,13 +35,13 @@ public class SpellPlagueSpell : MysticSpell, ISpellTargetingMobile Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful); } - public void Target(Mobile targeted) + public void Target(Mobile m) { - if (CheckHSequence(targeted)) + if (CheckHSequence(m)) { - SpellHelper.Turn(Caster, targeted); + SpellHelper.Turn(Caster, m); - SpellHelper.CheckReflect(6, Caster, ref targeted); + SpellHelper.CheckReflect(6, Caster, ref m); /* The target is hit with an explosion of chaos damage and then inflicted * with the spell plague curse. Each time the target is damaged while under @@ -53,26 +53,24 @@ public class SpellPlagueSpell : MysticSpell, ISpellTargetingMobile * plagues so that they are applied one after the other. */ - VisualEffect(targeted); + VisualEffect(m); // Before Time of Legends, SDI was not applied to initial damage. - var damage = GetNewAosDamage(33, 1, 5, Core.TOL, targeted); - SpellHelper.Damage(this, targeted, damage, 0, 0, 0, 0, 0); + var damage = GetNewAosDamage(33, 1, 5, Core.TOL, m); + SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 0); - var timer = new SpellPlagueTimer(this, targeted); + var timer = new SpellPlagueTimer(this, m); - if (_table.TryGetValue(targeted, out var oldtimer)) + if (_table.TryGetValue(m, out var oldtimer)) { oldtimer.SetNext(timer); } else { - _table[targeted] = timer; + _table[m] = timer; timer.StartPlague(); } } - - FinishSequence(); } public static bool UnderEffect(Mobile m) => _table.ContainsKey(m); diff --git a/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs b/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs index 5129f7047..8068b172d 100644 --- a/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs +++ b/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs @@ -92,8 +92,6 @@ public class BloodOathSpell : NecromancerSpell, ISpellTargetingMobile _table[m] = timer; HarmfulSpell(m); } - - FinishSequence(); } public override void OnCast() @@ -156,4 +154,4 @@ public class BloodOathSpell : NecromancerSpell, ISpellTargetingMobile } } } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Necromancy/CorpseSkin.cs b/Projects/UOContent/Spells/Necromancy/CorpseSkin.cs index a495aeaef..5f2cb7336 100644 --- a/Projects/UOContent/Spells/Necromancy/CorpseSkin.cs +++ b/Projects/UOContent/Spells/Necromancy/CorpseSkin.cs @@ -91,8 +91,6 @@ public class CorpseSkinSpell : NecromancerSpell, ISpellTargetingMobile HarmfulSpell(m); } - - FinishSequence(); } public override void OnCast() @@ -141,4 +139,4 @@ public class CorpseSkinSpell : NecromancerSpell, ISpellTargetingMobile DoExpire(); } } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Necromancy/EvilOmen.cs b/Projects/UOContent/Spells/Necromancy/EvilOmen.cs index 506c08c16..fa40513dd 100644 --- a/Projects/UOContent/Spells/Necromancy/EvilOmen.cs +++ b/Projects/UOContent/Spells/Necromancy/EvilOmen.cs @@ -66,8 +66,6 @@ public class EvilOmenSpell : NecromancerSpell, ISpellTargetingMobile BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.EvilOmen, 1075647, 1075648, duration, m)); } - - FinishSequence(); } public override void OnCast() @@ -85,4 +83,4 @@ public class EvilOmenSpell : NecromancerSpell, ISpellTargetingMobile return false; } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Necromancy/MindRot.cs b/Projects/UOContent/Spells/Necromancy/MindRot.cs index 1aa3fafab..637881ea9 100644 --- a/Projects/UOContent/Spells/Necromancy/MindRot.cs +++ b/Projects/UOContent/Spells/Necromancy/MindRot.cs @@ -59,8 +59,6 @@ public class MindRotSpell : NecromancerSpell, ISpellTargetingMobile HarmfulSpell(m); } - - FinishSequence(); } public override void OnCast() @@ -133,4 +131,4 @@ public class MRExpireTimer : Timer Stop(); } } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Necromancy/PainSpike.cs b/Projects/UOContent/Spells/Necromancy/PainSpike.cs index a02cf03dd..7253bbd0c 100644 --- a/Projects/UOContent/Spells/Necromancy/PainSpike.cs +++ b/Projects/UOContent/Spells/Necromancy/PainSpike.cs @@ -81,8 +81,6 @@ public class PainSpikeSpell : NecromancerSpell, ISpellTargetingMobile // SpellHelper.Damage( this, m, damage, 100, 0, 0, 0, 0, Misc.DFAlgorithm.PainSpike ); HarmfulSpell(m); } - - FinishSequence(); } public override void OnCast() @@ -114,4 +112,4 @@ public class PainSpikeSpell : NecromancerSpell, ISpellTargetingMobile BuffInfo.RemoveBuff(_mobile, BuffIcon.PainSpike); } } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Necromancy/PoisonStrike.cs b/Projects/UOContent/Spells/Necromancy/PoisonStrike.cs index c561c35ba..26f0559e5 100644 --- a/Projects/UOContent/Spells/Necromancy/PoisonStrike.cs +++ b/Projects/UOContent/Spells/Necromancy/PoisonStrike.cs @@ -142,12 +142,10 @@ public class PoisonStrikeSpell : NecromancerSpell, ISpellTargetingMobile } } } - - FinishSequence(); } public override void OnCast() { Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Necromancy/Strangle.cs b/Projects/UOContent/Spells/Necromancy/Strangle.cs index 1d90ee364..645d050b4 100644 --- a/Projects/UOContent/Spells/Necromancy/Strangle.cs +++ b/Projects/UOContent/Spells/Necromancy/Strangle.cs @@ -107,8 +107,6 @@ public class StrangleSpell : NecromancerSpell, ISpellTargetingMobile var t_Duration = TimeSpan.FromSeconds(length); BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Strangle, 1075794, 1075795, t_Duration, m, args)); - - FinishSequence(); } public override void OnCast() @@ -226,4 +224,4 @@ public class StrangleSpell : NecromancerSpell, ISpellTargetingMobile } } } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Necromancy/VengefulSpirit.cs b/Projects/UOContent/Spells/Necromancy/VengefulSpirit.cs index 93806ef43..3a69ae0b4 100644 --- a/Projects/UOContent/Spells/Necromancy/VengefulSpirit.cs +++ b/Projects/UOContent/Spells/Necromancy/VengefulSpirit.cs @@ -62,8 +62,6 @@ public class VengefulSpiritSpell : NecromancerSpell, ISpellTargetingMobile rev.FixedParticles(0x373A, 1, 15, 9909, EffectLayer.Waist); } } - - FinishSequence(); } public override void OnCast() @@ -86,4 +84,4 @@ public class VengefulSpiritSpell : NecromancerSpell, ISpellTargetingMobile return true; } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Ninjitsu/ShadowJump.cs b/Projects/UOContent/Spells/Ninjitsu/ShadowJump.cs index e225a7102..7e37c4ff7 100644 --- a/Projects/UOContent/Spells/Ninjitsu/ShadowJump.cs +++ b/Projects/UOContent/Spells/Ninjitsu/ShadowJump.cs @@ -92,8 +92,6 @@ public class Shadowjump : NinjaSpell, ISpellTargetingPoint3D Stealth.OnUse(m); // stealth check after the shadow jump } - - FinishSequence(); } public override bool CheckCast() @@ -115,4 +113,4 @@ public class Shadowjump : NinjaSpell, ISpellTargetingPoint3D Caster.SendLocalizedMessage(1063088); // You prepare to perform a Shadowjump. Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, 11); } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Spells/Second/Agility.cs b/Projects/UOContent/Spells/Second/Agility.cs index 9479245be..fdef1bdec 100644 --- a/Projects/UOContent/Spells/Second/Agility.cs +++ b/Projects/UOContent/Spells/Second/Agility.cs @@ -36,8 +36,6 @@ namespace Server.Spells.Second BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Agility, 1075841, length, m, percentage.ToString())); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Second/Cunning.cs b/Projects/UOContent/Spells/Second/Cunning.cs index ad3aeac36..9ea4ca479 100644 --- a/Projects/UOContent/Spells/Second/Cunning.cs +++ b/Projects/UOContent/Spells/Second/Cunning.cs @@ -36,8 +36,6 @@ namespace Server.Spells.Second BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Cunning, 1075843, length, m, percentage.ToString())); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Second/Cure.cs b/Projects/UOContent/Spells/Second/Cure.cs index c6ffde6b9..9a3d1fc64 100644 --- a/Projects/UOContent/Spells/Second/Cure.cs +++ b/Projects/UOContent/Spells/Second/Cure.cs @@ -55,8 +55,6 @@ namespace Server.Spells.Second m.FixedParticles(0x373A, 10, 15, 5012, EffectLayer.Waist); m.PlaySound(0x1E0); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Second/Harm.cs b/Projects/UOContent/Spells/Second/Harm.cs index 25735664e..f9d5aee2c 100644 --- a/Projects/UOContent/Spells/Second/Harm.cs +++ b/Projects/UOContent/Spells/Second/Harm.cs @@ -71,8 +71,6 @@ namespace Server.Spells.Second SpellHelper.Damage(this, m, damage, 0, 0, 100, 0, 0); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Second/MagicTrap.cs b/Projects/UOContent/Spells/Second/MagicTrap.cs index baf6e346f..fd27ef98f 100644 --- a/Projects/UOContent/Spells/Second/MagicTrap.cs +++ b/Projects/UOContent/Spells/Second/MagicTrap.cs @@ -78,8 +78,6 @@ namespace Server.Spells.Second Effects.PlaySound(loc, item.Map, 0x1EF); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Second/RemoveTrap.cs b/Projects/UOContent/Spells/Second/RemoveTrap.cs index 085aa319f..70a72224e 100644 --- a/Projects/UOContent/Spells/Second/RemoveTrap.cs +++ b/Projects/UOContent/Spells/Second/RemoveTrap.cs @@ -48,8 +48,6 @@ namespace Server.Spells.Second cont.TrapPower = 0; cont.TrapLevel = 0; } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Second/Strength.cs b/Projects/UOContent/Spells/Second/Strength.cs index 22f665a45..e4f776a2d 100644 --- a/Projects/UOContent/Spells/Second/Strength.cs +++ b/Projects/UOContent/Spells/Second/Strength.cs @@ -36,8 +36,6 @@ namespace Server.Spells.Second BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Strength, 1075845, length, m, percentage.ToString())); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Seventh/ChainLightning.cs b/Projects/UOContent/Spells/Seventh/ChainLightning.cs index 49743de6e..9271d8590 100644 --- a/Projects/UOContent/Spells/Seventh/ChainLightning.cs +++ b/Projects/UOContent/Spells/Seventh/ChainLightning.cs @@ -95,8 +95,6 @@ namespace Server.Spells.Seventh } } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Seventh/EnergyField.cs b/Projects/UOContent/Spells/Seventh/EnergyField.cs index 55cbf1540..e48a4be4b 100644 --- a/Projects/UOContent/Spells/Seventh/EnergyField.cs +++ b/Projects/UOContent/Spells/Seventh/EnergyField.cs @@ -67,8 +67,6 @@ public class EnergyFieldSpell : MagerySpell, ISpellTargetingPoint3D ); } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Seventh/FlameStrike.cs b/Projects/UOContent/Spells/Seventh/FlameStrike.cs index 6a53b053a..47cdf1ebd 100644 --- a/Projects/UOContent/Spells/Seventh/FlameStrike.cs +++ b/Projects/UOContent/Spells/Seventh/FlameStrike.cs @@ -54,8 +54,6 @@ namespace Server.Spells.Seventh SpellHelper.Damage(this, m, damage, 0, 100, 0, 0, 0); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Seventh/GateTravel.cs b/Projects/UOContent/Spells/Seventh/GateTravel.cs index c113b9708..8fb3309b9 100644 --- a/Projects/UOContent/Spells/Seventh/GateTravel.cs +++ b/Projects/UOContent/Spells/Seventh/GateTravel.cs @@ -94,8 +94,6 @@ public class GateTravelSpell : MagerySpell, IRecallSpell firstGate.LinkedGate = secondGate; secondGate.LinkedGate = firstGate; } - - FinishSequence(); } public override void OnCast() @@ -107,6 +105,7 @@ public class GateTravelSpell : MagerySpell, IRecallSpell else { Effect(m_Entry.Location, m_Entry.Map, true); + FinishSequence(); } } diff --git a/Projects/UOContent/Spells/Seventh/ManaVampire.cs b/Projects/UOContent/Spells/Seventh/ManaVampire.cs index df565e7f7..7dcd95d3e 100644 --- a/Projects/UOContent/Spells/Seventh/ManaVampire.cs +++ b/Projects/UOContent/Spells/Seventh/ManaVampire.cs @@ -75,8 +75,6 @@ namespace Server.Spells.Seventh HarmfulSpell(m); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Seventh/MassDispel.cs b/Projects/UOContent/Spells/Seventh/MassDispel.cs index 1032d3916..2341279df 100644 --- a/Projects/UOContent/Spells/Seventh/MassDispel.cs +++ b/Projects/UOContent/Spells/Seventh/MassDispel.cs @@ -72,8 +72,6 @@ namespace Server.Spells.Seventh } } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs b/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs index 723ddba95..b0b27ead8 100644 --- a/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs +++ b/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs @@ -100,8 +100,6 @@ namespace Server.Spells.Seventh } } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Sixth/Dispel.cs b/Projects/UOContent/Spells/Sixth/Dispel.cs index b1ab2dbf3..3587aa10d 100644 --- a/Projects/UOContent/Spells/Sixth/Dispel.cs +++ b/Projects/UOContent/Spells/Sixth/Dispel.cs @@ -54,8 +54,6 @@ namespace Server.Spells.Sixth Caster.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it! } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Sixth/EnergyBolt.cs b/Projects/UOContent/Spells/Sixth/EnergyBolt.cs index d7723204b..62a0cbfef 100644 --- a/Projects/UOContent/Spells/Sixth/EnergyBolt.cs +++ b/Projects/UOContent/Spells/Sixth/EnergyBolt.cs @@ -59,8 +59,6 @@ namespace Server.Spells.Sixth // Deal the damage SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 100); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Sixth/Explosion.cs b/Projects/UOContent/Spells/Sixth/Explosion.cs index ea361cb44..1d9b3b2e5 100644 --- a/Projects/UOContent/Spells/Sixth/Explosion.cs +++ b/Projects/UOContent/Spells/Sixth/Explosion.cs @@ -39,10 +39,8 @@ namespace Server.Spells.Sixth SpellHelper.Turn(Caster, m); SpellHelper.CheckReflect((int)Circle, Caster, ref m); - var t = new InternalTimer(this, Caster, defender, m).Start(); + new InternalTimer(this, Caster, defender, m).Start(); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Sixth/Invisibility.cs b/Projects/UOContent/Spells/Sixth/Invisibility.cs index c40b4eac1..407948302 100644 --- a/Projects/UOContent/Spells/Sixth/Invisibility.cs +++ b/Projects/UOContent/Spells/Sixth/Invisibility.cs @@ -67,8 +67,6 @@ namespace Server.Spells.Sixth _table[m] = timerToken; } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Sixth/Mark.cs b/Projects/UOContent/Spells/Sixth/Mark.cs index 8df1892e7..23aaa8b07 100644 --- a/Projects/UOContent/Spells/Sixth/Mark.cs +++ b/Projects/UOContent/Spells/Sixth/Mark.cs @@ -55,8 +55,6 @@ namespace Server.Spells.Sixth Caster.PlaySound(0x1FA); Effects.SendLocationEffect(Caster, 14201, 16); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Sixth/MassCurse.cs b/Projects/UOContent/Spells/Sixth/MassCurse.cs index 634e13e1e..28e04183a 100644 --- a/Projects/UOContent/Spells/Sixth/MassCurse.cs +++ b/Projects/UOContent/Spells/Sixth/MassCurse.cs @@ -54,8 +54,6 @@ namespace Server.Spells.Sixth } } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Sixth/ParalyzeField.cs b/Projects/UOContent/Spells/Sixth/ParalyzeField.cs index baf1df872..5fd4dd211 100644 --- a/Projects/UOContent/Spells/Sixth/ParalyzeField.cs +++ b/Projects/UOContent/Spells/Sixth/ParalyzeField.cs @@ -67,8 +67,6 @@ public class ParalyzeFieldSpell : MagerySpell, ISpellTargetingPoint3D ); } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Sixth/Reveal.cs b/Projects/UOContent/Spells/Sixth/Reveal.cs index a7e8263c4..4cdff62ce 100644 --- a/Projects/UOContent/Spells/Sixth/Reveal.cs +++ b/Projects/UOContent/Spells/Sixth/Reveal.cs @@ -51,8 +51,6 @@ namespace Server.Spells.Sixth } } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Spellweaving/GiftOfLife.cs b/Projects/UOContent/Spells/Spellweaving/GiftOfLife.cs index 84bdb69ad..d2fef9604 100644 --- a/Projects/UOContent/Spells/Spellweaving/GiftOfLife.cs +++ b/Projects/UOContent/Spells/Spellweaving/GiftOfLife.cs @@ -68,8 +68,6 @@ namespace Server.Spells.Spellweaving BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.GiftOfLife, 1031615, 1075807, duration, m, null, true)); } - - FinishSequence(); } public static void Initialize() diff --git a/Projects/UOContent/Spells/Spellweaving/GiftOfRenewal.cs b/Projects/UOContent/Spells/Spellweaving/GiftOfRenewal.cs index f268b808a..1c34fcb11 100644 --- a/Projects/UOContent/Spells/Spellweaving/GiftOfRenewal.cs +++ b/Projects/UOContent/Spells/Spellweaving/GiftOfRenewal.cs @@ -65,8 +65,6 @@ namespace Server.Spells.Spellweaving ); } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Spellweaving/NatureFury.cs b/Projects/UOContent/Spells/Spellweaving/NatureFury.cs index aa751ce9e..4a2e3f6a5 100644 --- a/Projects/UOContent/Spells/Spellweaving/NatureFury.cs +++ b/Projects/UOContent/Spells/Spellweaving/NatureFury.cs @@ -51,8 +51,6 @@ namespace Server.Spells.Spellweaving new InternalTimer(nf).Start(); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Spellweaving/WordOfDeath.cs b/Projects/UOContent/Spells/Spellweaving/WordOfDeath.cs index 572b68073..6211f4e35 100644 --- a/Projects/UOContent/Spells/Spellweaving/WordOfDeath.cs +++ b/Projects/UOContent/Spells/Spellweaving/WordOfDeath.cs @@ -68,8 +68,6 @@ namespace Server.Spells.Spellweaving SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 0, 100); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Targeting/RecallSpellTarget.cs b/Projects/UOContent/Spells/Targeting/RecallSpellTarget.cs index 85d94be6c..2a7084a85 100644 --- a/Projects/UOContent/Spells/Targeting/RecallSpellTarget.cs +++ b/Projects/UOContent/Spells/Targeting/RecallSpellTarget.cs @@ -3,90 +3,73 @@ using Server.Multis; using Server.Network; using Server.Targeting; -namespace Server.Spells +namespace Server.Spells; + +public class RecallSpellTarget : Target { - public class RecallSpellTarget : Target + private readonly IRecallSpell _spell; + private readonly bool _toBoat; + + public RecallSpellTarget(IRecallSpell spell, bool toBoat = true) : base(Core.ML ? 10 : 12, false, TargetFlags.None) { - private readonly IRecallSpell _spell; - private readonly bool m_ToBoat; + _spell = spell; + _toBoat = toBoat; + _spell.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item. + } - public RecallSpellTarget(IRecallSpell spell, bool toBoat = true) : base(Core.ML ? 10 : 12, false, TargetFlags.None) + protected override void OnTarget(Mobile from, object o) + { + if (o is RecallRune rune) { - _spell = spell; - m_ToBoat = toBoat; - _spell.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item. + if (!rune.Marked) + { + from.SendLocalizedMessage(501805); // That rune is not yet marked. + return; + } + + _spell.Effect(rune.Target, rune.TargetMap, true); } - - protected override void OnTarget(Mobile from, object o) + else if (o is Runebook runebook) { - if (o is RecallRune rune) - { - if (rune.Marked) - { - _spell.Effect(rune.Target, rune.TargetMap, true); - } - else - { - from.SendLocalizedMessage(501805); // That rune is not yet marked. - } - } - else if (o is Runebook runebook) - { - var e = runebook.Default; + var e = runebook.Default; - if (e != null) - { - _spell.Effect(e.Location, e.Map, true); - } - else - { - from.SendLocalizedMessage(502354); // Target is not marked. - } - } - else if (m_ToBoat && o is Key key && key.KeyValue != 0 && key.Link is BaseBoat boat) + if (e == null) { - if (!boat.Deleted && boat.CheckKey(key.KeyValue)) - { - _spell.Effect(boat.GetMarkedLocation(), boat.Map, false); - } - else - { - from.NetState.SendMessageLocalized( - from.Serial, - from.Body, - MessageType.Regular, - 0x3B2, - 3, - 502357, // I can not recall from that object. - from.Name - ); - } - } - else if (o is HouseRaffleDeed deed && deed.ValidLocation()) - { - _spell.Effect(deed.PlotLocation, deed.PlotFacet, true); - } - else - { - from.NetState.SendMessageLocalized( - from.Serial, - from.Body, - MessageType.Regular, - 0x3B2, - 3, - 502357, // I can not recall from that object. - from.Name - ); + from.SendLocalizedMessage(502354); // Target is not marked. + return; } + + _spell.Effect(e.Location, e.Map, true); } - - protected override void OnNonlocalTarget(Mobile from, object o) + else if (_toBoat && o is Key key && key.KeyValue != 0 && key.Link is BaseBoat boat && !boat.Deleted && + boat.CheckKey(key.KeyValue)) { + _spell.Effect(boat.GetMarkedLocation(), boat.Map, false); } - - protected override void OnTargetFinish(Mobile from) + else if (o is HouseRaffleDeed deed && deed.ValidLocation()) { - _spell?.FinishSequence(); + _spell.Effect(deed.PlotLocation, deed.PlotFacet, true); + } + else + { + from.NetState.SendMessageLocalized( + from.Serial, + from.Body, + MessageType.Regular, + 0x3B2, + 3, + 502357, // I can not recall from that object. + from.Name + ); } } + + protected override void OnNonlocalTarget(Mobile from, object o) + { + } + + protected override void OnTargetFinish(Mobile from) + { + _spell?.FinishSequence(); + } } diff --git a/Projects/UOContent/Spells/Targeting/SpellTargetMobile.cs b/Projects/UOContent/Spells/Targeting/SpellTargetMobile.cs index c97511dcd..c6c413d13 100644 --- a/Projects/UOContent/Spells/Targeting/SpellTargetMobile.cs +++ b/Projects/UOContent/Spells/Targeting/SpellTargetMobile.cs @@ -4,7 +4,7 @@ namespace Server.Spells { public interface ISpellTargetingMobile : ISpell { - void Target(Mobile from); + void Target(Mobile m); } public class SpellTargetMobile : Target, ISpellTarget diff --git a/Projects/UOContent/Spells/Third/Bless.cs b/Projects/UOContent/Spells/Third/Bless.cs index 09ea960e7..b0d0dcfef 100644 --- a/Projects/UOContent/Spells/Third/Bless.cs +++ b/Projects/UOContent/Spells/Third/Bless.cs @@ -40,8 +40,6 @@ namespace Server.Spells.Third BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Bless, 1075847, 1075848, length, m, args)); } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Third/Fireball.cs b/Projects/UOContent/Spells/Third/Fireball.cs index aa5ca6941..061b9e339 100644 --- a/Projects/UOContent/Spells/Third/Fireball.cs +++ b/Projects/UOContent/Spells/Third/Fireball.cs @@ -55,8 +55,6 @@ namespace Server.Spells.Third SpellHelper.Damage(this, m, damage, 0, 100, 0, 0, 0); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Third/MagicLock.cs b/Projects/UOContent/Spells/Third/MagicLock.cs index 5202d3136..903c197cd 100644 --- a/Projects/UOContent/Spells/Third/MagicLock.cs +++ b/Projects/UOContent/Spells/Third/MagicLock.cs @@ -58,8 +58,6 @@ namespace Server.Spells.Third cont.LockLevel = ILockpickable.MagicLock; // signal magic lock cont.Locked = true; } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Third/Poison.cs b/Projects/UOContent/Spells/Third/Poison.cs index 79fa35f7f..d86d35591 100644 --- a/Projects/UOContent/Spells/Third/Poison.cs +++ b/Projects/UOContent/Spells/Third/Poison.cs @@ -95,8 +95,6 @@ namespace Server.Spells.Third HarmfulSpell(m); } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Third/Telekinesis.cs b/Projects/UOContent/Spells/Third/Telekinesis.cs index aeb3a24be..01a0e2f3f 100644 --- a/Projects/UOContent/Spells/Third/Telekinesis.cs +++ b/Projects/UOContent/Spells/Third/Telekinesis.cs @@ -68,8 +68,6 @@ namespace Server.Spells.Third } } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Third/Teleport.cs b/Projects/UOContent/Spells/Third/Teleport.cs index 78860e5da..93a1adbb5 100644 --- a/Projects/UOContent/Spells/Third/Teleport.cs +++ b/Projects/UOContent/Spells/Third/Teleport.cs @@ -112,8 +112,6 @@ namespace Server.Spells.Third queue.Dequeue().OnMoveOver(m); } } - - FinishSequence(); } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Third/Unlock.cs b/Projects/UOContent/Spells/Third/Unlock.cs index eebe822a6..f3681f372 100644 --- a/Projects/UOContent/Spells/Third/Unlock.cs +++ b/Projects/UOContent/Spells/Third/Unlock.cs @@ -80,8 +80,6 @@ namespace Server.Spells.Third } } } - - FinishSequence(); } public override void OnCast() diff --git a/Projects/UOContent/Spells/Third/WallOfStone.cs b/Projects/UOContent/Spells/Third/WallOfStone.cs index d5037a9f6..4955714d6 100644 --- a/Projects/UOContent/Spells/Third/WallOfStone.cs +++ b/Projects/UOContent/Spells/Third/WallOfStone.cs @@ -42,22 +42,16 @@ public class WallOfStoneSpell : MagerySpell, ISpellTargetingPoint3D var targetLoc = new Point3D(eastToWest ? p.X + i : p.X, eastToWest ? p.Y : p.Y + i, p.Z); var canFit = SpellHelper.AdjustField(ref targetLoc, Caster.Map, 22, true); - // Effects.SendLocationParticles( EffectItem.Create( loc, Caster.Map, EffectItem.DefaultDuration ), 0x376A, 9, 10, 5025 ); - if (!canFit) { continue; } - Item item = new WallOfStone(targetLoc, Caster.Map, Caster); + var item = new WallOfStone(targetLoc, Caster.Map, Caster); Effects.SendLocationParticles(item, 0x376A, 9, 10, 5025); - - // new WallOfStone( loc, Caster.Map, Caster ); } } - - FinishSequence(); } public override void OnCast()