Guest User

Untitled

a guest
Feb 18th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.96 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Threading;
  6. using System.Timers;
  7. using Styx;
  8. using Styx.Combat.CombatRoutine;
  9. using Styx.Helpers;
  10. using Styx.Logic;
  11. using Styx.Logic.Combat;
  12. using Styx.Logic.Pathing;
  13. using Styx.WoWInternals;
  14. using Styx.WoWInternals.WoWObjects;
  15. using Styx.Logic.POI;
  16. using TreeSharp;
  17. namespace EzRetBeta
  18. {
  19. class Paladin : CombatRoutine
  20. {
  21.  
  22.  
  23. public override sealed string Name { get { return "EzRetBeta - " + ver; } }
  24. public override WoWClass Class { get { return WoWClass.Paladin; } }
  25. private static LocalPlayer Me { get { return ObjectManager.Me; } }
  26.  
  27.  
  28. private Version ver = new Version(2, 3, 0);
  29.  
  30. public override bool NeedPullBuffs { get { return false; } }
  31. public override bool NeedCombatBuffs { get { return false; } }
  32.  
  33. public struct Act
  34. {
  35. public string Spell;
  36. public float Trigger;
  37. public Act(String s, float t)
  38. {
  39. Spell = s;
  40. Trigger = t;
  41. }
  42. }
  43.  
  44. public struct Trinket
  45. {
  46. public string TrinketName;
  47. public string StackName;
  48. public int StackNumber;
  49. public float Trigger;
  50. public Trinket(String s, String sn,int snn,float t)
  51. {
  52. TrinketName = s;
  53. StackName = sn;
  54. StackNumber = snn;
  55. Trigger = t;
  56. }
  57. }
  58.  
  59. WoWUnit Target;
  60.  
  61.  
  62.  
  63. //Config
  64. private String SealName = "Seal of Truth";
  65. //private static int HEAL_THRESHOLD = 10;
  66. //private static int PULL_DISTANCE = 30;
  67. private static float HOF_THRESHOLD = 8.05f;
  68. //private static float LOH_THRESHOLD = 25.0f;
  69. //private static float DP_THRESHOLD = 60.0f;
  70. private static bool DisableInq = true;
  71. private static int InqRefreshDuration = 6;//In seconds
  72. //private static bool InstantHealsOnly = true;
  73.  
  74. //You can modify these lists in order to affect how the bot acts
  75. List<String> Cleanse = new List<String> { "Aftermath", "Concussive Shot", "Slow", "Infected Wounds", "Freeze", "Frost Nova", "Piercing Howl", "Earthgrab", "Entangling Roots", "Frost Shock", "Entrapment", "Chains of Ice", "Chilled", "Shattered Barrier", "Cone of Cold", "Frostbolt" };
  76. List<String> Rotation = new List<String> { "Hammer of Justice", "Crusader Strike", "Holy Wrath", "Judgement" };
  77. List<String> Interrupts = new List<String> { "Rebuke", "Repentance", "Arcane Torrent" };
  78. List<String> CD = new List<String> { "Avenging Wrath", "Guardian of Ancient Kings" };
  79. List<Act> HealRotation = new List<Act> { new Act("Divine Protection", 60.0f), new Act("Lay on Hands", 20.0f), new Act("Word of Glory", 10.0f) };
  80. List<Trinket> Trinkets = new List<Trinket> {new Trinket("Essence of the Eternal Flame",null,0,100.0f), new Trinket("Apparatus of Khaz'goroth", "Titanic Power", 5, 60.0f), new Trinket("Fury of Angerforge","Raw Fury",5,60.0f) };
  81.  
  82. public override void Combat()
  83. {
  84. Target = Me.CurrentTarget;
  85. if (Target == null || !Target.Attackable)
  86. {
  87. Heal();
  88. Rest();
  89. return;
  90. }
  91.  
  92. if (Target.Dead || (Target.Distance > 30d && !Me.Combat))
  93. {
  94. Me.ClearTarget();
  95. SeekTarget();
  96. Heal();
  97. Rest();
  98. return;
  99. }
  100. else if (Target != null && Target.IsPet)
  101. {
  102. WoWUnit Owner = Target.CreatedByUnit;
  103. if (Owner != null && Owner.IsValid)
  104. {
  105. Blacklist.Add(Target, new TimeSpan(0, 0, 5));
  106. Logging.Write("Changing targets to pet owner");
  107. Target = Owner;
  108. TargetUnit(Target);
  109. }
  110. }
  111. //Heal
  112. Heal();
  113. //Face the target
  114.  
  115. if (Styx.BotManager.Current.Name != "LazyRaider" && (Target.Distance > 6d || !Me.CurrentTarget.InLineOfSight))
  116. {
  117. Move(Target.Location);
  118. }
  119. //Always try and move ontop of the enemy target
  120.  
  121. if (Target.Distance > 30d && Me.Combat && Styx.BotManager.Current.Name != "LazyRaider")
  122. {
  123. Logging.Write(Target.Name + " is currently " + Target.Distance.ToString() + " dropping target");
  124. Me.ClearTarget();
  125. SeekTarget();
  126. }
  127. else if ((Target.HealthPercent <= 20d || isAuraActive("Avenging Wrath")) && CanCast("Hammer of Wrath"))
  128. {
  129. WoWMovement.Face();
  130. Cast("Hammer of Wrath");
  131. }
  132. else if (isAuraActive("The Art of War") && CanCast("Exorcism"))
  133. {
  134. WoWMovement.Face();
  135. Cast("Exorcism");
  136. }
  137. else if ((Target.Distance >= 5d || Target.Distance < 15d) && CanCast("Judgement"))
  138. {
  139. Cast("Judgement");
  140. Move(Target.Location);
  141. }
  142. else if (Target.Distance <= 6d || MeleeLatency())
  143. {
  144.  
  145. foreach (String Ability in CD)
  146. {
  147. WoWMovement.Face();
  148. cctc(Ability);
  149. }
  150.  
  151. if (Target.IsCasting)
  152. {
  153. foreach (String Ability in Interrupts)
  154. {
  155. WoWMovement.Face();
  156. if (cctc(Ability))
  157. {
  158. Thread.Sleep(50);
  159. break;
  160. }
  161. }
  162. }
  163. else if (Target.HealthPercent <= 20d && isAuraActive("The Art of War") && CanCast("Flash of Light"))
  164. {
  165. Cast("Exorcism");
  166. }
  167. else if (Me.CurrentHolyPower == 3d || isAuraActive("Divine Purpose"))
  168. {
  169. WoWMovement.Face();
  170. cctc("Zealotry");
  171. if ((isAuraActive("Inquisition") && Me.ActiveAuras["Inquisition"].TimeLeft.Seconds > InqRefreshDuration) || DisableInq)
  172. {
  173. cctc("Templar's Verdict");
  174. }
  175. else
  176. {
  177. cctc("Inquisition");
  178. }
  179.  
  180.  
  181. }
  182. else
  183. {
  184. foreach (String Ability in Rotation)
  185. {
  186. Heal();
  187. Usetrinkets();
  188. WoWMovement.Face();
  189. if (cctc(Ability))
  190. {
  191. break;
  192. }
  193. }
  194. }
  195. }
  196. }
  197.  
  198. public void Usetrinkets()
  199. {
  200. foreach (Trinket t in Trinkets)
  201. {
  202.  
  203. if (StyxWoW.Me.Inventory.Equipped.Trinket1 != null && StyxWoW.Me.Inventory.Equipped.Trinket1.Name.Contains(t.TrinketName) && StyxWoW.Me.Inventory.Equipped.Trinket1.Cooldown <= 0)
  204. {
  205. if ((t.StackName != null) && (HasAuraStacks(t.StackName, t.StackNumber, Me)) && Target.HealthPercent < t.Trigger)
  206. {
  207. Logging.Write("Trinket one");
  208. StyxWoW.Me.Inventory.Equipped.Trinket1.Use();
  209. }
  210. else if (t.StackName == null)
  211. {
  212. Logging.Write("Trinket one");
  213. StyxWoW.Me.Inventory.Equipped.Trinket1.Use();
  214. }
  215. }
  216. else if (StyxWoW.Me.Inventory.Equipped.Trinket2 != null && StyxWoW.Me.Inventory.Equipped.Trinket2.Name == t.TrinketName && StyxWoW.Me.Inventory.Equipped.Trinket2.Cooldown <= 0)
  217. {
  218. if ((t.StackName != null) && (HasAuraStacks(t.StackName,t.StackNumber,Me)) && Target.HealthPercent < t.Trigger)
  219. {
  220. Logging.Write("Trinket two");
  221. StyxWoW.Me.Inventory.Equipped.Trinket2.Use();
  222. }
  223. else if (t.StackName == null)
  224. {
  225. Logging.Write("Trinket two");
  226. StyxWoW.Me.Inventory.Equipped.Trinket2.Use();
  227. }
  228. }
  229.  
  230. }
  231. }
  232.  
  233. System.Timers.Timer Heartbeat;
  234. /// <summary>
  235. /// Gonna try something interesting, using a timer rather then pulse to check for target usage, as it seems sometimes pulse stops getting called
  236. /// </summary>
  237. public override void Initialize()
  238. {
  239. Logging.Write("Init gets called");
  240. Heartbeat = new System.Timers.Timer(200);
  241. Heartbeat.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
  242. Heartbeat.Enabled = true;
  243. //base.Initialize();
  244. }
  245.  
  246. void _timer_Elapsed(object sender, ElapsedEventArgs e)
  247. {
  248. if (!Me.Mounted && !Me.GotTarget && !Me.Dead)
  249. {
  250. SeekTarget();
  251. }
  252. }
  253.  
  254.  
  255. public bool HasAuraStacks(String aura,int stacks, WoWUnit unit)
  256. {
  257. if (unit.ActiveAuras.ContainsKey(aura))
  258. {
  259. return unit.ActiveAuras[aura].StackCount >= stacks;
  260. }
  261. return false;
  262. }
  263.  
  264.  
  265. /*public override void Pulse()
  266. {
  267. //Logging.Write("Pulse");
  268. if (!Me.IsActuallyInCombat && !Me.Mounted && !Me.GotTarget && !Me.Dead)
  269. {
  270. //Logging.Write("Pulse Pull");
  271. SeekTarget();
  272. }
  273. }*/
  274.  
  275. void Cast(string Name)
  276. {
  277. Logging.Write(Name);
  278. SpellManager.Cast(Name);
  279. while (Me.IsCasting)
  280. {
  281. Thread.Sleep(10);
  282. }
  283. }
  284.  
  285. bool CanCast(string Name)
  286. {
  287. return SpellManager.CanCast(Name);
  288. }
  289. /// <summary>
  290. /// Can cast, then cast
  291. /// </summary>
  292. /// <param name="Name"></param>
  293. /// <returns></returns>
  294. bool cctc(string Name)
  295. {
  296. if (SpellManager.CanCast(Name))
  297. {
  298. Logging.Write(Name);
  299. SpellManager.Cast(Name);
  300. return true;
  301. }
  302. else
  303. {
  304. return false;
  305. }
  306. }
  307.  
  308. bool cctc(WoWUnit Who, String Name)
  309. {
  310. if (SpellManager.CanCast(Name))
  311. {
  312. Logging.Write(Name+"@"+Who);
  313. SpellManager.Cast(Name,Who);
  314. return true;
  315. }
  316. else
  317. {
  318. return false;
  319. }
  320. }
  321. /// <summary>
  322. /// Tricky latency stuff, will work on later
  323. /// </summary>
  324. /// <returns></returns>
  325. bool MeleeLatency()
  326. {
  327. return false;
  328. }
  329.  
  330. /// <summary>
  331. /// Taken from singulars PVP helper function file, and then modified
  332. /// </summary>
  333. /// <param name="unit"></param>
  334. protected void TargetUnit(WoWUnit unit)
  335. {
  336. Logging.Write("Targeting " + unit.Name);
  337. WoWMovement.ConstantFace(unit.Guid);
  338. BotPoi.Current = new BotPoi(unit, PoiType.Kill);
  339. Tar(unit);
  340. }
  341.  
  342. public override void Pull()
  343. {
  344.  
  345. if (!Me.GotTarget || !Me.CurrentTarget.IsAlive)
  346. {
  347. SeekTarget();
  348. }
  349. else
  350. {
  351. cctc("Judgement");
  352. Move(Me.CurrentTarget.Location);
  353. }
  354.  
  355. }
  356.  
  357. private void SeekTarget()
  358. {
  359. WoWPlayer unit = ObjectManager.GetObjectsOfType<WoWPlayer>(false, false).
  360. Where(p => p.IsHostile && !p.IsTotem && !p.IsPet && !p.Dead && p.DistanceSqr <= (10 * 10)).
  361. OrderBy(u => u.HealthPercent).FirstOrDefault();
  362.  
  363. if (unit == null)
  364. {
  365. unit = ObjectManager.GetObjectsOfType<WoWPlayer>(false, false).Where(
  366. p => p.IsHostile && !p.IsTotem && !p.IsPet && !p.Dead && p.DistanceSqr <= (35 * 35)).OrderBy(
  367. u => u.DistanceSqr).FirstOrDefault();
  368. }
  369. if (unit != null)
  370. {
  371. TargetUnit(unit);
  372. }
  373.  
  374.  
  375. }
  376.  
  377. private void Move(WoWPoint loc)
  378. {
  379. WoWMovement.Face();
  380. if (Styx.BotManager.Current.Name != "LazyRaider" && Target.Distance > 6d)
  381. {
  382. Navigator.MoveTo(loc);
  383. if (Target.Distance <= 6d)
  384. Navigator.PlayerMover.MoveStop();
  385. }
  386. }
  387.  
  388. private void Tar(WoWUnit tar)
  389. {
  390. if (Styx.BotManager.Current.Name != "LazyRaider")
  391. {
  392. tar.Target();
  393. }
  394. }
  395. private void Face(WoWUnit tar)
  396. {
  397. if (Styx.BotManager.Current.Name != "LazyRaider")
  398. {
  399. tar.Face();
  400. Navigator.PlayerMover.MoveStop();
  401. }
  402. }
  403.  
  404. public override void PreCombatBuff()
  405. {
  406. if (!isAuraActive(SealName))
  407. {
  408. SpellManager.Cast(SealName, Me);
  409. Logging.Write(SealName);
  410. }
  411. else
  412. {
  413. cctc(Me,Buffcheck());
  414. }
  415. }
  416.  
  417.  
  418. public override bool NeedPreCombatBuffs
  419. {
  420. get
  421. {
  422. return !isAuraActive(SealName) || (Buffcheck() != null);
  423. }
  424. }
  425.  
  426. public override bool NeedHeal
  427. {
  428. get
  429. {//(Me.IsFalling && CanCast("Hand of Protection")) ||
  430. return CleanseTime() || HealCheck() || (Me.MovementInfo.RunSpeed < HOF_THRESHOLD && CanCast("Hand of Freedom"));
  431. }
  432. }
  433.  
  434. public override void Heal()
  435. {
  436. if (Me.HealthPercent <= 65d && isAuraActive("Crusade") && CanCast("Holy Light"))
  437. {
  438. Cast("Holy Light");
  439. }
  440. if (Me.HealthPercent <= 100d && isAuraActive("Sacred Shield") && CanCast("Divine Light"))
  441. {
  442. Cast("Divine Light");
  443. }
  444. else if ((Me.CurrentHolyPower == 3d || isAuraActive("Divine Purpose")) && Me.HealthPercent <= 65d && CanCast("Word of Glory"))
  445. {
  446. Cast("Word of Glory");
  447. }
  448. else if (Me.HealthPercent <= 10d && CanCast("Divine Shield"))
  449. {
  450. Cast("Divine Shield");
  451. if (Me.HealthPercent <= 90d && CanCast("Divine Light"))
  452. {
  453. Cast("Divine Light");
  454. }
  455. }
  456. else if (Me.HealthPercent <= 20d && CanCast("Lay on Hands"))
  457. {
  458. Cast("Lay on Hands");
  459. }
  460. if (Me.MovementInfo.RunSpeed < HOF_THRESHOLD && CanCast("Hand of Freedom"))
  461. {
  462. Cast("Hand of Freedom");
  463. }
  464. /*else if (Me.IsFalling && CanCast("Hand of Protection"))
  465. {
  466. Cast("Hand of Protection");
  467. }*/
  468. else if (CleanseTime())
  469. {
  470. cctc("Cleanse");
  471. }
  472. if (Me.ManaPercent < 50 && CanCast("Divine Plea"))
  473. {
  474. Cast("Divine Plea");
  475. }
  476. }
  477.  
  478.  
  479.  
  480. /// <summary>
  481. /// Return the name of the buff we need to use
  482. /// </summary>
  483. /// <returns></returns>
  484. private string Buffcheck()
  485. {
  486. if (!isAuraActive("Blessing of Might"))
  487. {
  488. return "Blessing of Might";
  489. }
  490. else if ((Me.ActiveAuras["Blessing of Might"].CreatorGuid != Me.Guid) && (!isAuraActive("Blessing of Kings") && !isAuraActive("Mark of the Wild")))
  491. {
  492. return "Blessing of Kings";
  493. }
  494.  
  495. return null;
  496. }
  497.  
  498. #region Rest Functions
  499. public override bool NeedRest
  500. {
  501. get
  502. {
  503. bool restNeeded = false;
  504. if (!StyxWoW.Me.Auras.ContainsKey("Food") && StyxWoW.Me.HealthPercent < 95 && !StyxWoW.Me.IsSwimming)
  505. {
  506. restNeeded = true;
  507. return restNeeded;
  508. }
  509. return restNeeded;
  510. }
  511. }
  512. public override void Rest()
  513. {
  514. if (StyxWoW.Me.Mounted)
  515. {
  516. Navigator.PlayerMover.MoveStop();
  517. Mount.Dismount();
  518. }
  519. // if we have food, eat it
  520. if (StyxWoW.Me.HealthPercent < 95 && StyxWoW.Me.HealthPercent > 55 && Me.ManaPercent > 50)
  521. {
  522. if (Me.HealthPercent <= 65d && isAuraActive("Crusade") && CanCast("Holy Light"))
  523. {
  524. Cast("Holy Light");
  525. }
  526. else if (CanCast("Holy Light"))
  527. {
  528. Cast("Divine Light");
  529. }
  530. }
  531. if (!Styx.Logic.Common.Rest.NoFood && StyxWoW.Me.HealthPercent < 55 && !StyxWoW.Me.IsSwimming)
  532. {
  533. Lua.DoString("UseItemByName(\"" + Styx.Helpers.LevelbotSettings.Instance.FoodName + "\")");
  534. Thread.Sleep(500);
  535. while (StyxWoW.Me.HealthPercent < 98 && StyxWoW.Me.HasAura("Food"))
  536. {
  537. Thread.Sleep(10);
  538. }
  539. }
  540. if (Me.ManaPercent < 50 && CanCast("Divine Plea"))
  541. {
  542. Cast("Divine Plea");
  543. }
  544. }
  545. #endregion
  546.  
  547. /// <summary>
  548. /// Runs through all the checks in the healrotation
  549. /// </summary>
  550. /// <returns></returns>
  551. private bool HealCheck()
  552. {
  553. foreach (Act action in HealRotation)
  554. {
  555. if ((Me.HealthPercent <= action.Trigger) && CanCast(action.Spell))
  556. {
  557. return true;
  558. }
  559. }
  560. return false;
  561. }
  562. private bool isAuraActive(string name)
  563. {
  564. //Me.Auras.con
  565. return Me.ActiveAuras.ContainsKey(name);
  566. }
  567.  
  568.  
  569. /// <summary>
  570. /// This function returns true only if the presence of one of the dispelable debuffs is applied
  571. /// if more the one debuff is applied we are probably being focus and shouldnt waste time dispelling
  572. /// Orginally this would return true once one debuff was detected
  573. /// </summary>
  574. /// <returns></returns>
  575. private bool CleanseTime()
  576. {
  577.  
  578.  
  579. if (Me.ManaPercent < 50)
  580. return false;
  581.  
  582. if (Me.GotTarget)
  583. {
  584. if (Me.CurrentTarget.Distance < 5d)
  585. {
  586. return false;
  587. }
  588. }
  589.  
  590. int Debuffs = 0;
  591. foreach (string spell in Cleanse)
  592. {
  593. if (isAuraActive(spell))
  594. {
  595. Debuffs++;
  596. }
  597. }
  598. if (Debuffs <= 2 && Debuffs != 0)
  599. {
  600. return true;
  601. }
  602. else
  603. {
  604. return false;
  605. }
  606. }
  607. }
  608. }
Add Comment
Please, Sign In to add comment