#region Web Attack
private DateTime m_NextWeb;
public void DoWebAttack()
{
List<Mobile> targets = new List<Mobile>();
foreach (Mobile m in GetMobilesInRange(RangePerception))
if (CanBeHarmful(m) && m.Player && !InRange(m, 1) && !m.Paralyzed)
targets.Add(m);
if (targets.Count > 0)
{
Mobile target = targets[Utility.Random(targets.Count)];
TimeSpan delay = TimeSpan.FromSeconds(GetDistanceToSqrt(target) / 15.0);
Effects.SendMovingEffect(this, target, 0x10D2, 20, 1, false, false);
Timer.DelayCall<Mobile>(delay, new TimerStateCallback<Mobile>(Entangle), target);
}
m_NextWeb = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 15));
}
public void Entangle( Mobile m )
{
Point3D p = Location;
if ( SpellHelper.FindValidSpawnLocation( Map, ref p, true ) )
{
TimeSpan delay = TimeSpan.FromSeconds( Utility.RandomMinMax( 3, 6 ) );
m.MoveToWorld( p, Map );
m.Freeze( delay );
m.SendLocalizedMessage( 1042555 ); // You become entangled in the spider web.
SpiderWeb web = new SpiderWeb( delay );
p.Z += 2;
web.MoveToWorld( p, Map );
Combatant = m;
}
}
private class SpiderWeb : Static
{
public SpiderWeb( TimeSpan delay ) : base( 0x10D2 )
{
Timer.DelayCall( delay, new TimerCallback( Delete ) );
}
public SpiderWeb( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
Delete();
}
}
#endregion