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.
This commit is contained in:
Kamron Batman 2024-06-17 15:19:06 -07:00 • committed by GitHub
parent 9c0b57213a
commit b8ad5c671d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
80 changed files with 201 additions and 406 deletions

View file

@ -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();
}
}