servuo/Scripts/Spells/Seventh/ChainLightning.cs
TrueUO 43ef3b7cf2
Changes (#4820)
- Shop item prices now reset at startup, per EA
- Nether Cyclone spell damage fixed
- magic reflect spell now EA like
- Vis list now persists through restarts.
- Fixed an exploit with ChickenStatue and CowStatue.cs
- Fishing poles now get luck accounted
- Restless soul is now grey
- Added proper CUB point value to tmaps
- Doom spawns are now seperated and EA accurate.

Co-authored-by: TrueUO <knight.daniel.r@gmail.com>
2020-07-26 18:18:34 -07:00

101 lines
3 KiB
C#

using Server.Mobiles;
using Server.Targeting;
using System;
using System.Linq;
namespace Server.Spells.Seventh
{
public class ChainLightningSpell : MagerySpell
{
public override DamageType SpellDamageType => DamageType.SpellAOE;
private static readonly SpellInfo m_Info = new SpellInfo(
"Chain Lightning", "Vas Ort Grav",
209,
9022,
false,
Reagent.BlackPearl,
Reagent.Bloodmoss,
Reagent.MandrakeRoot,
Reagent.SulfurousAsh);
public ChainLightningSpell(Mobile caster, Item scroll)
: base(caster, scroll, m_Info)
{
}
public override SpellCircle Circle => SpellCircle.Seventh;
public override bool DelayedDamage => true;
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
}
public void Target(IPoint3D p)
{
if (!Caster.CanSee(p))
{
Caster.SendLocalizedMessage(500237); // Target can not be seen.
}
else if (SpellHelper.CheckTown(p, Caster) && CheckSequence())
{
SpellHelper.Turn(Caster, p);
if (p is Item)
p = ((Item)p).GetWorldLocation();
System.Collections.Generic.List<IDamageable> targets = AcquireIndirectTargets(p, 2).ToList();
int count = Math.Max(1, targets.Count);
foreach (IDamageable dam in targets)
{
IDamageable id = dam;
Mobile m = id as Mobile;
double damage = GetNewAosDamage(51, 1, 5, id is PlayerMobile, id);
if (count > 2)
damage = (damage * 2) / count;
Mobile source = Caster;
SpellHelper.CheckReflect(this, ref source, ref id);
if (m != null)
{
damage *= GetDamageScalar(m);
}
Effects.SendBoltEffect(id, true, 0, false);
Caster.DoHarmful(id);
SpellHelper.Damage(this, id, damage, 0, 0, 0, 0, 100);
}
ColUtility.Free(targets);
}
FinishSequence();
}
private class InternalTarget : Target
{
private readonly ChainLightningSpell m_Owner;
public InternalTarget(ChainLightningSpell owner)
: base(10, true, TargetFlags.None)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile from, object o)
{
IPoint3D p = o as IPoint3D;
if (p != null)
m_Owner.Target(p);
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}