Cleans up Spell Targeting (#36)
This commit is contained in:
parent
de50bc9e43
commit
472b84f5ff
99 changed files with 653 additions and 2192 deletions
|
|
@ -4,7 +4,7 @@ using Server.Targeting;
|
|||
|
||||
namespace Server.Spells.Sixth
|
||||
{
|
||||
public class DispelSpell : MagerySpell
|
||||
public class DispelSpell : MagerySpell, ISpellTargetingMobile
|
||||
{
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Dispel", "An Ort",
|
||||
|
|
@ -23,60 +23,41 @@ namespace Server.Spells.Sixth
|
|||
|
||||
public override void OnCast()
|
||||
{
|
||||
Caster.Target = new InternalTarget(this);
|
||||
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
|
||||
}
|
||||
|
||||
public class InternalTarget : Target
|
||||
public void Target(Mobile m)
|
||||
{
|
||||
private DispelSpell m_Owner;
|
||||
if (m == null)
|
||||
return;
|
||||
|
||||
public InternalTarget(DispelSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful)
|
||||
if (!Caster.CanSee(m))
|
||||
Caster.SendLocalizedMessage(500237); // Target can not be seen.
|
||||
else if (!(m is BaseCreature bc && bc.IsDispellable))
|
||||
Caster.SendLocalizedMessage(1005049); // That cannot be dispelled.
|
||||
else if (CheckHSequence(m))
|
||||
{
|
||||
m_Owner = owner;
|
||||
}
|
||||
SpellHelper.Turn(Caster, m);
|
||||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
if (o is Mobile m)
|
||||
double dispelChance =
|
||||
(50.0 + 100 * (Caster.Skills.Magery.Value - bc.DispelDifficulty) / (bc.DispelFocus * 2)) / 100;
|
||||
|
||||
if (dispelChance > Utility.RandomDouble())
|
||||
{
|
||||
BaseCreature bc = m as BaseCreature;
|
||||
Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration),
|
||||
0x3728, 8, 20, 5042);
|
||||
Effects.PlaySound(m, m.Map, 0x201);
|
||||
|
||||
if (!from.CanSee(m))
|
||||
{
|
||||
from.SendLocalizedMessage(500237); // Target can not be seen.
|
||||
}
|
||||
else if (bc == null || !bc.IsDispellable)
|
||||
{
|
||||
from.SendLocalizedMessage(1005049); // That cannot be dispelled.
|
||||
}
|
||||
else if (m_Owner.CheckHSequence(m))
|
||||
{
|
||||
SpellHelper.Turn(from, m);
|
||||
|
||||
double dispelChance =
|
||||
(50.0 + 100 * (from.Skills.Magery.Value - bc.DispelDifficulty) / (bc.DispelFocus * 2)) / 100;
|
||||
|
||||
if (dispelChance > Utility.RandomDouble())
|
||||
{
|
||||
Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration),
|
||||
0x3728, 8, 20, 5042);
|
||||
Effects.PlaySound(m, m.Map, 0x201);
|
||||
|
||||
m.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
m.FixedEffect(0x3779, 10, 20);
|
||||
from.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it!
|
||||
}
|
||||
}
|
||||
m.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
m.FixedEffect(0x3779, 10, 20);
|
||||
Caster.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it!
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
m_Owner.FinishSequence();
|
||||
}
|
||||
FinishSequence();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ using Server.Targeting;
|
|||
|
||||
namespace Server.Spells.Sixth
|
||||
{
|
||||
public class EnergyBoltSpell : MagerySpell
|
||||
public class EnergyBoltSpell : MagerySpell, ISpellTargetingMobile
|
||||
{
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Energy Bolt", "Corp Por",
|
||||
|
|
@ -22,15 +22,16 @@ namespace Server.Spells.Sixth
|
|||
|
||||
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))
|
||||
{
|
||||
Mobile source = Caster;
|
||||
|
|
@ -70,26 +71,5 @@ namespace Server.Spells.Sixth
|
|||
|
||||
FinishSequence();
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private EnergyBoltSpell m_Owner;
|
||||
|
||||
public InternalTarget(EnergyBoltSpell 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using Server.Targeting;
|
|||
|
||||
namespace Server.Spells.Sixth
|
||||
{
|
||||
public class ExplosionSpell : MagerySpell
|
||||
public class ExplosionSpell : MagerySpell, ISpellTargetingMobile
|
||||
{
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Explosion", "Vas Ort Flam",
|
||||
|
|
@ -26,11 +26,14 @@ namespace Server.Spells.Sixth
|
|||
|
||||
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.
|
||||
|
|
@ -102,27 +105,5 @@ namespace Server.Spells.Sixth
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private ExplosionSpell m_Owner;
|
||||
|
||||
public InternalTarget(ExplosionSpell 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using Server.Targeting;
|
|||
|
||||
namespace Server.Spells.Sixth
|
||||
{
|
||||
public class InvisibilitySpell : MagerySpell
|
||||
public class InvisibilitySpell : MagerySpell, ISpellTargetingMobile
|
||||
{
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Invisibility", "An Lor Xen",
|
||||
|
|
@ -38,11 +38,14 @@ namespace Server.Spells.Sixth
|
|||
|
||||
public override void OnCast()
|
||||
{
|
||||
Caster.Target = new InternalTarget(this);
|
||||
Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, 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.
|
||||
|
|
@ -111,26 +114,5 @@ namespace Server.Spells.Sixth
|
|||
RemoveTimer(m_Mobile);
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalTarget : Target
|
||||
{
|
||||
private InvisibilitySpell m_Owner;
|
||||
|
||||
public InternalTarget(InvisibilitySpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using Server.Targeting;
|
|||
|
||||
namespace Server.Spells.Sixth
|
||||
{
|
||||
public class MarkSpell : MagerySpell
|
||||
public class MarkSpell : MagerySpell, ISpellTargetingItem
|
||||
{
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Mark", "Kal Por Ylem",
|
||||
|
|
@ -23,35 +23,29 @@ namespace Server.Spells.Sixth
|
|||
|
||||
public override void OnCast()
|
||||
{
|
||||
Caster.Target = new InternalTarget(this);
|
||||
Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12);
|
||||
}
|
||||
|
||||
public override bool CheckCast()
|
||||
{
|
||||
if (!base.CheckCast())
|
||||
return false;
|
||||
|
||||
return SpellHelper.CheckTravel(Caster, TravelCheckType.Mark);
|
||||
return base.CheckCast() && SpellHelper.CheckTravel(Caster, TravelCheckType.Mark);
|
||||
}
|
||||
|
||||
public void Target(RecallRune rune)
|
||||
public void Target(Item item)
|
||||
{
|
||||
if (!Caster.CanSee(rune))
|
||||
{
|
||||
if (!(item is RecallRune rune))
|
||||
Caster.Send(new MessageLocalized(Caster.Serial, Caster.Body, MessageType.Regular, 0x3B2, 3, 501797, Caster.Name,
|
||||
"")); // I cannot mark that object.
|
||||
else if (!Caster.CanSee(rune))
|
||||
Caster.SendLocalizedMessage(500237); // Target can not be seen.
|
||||
}
|
||||
else if (!SpellHelper.CheckTravel(Caster, TravelCheckType.Mark))
|
||||
{
|
||||
}
|
||||
else if (SpellHelper.CheckMulti(Caster.Location, Caster.Map, !Core.AOS))
|
||||
{
|
||||
Caster.SendLocalizedMessage(501942); // That location is blocked.
|
||||
}
|
||||
else if (!rune.IsChildOf(Caster.Backpack))
|
||||
{
|
||||
Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2,
|
||||
1062422); // You must have this rune in your backpack in order to mark it.
|
||||
}
|
||||
else if (CheckSequence())
|
||||
{
|
||||
rune.Mark(Caster);
|
||||
|
|
@ -62,29 +56,5 @@ namespace Server.Spells.Sixth
|
|||
|
||||
FinishSequence();
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private MarkSpell m_Owner;
|
||||
|
||||
public InternalTarget(MarkSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
|
||||
{
|
||||
m_Owner = owner;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
if (o is RecallRune rune)
|
||||
m_Owner.Target(rune);
|
||||
else
|
||||
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501797, from.Name,
|
||||
"")); // I cannot mark that object.
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
m_Owner.FinishSequence();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Spells.Sixth
|
||||
{
|
||||
public class MassCurseSpell : MagerySpell
|
||||
public class MassCurseSpell : MagerySpell, ISpellTargetingPoint3D
|
||||
{
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Mass Curse", "Vas Des Sanct",
|
||||
|
|
@ -25,7 +23,7 @@ namespace Server.Spells.Sixth
|
|||
|
||||
public override void OnCast()
|
||||
{
|
||||
Caster.Target = new InternalTarget(this);
|
||||
Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12);
|
||||
}
|
||||
|
||||
public void Target(IPoint3D p)
|
||||
|
|
@ -72,26 +70,5 @@ namespace Server.Spells.Sixth
|
|||
|
||||
FinishSequence();
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private MassCurseSpell m_Owner;
|
||||
|
||||
public InternalTarget(MassCurseSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None)
|
||||
{
|
||||
m_Owner = owner;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
if (o is IPoint3D p)
|
||||
m_Owner.Target(p);
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
m_Owner.FinishSequence();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using Server.Targeting;
|
|||
|
||||
namespace Server.Spells.Sixth
|
||||
{
|
||||
public class ParalyzeFieldSpell : MagerySpell
|
||||
public class ParalyzeFieldSpell : MagerySpell, ISpellTargetingPoint3D
|
||||
{
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Paralyze Field", "In Ex Grav",
|
||||
|
|
@ -26,7 +26,7 @@ namespace Server.Spells.Sixth
|
|||
|
||||
public override void OnCast()
|
||||
{
|
||||
Caster.Target = new InternalTarget(this);
|
||||
Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12);
|
||||
}
|
||||
|
||||
public void Target(IPoint3D p)
|
||||
|
|
@ -66,9 +66,8 @@ namespace Server.Spells.Sixth
|
|||
for (int i = -2; i <= 2; ++i)
|
||||
{
|
||||
Point3D loc = new Point3D(eastToWest ? p.X + i : p.X, eastToWest ? p.Y : p.Y + i, p.Z);
|
||||
bool canFit = SpellHelper.AdjustField(ref loc, Caster.Map, 12, false);
|
||||
|
||||
if (!canFit)
|
||||
if (!SpellHelper.AdjustField(ref loc, Caster.Map, 12, false))
|
||||
continue;
|
||||
|
||||
Item item = new InternalItem(Caster, itemID, loc, Caster.Map, duration);
|
||||
|
|
@ -212,26 +211,5 @@ namespace Server.Spells.Sixth
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private ParalyzeFieldSpell m_Owner;
|
||||
|
||||
public InternalTarget(ParalyzeFieldSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None)
|
||||
{
|
||||
m_Owner = owner;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
if (o is IPoint3D d)
|
||||
m_Owner.Target(d);
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
m_Owner.FinishSequence();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Spells.Sixth
|
||||
{
|
||||
public class RevealSpell : MagerySpell
|
||||
public class RevealSpell : MagerySpell, ISpellTargetingPoint3D
|
||||
{
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Reveal", "Wis Quas",
|
||||
|
|
@ -23,7 +21,7 @@ namespace Server.Spells.Sixth
|
|||
|
||||
public override void OnCast()
|
||||
{
|
||||
Caster.Target = new InternalTarget(this);
|
||||
Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12);
|
||||
}
|
||||
|
||||
public void Target(IPoint3D p)
|
||||
|
|
@ -86,26 +84,5 @@ namespace Server.Spells.Sixth
|
|||
|
||||
return chance > Utility.Random(100);
|
||||
}
|
||||
|
||||
public class InternalTarget : Target
|
||||
{
|
||||
private RevealSpell m_Owner;
|
||||
|
||||
public InternalTarget(RevealSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None)
|
||||
{
|
||||
m_Owner = owner;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
if (o is IPoint3D p)
|
||||
m_Owner.Target(p);
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
m_Owner.FinishSequence();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue