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

@ -1,4 +1,3 @@
using System.Collections.Generic;
using Server.Mobiles;
namespace Server.Engines.BulkOrders

View file

@ -1,4 +1,3 @@
using System.Collections.Generic;
using Mat = Server.Engines.BulkOrders.BulkMaterialType;
namespace Server.Engines.BulkOrders

View file

@ -1,4 +1,3 @@
using System.Collections.Generic;
using Mat = Server.Engines.BulkOrders.BulkMaterialType;
namespace Server.Engines.BulkOrders

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using Server.Items;
using Server.Mobiles;

View file

@ -469,7 +469,7 @@ namespace Server.Factions
if (m_Guard.Map == toHarm.Map && (targ.Range < 0 || m_Guard.InRange(toHarm, targ.Range)) &&
m_Guard.CanSee(toHarm) && m_Guard.InLOS(toHarm))
targ.Invoke(m_Guard, toHarm);
else if (targ is DispelSpell.InternalTarget)
else if ((targ as ISpellTarget)?.Spell is DispelSpell)
targ.Cancel(m_Guard, TargetCancelType.Canceled);
}
else if ((targ.Flags & TargetFlags.Beneficial) != 0)

View file

@ -1,5 +1,3 @@
using Server.Gumps;
namespace Server.Engines.Quests
{
public class QuestItemInfo

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Spells;
using Server.Targeting;

View file

@ -1,3 +1,4 @@
using Server.Spells;
using Server.Spells.First;
using Server.Spells.Fourth;
using Server.Spells.Second;
@ -28,11 +29,13 @@ namespace Server.Mobiles
if (targ != null)
{
if (targ is CureSpell.InternalTarget)
ISpellTarget spellTarg = targ as ISpellTarget;
if (spellTarg?.Spell is CureSpell)
ProcessTarget(targ, m_ACure);
else if (targ is GreaterHealSpell.InternalTarget)
else if (spellTarg?.Spell is GreaterHealSpell)
ProcessTarget(targ, m_AGHeal);
else if (targ is HealSpell.InternalTarget)
else if (spellTarg?.Spell is HealSpell)
ProcessTarget(targ, m_ALHeal);
else
targ.Cancel(m_Mobile, TargetCancelType.Canceled);

View file

@ -960,11 +960,13 @@ namespace Server.Mobiles
if (targ == null)
return false;
bool isReveal = targ is RevealSpell.InternalTarget;
bool isDispel = targ is DispelSpell.InternalTarget;
bool isParalyze = targ is ParalyzeSpell.InternalTarget;
bool isTeleport = targ is TeleportSpell.InternalTarget;
bool isInvisible = targ is InvisibilitySpell.InternalTarget;
ISpellTarget spellTarg = targ as ISpellTarget;
bool isReveal = spellTarg?.Spell is RevealSpell;
bool isDispel = spellTarg?.Spell is DispelSpell;
bool isParalyze = spellTarg?.Spell is ParalyzeSpell;
bool isTeleport = spellTarg?.Spell is TeleportSpell;
bool isInvisible = spellTarg?.Spell is InvisibilitySpell;
bool teleportAway = false;
Mobile toTarget;

View file

@ -51,20 +51,8 @@ namespace Server.Mobiles
VirtualArmor = 32;
Item shroud = new DeathShroud();
shroud.Hue = 0x455;
shroud.Movable = false;
AddItem(shroud);
Halberd weapon = new Halberd();
weapon.Hue = 1;
weapon.Movable = false;
AddItem(weapon);
AddItem(new DeathShroud { Hue = 0x455, Movable = false });
AddItem(new Halberd { Hue = 1, Movable = false });
}
public Revenant(Serial serial) : base(serial)
@ -181,4 +169,4 @@ namespace Server.Mobiles
Delete();
}
}
}
}

View file

@ -3269,6 +3269,12 @@
<Compile Include="Spells\Sixth\MassCurse.cs" />
<Compile Include="Spells\Sixth\ParalyzeField.cs" />
<Compile Include="Spells\Sixth\Reveal.cs" />
<Compile Include="Spells\Targeting\IRecallSpell.cs" />
<Compile Include="Spells\Targeting\ISpellTarget.cs" />
<Compile Include="Spells\Targeting\SpellTargetPoint3D.cs" />
<Compile Include="Spells\Targeting\SpellTargetItem.cs" />
<Compile Include="Spells\Targeting\SpellTargetMobile.cs" />
<Compile Include="Spells\Targeting\RecallSpellTarget.cs" />
<Compile Include="Spells\Spellweaving\ArcaneCircle.cs" />
<Compile Include="Spells\Spellweaving\ArcaneForm.cs" />
<Compile Include="Spells\Spellweaving\ArcaneSummon.cs" />

View file

@ -20,13 +20,7 @@ namespace Server.Spells
public override bool ConsumeReagents()
{
if (base.ConsumeReagents())
return true;
if (ArcaneGem.ConsumeCharges(Caster, Core.SE ? 1 : 1 + (int)Circle))
return true;
return false;
return base.ConsumeReagents() || ArcaneGem.ConsumeCharges(Caster, Core.SE ? 1 : 1 + (int)Circle);
}
public override void GetCastSkills(out double min, out double max)
@ -44,10 +38,7 @@ namespace Server.Spells
public override int GetMana()
{
if (Scroll is BaseWand)
return 0;
return m_ManaTable[(int)Circle];
return Scroll is BaseWand ? 0 : m_ManaTable[(int)Circle];
}
public override double GetResistSkill(Mobile m)
@ -108,4 +99,4 @@ namespace Server.Spells
return base.GetCastDelay();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Chivalry
{
public class CleanseByFireSpell : PaladinSpell
public class CleanseByFireSpell : PaladinSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Cleanse By Fire", "Expor Flamus",
@ -36,15 +36,16 @@ namespace Server.Spells.Chivalry
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 (!m.Poisoned)
{
Caster.SendLocalizedMessage(1060176); // That creature is not poisoned!
}
else if (CheckBSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -101,26 +102,5 @@ namespace Server.Spells.Chivalry
FinishSequence();
}
private class InternalTarget : Target
{
private CleanseByFireSpell m_Owner;
public InternalTarget(CleanseByFireSpell 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();
}
}
}
}

View file

@ -7,7 +7,7 @@ using Server.Targeting;
namespace Server.Spells.Chivalry
{
public class CloseWoundsSpell : PaladinSpell
public class CloseWoundsSpell : PaladinSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Close Wounds", "Obsu Vulni",
@ -39,31 +39,24 @@ namespace Server.Spells.Chivalry
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial);
}
public void Target(Mobile m)
{
if (m == null)
return;
if (!Caster.InRange(m, 2))
{
Caster.SendLocalizedMessage(1060178); // You are too far away to perform that action!
}
else if (m is BaseCreature creature && creature.IsAnimatedDead)
{
Caster.SendLocalizedMessage(1061654); // You cannot heal that which is not alive.
}
else if (m.IsDeadBondedPet)
{
Caster.SendLocalizedMessage(1060177); // You cannot heal a creature that is already dead!
}
else if (m.Hits >= m.HitsMax)
{
Caster.SendLocalizedMessage(500955); // That being is not damaged!
}
else if (m.Poisoned || MortalStrike.IsWounded(m))
{
Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, Caster == m ? 1005000 : 1010398);
}
else if (CheckBSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -90,26 +83,5 @@ namespace Server.Spells.Chivalry
FinishSequence();
}
private class InternalTarget : Target
{
private CloseWoundsSpell m_Owner;
public InternalTarget(CloseWoundsSpell owner) : base(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();
}
}
}
}

View file

@ -7,7 +7,7 @@ using Server.Targeting;
namespace Server.Spells.Chivalry
{
public class RemoveCurseSpell : PaladinSpell
public class RemoveCurseSpell : PaladinSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Remove Curse", "Extermo Vomica",
@ -39,11 +39,14 @@ namespace Server.Spells.Chivalry
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 (CheckBSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -54,7 +57,7 @@ namespace Server.Spells.Chivalry
* Chance of removing curse is affected by Caster's Karma.
*/
int chance = 0;
int chance;
if (Caster.Karma < -5000)
chance = 0;
@ -116,26 +119,5 @@ namespace Server.Spells.Chivalry
FinishSequence();
}
private class InternalTarget : Target
{
private RemoveCurseSpell m_Owner;
public InternalTarget(RemoveCurseSpell 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();
}
}
}
}

View file

