if (SpellHelper.CheckField(p, creature.Map))
{
TargetLocationItem s_Item = new TargetLocationItem();
s_Item.Location = p;
s_Item.Map = creature.Map;
}
for (int i = 1; i <= MaxRange; ++i)
{
Timer.DelayCall<int>(TimeSpan.FromMilliseconds(i * 200), index =>
{
//Point3D point = new Point3D(eastToWest ? pnt.X + index : pnt.X, eastToWest ? pnt.Y : pnt.Y + index, pnt.Z);
Point3D point = new Point3D(p);
creature.Direction = creature.GetDirectionTo(e_Item);
if(creature.GetDirectionTo(e_Item) == Direction.North)
{
point.X = creature.X;
point.Y = creature.Y - index;
}
else if(creature.GetDirectionTo(e_Item) == Direction.Right)
{
point.X = creature.X + index;
point.Y = creature.Y - index;
}
else if(creature.GetDirectionTo(e_Item) == Direction.East)
{
point.X = creature.X + index;
point.Y = creature.Y;
}
else if(creature.GetDirectionTo(e_Item) == Direction.Down)
{
point.X = creature.X + index;
point.Y = creature.Y + index;
}
else if(creature.GetDirectionTo(e_Item) == Direction.South)
{
point.X = creature.X;
point.Y = creature.Y + index;
}
else if(creature.GetDirectionTo(e_Item) == Direction.Left)
{
point.X = creature.X - index;
point.Y = creature.Y + index;
}
else if(creature.GetDirectionTo(e_Item) == Direction.West)
{
point.X = creature.X - index;
point.Y = creature.Y;
}
else if(creature.GetDirectionTo(e_Item) == Direction.Up)
{
point.X = creature.X + index;
point.Y = creature.Y + index;
}
SpellHelper.AdjustField(ref point, creature.Map, 16, false);
if (SpellHelper.CheckField(point, creature.Map))
{
TargetLocationItem m_Item = new TargetLocationItem();
m_Item.Location = point;
m_Item.Map = creature.Map;
Effects.SendLocationParticles(EffectItem.Create(point, creature.Map, EffectItem.DefaultDuration), 0x3709, 10, 30, hue, rm, 5052, 0);
IPooledEnumerable eable = m_Item.GetMobilesInRange(1);
foreach (Mobile m in eable)
{
if ((m is PlayerMobile || (m is BaseCreature && ((BaseCreature)m).GetMaster() is PlayerMobile)) && creature.CanBeHarmful(m))
{
Timer.DelayCall(TimeSpan.FromSeconds(0.75), () =>
{
int d = Utility.RandomMinMax(min, max);
AOS.Damage(m, d, phy, fir, col, poi, ene);
});
}
}
eable.Free();
}
}, i);
}
}
}
public class BarrageOfBolts : CustomAbility
{
public override double TriggerChance { get { return 0.1; } }
public override int MaxRange { get { return 12; } }
public override TimeSpan CooldownDuration { get { return TimeSpan.FromSeconds(15); } }
/* usage example:
BarrageOfBolts bob = new BarrageOfBolts();
public override void OnThink()
{
base.OnThink();
if(bob.ItemID != 0x0F42)
{
bob.SetDamage(10, 15); // set custom damage
bob.ItemID = 0x0F42; // arrow's ItemID
bob.Sond = 0x234; // bow hit sound
}
CustomAbility.CheckTrigger(this, bob); //CustomAbility.CheckTrigger(caster, ability);
}
*/
private int m_ItemID = 0x36D4;
private int m_Hue = 0;
private int m_SoundID = 0x349;
public int ItemID
{
get { return m_ItemID; }
set { m_ItemID = value; }
}
public int Hue
{
get { return m_Hue; }
set { m_Hue = value; }
}
public int Sound
{
get { return m_SoundID; }
set { m_SoundID = value; }
}
public BarrageOfBolts()
{
}
//default damage
private int m_Min = 12;
private int m_Max = 18;
public void SetDamage(int min, int max)
{
m_Min = min;
m_Max = max;
}
public override void Trigger(BaseCreature creature, Mobile defender, int min, int max)
{
if(min == 0 && max == 0)
{
min = m_Min;
max = m_Max;
}
if(creature.InRange(defender.Location, MaxRange) && TriggerChance >= Utility.RandomDouble() && !IsInCooldown(creature))
{
DoEffects(creature, defender, min, max);
AddToCooldown(creature);
}
}
public override void DoEffects(BaseCreature creature, Mobile defender, int min, int max)
{
if (defender == null || defender.Deleted || !defender.Alive || !creature.Alive || !creature.CanBeHarmful(defender))
return;
defender.PlaySound(m_SoundID);
Effects.PlaySound(creature.Location, creature.Map, m_SoundID);
Point3D p = defender.Location;
if((defender.X > creature.X) && (defender.X - creature.X <= 3))
p.X = creature.X + 3;
else if((defender.X < creature.X) && (creature.X -defender.X <= 3))
p.X = creature.X - 3;
if((defender.Y > creature.Y) && (defender.Y - creature.Y <= 3))
p.Y = creature.Y + 3;
else if((defender.Y < creature.Y) && (creature.Y -defender.Y <= 3))
p.Y = creature.Y - 3;
int dx = creature.Location.X - p.X;
int dy = creature.Location.Y - p.Y;
int rx = (dx - dy) * 44;
int ry = (dx + dy) * 44;
bool eastToWest;
if (rx >= 0 && ry >= 0)
{
eastToWest = false;
}
else if (rx >= 0)
{
eastToWest = true;
}
else if (ry >= 0)
{
eastToWest = true;
}
else
{
eastToWest = false;
}
Point3D pnt = new Point3D(p);
TargetLocationItem s_Item = new TargetLocationItem();
s_Item.Location = pnt;
s_Item.Map = creature.Map;
creature.MovingEffect(s_Item, m_ItemID, 1, 0, false, false, m_Hue, 0);
TimeSpan duration = TimeSpan.FromSeconds(6);
for (int i = 1; i <= 2; ++i)
{
Timer.DelayCall<int>(TimeSpan.FromMilliseconds(i * 300), index =>
{
Point3D point = new Point3D(eastToWest ? pnt.X + index : pnt.X, eastToWest ? pnt.Y : pnt.Y + index, pnt.Z);
SpellHelper.AdjustField(ref point, creature.Map, 16, false);
if (SpellHelper.CheckField(point, creature.Map))
{
TargetLocationItem m_item = new TargetLocationItem( point, creature.Map, duration);
creature.MovingEffect(m_item, m_ItemID, 1, 0, false, false, m_Hue, 0);
}
point = new Point3D(eastToWest ? pnt.X + -index : pnt.X, eastToWest ? pnt.Y : pnt.Y + -index, pnt.Z);
SpellHelper.AdjustField(ref point, creature.Map, 16, false);
if (SpellHelper.CheckField(point, creature.Map))
{
TargetLocationItem n_item = new TargetLocationItem( point, creature.Map, duration);
creature.MovingEffect(n_item, m_ItemID, 1, 0, false, false, m_Hue, 0);
}
}, i);
}