### 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
64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
using Server.Items;
|
|
using Server.Mobiles;
|
|
using Server.Targeting;
|
|
|
|
namespace Server.Spells.Sixth
|
|
{
|
|
public class DispelSpell : MagerySpell, ITargetingSpell<Mobile>
|
|
{
|
|
private static readonly SpellInfo _info = new(
|
|
"Dispel",
|
|
"An Ort",
|
|
218,
|
|
9002,
|
|
Reagent.Garlic,
|
|
Reagent.MandrakeRoot,
|
|
Reagent.SulfurousAsh
|
|
);
|
|
|
|
public DispelSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
|
|
{
|
|
}
|
|
|
|
public override SpellCircle Circle => SpellCircle.Sixth;
|
|
|
|
public void Target(Mobile m)
|
|
{
|
|
if (m is not BaseCreature { IsDispellable: true } bc)
|
|
{
|
|
Caster.SendLocalizedMessage(1005049); // That cannot be dispelled.
|
|
}
|
|
else if (CheckHSequence(m))
|
|
{
|
|
SpellHelper.Turn(Caster, m);
|
|
|
|
var dispelChance =
|
|
(50.0 + 100 * (Caster.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, 0x201);
|
|
|
|
m.Delete();
|
|
}
|
|
else
|
|
{
|
|
m.FixedEffect(0x3779, 10, 20);
|
|
Caster.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it!
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnCast()
|
|
{
|
|
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Harmful);
|
|
}
|
|
}
|
|
}
|