@ -3,13 +3,10 @@ using Server.Factions;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Multis;
using Server.Network;
using Server.Targeting;
namespace Server.Spells.Chivalry
{
public class SacredJourneySpell : PaladinSpell
public class SacredJourneySpell : PaladinSpell, IRecallSpell
{
private static SpellInfo m_Info = new SpellInfo(
"Sacred Journey", "Sanctum Viatas",
@ -39,7 +36,7 @@ namespace Server.Spells.Chivalry
public override void OnCast()
{
if (m_Entry == null)
Caster.Target = new InternalTarget(this);
Caster.Target = new RecallSpellTarget(this);
else
Effect(m_Entry.Location, m_Entry.Map, true);
}
@ -141,61 +138,5 @@ namespace Server.Spells.Chivalry
FinishSequence();
}
private class InternalTarget : Target
{
private SacredJourneySpell m_Owner;
public InternalTarget(SacredJourneySpell 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)
{
if (rune.Marked)
m_Owner.Effect(rune.Target, rune.TargetMap, true);
else
from.SendLocalizedMessage(501805); // That rune is not yet marked.
}
else if (o is Runebook runebook)
{
RunebookEntry e = runebook.Default;
if (e != null)
m_Owner.Effect(e.Location, e.Map, true);
else
from.SendLocalizedMessage(502354); // Target is not marked.
}
else if (o is Key key && key.KeyValue != 0 && key.Link is BaseBoat boat)
{
if (!boat.Deleted && boat.CheckKey(key.KeyValue))
m_Owner.Effect(boat.GetMarkedLocation(), boat.Map, false);
else
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357,
from.Name, "")); // I can not recall from that object.
}
else if (o is HouseRaffleDeed deed && deed.ValidLocation())
{
m_Owner.Effect(deed.PlotLocation, deed.PlotFacet, true);
}
else
{
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name,
"")); // I can not recall from that object.
}
}
protected override void OnNonlocalTarget(Mobile from, object o)
{
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}

View file

@ -1,10 +1,9 @@
using System;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Spells.Eighth
{
public class EnergyVortexSpell : MagerySpell
public class EnergyVortexSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Energy Vortex", "Vas Corp Por",
@ -39,7 +38,7 @@ namespace Server.Spells.Eighth
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetPoint3D(this);
}
public void Target(IPoint3D p)
@ -66,34 +65,5 @@ namespace Server.Spells.Eighth
FinishSequence();
}
private class InternalTarget : Target
{
private EnergyVortexSpell m_Owner;
public InternalTarget(EnergyVortexSpell 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 OnTargetOutOfLOS(Mobile from, object o)
{
from.SendLocalizedMessage(501943); // Target cannot be seen. Try again.
from.Target = new InternalTarget(m_Owner);
from.Target.BeginTimeout(from, TimeoutTime - DateTime.UtcNow);
m_Owner = null;
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner?.FinishSequence();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Eighth
{
public class ResurrectionSpell : MagerySpell
public class ResurrectionSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Resurrection", "An Corp",
@ -34,45 +34,34 @@ namespace Server.Spells.Eighth
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, 1);
}
public void Target(Mobile m)
{
if (m == null)
return;
if (!Caster.CanSee(m))
{
Caster.SendLocalizedMessage(500237); // Target can not be seen.
}
else if (m == Caster)
{
Caster.SendLocalizedMessage(501039); // Thou can not resurrect thyself.
}
else if (!Caster.Alive)
{
Caster.SendLocalizedMessage(501040); // The resurrecter must be alive.
}
else if (m.Alive)
{
Caster.SendLocalizedMessage(501041); // Target is not dead.
}
else if (!Caster.InRange(m, 1))
{
Caster.SendLocalizedMessage(501042); // Target is not close enough.
}
else if (!m.Player)
{
Caster.SendLocalizedMessage(501043); // Target is not a being.
}
else if (m.Map == null || !m.Map.CanFit(m.Location, 16, false, false))
{
Caster.SendLocalizedMessage(501042); // Target can not be resurrected at that location.
m.SendLocalizedMessage(502391); // Thou can not be resurrected there!
}
else if (m.Region?.IsPartOf("Khaldun") == true)
{
Caster.SendLocalizedMessage(
1010395); // The veil of death in this area is too strong and resists thy efforts to restore life.
}
else if (CheckBSequence(m, true))
{
SpellHelper.Turn(Caster, m);
@ -86,26 +75,5 @@ namespace Server.Spells.Eighth
FinishSequence();
}
private class InternalTarget : Target
{
private ResurrectionSpell m_Owner;
public InternalTarget(ResurrectionSpell owner) : base(1, 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();
}
}
}
}

View file

@ -1,10 +1,9 @@
using System;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Spells.Fifth
{
public class BladeSpiritsSpell : MagerySpell
public class BladeSpiritsSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Blade Spirits", "In Jux Hur Ylem",
@ -46,7 +45,7 @@ namespace Server.Spells.Fifth
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetPoint3D(this);
}
public void Target(IPoint3D p)
@ -73,34 +72,5 @@ namespace Server.Spells.Fifth
FinishSequence();
}
private class InternalTarget : Target
{
private BladeSpiritsSpell m_Owner;
public InternalTarget(BladeSpiritsSpell 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 OnTargetOutOfLOS(Mobile from, object o)
{
from.SendLocalizedMessage(501943); // Target cannot be seen. Try again.
from.Target = new InternalTarget(m_Owner);
from.Target.BeginTimeout(from, TimeoutTime - DateTime.UtcNow);
m_Owner = null;
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner?.FinishSequence();
}
}
}
}

View file

@ -1,11 +1,10 @@
using System;
using Server.Items;
using Server.Misc;
using Server.Targeting;
namespace Server.Spells.Fifth
{
public class DispelFieldSpell : MagerySpell
public class DispelFieldSpell : MagerySpell, ISpellTargetingItem
{
private static SpellInfo m_Info = new SpellInfo(
"Dispel Field", "An Grav",
@ -25,25 +24,19 @@ namespace Server.Spells.Fifth
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12);
}
public void Target(Item item)
{
Type t = item.GetType();
if (!Caster.CanSee(item))
{
Caster.SendLocalizedMessage(500237); // Target can not be seen.
}
else if (!t.IsDefined(typeof(DispellableFieldAttribute), false))
{
if (item == null)
Caster.SendLocalizedMessage(1005049); // That cannot be dispelled.
else if (!Caster.CanSee(item))
Caster.SendLocalizedMessage(500237); // Target can not be seen.
else if (!item.GetType().IsDefined(typeof(DispellableFieldAttribute), false))
Caster.SendLocalizedMessage(1005049); // That cannot be dispelled.
}
else if (item is Moongate moongate && !moongate.Dispellable)
{
Caster.SendLocalizedMessage(1005047); // That magic is too chaotic
}
else if (CheckSequence())
{
SpellHelper.Turn(Caster, item);
@ -57,28 +50,5 @@ namespace Server.Spells.Fifth
FinishSequence();
}
private class InternalTarget : Target
{
private DispelFieldSpell m_Owner;
public InternalTarget(DispelFieldSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile from, object o)
{
if (o is Item item)
m_Owner.Target(item);
else
m_Owner.Caster.SendLocalizedMessage(1005049); // That cannot be dispelled.
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}

View file

@ -132,16 +132,14 @@ namespace Server.Spells.Fifth
public static void EndReflect(Mobile m)
{
ResistanceMod[] mods = m_Table[m];
if (!m_Table.TryGetValue(m, out ResistanceMod[] mods))
return;
if (mods != null)
{
for (int i = 0; i < mods.Length; ++i)
m.RemoveResistanceMod(mods[i]);
for (int i = 0; i < mods?.Length; ++i)
m.RemoveResistanceMod(mods[i]);
m_Table.Remove(m);
BuffInfo.RemoveBuff(m, BuffIcon.MagicReflection);
}
m_Table.Remove(m);
BuffInfo.RemoveBuff(m, BuffIcon.MagicReflection);
}
}
}

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Spells.Fifth
{
public class MindBlastSpell : MagerySpell
public class MindBlastSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Mind Blast", "Por Corp Wis",
@ -27,7 +27,7 @@ namespace Server.Spells.Fifth
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
}
private void AosDelay_Callback(Mobile caster, Mobile target, Mobile defender, int damage)
@ -43,10 +43,11 @@ namespace Server.Spells.Fifth
public void Target(Mobile m)
{
if (m == null)
return;
if (!Caster.CanSee(m))
{
Caster.SendLocalizedMessage(500237); // Target can not be seen.
}
else if (Core.AOS)
{
if (Caster.CanBeHarmful(m) && CheckSequence())
@ -122,26 +123,5 @@ namespace Server.Spells.Fifth
{
return 1.0; //This spell isn't affected by slayer spellbooks
}
private class InternalTarget : Target
{
private MindBlastSpell m_Owner;
public InternalTarget(MindBlastSpell 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();
}
}
}
}

View file

@ -5,7 +5,7 @@ using Server.Targeting;
namespace Server.Spells.Fifth
{
public class ParalyzeSpell : MagerySpell
public class ParalyzeSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Paralyze", "An Ex Por",
@ -24,15 +24,16 @@ namespace Server.Spells.Fifth
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 (Core.AOS && (m.Frozen || m.Paralyzed ||
m.Spell != null && m.Spell.IsCasting && !(m.Spell is PaladinSpell)))
{
@ -87,26 +88,5 @@ namespace Server.Spells.Fifth
FinishSequence();
}
public class InternalTarget : Target
{
private ParalyzeSpell m_Owner;
public InternalTarget(ParalyzeSpell 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();
}
}
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Items;
using Server.Misc;
@ -8,7 +7,7 @@ using Server.Targeting;
namespace Server.Spells.Fifth
{
public class PoisonFieldSpell : MagerySpell
public class PoisonFieldSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Poison Field", "In Nox Grav",
@ -28,7 +27,7 @@ namespace Server.Spells.Fifth
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12, false);
}
public void Target(IPoint3D p)
@ -270,26 +269,5 @@ namespace Server.Spells.Fifth
}
}
}
private class InternalTarget : Target
{
private PoisonFieldSpell m_Owner;
public InternalTarget(PoisonFieldSpell 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();
}
}
}
}

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Spells.First
{
public class ClumsySpell : MagerySpell
public class ClumsySpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Clumsy", "Uus Jux",
@ -21,11 +21,14 @@ namespace Server.Spells.First
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.
@ -55,26 +58,5 @@ namespace Server.Spells.First
FinishSequence();
}
private class InternalTarget : Target
{
private ClumsySpell m_Owner;
public InternalTarget(ClumsySpell 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();
}
}
}
}

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Spells.First
{
public class FeeblemindSpell : MagerySpell
public class FeeblemindSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Feeblemind", "Rel Wis",
@ -21,15 +21,16 @@ namespace Server.Spells.First
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);
@ -55,26 +56,5 @@ namespace Server.Spells.First
FinishSequence();
}
private class InternalTarget : Target
{
private FeeblemindSpell m_Owner;
public InternalTarget(FeeblemindSpell 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();
}
}
}
}

