ModernUO/Projects/UOContent/Spells/Third/Telekinesis.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

86 lines
2.5 KiB
C#

using Server.Items;
namespace Server.Spells.Third
{
public class TelekinesisSpell : MagerySpell, ITargetingSpell<Item>
{
private static readonly SpellInfo _info = new(
"Telekinesis",
"Ort Por Ylem",
203,
9031,
Reagent.Bloodmoss,
Reagent.MandrakeRoot
);
public TelekinesisSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
public override SpellCircle Circle => SpellCircle.Third;
public void Target(Item item)
{
var t = item as ITelekinesisable;
if (!(t != null || item is Container))
{
Caster.SendLocalizedMessage(501857); // This spell won't work on that!
return;
}
if (CheckSequence())
{
if (t != null)
{
SpellHelper.Turn(Caster, t);
t.OnTelekinesis(Caster);
}
else
{
SpellHelper.Turn(Caster, item);
if (!item.IsAccessibleTo(Caster))
{
item.OnDoubleClickNotAccessible(Caster);
}
else if (!item.CheckItemUse(Caster, item))
{
}
else if (item.RootParent is Mobile && item.RootParent != Caster)
{
item.OnSnoop(Caster);
}
else if (item is Corpse corpse && !corpse.CheckLoot(Caster, null))
{
}
else if (Caster.Region.OnDoubleClick(Caster, item))
{
Effects.SendLocationParticles(
EffectItem.Create(item.Location, item.Map, EffectItem.DefaultDuration),
0x376A,
9,
32,
5022
);
Effects.PlaySound(item.Location, item.Map, 0x1F5);
item.OnItemUsed(Caster, item);
}
}
}
}
public override void OnCast()
{
Caster.Target = new SpellTarget<Item>(this);
}
}
}
namespace Server
{
public interface ITelekinesisable : IPoint3D
{
void OnTelekinesis(Mobile from);
}
}