using System;
using Server;using System.Collections.Generic;
using System.Linq;
using Server.Items;
using Server.Network;
using System.Collections;
using Server.Spells;
namespace Server.Mobiles
{
public class ForkedFlameStrike : CustomAbility
{
public override double TriggerChance { get { return 0.8; } }
public override int MaxRange { get { return 8; } }
public override TimeSpan CooldownDuration { get { return TimeSpan.FromSeconds(10); } }
public enum StrikeType
{
Fire,
Ice,
Poison,
Energy,
Water,
Steam,
Necrotic,
Holy
}
private StrikeType m_Type = StrikeType.Fire;
private int hue, rm, phy, fir, col, poi, ene;
private int m_Range = 5;
public StrikeType Type
{
get { return m_Type; }
set { m_Type = value; }
}
public int Range
{
get { return m_Range; }
set { m_Range = value; }
}
public ForkedFlameStrike()
{
}
private int m_Wait = 3;
private int Wait
{
get { return m_Wait; }
set { m_Wait = value; }
}
private string m_Message = "*The creature is preparing to use its fire breath.*";
public string Message
{
get { return m_Message; }
set { m_Message = value; }
}
//default damage
private int m_Min = 16;
private int m_Max = 20;
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, m_Range) && TriggerChance >= Utility.RandomDouble() && !IsInCooldown(creature))
{
DoEffects(creature, defender, min, max);
AddToCooldown(creature);
}
}
public override void DoEffects(BaseCreature creature, Mobile defender, int min, int max)
{
switch(Type)
{
case StrikeType.Fire: hue = 0; rm = 0;
phy = 0; fir = 100; col = 0; poi = 0; ene = 0; break;
case StrikeType.Ice: hue = 1151; rm = 0;
phy = 0; fir = 0; col = 100; poi = 0; ene = 0; break;
case StrikeType.Poison: hue = 1366; rm = 0;
phy = 0; fir = 0; col = 0; poi = 100; ene = 0; break;
case StrikeType.Energy: hue = 1169; rm = 7;
phy = 0; fir = 0; col = 0; poi = 0; ene = 100; break;
case StrikeType.Water: hue = 1365; rm = 0;
phy = 50; fir = 0; col = 50; poi = 0; ene = 0; break;
case StrikeType.Steam: hue = 2103; rm = 7;
phy = 50; fir = 50; col = 0; poi = 0; ene = 0; break;
case StrikeType.Necrotic: hue = 1174; rm = 7;
phy = 50; fir = 0; col = 0; poi = 50; ene = 0; break;
case StrikeType.Holy: hue = 1280; rm = 0;
phy = 50; fir = 0; col = 0; poi = 0; ene = 50; break;
}
if( creature.Body == 0x191 || creature.Body == 0x190)
creature.Animate(AnimationType.Spell, 0);
if (!creature.Alive || creature.Map == null)
return;
creature.Say(m_Message);
Timer.DelayCall(TimeSpan.FromSeconds(m_Wait), () =>
{
DoFFS(creature, defender, min, max);
});
}
public void DoFFS(BaseCreature creature, Mobile defender, int min, int max)
{
Effects.PlaySound(creature.Location, creature.Map, 0x349);
Point3D p = creature.Location;
TargetLocationItem e_Item = new TargetLocationItem(p, creature.Map, TimeSpan.FromSeconds(8));
if(creature.Direction is Direction.North)
{
e_Item.X = creature.X;
e_Item.Y = creature.Y - m_Range;
}
else if( creature.Direction is Direction.Right)
{
e_Item.X = creature.X + m_Range;
e_Item.Y = creature.Y - m_Range;
}
else if( creature.Direction is Direction.East)
{
e_Item.X = creature.X + m_Range;
e_Item.Y = creature.Y;
}
else if( creature.Direction is Direction.Down)
{
e_Item.X = creature.X + m_Range;
e_Item.Y = creature.Y + m_Range;
}
else if( creature.Direction is Direction.South)
{
e_Item.X = creature.X;
e_Item.Y = creature.Y + m_Range;
}
else if( creature.Direction is Direction.Left)
{
e_Item.X = creature.X - m_Range;
e_Item.Y = creature.Y + m_Range;
}
else if( creature.Direction is Direction.West)
{
e_Item.X = creature.X - m_Range;
e_Item.Y = creature.Y;
}
else if( creature.Direction is Direction.Up)
{
e_Item.X = creature.X - m_Range;
e_Item.Y = creature.Y - m_Range;
}
else
e_Item.Location = defender.Location;
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(p);
Point3D pL = new Point3D(p);
Point3D pR = new Point3D(p);
creature.Direction = creature.GetDirectionTo(e_Item);
if(creature.GetDirectionTo(e_Item) is Direction.North)
{
point.X = creature.X;
point.Y = creature.Y - index;
pL.X = creature.X - index;
pL.Y = creature.Y - index;
pR.X = creature.X + index;
pR.Y = creature.Y - index;
}
else if(creature.GetDirectionTo(e_Item) is Direction.Right)
{
point.X = creature.X + index;
point.Y = creature.Y - index;
pL.X = creature.X;
pL.Y = creature.Y - index;
pR.X = creature.X + index;
pR.Y = creature.Y;
}
else if(creature.GetDirectionTo(e_Item) is Direction.East)
{
point.X = creature.X + index;
point.Y = creature.Y;
pL.X = creature.X + index;
pL.Y = creature.Y - index;
pR.X = creature.X + index;
pR.Y = creature.Y + index;
}
else if(creature.GetDirectionTo(e_Item) is Direction.Down)
{
point.X = creature.X + index;
point.Y = creature.Y + index;
pL.X = creature.X + index;
pL.Y = creature.Y;
pR.X = creature.X;
pR.Y = creature.Y + index;
}
else if(creature.GetDirectionTo(e_Item) is Direction.South)
{
point.X = creature.X;
point.Y = creature.Y + index;
pL.X = creature.X + index;
pL.Y = creature.Y + index;
pR.X = creature.X - index;
pR.Y = creature.Y + index;
}
else if(creature.GetDirectionTo(e_Item) is Direction.Left)
{
point.X = creature.X - index;
point.Y = creature.Y + index;
pL.X = creature.X;
pL.Y = creature.Y + index;
pR.X = creature.X - index;
pR.Y = creature.Y;
}
else if(creature.GetDirectionTo(e_Item) is Direction.West)
{
point.X = creature.X - index;
point.Y = creature.Y;
pL.X = creature.X - index;
pL.Y = creature.Y + index;
pR.X = creature.X - index;
pR.Y = creature.Y - index;
}
else if(creature.GetDirectionTo(e_Item) is Direction.Up)
{
point.X = creature.X - index;
point.Y = creature.Y - index;
pL.X = creature.X - index;
pL.Y = creature.Y;
pR.X = creature.X;
pR.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);
TargetLocationItem l_Item = new TargetLocationItem();
l_Item.Location = pL;
l_Item.Map = creature.Map;
Effects.SendLocationParticles(EffectItem.Create(pL, creature.Map, EffectItem.DefaultDuration), 0x3709, 10, 30, hue, rm, 5052, 0);
IPooledEnumerable lable = l_Item.GetMobilesInRange(1);
TargetLocationItem r_Item = new TargetLocationItem();
r_Item.Location = pR;
r_Item.Map = creature.Map;
Effects.SendLocationParticles(EffectItem.Create(pR, creature.Map, EffectItem.DefaultDuration), 0x3709, 10, 30, hue, rm, 5052, 0);
IPooledEnumerable rable = r_Item.GetMobilesInRange(1);
foreach (Mobile m in eable)
{
if ((m is PlayerMobile || (m is BaseCreature && ((BaseCreature)m).GetMaster() is PlayerMobile)) && creature.CanBeHarmful(m) && !creature.Controlled)
{
Timer.DelayCall(TimeSpan.FromSeconds(0.75), () =>
{
int d = Utility.RandomMinMax(min, max);
AOS.Damage(m, d, phy, fir, col, poi, ene);
});
}
else if (creature.Controlled && (m is BaseCreature && !((BaseCreature)m).Controlled))
{
Timer.DelayCall(TimeSpan.FromSeconds(0.75), () =>
{
int d = Utility.RandomMinMax(min, max);
AOS.Damage(m, d, phy, fir, col, poi, ene);
});
}
else
return;
}
eable.Free();
foreach (Mobile m in lable)
{
if ((m is PlayerMobile || (m is BaseCreature && ((BaseCreature)m).GetMaster() is PlayerMobile)) && creature.CanBeHarmful(m) && !creature.Controlled)
{
Timer.DelayCall(TimeSpan.FromSeconds(0.75), () =>
{
int d = Utility.RandomMinMax(min, max);
AOS.Damage(m, d, phy, fir, col, poi, ene);
});
}
else if (creature.Controlled && (m is BaseCreature && !((BaseCreature)m).Controlled))
{
Timer.DelayCall(TimeSpan.FromSeconds(0.75), () =>
{
int d = Utility.RandomMinMax(min, max);
AOS.Damage(m, d, phy, fir, col, poi, ene);
});
}
else
return;
}
lable.Free();
foreach (Mobile m in rable)
{
if ((m is PlayerMobile || (m is BaseCreature && ((BaseCreature)m).GetMaster() is PlayerMobile)) && creature.CanBeHarmful(m) && !creature.Controlled)
{
Timer.DelayCall(TimeSpan.FromSeconds(0.75), () =>
{
int d = Utility.RandomMinMax(min, max);
AOS.Damage(m, d, phy, fir, col, poi, ene);
});
}
else if (creature.Controlled && (m is BaseCreature && !((BaseCreature)m).Controlled))
{
Timer.DelayCall(TimeSpan.FromSeconds(0.75), () =>
{
int d = Utility.RandomMinMax(min, max);
AOS.Damage(m, d, phy, fir, col, poi, ene);
});
}
else
return;
}
rable.Free();
}
}, i);
}
}
}
}