fix: Magic NPCs now use spell range (#1870)

### Summary
- Drastically streamlines the spell targeting by collapsing the target classes into a single `SpellTarget<T>` class.
- Moves TargetRange to the spell itself so it can be used by MageAI.
- Changes range check in MageAI to use TargetRange. This should fix target acquisition bugs
This commit is contained in:
Kamron Batman 2024-08-08 07:05:27 -07:00 • committed by GitHub
parent 91e37fb8d4
commit 9b7fea2c20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
85 changed files with 255 additions and 313 deletions

View file

@ -7,7 +7,7 @@ using Server.Mobiles;
namespace Server.Spells.Necromancy;
public class AnimateDeadSpell : NecromancerSpell, ISpellTargetingItem
public class AnimateDeadSpell : NecromancerSpell, ITargetingSpell<Item>
{
private static readonly SpellInfo _info = new(
"Animate Dead",
@ -190,7 +190,7 @@ public class AnimateDeadSpell : NecromancerSpell, ISpellTargetingItem
public override void OnCast()
{
Caster.Target = new SpellTargetItem(this, range: Core.ML ? 10 : 12);
Caster.Target = new SpellTarget<Item>(this);
Caster.SendLocalizedMessage(1061083); // Animate what corpse?
}

View file

@ -5,7 +5,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy;
public class BloodOathSpell : NecromancerSpell, ISpellTargetingMobile
public class BloodOathSpell : NecromancerSpell, ITargetingSpell<Mobile>
{
private static readonly SpellInfo _info = new(
"Blood Oath",
@ -96,7 +96,7 @@ public class BloodOathSpell : NecromancerSpell, ISpellTargetingMobile
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Harmful);
}
public static bool RemoveCurse(Mobile target)

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy;
public class CorpseSkinSpell : NecromancerSpell, ISpellTargetingMobile
public class CorpseSkinSpell : NecromancerSpell, ITargetingSpell<Mobile>
{
private static readonly SpellInfo _info = new(
"Corpse Skin",
@ -95,7 +95,7 @@ public class CorpseSkinSpell : NecromancerSpell, ISpellTargetingMobile
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Harmful);
}
public static bool RemoveCurse(Mobile m)

View file

@ -5,7 +5,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy;
public class EvilOmenSpell : NecromancerSpell, ISpellTargetingMobile
public class EvilOmenSpell : NecromancerSpell, ITargetingSpell<Mobile>
{
private static readonly SpellInfo _info = new(
"Evil Omen",
@ -70,7 +70,7 @@ public class EvilOmenSpell : NecromancerSpell, ISpellTargetingMobile
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Harmful);
}
public static bool EndEffect(Mobile m)

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy;
public class MindRotSpell : NecromancerSpell, ISpellTargetingMobile
public class MindRotSpell : NecromancerSpell, ITargetingSpell<Mobile>
{
private static readonly SpellInfo _info = new(
"Mind Rot",
@ -63,7 +63,7 @@ public class MindRotSpell : NecromancerSpell, ISpellTargetingMobile
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Harmful);
}
public static bool ClearMindRotScalar(Mobile m)

View file

@ -5,7 +5,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy;
public class PainSpikeSpell : NecromancerSpell, ISpellTargetingMobile
public class PainSpikeSpell : NecromancerSpell, ITargetingSpell<Mobile>
{
private static readonly SpellInfo _info = new(
"Pain Spike",
@ -85,7 +85,7 @@ public class PainSpikeSpell : NecromancerSpell, ISpellTargetingMobile
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Harmful);
}
private class InternalTimer : Timer

View file

@ -6,7 +6,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy;
public class PoisonStrikeSpell : NecromancerSpell, ISpellTargetingMobile
public class PoisonStrikeSpell : NecromancerSpell, ITargetingSpell<Mobile>
{
private static readonly SpellInfo _info = new(
"Poison Strike",
@ -146,6 +146,6 @@ public class PoisonStrikeSpell : NecromancerSpell, ISpellTargetingMobile
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Harmful);
}
}

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy;
public class StrangleSpell : NecromancerSpell, ISpellTargetingMobile
public class StrangleSpell : NecromancerSpell, ITargetingSpell<Mobile>
{
private static readonly SpellInfo _info = new(
"Strangle",
@ -111,7 +111,7 @@ public class StrangleSpell : NecromancerSpell, ISpellTargetingMobile
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Harmful);
}
public static bool RemoveCurse(Mobile m)

View file

@ -4,7 +4,7 @@ using Server.Targeting;
namespace Server.Spells.Necromancy;
public class VengefulSpiritSpell : NecromancerSpell, ISpellTargetingMobile
public class VengefulSpiritSpell : NecromancerSpell, ITargetingSpell<Mobile>
{
private static readonly SpellInfo _info = new(
"Vengeful Spirit",
@ -66,7 +66,7 @@ public class VengefulSpiritSpell : NecromancerSpell, ISpellTargetingMobile
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Harmful);
}
public override bool CheckCast()