Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Threading;
- using Styx.CustomCombat.CombatInterface;
- using Styx.Helpers;
- using Styx.Logic;
- using Styx.Logic.Common.Combat;
- using Styx.Logic.Pathing;
- using Styx.Object_Dumping_Enumeration;
- using Styx.Object_Dumping_Enumeration.WoWObjects;
- namespace Styx.Bot.CustomClasses
- {
- public partial class Hades : ICombat, IDisposable
- {
- private readonly AutoResetEvent _toggleEvent;
- private readonly AutoResetEvent _uiEvent;
- private readonly AutoResetEvent _bufferEvent;
- private static volatile bool _bufferToggle = false;
- public string Name { get { return "Hades 1.0"; } }
- public WoWClass Class { get { return WoWClass.DeathKnight; } }
- public Hades()
- {
- OnCombatFinished += Hades_OnCombatFinished;
- OnPullFinished += Hades_OnPullFinished;
- _toggleEvent = new AutoResetEvent(true);
- _uiEvent = new AutoResetEvent(true);
- _bufferEvent = new AutoResetEvent(false);
- }
- ~Hades()
- {
- Dispose();
- }
- #region Event Handlers
- static void Hades_OnPullFinished(object sender, PullFinishedEventArgs e)
- {
- if (e.Aggro)
- Logging.Write("Sucesfully pulled {0}!", e.Name);
- }
- void Hades_OnCombatFinished(object sender, EventArgs e)
- {
- Dispose();
- }
- #endregion
- private Thread _handleSpellcast;
- private Thread _handleStun;
- private Thread _handleFear;
- private Thread _handleRoot;
- private Thread _handleAdds;
- private Thread _handleClass;
- #region Global Scope
- #endregion
- /// <summary>
- /// Some variables used thruout the cc including settings
- /// </summary>
- #region Global variables
- private readonly LocalPlayer _me = ObjectManager.Me;
- #endregion
- /// <summary>
- /// Functions and properties associated with resting
- /// </summary>
- #region Rest
- public bool NeedRest { get { return _me.ManaPercent <= 50 || _me.HealthPercent <= 50; } }
- public void Rest()
- {
- Logic.Common.Rest.Feed();
- }
- #endregion
- /// <summary>
- /// Functions and properties associated with buffs prior to combat
- /// This is regular buffs like Mark of the Wild, PW: Fortitude, Thorns etc..
- /// </summary>
- #region Pre Combat Buffs
- public bool NeedPreCombatBuffs { get { return false; } }
- public void PreCombatBuff()
- {
- }
- #endregion
- /// <summary>
- /// Functions and properties associated with combat buffs
- /// this logic will be ran once you enter combat. Put any defensive type buffs here ie.
- /// Power Word: Shield
- /// </summary>
- #region Combat Buffs
- public bool NeedCombatBuffs { get { return false; } }
- public void CombatBuff()
- {
- }
- #endregion
- /// <summary>
- /// Put any healing code here. this state isnt implemented yet but soon to come :)
- /// </summary>
- #region Heal
- public bool NeedHeal { get { return false; } }
- public void Heal()
- {
- }
- #endregion
- /// <summary>
- /// Pet any buffs here that prior to pulling ie. Horn of Winter for deathknights
- /// </summary>
- #region Pull Buffs
- public bool NeedPullBuffs { get { return false; } }
- public void PullBuff() { }
- #endregion
- /// <summary>
- /// Pull logic here for approaching and engaging target's in combat
- /// </summary>
- #region Pull
- private readonly Stopwatch _pullTimer = new Stopwatch();
- public void Pull()
- {
- if (!_pullTimer.IsRunning)
- _pullTimer.Start();
- if (_me.CurrentTarget != null)
- {
- if (_me.CurrentTarget.Distance >= Targeting.PullDistance && !_me.Combat && _pullTimer.Elapsed.Seconds <= 25)
- {
- WoWMovement.ClickToMove(_me.CurrentTarget.Location, 5f);
- Thread.Sleep(100);
- return;
- }
- if (_pullTimer.Elapsed.Seconds > 25)
- {
- Log("Blacklisting {0}", _me.CurrentTarget.Name);
- Blacklist.Add(_me.CurrentTarget != null ? _me.CurrentTarget.CurrentTargetGuid : 0, TimeSpan.FromMinutes(15));
- _me.ClearTarget();
- _pullTimer.Reset();
- return;
- }
- if(_me.Combat)
- return;
- _pullTimer.Reset();
- WoWMovement.MoveStop();
- WoWMovement.Face();
- }
- if(OnPullFinished != null)
- OnPullFinished(new object(), new PullFinishedEventArgs(_me.CurrentTarget));
- }
- #endregion
- /// <summary>
- /// For handling falling, not implemented yet tho :(
- /// </summary>
- #region Falling
- public void HandleFalling()
- {
- }
- #endregion
- /// <summary>
- /// Oh yummy, here's the actual code that get's run in combat when you have a target.
- /// make it pwetty!
- /// </summary>
- #region Combat
- public void Combat()
- {
- WoWMovement.MoveStop();
- if (_me.CurrentTarget != null)
- {
- WoWMovement.Face();
- var spell = "";
- if (spell != "" && (!_me.Stunned || !_me.Possessed || !_me.Pacified))
- {
- if (spell == "Shoot" && _me.IsAutoAttacking)
- return;
- Log("Casting **{0}**", spell);
- SpellManager.CastSpell(spell);
- }
- }
- if (OnCombatFinished != null)
- OnCombatFinished(new object(), new EventArgs());
- }
- #endregion
- #region Implementation of IDisposable
- /// <summary>
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- /// </summary>
- /// <filterpriority>2</filterpriority>
- public void Dispose()
- {
- }
- #endregion
- }
- /// <summary>
- /// Functions and Events
- /// </summary>
- public partial class Hades
- {
- private delegate void CombatFinishedDelegate(object sender, EventArgs e);
- private static event CombatFinishedDelegate OnCombatFinished;
- private class PullFinishedEventArgs
- {
- private readonly WoWUnit _unit;
- public PullFinishedEventArgs(WoWUnit unit)
- {
- _unit = unit;
- }
- public string Name { get { return _unit.Name; } }
- public int Level { get { return _unit.Level; } }
- public bool Aggro { get { return _unit.Aggro; } }
- }
- private delegate void PullFinishedDelegate(object sender, PullFinishedEventArgs e);
- private static event PullFinishedDelegate OnPullFinished;
- /// <summary>
- /// Small wrapper for Logging.Write(...)
- /// </summary>
- /// <param name="format">text to print</param>
- /// <param name="args">arguments</param>
- private void Log(string format, params object[] args)
- {
- Logging.Write("[" + Name + "]: " + format, args);
- }
- /// <summary>
- /// Small wrapper for Logging.Write(...)
- /// </summary>
- /// <param name="format">text to print</param>
- /// <param name="name">boolean that makes the name appear in the log</param>
- private void Log(string format, bool name)
- {
- Logging.Write(name ? "[" + Name + "]:" : "" + format);
- }
- /// <summary>
- /// Small wrapper for Logging.Write(...)
- /// </summary>
- /// <param name="format">text to print</param>
- private void Log(string format)
- {
- if (format != "")
- Log(format, true);
- }
- }
- }
Add Comment
Please, Sign In to add comment