Guest User

Untitled

a guest
Jul 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.41 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3. using System.Threading;
  4. using Styx.CustomCombat.CombatInterface;
  5. using Styx.Helpers;
  6. using Styx.Logic;
  7. using Styx.Logic.Common.Combat;
  8. using Styx.Logic.Pathing;
  9. using Styx.Object_Dumping_Enumeration;
  10. using Styx.Object_Dumping_Enumeration.WoWObjects;
  11.  
  12. namespace Styx.Bot.CustomClasses
  13. {
  14. public partial class Hades : ICombat, IDisposable
  15. {
  16. private readonly AutoResetEvent _toggleEvent;
  17. private readonly AutoResetEvent _uiEvent;
  18. private readonly AutoResetEvent _bufferEvent;
  19.  
  20. private static volatile bool _bufferToggle = false;
  21.  
  22. public string Name { get { return "Hades 1.0"; } }
  23. public WoWClass Class { get { return WoWClass.DeathKnight; } }
  24.  
  25. public Hades()
  26. {
  27. OnCombatFinished += Hades_OnCombatFinished;
  28. OnPullFinished += Hades_OnPullFinished;
  29.  
  30. _toggleEvent = new AutoResetEvent(true);
  31. _uiEvent = new AutoResetEvent(true);
  32. _bufferEvent = new AutoResetEvent(false);
  33. }
  34.  
  35. ~Hades()
  36. {
  37. Dispose();
  38. }
  39.  
  40. #region Event Handlers
  41.  
  42. static void Hades_OnPullFinished(object sender, PullFinishedEventArgs e)
  43. {
  44. if (e.Aggro)
  45. Logging.Write("Sucesfully pulled {0}!", e.Name);
  46. }
  47.  
  48. void Hades_OnCombatFinished(object sender, EventArgs e)
  49. {
  50. Dispose();
  51. }
  52.  
  53. #endregion
  54.  
  55. private Thread _handleSpellcast;
  56. private Thread _handleStun;
  57. private Thread _handleFear;
  58. private Thread _handleRoot;
  59. private Thread _handleAdds;
  60. private Thread _handleClass;
  61.  
  62. #region Global Scope
  63.  
  64. #endregion
  65.  
  66. /// <summary>
  67. /// Some variables used thruout the cc including settings
  68. /// </summary>
  69. #region Global variables
  70.  
  71. private readonly LocalPlayer _me = ObjectManager.Me;
  72.  
  73. #endregion
  74.  
  75. /// <summary>
  76. /// Functions and properties associated with resting
  77. /// </summary>
  78. #region Rest
  79.  
  80. public bool NeedRest { get { return _me.ManaPercent <= 50 || _me.HealthPercent <= 50; } }
  81.  
  82. public void Rest()
  83. {
  84. Logic.Common.Rest.Feed();
  85. }
  86.  
  87. #endregion
  88.  
  89. /// <summary>
  90. /// Functions and properties associated with buffs prior to combat
  91. /// This is regular buffs like Mark of the Wild, PW: Fortitude, Thorns etc..
  92. /// </summary>
  93. #region Pre Combat Buffs
  94.  
  95. public bool NeedPreCombatBuffs { get { return false; } }
  96.  
  97. public void PreCombatBuff()
  98. {
  99. }
  100.  
  101. #endregion
  102.  
  103. /// <summary>
  104. /// Functions and properties associated with combat buffs
  105. /// this logic will be ran once you enter combat. Put any defensive type buffs here ie.
  106. /// Power Word: Shield
  107. /// </summary>
  108. #region Combat Buffs
  109.  
  110. public bool NeedCombatBuffs { get { return false; } }
  111.  
  112. public void CombatBuff()
  113. {
  114. }
  115.  
  116. #endregion
  117.  
  118. /// <summary>
  119. /// Put any healing code here. this state isnt implemented yet but soon to come :)
  120. /// </summary>
  121. #region Heal
  122.  
  123. public bool NeedHeal { get { return false; } }
  124.  
  125. public void Heal()
  126. {
  127. }
  128.  
  129. #endregion
  130.  
  131. /// <summary>
  132. /// Pet any buffs here that prior to pulling ie. Horn of Winter for deathknights
  133. /// </summary>
  134. #region Pull Buffs
  135.  
  136. public bool NeedPullBuffs { get { return false; } }
  137.  
  138. public void PullBuff() { }
  139.  
  140. #endregion
  141.  
  142.  
  143. /// <summary>
  144. /// Pull logic here for approaching and engaging target's in combat
  145. /// </summary>
  146. #region Pull
  147.  
  148. private readonly Stopwatch _pullTimer = new Stopwatch();
  149.  
  150. public void Pull()
  151. {
  152. if (!_pullTimer.IsRunning)
  153. _pullTimer.Start();
  154.  
  155. if (_me.CurrentTarget != null)
  156. {
  157. if (_me.CurrentTarget.Distance >= Targeting.PullDistance && !_me.Combat && _pullTimer.Elapsed.Seconds <= 25)
  158. {
  159. WoWMovement.ClickToMove(_me.CurrentTarget.Location, 5f);
  160. Thread.Sleep(100);
  161. return;
  162. }
  163.  
  164. if (_pullTimer.Elapsed.Seconds > 25)
  165. {
  166. Log("Blacklisting {0}", _me.CurrentTarget.Name);
  167. Blacklist.Add(_me.CurrentTarget != null ? _me.CurrentTarget.CurrentTargetGuid : 0, TimeSpan.FromMinutes(15));
  168.  
  169. _me.ClearTarget();
  170. _pullTimer.Reset();
  171. return;
  172. }
  173.  
  174. if(_me.Combat)
  175. return;
  176.  
  177. _pullTimer.Reset();
  178. WoWMovement.MoveStop();
  179. WoWMovement.Face();
  180. }
  181.  
  182. if(OnPullFinished != null)
  183. OnPullFinished(new object(), new PullFinishedEventArgs(_me.CurrentTarget));
  184. }
  185.  
  186. #endregion
  187.  
  188. /// <summary>
  189. /// For handling falling, not implemented yet tho :(
  190. /// </summary>
  191. #region Falling
  192.  
  193. public void HandleFalling()
  194. {
  195. }
  196.  
  197. #endregion
  198.  
  199. /// <summary>
  200. /// Oh yummy, here's the actual code that get's run in combat when you have a target.
  201. /// make it pwetty!
  202. /// </summary>
  203. #region Combat
  204.  
  205. public void Combat()
  206. {
  207. WoWMovement.MoveStop();
  208.  
  209. if (_me.CurrentTarget != null)
  210. {
  211. WoWMovement.Face();
  212.  
  213. var spell = "";
  214.  
  215. if (spell != "" && (!_me.Stunned || !_me.Possessed || !_me.Pacified))
  216. {
  217. if (spell == "Shoot" && _me.IsAutoAttacking)
  218. return;
  219.  
  220. Log("Casting **{0}**", spell);
  221. SpellManager.CastSpell(spell);
  222. }
  223. }
  224.  
  225. if (OnCombatFinished != null)
  226. OnCombatFinished(new object(), new EventArgs());
  227. }
  228.  
  229. #endregion
  230.  
  231. #region Implementation of IDisposable
  232.  
  233. /// <summary>
  234. /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
  235. /// </summary>
  236. /// <filterpriority>2</filterpriority>
  237. public void Dispose()
  238. {
  239.  
  240. }
  241.  
  242. #endregion
  243. }
  244.  
  245. /// <summary>
  246. /// Functions and Events
  247. /// </summary>
  248. public partial class Hades
  249. {
  250. private delegate void CombatFinishedDelegate(object sender, EventArgs e);
  251. private static event CombatFinishedDelegate OnCombatFinished;
  252.  
  253. private class PullFinishedEventArgs
  254. {
  255. private readonly WoWUnit _unit;
  256.  
  257. public PullFinishedEventArgs(WoWUnit unit)
  258. {
  259. _unit = unit;
  260. }
  261.  
  262. public string Name { get { return _unit.Name; } }
  263. public int Level { get { return _unit.Level; } }
  264. public bool Aggro { get { return _unit.Aggro; } }
  265. }
  266.  
  267. private delegate void PullFinishedDelegate(object sender, PullFinishedEventArgs e);
  268. private static event PullFinishedDelegate OnPullFinished;
  269.  
  270. /// <summary>
  271. /// Small wrapper for Logging.Write(...)
  272. /// </summary>
  273. /// <param name="format">text to print</param>
  274. /// <param name="args">arguments</param>
  275. private void Log(string format, params object[] args)
  276. {
  277. Logging.Write("[" + Name + "]: " + format, args);
  278. }
  279.  
  280. /// <summary>
  281. /// Small wrapper for Logging.Write(...)
  282. /// </summary>
  283. /// <param name="format">text to print</param>
  284. /// <param name="name">boolean that makes the name appear in the log</param>
  285. private void Log(string format, bool name)
  286. {
  287. Logging.Write(name ? "[" + Name + "]:" : "" + format);
  288. }
  289.  
  290. /// <summary>
  291. /// Small wrapper for Logging.Write(...)
  292. /// </summary>
  293. /// <param name="format">text to print</param>
  294. private void Log(string format)
  295. {
  296. if (format != "")
  297. Log(format, true);
  298. }
  299. }
  300. }
Add Comment
Please, Sign In to add comment