using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.CommonBot.POI;
using Styx.CommonBot.Profiles;
using Styx.CommonBot.AreaManagement;
using Styx.Pathing;
using Styx.Helpers;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Styx.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using System.Windows.Media;
namespace TimelessBuffs
{
public class FightHere : HBPlugin
{
public override string Name { get { return "Timeless Buffs"; } }
public override string Author { get { return "Pasterke"; } }
public override bool WantButton { get { return false; } }
public override Version Version { get { return _version; } }
private readonly Version _version = new Version(1, 0, 0, 0);
private static LocalPlayer Me { get { return StyxWoW.Me; } }
public string LastSpell { get; set; }
public Stopwatch checkingBuffsTimer = new Stopwatch();
public override void Initialize()
{
if (Me.ZoneId == 6757) { LogMsg("Good, we are on Timeless Isle"); }
else { LogMsg("We are not on Timeless Isle, no use use of buffs"); }
}
public override void Pulse()
{
try
{
if (Me.ZoneId == 6757)
{
if (StyxWoW.Me.IsActuallyInCombat
|| StyxWoW.Me.Mounted
|| StyxWoW.Me.IsDead
|| StyxWoW.Me.IsGhost
)
{
return;
}
checkBuffs();
return;
}
}
catch { }
}
public void checkBuffs()
{
if (!buffExists(147476, Me)
&& LastSpell != "Dew of Eternal Morning" )
{
applyBuffs("Dew of Eternal Morning");
}
if (!buffExists(147226, Me)
&& LastSpell != "Book of the Ages")
{
applyBuffs("Book of the Ages");
}
if (!buffExists(147055, Me)
&& LastSpell != "Singing Crystal")
{
applyBuffs("Singing Crystal");
}
if (!buffExists(86569, Me)
&& LastSpell != "Crystal of Insanity")
{
applyBuffs("Crystal of Insanity");
}
if (Me.Combat
&& Me.HealthPercent <= 40
&& !buffExists(104289, Me))
{
applyBuffs("Faintly-Glowing Herb");
}
return;
}
public void applyBuffs(string buffName)
{
if (!buffExists(buffName, Me))
{
WoWItem potion = Me.BagItems.FirstOrDefault(h => h.Name == buffName);
if (potion == null)
{
return;
}
if (potion != null && potion.CooldownTimeLeft.TotalMilliseconds <= 0 && LastSpell != buffName)
{
potion.Use();
LogMsg("Using " + potion.Name);
LastSpell = buffName;
}
}
}
#region logs
public void LogMsg(string msg)
{
Logging.Write(Colors.CornflowerBlue, msg);
}
#endregion logs
#region Buff Checks
public bool buffExists(int Buff, WoWUnit onTarget)
{
if (onTarget != null)
{
var Results = onTarget.GetAuraById(Buff);
if (Results != null)
return true;
}
return false;
}
public double buffTimeLeft(int Buff, WoWUnit onTarget)
{
if (onTarget != null)
{
var Results = onTarget.GetAuraById(Buff);
if (Results != null)
{
if (Results.TimeLeft.TotalMilliseconds > 0)
return Results.TimeLeft.TotalMilliseconds;
}
}
return 0;
}
public bool buffExists(string Buff, WoWUnit onTarget)
{
if (onTarget != null)
{
var Results = onTarget.GetAuraByName(Buff);
if (Results != null)
return true;
}
return false;
}
public double buffTimeLeft(string Buff, WoWUnit onTarget)
{
if (onTarget != null)
{
var Results = onTarget.GetAuraByName(Buff);
if (Results != null)
{
if (Results.TimeLeft.TotalMilliseconds > 0)
return Results.TimeLeft.TotalMilliseconds;
}
}
return 0;
}
public uint buffStackCount(int Buff, WoWUnit onTarget)
{
if (onTarget != null)
{
var Results = onTarget.GetAuraById(Buff);
if (Results != null)
return Results.StackCount;
}
return 0;
}
public uint buffStackCount(string Buff, WoWUnit onTarget)
{
if (onTarget != null)
{
var Results = onTarget.GetAuraByName(Buff);
if (Results != null)
return Results.StackCount;
}
return 0;
}
#endregion buffchecks
//the end
}
}