View file

@ -6,7 +6,7 @@ using Server.Targeting;
namespace Server.Spells.First
{
public class HealSpell : MagerySpell
public class HealSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Heal", "In Mani",
@ -36,11 +36,14 @@ namespace Server.Spells.First
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.
@ -90,26 +93,5 @@ namespace Server.Spells.First
FinishSequence();
}
public class InternalTarget : Target
{
private HealSpell m_Owner;
public InternalTarget(HealSpell 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();
}
}
}
}

View file

@ -2,7 +2,7 @@ using Server.Targeting;
namespace Server.Spells.First
{
public class MagicArrowSpell : MagerySpell
public class MagicArrowSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Magic Arrow", "In Por Ylem",
@ -23,15 +23,16 @@ namespace Server.Spells.First
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;
@ -68,26 +69,5 @@ namespace Server.Spells.First
FinishSequence();
}
private class InternalTarget : Target
{
private MagicArrowSpell m_Owner;
public InternalTarget(MagicArrowSpell 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();
}
}
}
}

View file

@ -138,16 +138,14 @@ namespace Server.Spells.First
public static void EndArmor(Mobile m)
{
ResistanceMod[] mods = m_Table[m];
if (!m_Table.TryGetValue(m, out ResistanceMod[] mods))
return;
if (mods != null)
{
for (int i = 0; i < mods.Length; ++i)
m.RemoveResistanceMod(mods[i]);
for (int i = 0; i < mods?.Length; ++i)
m.RemoveResistanceMod(mods[i]);
m_Table.Remove(m);
BuffInfo.RemoveBuff(m, BuffIcon.ReactiveArmor);
}
m_Table.Remove(m);
BuffInfo.RemoveBuff(m, BuffIcon.ReactiveArmor);
}
}
}

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Spells.First
{
public class WeakenSpell : MagerySpell
public class WeakenSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Weaken", "Des Mani",
@ -21,15 +21,16 @@ namespace Server.Spells.First
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);
@ -55,26 +56,5 @@ namespace Server.Spells.First
FinishSequence();
}
public class InternalTarget : Target
{
private WeakenSpell m_Owner;
public InternalTarget(WeakenSpell 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();
}
}
}
}

View file

@ -6,7 +6,7 @@ using Server.Targeting;
namespace Server.Spells.Fourth
{
public class ArchCureSpell : MagerySpell
public class ArchCureSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Arch Cure", "Vas An Nox",
@ -28,7 +28,7 @@ namespace Server.Spells.Fourth
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)
@ -151,26 +151,5 @@ namespace Server.Spells.Fourth
{
return Notoriety.Compute(from, to) == Notoriety.Ally;
}
private class InternalTarget : Target
{
private ArchCureSpell m_Owner;
public InternalTarget(ArchCureSpell 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();
}
}
}
}

View file

@ -7,7 +7,7 @@ using Server.Targeting;
namespace Server.Spells.Fourth
{
public class ArchProtectionSpell : MagerySpell
public class ArchProtectionSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Arch Protection", "Vas Uus Sanct",
@ -29,7 +29,7 @@ namespace Server.Spells.Fourth
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)
@ -130,26 +130,5 @@ namespace Server.Spells.Fourth
RemoveEntry(m_Owner);
}
}
private class InternalTarget : Target
{
private ArchProtectionSpell m_Owner;
public InternalTarget(ArchProtectionSpell 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();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Fourth
{
public class CurseSpell : MagerySpell
public class CurseSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Curse", "Des Sanct",
@ -25,7 +25,7 @@ namespace Server.Spells.Fourth
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
}
public static void RemoveEffect(Mobile m)
@ -42,10 +42,11 @@ namespace Server.Spells.Fourth
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);
@ -86,26 +87,5 @@ namespace Server.Spells.Fourth
FinishSequence();
}
private class InternalTarget : Target
{
private CurseSpell m_Owner;
public InternalTarget(CurseSpell 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();
}
}
}
}

View file

@ -7,7 +7,7 @@ using Server.Targeting;
namespace Server.Spells.Fourth
{
public class FireFieldSpell : MagerySpell
public class FireFieldSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Fire Field", "In Flam Grav",
@ -27,7 +27,7 @@ namespace Server.Spells.Fourth
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)
@ -276,26 +276,5 @@ namespace Server.Spells.Fourth
}
}
}
private class InternalTarget : Target
{
private FireFieldSpell m_Owner;
public InternalTarget(FireFieldSpell 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();
}
}
}
}

View file

@ -6,7 +6,7 @@ using Server.Targeting;
namespace Server.Spells.Fourth
{
public class GreaterHealSpell : MagerySpell
public class GreaterHealSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Greater Heal", "In Vas Mani",
@ -37,15 +37,16 @@ namespace Server.Spells.Fourth
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.
}
else if (m is BaseCreature creature && creature.IsAnimatedDead)
{
Caster.SendLocalizedMessage(1061654); // You cannot heal that which is not alive.
@ -80,26 +81,5 @@ namespace Server.Spells.Fourth
FinishSequence();
}
public class InternalTarget : Target
{
private GreaterHealSpell m_Owner;
public InternalTarget(GreaterHealSpell 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();
}
}
}
}

View file

@ -2,7 +2,7 @@ using Server.Targeting;
namespace Server.Spells.Fourth
{
public class LightningSpell : MagerySpell
public class LightningSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Lightning", "Por Ort Grav",
@ -22,15 +22,16 @@ namespace Server.Spells.Fourth
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);
@ -64,26 +65,5 @@ namespace Server.Spells.Fourth
FinishSequence();
}
private class InternalTarget : Target
{
private LightningSpell m_Owner;
public InternalTarget(LightningSpell 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();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Fourth
{
public class ManaDrainSpell : MagerySpell
public class ManaDrainSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Mana Drain", "Ort Rel",
@ -25,7 +25,7 @@ namespace Server.Spells.Fourth
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
}
private void AosDelay_Callback(Mobile m, int mana)
@ -43,10 +43,11 @@ namespace Server.Spells.Fourth
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);
@ -103,26 +104,5 @@ namespace Server.Spells.Fourth
{
return 99.0;
}
private class InternalTarget : Target
{
private ManaDrainSpell m_Owner;
public InternalTarget(ManaDrainSpell 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();
}
}
}
}

View file

