using System.Linq;
using Singular.Dynamics;
using Singular.Helpers;
using Singular.Managers;
using Singular.Settings;
using Styx;
using Styx.Combat.CombatRoutine;
using Styx.Logic.Combat;
using TreeSharp;
using Action = TreeSharp.Action;
using Styx.WoWInternals;
using System;
namespace Singular.ClassSpecific.DeathKnight
{
public class Frost
{
[Class(WoWClass.DeathKnight)]
[Spec(TalentSpec.FrostDeathKnight)]
[Behavior(BehaviorType.Combat)]
[Context(WoWContext.All)]
public static Composite CreateFrostDeathKnightCombat()
{
return new PrioritySelector(
Safers.EnsureTarget(),
Movement.CreateMoveToLosBehavior(),
Movement.CreateFaceTargetBehavior(),
Helpers.Common.CreateAutoAttack(true),
Helpers.Common.CreateInterruptSpellCast(ret => StyxWoW.Me.CurrentTarget),
Movement.CreateMoveBehindTargetBehavior(),
new Decorator(ret => SingularSettings.Instance.DeathKnight.UseMasterFrostRotation,
new PrioritySelector(
Spell.BuffSelf("Pillar of Frost", ret => SingularSettings.Instance.DeathKnight.UsePillarOfFrost),
Spell.Cast("Blood Tap", ret => GetAllRuneCooldowns(1, 2) > 2),
Spell.Cast("Outbreak", ret => !StyxWoW.Me.CurrentTarget.ActiveAuras.ContainsKey("Frost Fever") || !StyxWoW.Me.CurrentTarget.ActiveAuras.ContainsKey("Blood Plague")),
Spell.Cast("Howling Blast", ret => !StyxWoW.Me.CurrentTarget.ActiveAuras.ContainsKey("Frost Fever") && TalentManager.HasGlyph("Howling Blast")),
Spell.Cast("Icy Touch", ret => !StyxWoW.Me.CurrentTarget.ActiveAuras.ContainsKey("Frost Fever") && (!TalentManager.HasGlyph("Howling Blast") || !SpellManager.HasSpell("Howling Blast"))),
Spell.Cast("Plague Strike", ret => !StyxWoW.Me.CurrentTarget.ActiveAuras.ContainsKey("Blood Plague")),
Spell.Cast("Obliterate", ret => StyxWoW.Me.DeathRuneCount >= 1 && StyxWoW.Me.FrostRuneCount >= 1 && StyxWoW.Me.UnholyRuneCount >= 1),
Spell.Cast("Obliterate", ret => (StyxWoW.Me.DeathRuneCount == 2 && StyxWoW.Me.FrostRuneCount == 2) ||
(StyxWoW.Me.DeathRuneCount == 2 && StyxWoW.Me.UnholyRuneCount == 2) ||
(StyxWoW.Me.UnholyRuneCount == 2 && StyxWoW.Me.FrostRuneCount == 2)),
Spell.Cast("Obliterate", ret => StyxWoW.Me.DeathRuneCount == 2 || StyxWoW.Me.UnholyRuneCount == 2 || StyxWoW.Me.FrostRuneCount == 2),
Spell.Cast("Frost Strike", ret => StyxWoW.Me.CurrentRunicPower >= 110),
Spell.Cast("Howling Blast", ret => StyxWoW.Me.ActiveAuras.ContainsKey("Freezing Fog")),
Spell.Cast("Obliterate", ret => StyxWoW.Me.UnholyRuneCount == 2 || GetAllRuneCooldowns(5, 6) < 2),
Spell.Cast("Howling Blast", ret => StyxWoW.Me.CurrentRunicPower < 90),
Spell.Cast("Frost Strike", ret => StyxWoW.Me.CurrentRunicPower > 90),
Spell.Cast("Howling Blast", ret => StyxWoW.Me.CurrentRunicPower < 60),
Spell.Cast("Frost Strike"),
Spell.Cast("Empower Rune Weapon", ret => GetAllRuneCooldowns(1, 2) + GetAllRuneCooldowns(3, 4) + GetAllRuneCooldowns(5, 6) > 8),
Spell.Cast("Horn of Winter"),
//Goblins
Spell.Cast("Rocket Barrage")
)
),
new Decorator(ret => !SingularSettings.Instance.DeathKnight.UseMasterFrostRotation,
new PrioritySelector(
Spell.BuffSelf("Pillar of Frost", ret => SingularSettings.Instance.DeathKnight.UsePillarOfFrost),
Spell.Cast("Blood Tap", ret => GetAllRuneCooldowns(1, 2) > 2),
Spell.Cast("Outbreak", ret => !StyxWoW.Me.CurrentTarget.ActiveAuras.ContainsKey("Frost Fever") || !StyxWoW.Me.CurrentTarget.ActiveAuras.ContainsKey("Blood Plague")),
Spell.Cast("Howling Blast", ret => !StyxWoW.Me.CurrentTarget.ActiveAuras.ContainsKey("Frost Fever") && TalentManager.HasGlyph("Howling Blast")),
Spell.Cast("Icy Touch", ret => !StyxWoW.Me.CurrentTarget.ActiveAuras.ContainsKey("Frost Fever") && (!TalentManager.HasGlyph("Howling Blast") || !SpellManager.HasSpell("Howling Blast"))),
Spell.Cast("Plague Strike", ret => !StyxWoW.Me.CurrentTarget.ActiveAuras.ContainsKey("Blood Plague")),
Spell.Cast("Obliterate", ret => StyxWoW.Me.DeathRuneCount >= 1 && StyxWoW.Me.FrostRuneCount >= 1 && StyxWoW.Me.UnholyRuneCount >= 1),
Spell.Cast("Obliterate", ret => StyxWoW.Me.ActiveAuras.ContainsKey("Killing Machine")),
Spell.Cast("Obliterate", ret => (StyxWoW.Me.DeathRuneCount == 2 && StyxWoW.Me.FrostRuneCount == 2) ||
(StyxWoW.Me.DeathRuneCount == 2 && StyxWoW.Me.UnholyRuneCount == 2) ||
(StyxWoW.Me.UnholyRuneCount == 2 && StyxWoW.Me.FrostRuneCount == 2)),
Spell.Cast("Frost Strike", ret => StyxWoW.Me.CurrentRunicPower >= 110),
Spell.Cast("Obliterate", ret => StyxWoW.Me.DeathRuneCount == 2 || StyxWoW.Me.UnholyRuneCount == 2 || StyxWoW.Me.FrostRuneCount == 2),
Spell.Cast("Frost Strike", ret => StyxWoW.Me.CurrentRunicPower >= 100),
Spell.Cast("Howling Blast", ret => StyxWoW.Me.ActiveAuras.ContainsKey("Freezing Fog")),
Spell.Cast("Obliterate"),
Spell.Cast("Frost Strike"),
Spell.Cast("Howling Blast"),
Spell.Cast("Empower Rune Weapon", ret => GetAllRuneCooldowns(1, 2) + GetAllRuneCooldowns(3, 4) + GetAllRuneCooldowns(5, 6) > 8),
Spell.Cast("Horn of Winter"),
//Goblins
Spell.Cast("Rocket Barrage")
)
),
Movement.CreateMoveToMeleeBehavior(true)
);
}
public static int GetAllRuneCooldowns(params int[] runes)
{
int cooldown = 0;
foreach (int rune in runes)
{
cooldown += GetRuneCooldown(rune);
}
return cooldown;
}
public static int GetRuneCooldown(int rune)
{
float finish = Lua.GetReturnVal<float>(string.Format("local start, dur, ready = GetRuneCooldown({0}); local finish = start + dur; return finish", rune), 0);
float time_now = Lua.GetReturnVal<float>("return GetTime()", 0);
return (int) Math.Round(finish - time_now);
}
}
}