Cleans up Spell Targeting (#36)
This commit is contained in:
parent
de50bc9e43
commit
472b84f5ff
99 changed files with 653 additions and 2192 deletions
|
|
@ -5,7 +5,7 @@ using Server.Targeting;
|
|||
|
||||
namespace Server.Spells.Necromancy
|
||||
{
|
||||
public class EvilOmenSpell : NecromancerSpell
|
||||
public class EvilOmenSpell : NecromancerSpell, ISpellTargetingMobile
|
||||
{
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Evil Omen", "Pas Tym An Sanct",
|
||||
|
|
@ -29,15 +29,13 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
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 is BaseCreature || m is PlayerMobile))
|
||||
{
|
||||
Caster.SendLocalizedMessage(1060508); // You can't curse that.
|
||||
}
|
||||
else if (CheckHSequence(m))
|
||||
{
|
||||
SpellHelper.Turn(Caster, m);
|
||||
|
|
@ -68,7 +66,7 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
TimeSpan duration = TimeSpan.FromSeconds(Caster.Skills.SpiritSpeak.Value / 12 + 1.0);
|
||||
|
||||
Timer.DelayCall(duration, TryEndEffect_Callback, m);
|
||||
Timer.DelayCall(duration, mob => TryEndEffect(mob), m);
|
||||
|
||||
HarmfulSpell(m);
|
||||
|
||||
|
|
@ -78,53 +76,15 @@ namespace Server.Spells.Necromancy
|
|||
FinishSequence();
|
||||
}
|
||||
|
||||
/*
|
||||
* The naming here was confusing. Its a 1-off effect spell.
|
||||
* So, we don't actually "checkeffect"; we endeffect with bool
|
||||
* return to determine external behaviors.
|
||||
*
|
||||
* -refactored.
|
||||
*/
|
||||
private static void TryEndEffect_Callback(Mobile m)
|
||||
{
|
||||
TryEndEffect(m);
|
||||
}
|
||||
|
||||
public static bool TryEndEffect(Mobile m)
|
||||
{
|
||||
DefaultSkillMod mod = m_Table[m];
|
||||
|
||||
if (mod == null)
|
||||
if (!m_Table.TryGetValue(m, out DefaultSkillMod mod))
|
||||
return false;
|
||||
|
||||
m_Table.Remove(m);
|
||||
mod.Remove();
|
||||
mod?.Remove();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private EvilOmenSpell m_Owner;
|
||||
|
||||
public InternalTarget(EvilOmenSpell 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);
|
||||
else
|
||||
from.SendLocalizedMessage(1060508); // You can't curse that.
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
m_Owner.FinishSequence();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue