using System.Linq;
using Styx;
using Styx.TreeSharp;
using Styx.WoWInternals.WoWObjects;
using Action = Styx.TreeSharp.Action;
using Styx.CommonBot;
using Styx.CommonBot.Routines;
using Styx.WoWInternals;
namespace Interrupter
{
public class Interrupter : CombatRoutine
{
public override string Name
{
get { return "Interrupter"; }
}
public override WoWClass Class
{
get { return StyxWoW.Me.Class; }
}
private WoWSpell _iSpell;
public override Composite CombatBehavior
{
get
{
return
new PrioritySelector(
ctx => ObjectManager.GetObjectsOfType<WoWUnit>(true).OrderBy(u => u.DistanceSqr).FirstOrDefault(u => u.IsCasting && u.CanInterruptCurrentSpellCast),
new Decorator(
ret => ret != null,
new PrioritySelector(
new Decorator(
ret =>
{
_iSpell =
SpellManager.Spells.Values.FirstOrDefault(
s =>
!s.Cooldown &&
(s.SpellEffect1.EffectType == WoWSpellEffectType.InterruptCast ||
s.SpellEffect2.EffectType == WoWSpellEffectType.InterruptCast ||
s.SpellEffect3.EffectType == WoWSpellEffectType.InterruptCast));
if (_iSpell == null)
return false;
return SpellManager.CanCast(_iSpell, (WoWUnit)ret, true, false);
},
new Action(ret => SpellManager.Cast(_iSpell, (WoWUnit)ret)))
)
)
);
}
}
}
}