@ -2,14 +2,11 @@ using Server.Factions;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Multis;
using Server.Network;
using Server.Spells.Necromancy;
using Server.Targeting;
namespace Server.Spells.Fourth
{
public class RecallSpell : MagerySpell
public class RecallSpell : MagerySpell, IRecallSpell
{
private static SpellInfo m_Info = new SpellInfo(
"Recall", "Kal Ort Por",
@ -46,7 +43,7 @@ namespace Server.Spells.Fourth
public override void OnCast()
{
if (m_Entry == null)
Caster.Target = new InternalTarget(this);
Caster.Target = new RecallSpellTarget(this);
else
Effect(m_Entry.Location, m_Entry.Map, true);
}
@ -142,63 +139,5 @@ namespace Server.Spells.Fourth
FinishSequence();
}
private class InternalTarget : Target
{
private RecallSpell m_Owner;
public InternalTarget(RecallSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
{
m_Owner = owner;
owner.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item.
}
protected override void OnTarget(Mobile from, object o)
{
if (o is RecallRune rune)
{
if (rune.Marked)
m_Owner.Effect(rune.Target, rune.TargetMap, true);
else
from.SendLocalizedMessage(501805); // That rune is not yet marked.
}
else if (o is Runebook runebook)
{
RunebookEntry e = runebook.Default;
if (e != null)
m_Owner.Effect(e.Location, e.Map, true);
else
from.SendLocalizedMessage(502354); // Target is not marked.
}
else if (o is Key key && key.KeyValue != 0 && key.Link is BaseBoat boat)
{
if (!boat.Deleted && boat.CheckKey(key.KeyValue))
m_Owner.Effect(boat.GetMarkedLocation(), boat.Map, false);
else
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357,
from.Name, "")); // I can not recall from that object.
}
else if (o is HouseRaffleDeed deed && deed.ValidLocation())
{
m_Owner.Effect(deed.PlotLocation, deed.PlotFacet, true);
}
else
{
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name,
"")); // I can not recall from that object.
}
}
protected override void OnNonlocalTarget(Mobile from, object o)
{
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}

View file

