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