ModernUO/Projects/UOContent/Spells/Fifth/DispelField.cs
Kamron Batman b8ad5c671d
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.
2024-06-17 15:19:06 -07:00

57 lines
1.6 KiB
C#

using Server.Items;
using Server.Misc;
namespace Server.Spells.Fifth
{
public class DispelFieldSpell : MagerySpell, ISpellTargetingItem
{
private static readonly SpellInfo _info = new(
"Dispel Field",
"An Grav",
206,
9002,
Reagent.BlackPearl,
Reagent.SpidersSilk,
Reagent.SulfurousAsh,
Reagent.Garlic
);
public DispelFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
public override SpellCircle Circle => SpellCircle.Fifth;
public void Target(Item item)
{
if (!item.GetType().IsDefined(typeof(DispellableFieldAttribute), false))
{
Caster.SendLocalizedMessage(1005049); // That cannot be dispelled.
}
else if (item is Moongate { Dispellable: false })
{
Caster.SendLocalizedMessage(1005047); // That magic is too chaotic
}
else if (CheckSequence())
{
SpellHelper.Turn(Caster, item);
Effects.SendLocationParticles(
EffectItem.Create(item.Location, item.Map, EffectItem.DefaultDuration),
0x376A,
9,
20,
5042
);
Effects.PlaySound(item.GetWorldLocation(), item.Map, 0x201);
item.Delete();
}
}
public override void OnCast()
{
Caster.Target = new SpellTargetItem(this, range: Core.ML ? 10 : 12);
}
}
}