@ -1,10 +1,9 @@
using System;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Spells.Mysticism
{
public class AnimatedWeaponSpell : MysticSpell
public class AnimatedWeaponSpell : MysticSpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Animated Weapon", "In Jux Por Ylem",
@ -28,7 +27,7 @@ namespace Server.Spells.Mysticism
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetPoint3D(this);
}
public void Target(IPoint3D p)
@ -63,27 +62,5 @@ namespace Server.Spells.Mysticism
FinishSequence();
}
public class InternalTarget : Target
{
private AnimatedWeaponSpell m_Owner;
public InternalTarget(AnimatedWeaponSpell owner)
: base(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();
}
}
}
}

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Spells.Mysticism
{
public class EagleStrikeSpell : MysticSpell
public class EagleStrikeSpell : MysticSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Eagle Strike", "Kal Por Xen",
@ -27,11 +27,14 @@ namespace Server.Spells.Mysticism
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful);
}
public void Target(Mobile m)
{
if (m == null)
return;
if (CheckHSequence(m))
{
/* Conjures a magical eagle that assaults the Target with
@ -62,27 +65,5 @@ namespace Server.Spells.Mysticism
to.PlaySound(0x64D);
}
private class InternalTarget : Target
{
private EagleStrikeSpell m_Owner;
public InternalTarget(EagleStrikeSpell owner)
: base(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();
}
}
}
}

View file

@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using Server.Network;
using Server.Targeting;
namespace Server.Spells.Mysticism
{
public class HailStormSpell : MysticSpell
public class HailStormSpell : MysticSpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Hail Storm", "Kal Des Ylem",
@ -29,7 +28,7 @@ namespace Server.Spells.Mysticism
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetPoint3D(this);
}
public void Target(IPoint3D p)
@ -118,27 +117,5 @@ namespace Server.Spells.Mysticism
new HuedEffect(EffectType.Moving, Serial.Zero, Serial.Zero, 0x36D4, orig, dest, 0, 0, false, false, 0x63,
0x4));
}
private class InternalTarget : Target
{
private HailStormSpell m_Owner;
public InternalTarget(HailStormSpell owner)
: base(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();
}
}
}
}

View file

@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using Server.Network;
using Server.Targeting;
namespace Server.Spells.Mysticism
{
public class NetherCycloneSpell : MysticSpell
public class NetherCycloneSpell : MysticSpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Nether Cyclone", "Grav Hur",
@ -29,7 +28,7 @@ namespace Server.Spells.Mysticism
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetPoint3D(this);
}
public void Target(IPoint3D p)
@ -127,27 +126,5 @@ namespace Server.Spells.Mysticism
new HuedEffect(EffectType.Moving, Serial.Zero, Serial.Zero, 0x375A, orig, dest, 0, 0, false, false, 0x49A,
0x4));
}
private class InternalTarget : Target
{
private NetherCycloneSpell m_Owner;
public InternalTarget(NetherCycloneSpell owner)
: base(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();
}
}
}
}

View file

@ -8,7 +8,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy
{
public class AnimateDeadSpell : NecromancerSpell
public class AnimateDeadSpell : NecromancerSpell, ISpellTargetingItem
{
private static SpellInfo m_Info = new SpellInfo(
"Animate Dead", "Uus Corp",
@ -105,7 +105,7 @@ namespace Server.Spells.Necromancy
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12);
Caster.SendLocalizedMessage(1061083); // Animate what corpse?
}
@ -128,9 +128,9 @@ namespace Server.Spells.Necromancy
return null;
}
public void Target(object obj)
public void Target(Item item)
{
MaabusCoffinComponent comp = obj as MaabusCoffinComponent;
MaabusCoffinComponent comp = item as MaabusCoffinComponent;
if (comp?.Addon is MaabusCoffin addon)
{
@ -152,7 +152,7 @@ namespace Server.Spells.Necromancy
return;
}
if (!(obj is Corpse c))
if (!(item is Corpse c))
{
Caster.SendLocalizedMessage(1061084); // You cannot animate that.
}
@ -370,25 +370,5 @@ namespace Server.Spells.Necromancy
m_Requirement = requirement;
}
}
private class InternalTarget : Target
{
private AnimateDeadSpell m_Owner;
public InternalTarget(AnimateDeadSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile from, object o)
{
m_Owner.Target(o);
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}

View file

@ -5,7 +5,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy
{
public class BloodOathSpell : NecromancerSpell
public class BloodOathSpell : NecromancerSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Blood Oath", "In Jux Mani Xen",
@ -28,20 +28,18 @@ 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 (Caster == m || !(m is PlayerMobile || m is BaseCreature)
) // only PlayerMobile and BaseCreature implement blood oath checking
{
if (m == null)
Caster.SendLocalizedMessage(1060508); // You can't curse that.
// only PlayerMobile and BaseCreature implement blood oath checking
else if (Caster == m || !(m is PlayerMobile || m is BaseCreature))
Caster.SendLocalizedMessage(1060508); // You can't curse that.
}
else if (m_OathTable.ContainsKey(Caster))
{
Caster.SendLocalizedMessage(1061607); // You are already bonded in a Blood Oath.
}
else if (m_OathTable.ContainsKey(m))
{
if (m.Player)
@ -148,28 +146,5 @@ namespace Server.Spells.Necromancy
m_Table.Remove(m_Caster);
}
}
private class InternalTarget : Target
{
private BloodOathSpell m_Owner;
public InternalTarget(BloodOathSpell 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();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy
{
public class CorpseSkinSpell : NecromancerSpell
public class CorpseSkinSpell : NecromancerSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Corpse Skin", "In Agle Corp Ylem",
@ -27,11 +27,14 @@ 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 == null)
return;
if (CheckHSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -89,13 +92,11 @@ namespace Server.Spells.Necromancy
public static bool RemoveCurse(Mobile m)
{
ExpireTimer t = m_Table[m];
if (t == null)
if (!m_Table.TryGetValue(m, out ExpireTimer t))
return false;
m.SendLocalizedMessage(1061688); // Your skin returns to normal.
t.DoExpire();
t?.DoExpire();
return true;
}
@ -126,26 +127,5 @@ namespace Server.Spells.Necromancy
DoExpire();
}
}
private class InternalTarget : Target
{
private CorpseSkinSpell m_Owner;
public InternalTarget(CorpseSkinSpell 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();
}
}
}
}

View file

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

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy
{
public class MindRotSpell : NecromancerSpell
public class MindRotSpell : NecromancerSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Mind Rot", "Wis An Ben",
@ -28,15 +28,15 @@ 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 (HasMindRotScalar(m))
{
if (m == null)
Caster.SendLocalizedMessage(1060508); // You can't curse that.
else if (HasMindRotScalar(m))
Caster.SendLocalizedMessage(1005559); // This spell is already in effect.
}
else if (CheckHSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -103,29 +103,6 @@ namespace Server.Spells.Necromancy
target.SendLocalizedMessage(1074384);
}
}
private class InternalTarget : Target
{
private MindRotSpell m_Owner;
public InternalTarget(MindRotSpell 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();
}
}
}
public class MRExpireTimer : Timer

View file

@ -5,7 +5,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy
{
public class PainSpikeSpell : NecromancerSpell
public class PainSpikeSpell : NecromancerSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Pain Spike", "In Sar",
@ -30,11 +30,14 @@ 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 == null)
return;
if (CheckHSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -108,26 +111,5 @@ namespace Server.Spells.Necromancy
BuffInfo.RemoveBuff(m_Mobile, BuffIcon.PainSpike);
}
}
private class InternalTarget : Target
{
private PainSpikeSpell m_Owner;
public InternalTarget(PainSpikeSpell 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();
}
}
}
}

View file

@ -7,7 +7,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy
{
public class PoisonStrikeSpell : NecromancerSpell
public class PoisonStrikeSpell : NecromancerSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Poison Strike", "In Vas Nox",
@ -30,11 +30,14 @@ 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 == null)
return;
if (CheckHSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -92,27 +95,5 @@ namespace Server.Spells.Necromancy
FinishSequence();
}
private class InternalTarget : Target
{
private PoisonStrikeSpell m_Owner;
public InternalTarget(PoisonStrikeSpell 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();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy
{
public class StrangleSpell : NecromancerSpell
public class StrangleSpell : NecromancerSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Strangle", "In Bal Nox",
@ -27,11 +27,14 @@ 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 == null)
return;
if (CheckHSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -208,26 +211,5 @@ namespace Server.Spells.Necromancy
}
}
}
private class InternalTarget : Target
{
private StrangleSpell m_Owner;
public InternalTarget(StrangleSpell 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();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy
{
public class VengefulSpiritSpell : NecromancerSpell
public class VengefulSpiritSpell : NecromancerSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Vengeful Spirit", "Kal Xen Bal Beh",
@ -26,7 +26,7 @@ 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 override bool CheckCast()
@ -45,10 +45,11 @@ namespace Server.Spells.Necromancy
public void Target(Mobile m)
{
if (m == null)
return;
if (Caster == m)
{
Caster.SendLocalizedMessage(1061832); // You cannot exact vengeance on yourself.
}
else if (CheckHSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -70,26 +71,5 @@ namespace Server.Spells.Necromancy
FinishSequence();
}
private class InternalTarget : Target
{
private VengefulSpiritSpell m_Owner;
public InternalTarget(VengefulSpiritSpell 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();
}
}
}
}

View file

@ -9,7 +9,7 @@ using Server.Targeting;
namespace Server.Spells.Ninjitsu
{
public class Shadowjump : NinjaSpell
public class Shadowjump : NinjaSpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Shadowjump", null,
@ -48,7 +48,7 @@ namespace Server.Spells.Ninjitsu
public override void OnCast()
{
Caster.SendLocalizedMessage(1063088); // You prepare to perform a Shadowjump.
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, 11);
}
public void Target(IPoint3D p)
@ -110,26 +110,5 @@ namespace Server.Spells.Ninjitsu
FinishSequence();
}
public class InternalTarget : Target
{
private Shadowjump m_Owner;
public InternalTarget(Shadowjump owner) : base(11, 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();
}
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Second
{
public class AgilitySpell : MagerySpell
public class AgilitySpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Agility", "Ex Uus",
@ -33,15 +33,16 @@ namespace Server.Spells.Second
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.
}
else if (CheckBSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -59,26 +60,5 @@ namespace Server.Spells.Second
FinishSequence();
}
private class InternalTarget : Target
{
private AgilitySpell m_Owner;
public InternalTarget(AgilitySpell 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();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Second
{
public class CunningSpell : MagerySpell
public class CunningSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Cunning", "Uus Wis",
@ -33,15 +33,16 @@ namespace Server.Spells.Second
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.
}
else if (CheckBSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -59,26 +60,5 @@ namespace Server.Spells.Second
FinishSequence();
}
private class InternalTarget : Target
{
private CunningSpell m_Owner;
public InternalTarget(CunningSpell 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();
}
}
}
}

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Spells.Second
{
public class CureSpell : MagerySpell
public class CureSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Cure", "An Nox",
@ -32,15 +32,16 @@ namespace Server.Spells.Second
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.
}
else if (CheckBSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -75,26 +76,5 @@ namespace Server.Spells.Second
FinishSequence();
}
public class InternalTarget : Target
{
private CureSpell m_Owner;
public InternalTarget(CureSpell 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();
}
}
}
}

View file

@ -2,7 +2,7 @@ using Server.Targeting;
namespace Server.Spells.Second
{
public class HarmSpell : MagerySpell
public class HarmSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Harm", "An Mani",
@ -22,7 +22,7 @@ namespace Server.Spells.Second
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
}
public override double GetSlayerDamageScalar(Mobile target)
@ -32,10 +32,11 @@ namespace Server.Spells.Second
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);
@ -83,26 +84,5 @@ namespace Server.Spells.Second
FinishSequence();
}
private class InternalTarget : Target
{
private HarmSpell m_Owner;
public InternalTarget(HarmSpell 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();
}
}
}
}

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Spells.Second
{
public class MagicTrapSpell : MagerySpell
public class MagicTrapSpell : MagerySpell, ISpellTargetingItem
{
private static SpellInfo m_Info = new SpellInfo(
"Magic Trap", "In Jux",
@ -22,16 +22,18 @@ namespace Server.Spells.Second
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12);
}
public void Target(TrappableContainer item)
public void Target(Item item)
{
if (!Caster.CanSee(item))
if (!(item is TrappableContainer cont))
Caster.SendMessage("You can't trap that"); // TODO: Localization for this?
else if (!Caster.CanSee(item))
{
Caster.SendLocalizedMessage(500237); // Target can not be seen.
}
else if (item.TrapType != TrapType.None && item.TrapType != TrapType.MagicTrap)
else if (cont.TrapType != TrapType.None && cont.TrapType != TrapType.MagicTrap)
{
base.DoFizzle();
}
@ -39,9 +41,9 @@ namespace Server.Spells.Second
{
SpellHelper.Turn(Caster, item);
item.TrapType = TrapType.MagicTrap;
item.TrapPower = Core.AOS ? Utility.RandomMinMax(10, 50) : 1;
item.TrapLevel = 0;
cont.TrapType = TrapType.MagicTrap;
cont.TrapPower = Core.AOS ? Utility.RandomMinMax(10, 50) : 1;
cont.TrapLevel = 0;
Point3D loc = item.GetWorldLocation();
@ -66,28 +68,5 @@ namespace Server.Spells.Second
FinishSequence();
}
private class InternalTarget : Target
{
private MagicTrapSpell m_Owner;
public InternalTarget(MagicTrapSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile from, object o)
{
if (o is TrappableContainer container)
m_Owner.Target(container);
else
from.SendMessage("You can't trap that");
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Spells.Second
{
public class RemoveTrapSpell : MagerySpell
public class RemoveTrapSpell : MagerySpell, ISpellTargetingItem
{
private static SpellInfo m_Info = new SpellInfo(
"Remove Trap", "An Jux",
@ -21,17 +21,19 @@ namespace Server.Spells.Second
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.SendMessage("What do you wish to untrap?");
Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12);
Caster.SendMessage("What do you wish to untrap?"); // TODO: Localization?
}
public void Target(TrappableContainer item)
public void Target(Item item)
{
if (!Caster.CanSee(item))
if (!(item is TrappableContainer cont))
Caster.SendMessage("You can't disarm that"); // TODO: Localization?
else if (!Caster.CanSee(item))
{
Caster.SendLocalizedMessage(500237); // Target can not be seen.
}
else if (item.TrapType != TrapType.None && item.TrapType != TrapType.MagicTrap)
else if (cont.TrapType != TrapType.None && cont.TrapType != TrapType.MagicTrap)
{
base.DoFizzle();
}
@ -45,35 +47,12 @@ namespace Server.Spells.Second
5015);
Effects.PlaySound(loc, item.Map, 0x1F0);
item.TrapType = TrapType.None;
item.TrapPower = 0;
item.TrapLevel = 0;
cont.TrapType = TrapType.None;
cont.TrapPower = 0;
cont.TrapLevel = 0;
}
FinishSequence();
}
private class InternalTarget : Target
{
private RemoveTrapSpell m_Owner;
public InternalTarget(RemoveTrapSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile from, object o)
{
if (o is TrappableContainer container)
m_Owner.Target(container);
else
from.SendMessage("You can't disarm that");
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Second
{
public class StrengthSpell : MagerySpell
public class StrengthSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Strength", "Uus Mani",
@ -33,15 +33,16 @@ namespace Server.Spells.Second
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.
}
else if (CheckBSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -59,26 +60,5 @@ namespace Server.Spells.Second
FinishSequence();
}
private class InternalTarget : Target
{
private StrengthSpell m_Owner;
public InternalTarget(StrengthSpell 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();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Seventh
{
public class ChainLightningSpell : MagerySpell
public class ChainLightningSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Chain Lightning", "Vas Ort Grav",
@ -27,7 +27,7 @@ namespace Server.Spells.Seventh
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)
@ -107,26 +107,5 @@ namespace Server.Spells.Seventh
FinishSequence();
}
private class InternalTarget : Target
{
private ChainLightningSpell m_Owner;
public InternalTarget(ChainLightningSpell 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();
}
}
}
}

View file

@ -6,7 +6,7 @@ using Server.Targeting;
namespace Server.Spells.Seventh
{
public class EnergyFieldSpell : MagerySpell
public class EnergyFieldSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Energy Field", "In Sanct Grav",
@ -27,7 +27,7 @@ namespace Server.Spells.Seventh
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)
@ -63,7 +63,7 @@ namespace Server.Spells.Seventh
TimeSpan duration;
if (Core.AOS)
duration = TimeSpan.FromSeconds((15 + Caster.Skills.Magery.Fixed / 5) / 7);
duration = TimeSpan.FromSeconds((15 + Caster.Skills.Magery.Fixed / 5) / 7.0);
else
duration = TimeSpan.FromSeconds(Caster.Skills.Magery.Value * 0.28 +
2.0); // (28% of magery) + 2.0 seconds
@ -141,16 +141,11 @@ namespace Server.Spells.Seventh
public override bool OnMoveOver(Mobile m)
{
int noto;
if (m is PlayerMobile)
{
noto = Notoriety.Compute(m_Caster, m);
if (noto == Notoriety.Enemy || noto == Notoriety.Ally)
return false;
}
return base.OnMoveOver(m);
if (!(m is PlayerMobile))
return base.OnMoveOver(m);
int noto = Notoriety.Compute(m_Caster, m);
return noto != Notoriety.Enemy && noto != Notoriety.Ally && base.OnMoveOver(m);
}
public override void OnAfterDelete()
@ -176,26 +171,5 @@ namespace Server.Spells.Seventh
}
}
}
private class InternalTarget : Target
{
private EnergyFieldSpell m_Owner;
public InternalTarget(EnergyFieldSpell 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();
}
}
}
}

View file

@ -2,7 +2,7 @@ using Server.Targeting;
namespace Server.Spells.Seventh
{
public class FlameStrikeSpell : MagerySpell
public class FlameStrikeSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Flame Strike", "Kal Vas Flam",
@ -22,15 +22,16 @@ namespace Server.Spells.Seventh
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);
@ -65,26 +66,5 @@ namespace Server.Spells.Seventh
FinishSequence();
}
private class InternalTarget : Target
{
private FlameStrikeSpell m_Owner;
public InternalTarget(FlameStrikeSpell 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();
}
}
}
}

View file

@ -4,12 +4,10 @@ using Server.Factions;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Network;
using Server.Targeting;
namespace Server.Spells.Seventh
{
public class GateTravelSpell : MagerySpell
public class GateTravelSpell : MagerySpell, IRecallSpell
{
private static SpellInfo m_Info = new SpellInfo(
"Gate Travel", "Vas Rel Por",
@ -32,7 +30,7 @@ namespace Server.Spells.Seventh
public override void OnCast()
{
if (m_Entry == null)
Caster.Target = new InternalTarget(this);
Caster.Target = new RecallSpellTarget(this, false);
else
Effect(m_Entry.Location, m_Entry.Map, true);
}
@ -182,64 +180,5 @@ namespace Server.Spells.Seventh
}
}
}
private class InternalTarget : Target
{
private GateTravelSpell m_Owner;
public InternalTarget(GateTravelSpell owner) : base(12, false, TargetFlags.None)
{
m_Owner = owner;
owner.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item.
}
protected override void OnTarget(Mobile from, object o)
{
if (o is RecallRune rune)
{
if (rune.Marked)
m_Owner.Effect(rune.Target, rune.TargetMap, true);
else
from.SendLocalizedMessage(501803); // That rune is not yet marked.
}
else if (o is Runebook runebook)
{
RunebookEntry e = runebook.Default;
if (e != null)
m_Owner.Effect(e.Location, e.Map, true);
else
from.SendLocalizedMessage(502354); // Target is not marked.
}
/*else if ( o is Key && ((Key)o).KeyValue != 0 && ((Key)o).Link is BaseBoat )
{
BaseBoat boat = ((Key)o).Link as BaseBoat;
if ( !boat.Deleted && boat.CheckKey( ((Key)o).KeyValue ) )
m_Owner.Effect( boat.GetMarkedLocation(), boat.Map, false );
else
from.Send( new MessageLocalized( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501030, from.Name, "" ) ); // I can not gate travel from that object.
}*/
else if (o is HouseRaffleDeed deed && deed.ValidLocation())
{
m_Owner.Effect(deed.PlotLocation, deed.PlotFacet, true);
}
else
{
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501030, from.Name,
"")); // I can not gate travel from that object.
}
}
protected override void OnNonlocalTarget(Mobile from, object o)
{
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}

