using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Styx;
using Styx.CommonBot;
using Styx.Common.Helpers;
using Styx.Common;
using Styx.Helpers;
using Styx.Pathing;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWCache;
using Styx.WoWInternals.WoWObjects;
using Styx.Plugins;
using CommonBehaviors.Actions;
using Styx.TreeSharp;
namespace RunKeyPress
{
public class RunKeyPressMacro : HBPlugin
{
private static readonly WaitTimer CallPetTimer = WaitTimer.OneSecond;
private static ulong _petGuid;
private static readonly List<WoWPetSpell> PetSpells = new List<WoWPetSpell>();
public static readonly WaitTimer PetTimer = new WaitTimer(TimeSpan.FromSeconds(2));
private static bool _wasMounted;
public override Version Version { get { return new Version(1, 0, 0); } }
public override string Author
{
get { return "Upperfoot"; }
}
public override string Name
{
get { return " Run Key Press Macro "; }
}
public override string ButtonText
{
get
{
return "* Run Key Press Macro *";
}
}
public override bool WantButton
{
get
{
return true;
}
}
public override void Pulse()
{
if (!StyxWoW.Me.GotAlivePet)
{
PetSpells.Clear();
return;
}
if (StyxWoW.Me.Mounted)
{
_wasMounted = true;
}
if (_wasMounted && !StyxWoW.Me.Mounted)
{
_wasMounted = false;
PetTimer.Reset();
}
if (StyxWoW.Me.Pet != null && _petGuid != StyxWoW.Me.Pet.Guid)
{
_petGuid = StyxWoW.Me.Pet.Guid;
PetSpells.Clear();
// Cache the list. yea yea, we should just copy it, but I'd rather have shallow copies of each object, rather than a copy of the list.
PetSpells.AddRange(StyxWoW.Me.PetSpells);
PetTimer.Reset();
}
}
public override void OnButtonPress()
{
}
public override void Initialize()
{
Hotkeys.RegisterHotkey("Toggle Movement", () => { MovementToggle(); }, Keys.PageDown);
}
public bool CanCastPetAction(string action)
{
WoWPetSpell petAction = PetSpells.FirstOrDefault(p => p.ToString() == action);
if (petAction == null || petAction.Spell == null)
{
return false;
}
return !petAction.Spell.Cooldown;
}
public void CastPetAction(string action)
{
WoWPetSpell spell = PetSpells.FirstOrDefault(p => p.ToString() == action);
if (spell == null)
return;
Logging.Write(string.Format("[Pet] Casting {0}", action));
Lua.DoString("CastPetAction({0})", spell.ActionBarIndex + 1);
}
public bool MovementToggle()
{
string action = "Freeze";
Logging.Write("attempted " + action);
if (StyxWoW.Me.CurrentTarget != null && CanCastPetAction(action))
{
Logging.Write(action + " Player");
//Spell.CastOnGround("Blizzard", ret => StyxWoW.Me.CurrentTarget.Location);
CastPetAction(action);
new WaitContinue(System.TimeSpan.FromMilliseconds(250), ret => false, new ActionAlwaysSucceed());
SpellManager.ClickRemoteLocation(StyxWoW.Me.CurrentTarget.Location);
//Pet.CreateCastPetActionOnLocation("Freeze", ret => !StyxWoW.Me.Mounted && !StyxWoW.Me.CurrentTarget.HasAura("Frost Nova") && StyxWoW.Me.GotAlivePet && StyxWoW.Me.Pet.ManaPercent >= 12);
}
return (true);
}
}
}