Cleans up Spell Targeting (#36)

This commit is contained in:
Kamron Batman 2019-03-15 15:23:03 -07:00 • committed by GitHub
parent de50bc9e43
commit 472b84f5ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 653 additions and 2192 deletions

View file

@ -2,14 +2,11 @@ using Server.Factions;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Multis;
using Server.Network;
using Server.Spells.Necromancy;
using Server.Targeting;
namespace Server.Spells.Fourth
{
public class RecallSpell : MagerySpell
public class RecallSpell : MagerySpell, IRecallSpell
{
private static SpellInfo m_Info = new SpellInfo(
"Recall", "Kal Ort Por",
@ -46,7 +43,7 @@ namespace Server.Spells.Fourth
public override void OnCast()
{
if (m_Entry == null)
Caster.Target = new InternalTarget(this);
Caster.Target = new RecallSpellTarget(this);
else
Effect(m_Entry.Location, m_Entry.Map, true);
}
@ -142,63 +139,5 @@ namespace Server.Spells.Fourth
FinishSequence();
}
private class InternalTarget : Target
{
private RecallSpell m_Owner;
public InternalTarget(RecallSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
{
m_Owner = owner;
owner.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item.
}
protected override void OnTarget(Mobile from, object o)
{
if (o is RecallRune rune)
{
if (rune.Marked)
m_Owner.Effect(rune.Target, rune.TargetMap, true);
else
from.SendLocalizedMessage(501805); // That rune is not yet marked.
}
else if (o is Runebook runebook)
{
RunebookEntry e = runebook.Default;
if (e != null)
m_Owner.Effect(e.Location, e.Map, true);
else
from.SendLocalizedMessage(502354); // Target is not marked.
}
else if (o is Key key && key.KeyValue != 0 && key.Link is BaseBoat boat)
{
if (!boat.Deleted && boat.CheckKey(key.KeyValue))
m_Owner.Effect(boat.GetMarkedLocation(), boat.Map, false);
else
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357,
from.Name, "")); // I can not recall from that object.
}
else if (o is HouseRaffleDeed deed && deed.ValidLocation())
{
m_Owner.Effect(deed.PlotLocation, deed.PlotFacet, true);
}
else
{
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name,
"")); // I can not recall from that object.
}
}
protected override void OnNonlocalTarget(Mobile from, object o)
{
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}