View file

@ -2,7 +2,7 @@ using Server.Targeting;
namespace Server.Spells.Seventh
{
public class ManaVampireSpell : MagerySpell
public class ManaVampireSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Mana Vampire", "Ort Sanct",
@ -22,15 +22,16 @@ namespace Server.Spells.Seventh
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);
@ -92,25 +93,5 @@ namespace Server.Spells.Seventh
{
return 98.0;
}
private class InternalTarget : Target
{
private ManaVampireSpell m_Owner;
public InternalTarget(ManaVampireSpell 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();
}
}
}
}

View file

@ -1,12 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using Server.Items;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Spells.Seventh
{
public class MassDispelSpell : MagerySpell
public class MassDispelSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Mass Dispel", "Vas An Ort",
@ -26,7 +24,7 @@ namespace Server.Spells.Seventh
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)
@ -77,26 +75,5 @@ namespace Server.Spells.Seventh
FinishSequence();
}
private class InternalTarget : Target
{
private MassDispelSpell m_Owner;
public InternalTarget(MassDispelSpell 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();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Seventh
{
public class MeteorSwarmSpell : MagerySpell
public class MeteorSwarmSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Meteor Swarm", "Flam Kal Des Ylem",
@ -27,7 +27,7 @@ namespace Server.Spells.Seventh
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)
@ -110,26 +110,5 @@ namespace Server.Spells.Seventh
FinishSequence();
}
private class InternalTarget : Target
{
private MeteorSwarmSpell m_Owner;
public InternalTarget(MeteorSwarmSpell 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();
}
}
}
}

View file

