using System;
using System.Collections;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Targeting;
using System.Collections.Generic;
using System.Linq;
using Server.Multis;
using Server.Regions;
namespace Server.Spells.Eighth
{
public class LightningStromSpell : MagerySpell
{
public override DamageType SpellDamageType { get { return DamageType.SpellAOE; } }
private static readonly SpellInfo m_Info = new SpellInfo(
"Lightning Strom", "Lightning Strom",
269,
9050,
false,
Reagent.Bloodmoss,
Reagent.MandrakeRoot,
Reagent.SpidersSilk,
Reagent.SulfurousAsh);
public LightningStromSpell(Mobile caster, Item scroll)
: base(caster, scroll, m_Info)
{
}
public override SpellCircle Circle
{
get
{
return SpellCircle.Eighth;
}
}
public override double RequiredSkill
{
get
{
return 150.0;
}
}
public override bool DelayedDamage
{
get
{
return false;
}
}
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();
var targets = AcquireIndirectTargets(p, 10).ToList();
var count = Math.Max(1, targets.Count);
foreach (var dam in targets)
{
var id = dam;
var m = id as Mobile;
double damage;
if (Core.AOS)
damage = GetNewAosDamage(150, 1, 5, id is PlayerMobile, id);
else
damage = Utility.Random(70, 80);
if (!Core.AOS && m != null && CheckResisted(m))
{
damage *= 0.5;
m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy.
}
Mobile source = Caster;
SpellHelper.CheckReflect((int)Circle, ref source, ref id, SpellDamageType);
if (m != null)
{
damage *= GetDamageScalar(m);
}
if (m != null)
{
m.FixedParticles(0x3BCE, 10, 10, 5052, 0x256, 3, EffectLayer.Head);
}
Caster.DoHarmful(id);
SpellHelper.Damage(this, id, damage, 0, 0, 0, 0, 100);
}
ColUtility.Free(targets);
}
FinishSequence();
}
public class InternalTarget : Target
{
public readonly LightningStromSpell m_Owner;
public InternalTarget(LightningStromSpell owner)
: base(Core.ML ? 10 : 12, 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();
}
}
}
}