fix: Cleans up spell targeting (#851)

This commit is contained in:
Kamron Batman 2021-11-14 21:07:54 -08:00 • committed by GitHub
parent 15b2d08ea2
commit 239dda4b3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 61 additions and 70 deletions

View file

@ -7,14 +7,14 @@ namespace Server.Spells
{
public class RecallSpellTarget : Target
{
private readonly IRecallSpell m_Spell;
private readonly IRecallSpell _spell;
private readonly bool m_ToBoat;
public RecallSpellTarget(IRecallSpell spell, bool toBoat = true) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
{
m_Spell = spell;
_spell = spell;
m_ToBoat = toBoat;
m_Spell.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item.
_spell.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item.
}
protected override void OnTarget(Mobile from, object o)
@ -23,7 +23,7 @@ namespace Server.Spells
{
if (rune.Marked)
{
m_Spell.Effect(rune.Target, rune.TargetMap, true);
_spell.Effect(rune.Target, rune.TargetMap, true);
}
else
{
@ -36,7 +36,7 @@ namespace Server.Spells
if (e != null)
{
m_Spell.Effect(e.Location, e.Map, true);
_spell.Effect(e.Location, e.Map, true);
}
else
{
@ -47,7 +47,7 @@ namespace Server.Spells
{
if (!boat.Deleted && boat.CheckKey(key.KeyValue))
{
m_Spell.Effect(boat.GetMarkedLocation(), boat.Map, false);
_spell.Effect(boat.GetMarkedLocation(), boat.Map, false);
}
else
{
@ -64,7 +64,7 @@ namespace Server.Spells
}
else if (o is HouseRaffleDeed deed && deed.ValidLocation())
{
m_Spell.Effect(deed.PlotLocation, deed.PlotFacet, true);
_spell.Effect(deed.PlotLocation, deed.PlotFacet, true);
}
else
{
@ -86,7 +86,7 @@ namespace Server.Spells
protected override void OnTargetFinish(Mobile from)
{
m_Spell?.FinishSequence();
_spell?.FinishSequence();
}
}
}

View file

@ -9,24 +9,24 @@ namespace Server.Spells
public class SpellTargetItem : Target, ISpellTarget
{
private readonly ISpellTargetingItem m_Spell;
private readonly ISpellTargetingItem _spell;
public SpellTargetItem(ISpellTargetingItem spell, TargetFlags flags, int range = 12) : base(range, false, flags) =>
m_Spell = spell;
public SpellTargetItem(ISpellTargetingItem spell, TargetFlags flags = TargetFlags.None, int range = 12)
: base(range, false, flags) => _spell = spell;
public ISpell Spell => m_Spell;
public ISpell Spell => _spell;
protected override void OnTarget(Mobile from, object o)
{
if (o is Item item)
{
m_Spell.Target(item);
_spell.Target(item);
}
}
protected override void OnTargetFinish(Mobile from)
{
m_Spell?.FinishSequence();
_spell?.FinishSequence();
}
}
}

View file

@ -9,21 +9,21 @@ namespace Server.Spells
public class SpellTargetMobile : Target, ISpellTarget
{
private readonly ISpellTargetingMobile m_Spell;
private readonly ISpellTargetingMobile _spell;
public SpellTargetMobile(ISpellTargetingMobile spell, TargetFlags flags, int range = 12) :
base(range, false, flags) => m_Spell = spell;
base(range, false, flags) => _spell = spell;
public ISpell Spell => m_Spell;
public ISpell Spell => _spell;
protected override void OnTarget(Mobile from, object o)
{
m_Spell.Target(o as Mobile);
_spell.Target(o as Mobile);
}
protected override void OnTargetFinish(Mobile from)
{
m_Spell?.FinishSequence();
_spell?.FinishSequence();
}
}
}

View file

@ -9,43 +9,43 @@ namespace Server.Spells
public class SpellTargetPoint3D : Target, ISpellTarget
{
private readonly bool m_CheckLOS;
private ISpellTargetingPoint3D m_Spell;
private readonly bool _retryOnLos;
private ISpellTargetingPoint3D _spell;
public SpellTargetPoint3D(
ISpellTargetingPoint3D spell, TargetFlags flags = TargetFlags.None, int range = 12, bool checkLOS = true
ISpellTargetingPoint3D spell, TargetFlags flags = TargetFlags.None, int range = 12, bool retryOnLOS = false
) : base(range, true, flags)
{
m_Spell = spell;
m_CheckLOS = checkLOS;
_spell = spell;
_retryOnLos = retryOnLOS;
}
public ISpell Spell => m_Spell;
public ISpell Spell => _spell;
protected override void OnTarget(Mobile from, object o)
{
if (o is IPoint3D p)
{
m_Spell.Target(p);
_spell.Target(p);
}
}
protected override void OnTargetOutOfLOS(Mobile from, object o)
{
if (!m_CheckLOS)
if (!_retryOnLos)
{
return;
}
from.SendLocalizedMessage(501943); // Target cannot be seen. Try again.
from.Target = new SpellTargetPoint3D(m_Spell);
from.Target = new SpellTargetPoint3D(_spell);
from.Target.BeginTimeout(from, TimeoutTime - Core.TickCount);
m_Spell = null; // Needed?
_spell = null; // Needed?
}
protected override void OnTargetFinish(Mobile from)
{
m_Spell?.FinishSequence();
_spell?.FinishSequence();
}
}
}