@ -166,7 +166,7 @@ namespace Server.Spells.Seventh
if (!m_Timers.TryGetValue(m, out InternalTimer timer))
return;
timer.Stop();
timer?.Stop();
m_Timers.Remove(m);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Server.Spells.Spellweaving
{

View file

@ -6,7 +6,7 @@ using Server.Targeting;
namespace Server.Spells.Spellweaving
{
public class GiftOfLifeSpell : ArcanistSpell
public class GiftOfLifeSpell : ArcanistSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Gift of Life", "Illorae",
@ -34,27 +34,23 @@ namespace Server.Spells.Spellweaving
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, 10);
}
public void Target(Mobile m)
{
if (!Caster.CanSee(m))
{
if (m == null)
Caster.SendLocalizedMessage(1072077); // You may only cast this spell on yourself or a bonded pet.
else if (!Caster.CanSee(m))
Caster.SendLocalizedMessage(500237); // Target can not be seen.
}
else if (m.IsDeadBondedPet || !m.Alive)
{
// As per Osi: Nothing happens.
}
else if (m != Caster && !(m is BaseCreature bc && bc.IsBonded && bc.ControlMaster == Caster))
{
Caster.SendLocalizedMessage(1072077); // You may only cast this spell on yourself or a bonded pet.
}
else if (m_Table.ContainsKey(m))
{
Caster.SendLocalizedMessage(501775); // This spell is already in effect.
}
else if (CheckBSequence(m))
{
if (Caster == m)
@ -132,7 +128,7 @@ namespace Server.Spells.Spellweaving
m.SendGump(new ResurrectGump(m, hitsScalar));
}
//Per OSI, buff is removed when gump sent, irregardless of online status or acceptence
//Per OSI, buff is removed when gump sent, irregardless of online status or acceptance
timer.DoExpire();
}
@ -174,29 +170,5 @@ namespace Server.Spells.Spellweaving
BuffInfo.RemoveBuff(m_Mobile, BuffIcon.GiftOfLife);
}
}
public class InternalTarget : Target
{
private GiftOfLifeSpell m_Owner;
public InternalTarget(GiftOfLifeSpell owner)
: base(10, false, TargetFlags.Beneficial)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile m, object o)
{
if (o is Mobile mobile)
m_Owner.Target(mobile);
else
m.SendLocalizedMessage(1072077); // You may only cast this spell on yourself or a bonded pet.
}
protected override void OnTargetFinish(Mobile m)
{
m_Owner.FinishSequence();
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Spellweaving
{
public class GiftOfRenewalSpell : ArcanistSpell
public class GiftOfRenewalSpell : ArcanistSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Gift of Renewal", "Olorisstra",
@ -25,20 +25,20 @@ namespace Server.Spells.Spellweaving
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, 10);
}
public void Target(Mobile m)
{
if (!Caster.CanSee(m)) Caster.SendLocalizedMessage(500237); // Target can not be seen.
if (m_Table.ContainsKey(m))
{
if (m == null)
return;
if (!Caster.CanSee(m))
Caster.SendLocalizedMessage(500237); // Target can not be seen.
else if (m_Table.ContainsKey(m))
Caster.SendLocalizedMessage(501775); // This spell is already in effect.
}
else if (!Caster.CanBeginAction<GiftOfRenewalSpell>())
{
Caster.SendLocalizedMessage(501789); // You must wait before trying again.
}
else if (CheckBSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -151,27 +151,5 @@ namespace Server.Spells.Spellweaving
m.FixedParticles(0x376A, 9, 32, 5005, EffectLayer.Waist);
}
}
private class InternalTarget : Target
{
private GiftOfRenewalSpell m_Owner;
public InternalTarget(GiftOfRenewalSpell owner)
: base(10, false, TargetFlags.Beneficial)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile m, object o)
{
if (o is Mobile mobile)
m_Owner.Target(mobile);
}
protected override void OnTargetFinish(Mobile m)
{
m_Owner.FinishSequence();
}
}
}
}

View file

@ -5,7 +5,7 @@ using Server.Targeting;
namespace Server.Spells.Spellweaving
{
public class NatureFurySpell : ArcanistSpell
public class NatureFurySpell : ArcanistSpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Nature's Fury", "Rauvvrae",
@ -39,7 +39,7 @@ namespace Server.Spells.Spellweaving
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, 10);
}
public void Target(IPoint3D point)
@ -70,28 +70,6 @@ namespace Server.Spells.Spellweaving
FinishSequence();
}
private class InternalTarget : Target
{
private NatureFurySpell m_Owner;
public InternalTarget(NatureFurySpell owner)
: base(10, 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();
}
}
private class InternalTimer : Timer
{
private NatureFury m_NatureFury;

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Server.Spells.Spellweaving
{

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Spells.Spellweaving
{
public class WordOfDeathSpell : ArcanistSpell
public class WordOfDeathSpell : ArcanistSpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo("Word of Death", "Nyraxle", -1);
@ -18,15 +18,16 @@ namespace Server.Spells.Spellweaving
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, 10);
}
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))
{
Point3D loc = m.Location;
@ -63,26 +64,5 @@ namespace Server.Spells.Spellweaving
FinishSequence();
}
public class InternalTarget : Target
{
private WordOfDeathSpell m_Owner;
public InternalTarget(WordOfDeathSpell owner) : base(10, false, TargetFlags.Harmful)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile m, object o)
{
if (o is Mobile mobile)
m_Owner.Target(mobile);
}
protected override void OnTargetFinish(Mobile m)
{
m_Owner.FinishSequence();
}
}
}
}

View file

@ -0,0 +1,9 @@
namespace Server.Spells
{
public interface IRecallSpell
{
Mobile Caster{ get; }
void Effect(Point3D loc, Map map, bool checkMulti);
void FinishSequence();
}
}

View file

@ -0,0 +1,7 @@
namespace Server.Spells
{
public interface ISpellTarget
{
ISpell Spell{ get; }
}
}

View file

@ -0,0 +1,66 @@
using Server.Items;
using Server.Multis;
using Server.Network;
using Server.Targeting;
namespace Server.Spells
{
public class RecallSpellTarget : Target
{
private IRecallSpell m_Spell;
private bool m_ToBoat;
public RecallSpellTarget(IRecallSpell spell, bool toBoat = true) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
{
m_Spell = spell;
m_ToBoat = toBoat;
m_Spell.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item.
}
protected override void OnTarget(Mobile from, object o)
{
if (o is RecallRune rune)
{
if (rune.Marked)
m_Spell.Effect(rune.Target, rune.TargetMap, true);
else
from.SendLocalizedMessage(501805); // That rune is not yet marked.
}
else if (o is Runebook runebook)
{
RunebookEntry e = runebook.Default;
if (e != null)
m_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 (!boat.Deleted && boat.CheckKey(key.KeyValue))
m_Spell.Effect(boat.GetMarkedLocation(), boat.Map, false);
else
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357,
from.Name, "")); // I can not recall from that object.
}
else if (o is HouseRaffleDeed deed && deed.ValidLocation())
{
m_Spell.Effect(deed.PlotLocation, deed.PlotFacet, true);
}
else
{
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name,
"")); // I can not recall from that object.
}
}
protected override void OnNonlocalTarget(Mobile from, object o)
{
}
protected override void OnTargetFinish(Mobile from)
{
m_Spell?.FinishSequence();
}
}
}

View file

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

View file

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

View file

@ -0,0 +1,46 @@
using System;
using Server.Targeting;
namespace Server.Spells
{
public interface ISpellTargetingPoint3D : ISpell
{
void Target(IPoint3D p);
}
public class SpellTargetPoint3D : Target
{
private ISpellTargetingPoint3D m_Spell;
public ISpell Spell => m_Spell;
private bool m_CheckLOS;
public SpellTargetPoint3D(ISpellTargetingPoint3D spell, TargetFlags flags = TargetFlags.None, int range = 12, bool checkLOS = true) : base(range, true, flags)
{
m_Spell = spell;
m_CheckLOS = checkLOS;
}
protected override void OnTarget(Mobile from, object o)
{
if (o is IPoint3D p)
m_Spell.Target(p);
}
protected override void OnTargetOutOfLOS(Mobile from, object o)
{
if (!m_CheckLOS)
return;
from.SendLocalizedMessage(501943); // Target cannot be seen. Try again.
from.Target = new SpellTargetPoint3D(m_Spell);
from.Target.BeginTimeout(from, TimeoutTime - DateTime.UtcNow);
m_Spell = null; // Needed?
}
protected override void OnTargetFinish(Mobile from)
{
m_Spell?.FinishSequence();
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Third
{
public class BlessSpell : MagerySpell
public class BlessSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Bless", "Rel Sanct",
@ -33,15 +33,16 @@ namespace Server.Spells.Third
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.
}
else if (CheckBSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -65,26 +66,5 @@ namespace Server.Spells.Third
FinishSequence();
}
private class InternalTarget : Target
{
private BlessSpell m_Owner;
public InternalTarget(BlessSpell 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();
}
}
}
}

View file

@ -2,7 +2,7 @@ using Server.Targeting;
namespace Server.Spells.Third
{
public class FireballSpell : MagerySpell
public class FireballSpell : MagerySpell, ISpellTargetingMobile
{
private static SpellInfo m_Info = new SpellInfo(
"Fireball", "Vas Flam",
@ -21,15 +21,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))
{
Mobile source = Caster;
@ -66,26 +67,5 @@ namespace Server.Spells.Third
FinishSequence();
}
private class InternalTarget : Target
{
private FireballSpell m_Owner;
public InternalTarget(FireballSpell 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();
}
}
}
}

View file

