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

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Spells.Third
{
public class PoisonSpell : MagerySpell
public class PoisonSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Poison", "In Nox",
@ -20,15 +20,16 @@ namespace Server.Spells.Third
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
}
public void Target(Mobile m)
{
if (m == null)
return;
if (!Caster.CanSee(m))
{
Caster.SendLocalizedMessage(500237); // Target can not be seen.
}
else if (CheckHSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -77,11 +78,8 @@ namespace Server.Spells.Third
if (Caster is PlayerMobile pm)
{
if (pm.DuelContext != null && pm.DuelContext.Started && !pm.DuelContext.Finished &&
!pm.DuelContext.Ruleset.GetOption("Skills", "Poisoning"))
{
}
else
if (pm.DuelContext == null || !pm.DuelContext.Started || pm.DuelContext.Finished ||
pm.DuelContext.Ruleset.GetOption("Skills", "Poisoning"))
{
total += pm.Skills.Poisoning.Value;
}
@ -119,25 +117,5 @@ namespace Server.Spells.Third
FinishSequence();
}
private class InternalTarget : Target
{
private PoisonSpell m_Owner;
public InternalTarget(PoisonSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile from, object o)
{
if (o is Mobile mobile) m_Owner.Target(mobile);
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}