ModernUO/Projects/UOContent/Spells/Second/RemoveTrap.cs
Kamron Batman 9b7fea2c20
fix: Magic NPCs now use spell range (#1870)
### Summary
- Drastically streamlines the spell targeting by collapsing the target classes into a single `SpellTarget<T>` class.
- Moves TargetRange to the spell itself so it can be used by MageAI.
- Changes range check in MageAI to use TargetRange. This should fix target acquisition bugs
2024-08-08 07:05:27 -07:00

59 lines
1.6 KiB
C#

using Server.Items;
namespace Server.Spells.Second
{
public class RemoveTrapSpell : MagerySpell, ITargetingSpell<Item>
{
private static readonly SpellInfo _info = new(
"Remove Trap",
"An Jux",
212,
9001,
Reagent.Bloodmoss,
Reagent.SulfurousAsh
);
public RemoveTrapSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
public override SpellCircle Circle => SpellCircle.Second;
public void Target(Item item)
{
if (item is not TrappableContainer cont)
{
Caster.SendLocalizedMessage(502373); // That doesn't appear to be trapped
}
else if (cont.TrapType != TrapType.None && cont.TrapType != TrapType.MagicTrap)
{
DoFizzle();
}
else if (CheckSequence())
{
SpellHelper.Turn(Caster, item);
var loc = item.GetWorldLocation();
Effects.SendLocationParticles(
EffectItem.Create(loc, item.Map, EffectItem.DefaultDuration),
0x376A,
9,
32,
5015
);
Effects.PlaySound(loc, item.Map, 0x1F0);
cont.TrapType = TrapType.None;
cont.TrapPower = 0;
cont.TrapLevel = 0;
}
}
public override void OnCast()
{
Caster.Target = new SpellTarget<Item>(this);
Caster.SendLocalizedMessage(502368);
}
}
}