@ -5,7 +5,7 @@ using Server.Targeting;
namespace Server.Spells.Third
{
public class MagicLockSpell : MagerySpell
public class MagicLockSpell : MagerySpell, ISpellTargetingItem
{
private static SpellInfo m_Info = new SpellInfo(
"Magic Lock", "An Por",
@ -24,64 +24,37 @@ namespace Server.Spells.Third
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12);
}
public void Target(LockableContainer targ)
public void Target(Item item)
{
if (BaseHouse.CheckLockedDownOrSecured(targ))
{
// You cannot cast this on a locked down item.
Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 501761);
}
else if (targ.Locked || targ.LockLevel == 0 || targ is ParagonChest)
{
// Target must be an unlocked chest.
Caster.SendLocalizedMessage(501762);
}
if (!(item is LockableContainer cont))
Caster.SendLocalizedMessage(501762); // Target must be an unlocked chest.
else if (BaseHouse.CheckLockedDownOrSecured(cont))
Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 501761); // You cannot cast this on a locked down item.
else if (cont.Locked || cont.LockLevel == 0 || cont is ParagonChest)
Caster.SendLocalizedMessage(501762); // Target must be an unlocked chest.
else if (CheckSequence())
{
SpellHelper.Turn(Caster, targ);
SpellHelper.Turn(Caster, cont);
Point3D loc = targ.GetWorldLocation();
Point3D loc = cont.GetWorldLocation();
Effects.SendLocationParticles(
EffectItem.Create(loc, targ.Map, EffectItem.DefaultDuration),
EffectItem.Create(loc, cont.Map, EffectItem.DefaultDuration),
0x376A, 9, 32, 5020);
Effects.PlaySound(loc, targ.Map, 0x1FA);
Effects.PlaySound(loc, cont.Map, 0x1FA);
// The chest is now locked!
Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501763);
targ.LockLevel = -255; // signal magic lock
targ.Locked = true;
cont.LockLevel = -255; // signal magic lock
cont.Locked = true;
}
FinishSequence();
}
private class InternalTarget : Target
{
private MagicLockSpell m_Owner;
public InternalTarget(MagicLockSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile from, object o)
{
if (o is LockableContainer container)
m_Owner.Target(container);
else
from.SendLocalizedMessage(501762); // Target must be an unlocked chest.
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}

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

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Spells.Third
{
public class TelekinesisSpell : MagerySpell
public class TelekinesisSpell : MagerySpell, ISpellTargetingItem
{
private static SpellInfo m_Info = new SpellInfo(
"Telekinesis", "Ort Por Ylem",
@ -21,77 +21,55 @@ namespace Server.Spells.Third
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12);
}
public void Target(ITelekinesisable obj)
public void Target(Item item)
{
ITelekinesisable t = item as ITelekinesisable;
if (!(t != null || item is Container))
{
Caster.SendLocalizedMessage(501857); // This spell won't work on that!
return;
}
if (CheckSequence())
{
SpellHelper.Turn(Caster, obj);
obj.OnTelekinesis(Caster);
}
FinishSequence();
}
public void Target(Container item)
{
if (CheckSequence())
{
SpellHelper.Turn(Caster, item);
if (!item.IsAccessibleTo(Caster))
if (t != null)
{
item.OnDoubleClickNotAccessible(Caster);
SpellHelper.Turn(Caster, t);
t.OnTelekinesis(Caster);
}
else if (!item.CheckItemUse(Caster, item))
{
}
else if (item.RootParent is Mobile && item.RootParent != Caster)
{
item.OnSnoop(Caster);
}
else if (item is Corpse corpse && !corpse.CheckLoot(Caster, null))
{
}
else if (Caster.Region.OnDoubleClick(Caster, item))
{
Effects.SendLocationParticles(EffectItem.Create(item.Location, item.Map, EffectItem.DefaultDuration),
0x376A, 9, 32, 5022);
Effects.PlaySound(item.Location, item.Map, 0x1F5);
item.OnItemUsed(Caster, item);
}
}
FinishSequence();
}
public class InternalTarget : Target
{
private TelekinesisSpell m_Owner;
public InternalTarget(TelekinesisSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile from, object o)
{
if (o is ITelekinesisable telekinesisable)
m_Owner.Target(telekinesisable);
else if (o is Container container)
m_Owner.Target(container);
else
from.SendLocalizedMessage(501857); // This spell won't work on that!
{
SpellHelper.Turn(Caster, item);
if (!item.IsAccessibleTo(Caster))
{
item.OnDoubleClickNotAccessible(Caster);
}
else if (!item.CheckItemUse(Caster, item))
{
}
else if (item.RootParent is Mobile && item.RootParent != Caster)
{
item.OnSnoop(Caster);
}
else if (item is Corpse corpse && !corpse.CheckLoot(Caster, null))
{
}
else if (Caster.Region.OnDoubleClick(Caster, item))
{
Effects.SendLocationParticles(EffectItem.Create(item.Location, item.Map, EffectItem.DefaultDuration),
0x376A, 9, 32, 5022);
Effects.PlaySound(item.Location, item.Map, 0x1F5);
item.OnItemUsed(Caster, item);
}
}
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
FinishSequence();
}
}
}

View file

@ -9,7 +9,7 @@ using Server.Targeting;
namespace Server.Spells.Third
{
public class TeleportSpell : MagerySpell
public class TeleportSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Teleport", "Rel Por",
@ -44,7 +44,7 @@ namespace Server.Spells.Third
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)
@ -118,26 +118,5 @@ namespace Server.Spells.Third
FinishSequence();
}
public class InternalTarget : Target
{
private TeleportSpell m_Owner;
public InternalTarget(TeleportSpell owner) : base(Core.ML ? 11 : 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();
}
}
}
}

View file

@ -5,7 +5,7 @@ using Server.Targeting;
namespace Server.Spells.Third
{
public class UnlockSpell : MagerySpell
public class UnlockSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Unlock Spell", "Ex Por",
@ -23,85 +23,53 @@ namespace Server.Spells.Third
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12);
}
private class InternalTarget : Target
public void Target(IPoint3D p)
{
private UnlockSpell m_Owner;
public InternalTarget(UnlockSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
if (CheckSequence())
{
m_Owner = owner;
}
SpellHelper.Turn(Caster, p);
protected override void OnTarget(Mobile from, object o)
{
if (!(o is IPoint3D loc))
return;
Effects.SendLocationParticles(EffectItem.Create(new Point3D(p), Caster.Map, EffectItem.DefaultDuration),
0x376A, 9, 32, 5024);
if (m_Owner.CheckSequence())
Effects.PlaySound(p, Caster.Map, 0x1FF);
if (p is Mobile)
Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 503101); // That did not need to be unlocked.
else if (!(p is LockableContainer cont))
Caster.SendLocalizedMessage(501666); // You can't unlock that!
else
{
SpellHelper.Turn(from, o);
Effects.SendLocationParticles(EffectItem.Create(new Point3D(loc), from.Map, EffectItem.DefaultDuration),
0x376A, 9, 32, 5024);
Effects.PlaySound(loc, from.Map, 0x1FF);
if (o is Mobile)
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 503101); // That did not need to be unlocked.
}
else if (!(o is LockableContainer))
{
from.SendLocalizedMessage(501666); // You can't unlock that!
}
if (BaseHouse.CheckSecured(cont))
Caster.SendLocalizedMessage(503098); // You cannot cast this on a secure item.
else if (!cont.Locked)
Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2,
503101); // That did not need to be unlocked.
else if (cont.LockLevel == 0)
Caster.SendLocalizedMessage(501666); // You can't unlock that!
else
{
LockableContainer cont = (LockableContainer)o;
int level = (int)(Caster.Skills.Magery.Value * 0.8) - 4;
if (BaseHouse.CheckSecured(cont))
if (level >= cont.RequiredSkill &&
!(cont is TreasureMapChest chest && chest.Level > 2))
{
from.SendLocalizedMessage(503098); // You cannot cast this on a secure item.
}
else if (!cont.Locked)
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2,
503101); // That did not need to be unlocked.
}
else if (cont.LockLevel == 0)
{
from.SendLocalizedMessage(501666); // You can't unlock that!
cont.Locked = false;
if (cont.LockLevel == -255)
cont.LockLevel = cont.RequiredSkill - 10;
}
else
{
int level = (int)(from.Skills.Magery.Value * 0.8) - 4;
if (level >= cont.RequiredSkill &&
!(cont is TreasureMapChest chest && chest.Level > 2))
{
cont.Locked = false;
if (cont.LockLevel == -255)
cont.LockLevel = cont.RequiredSkill - 10;
}
else
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2,
503099); // My spell does not seem to have an effect on that lock.
}
}
Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2,
503099); // My spell does not seem to have an effect on that lock.
}
}
m_Owner.FinishSequence();
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
FinishSequence();
}
}
}

View file

@ -5,7 +5,7 @@ using Server.Targeting;
namespace Server.Spells.Third
{
public class WallOfStoneSpell : MagerySpell
public class WallOfStoneSpell : MagerySpell, ISpellTargetingPoint3D
{
private static SpellInfo m_Info = new SpellInfo(
"Wall of Stone", "In Sanct Ylem",
@ -24,7 +24,7 @@ namespace Server.Spells.Third
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)
@ -189,26 +189,5 @@ namespace Server.Spells.Third
}
}
}
private class InternalTarget : Target
{
private WallOfStoneSpell m_Owner;
public InternalTarget(WallOfStoneSpell 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();
}
}
}
}