AzScript


SUBMITTED BY: Alerand

DATE: May 7, 2016, 10:39 a.m.

FORMAT: Text only

SIZE: 19.9 kB

HITS: 12091

  1. Skip to content
  2. Personal Open source Business Explore
  3. Sign upSign inPricingBlogSupport
  4. This repository
  5. Search
  6. Watch 1 Star 2 Fork 13 detuks/GoodGuyJodu
  7. Code Issues 0 Pull requests 0 Pulse Graphs
  8. Branch: master Find file Copy pathGoodGuyJodu/AzirSharp/Azir.cs
  9. 67ee3f9 on 20 Mar
  10. @detuks detuks BETA injection glide
  11. 1 contributor
  12. RawBlameHistory 537 lines (453 sloc) 18.4 KB
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using DetuksSharp;
  17. using LeagueSharp;
  18. using LeagueSharp.Common;
  19. using SharpDX;
  20. using DeathWalker = DetuksSharp.DeathWalker;
  21. namespace AzirSharp
  22. {
  23. class Azir
  24. {
  25. public static Obj_AI_Hero Player = ObjectManager.Player;
  26. public static Vector3 testShow = new Vector3();
  27. public static SummonerItems sumItems = new SummonerItems(Player);
  28. public static Spellbook sBook = Player.Spellbook;
  29. public static SpellDataInst Qdata = sBook.GetSpell(SpellSlot.Q);
  30. public static SpellDataInst Wdata = sBook.GetSpell(SpellSlot.W);
  31. public static SpellDataInst Edata = sBook.GetSpell(SpellSlot.E);
  32. public static SpellDataInst Rdata = sBook.GetSpell(SpellSlot.R);
  33. public static Spell Q;
  34. public static Spell W;
  35. public static Spell E;
  36. public static Spell R;
  37. public static List<Obj_AI_Minion> MySoldiers = new List<Obj_AI_Minion>();
  38. public static void setSkillShots()
  39. {
  40. Q = new Spell(SpellSlot.Q, 1075);
  41. W = new Spell(SpellSlot.W, 450);
  42. E = new Spell(SpellSlot.E, 1150);
  43. R = new Spell(SpellSlot.R, 250);
  44. Q.SetSkillshot(0.0f, 65f, 1500f, false, SkillshotType.SkillshotLine);
  45. E.SetSkillshot(0.0f, 65f, 1500f, false, SkillshotType.SkillshotLine);
  46. R.SetSkillshot(0.5f, 400, 1400, false, SkillshotType.SkillshotLine);
  47. }
  48. public static List<Obj_AI_Minion> getUsableSoliders()
  49. {
  50. return MySoldiers.Where(sol => !sol.IsDead).ToList();
  51. }
  52. public static Obj_AI_Minion getClosestSolider(Vector3 pos)
  53. {
  54. return MySoldiers.Where(sol => !sol.IsDead).OrderBy(sol => sol.Distance(pos, true)-((sol.IsMoving)?500:0)).FirstOrDefault();
  55. }
  56. public static bool newSloiderSoon()
  57. {
  58. //Console.WriteLine("cd:"+(W.Instance.CooldownExpires-Game.Time));
  59. return (W.Instance.CooldownExpires - Game.Time) > 0 && (W.Instance.CooldownExpires - Game.Time)<0.5f;
  60. }
  61. public static void doCombo(Obj_AI_Hero targ)
  62. {
  63. if (Player.IsDead)
  64. return;
  65. if (AzirSharp.Config.Item("useW").GetValue<bool>())
  66. {
  67. castWTarget(targ);
  68. }
  69. // if (getEnemiesInSolRange().Count == 0)
  70. if (!newSloiderSoon() && (!enemyInAzirRange(targ) || (targ.Health <= Q.GetDamage(targ) + DeathWalker.getRealAADmg(targ))) && AzirSharp.Config.Item("useQ").GetValue<bool>())
  71. castQTarget(targ);
  72. if (AzirSharp.Config.Item("useE").GetValue<bool>() )
  73. castETarget(targ);
  74. if (AzirSharp.Config.Item("useR").GetValue<bool>())
  75. {
  76. if (targ.Health < R.GetDamage(targ))
  77. R.Cast(targ);
  78. }
  79. }
  80. public static void doAttack()
  81. {
  82. List<Obj_AI_Hero> enes = getEnemiesInSolRange();
  83. if (enes != null)
  84. {
  85. foreach (var ene in enes)
  86. {
  87. if (DeathWalker.canAttack() && solisAreStill())
  88. {
  89. Console.WriteLine("Attack");
  90. DeathWalker.doAttack(ene);
  91. }
  92. }
  93. }
  94. }
  95. public static void castQTarget(Obj_AI_Hero target)
  96. {
  97. if (!Q.IsReady())
  98. return;
  99. try
  100. {
  101. if (getMiddleDelay(target) != -1)
  102. {
  103. PredictionOutput po2 = Prediction.GetPrediction(target, getMiddleDelay(target)*1.1f);
  104. PredictionOutput po = Q.GetPrediction(target);
  105. if (po2.Hitchance > HitChance.Low)
  106. {
  107. Q.Cast(po2.UnitPosition);
  108. }
  109. }
  110. }
  111. catch (Exception)
  112. {
  113. }
  114. }
  115. public static void castWTarget(Obj_AI_Hero target)
  116. {
  117. if ((!W.IsReady() && Wdata.Ammo == 0) )
  118. return;
  119. PredictionOutput po = Prediction.GetPrediction(target, 0.2f);
  120. if (Qdata.CooldownExpires < Game.Time || po.UnitPosition.Distance(Player.Position, true) < 630*630 && (Player.Mana > Wdata.ManaCost+Qdata.ManaCost || target.Distance(Player,true)<700*700))
  121. {
  122. summonSolider(po.UnitPosition);
  123. }
  124. }
  125. public static void summonSolider(Vector3 posIn)
  126. {
  127. if(!W.IsReady())
  128. return;
  129. var pos = (posIn.Distance(Player.Position, true) < W.RangeSqr) ? posIn : Player.Position.Extend(posIn, W.Range);
  130. Obj_AI_Base tower = DeathWalker.EnemyTowers.Where(tur => tur != null && tur.IsValid && tur.IsEnemy && tur.Health > 0 && tur.Distance(Player, true) < 700 * 700).OrderBy(tur => pos.Distance(tur.Position)).FirstOrDefault();
  131. if (tower != null )
  132. {
  133. var rad = tower.BoundingRadius + 150;
  134. if (tower.Distance(pos, true) <= rad*rad)
  135. {
  136. var bestPo =
  137. tower.BBox.GetCorners()
  138. .Where(corn => corn.Distance(Player.Position, true) < W.RangeSqr)
  139. .OrderBy(cor => cor.Distance(pos, true))
  140. .FirstOrDefault();
  141. pos = tower.Position.To2D().Extend(bestPo.To2D(), tower.BoundingRadius + 300).To3D();
  142. }
  143. }
  144. W.Cast(pos);
  145. Player.IssueOrder(GameObjectOrder.MoveTo, Game.CursorPos);
  146. }
  147. public static void castETarget(Obj_AI_Hero target)
  148. {
  149. if (!E.IsReady())
  150. return;
  151. List<Obj_AI_Minion> solis = getUsableSoliders().Where(sol => !sol.IsMoving && !sol.UnderTurret(true)).ToList();
  152. if (solis.Count == 0)
  153. return;
  154. foreach (var sol in solis)
  155. {
  156. float toSol = Player.Distance(sol.Position);
  157. //Collision.GetCollision(new List<Vector3>{sol.Position},getMyEPred(sol));
  158. PredictionOutput po = Prediction.GetPrediction(target,toSol/1500f);
  159. if (sol.Distance(po.UnitPosition)<325 && interact(Player.Position.To2D(), sol.Position.To2D(), po.UnitPosition.To2D(), 45)
  160. && interactsOnlyWithTarg(target,sol,Player.Distance(po.UnitPosition)))
  161. {
  162. E.Cast(sol.Position);
  163. return;
  164. }
  165. /*if (po.CollisionObjects.Count == 0)
  166. continue;
  167. Console.WriteLine(po.CollisionObjects.Count);
  168. Obj_AI_Base col = po.CollisionObjects.OrderBy(obj => obj.Distance(Player.Position)).First();
  169. if (col.NetworkId == target.NetworkId)
  170. {
  171. E.Cast(sol);
  172. return;
  173. }*/
  174. }
  175. }
  176. private static Vector3 startPos = new Vector3();
  177. public static void doGlideToMouse(Vector3 pos)
  178. {
  179. if (!Q.IsReady() && R.IsReady())
  180. {
  181. Obj_AI_Base tower = ObjectManager.Get<Obj_AI_Turret>().Where(tur => tur.IsAlly && tur.Health > 0).OrderBy(tur => Player.Distance(tur)).First();
  182. if (tower != null)
  183. {
  184. var pol = DeathMath.getPolygonOn(Player.Position.Extend(tower.Position, -255).To2D(), tower.Position.To2D(), 300 + R.Level * 100, 270);
  185. if (
  186. DeathWalker.AllEnemys.Any(
  187. ene => ene.IsValid && !ene.IsDead && pol.pointInside(ene.Position.To2D())))
  188. {
  189. R.Cast(tower.Position);
  190. }
  191. }
  192. }
  193. var closest = getClosestSolider(pos);
  194. if (closest == null || closest.Distance(pos)>400)
  195. return;
  196. if (E.IsReady())
  197. {
  198. startPos = Player.Position;
  199. E.CastOnUnit(closest);
  200. }
  201. var playToSoli = Player.Distance(closest);
  202. if (Player.IsDashing() && playToSoli < 400)
  203. {
  204. if (Q.IsReady())
  205. Q.Cast(Player.Position.Extend(startPos,1234));
  206. }
  207. }
  208. public static void doFlyToMouse(Vector3 pos)
  209. {
  210. /* E use if soli dist targ < 250
  211. * or soli dist targ < play dist targ and soli dist play > 650
  212. *
  213. * if palyer time to soli < soli tiem to targ
  214. */
  215. var closest = getClosestSolider(pos);
  216. var dist = Player.Distance(pos, true);
  217. if ((closest == null || (closest.Distance(pos, true) > dist)) && W.IsReady() &&
  218. Qdata.CooldownExpires < Game.Time && Edata.CooldownExpires < Game.Time)
  219. {
  220. summonSolider(pos);
  221. Player.IssueOrder(GameObjectOrder.MoveTo, Game.CursorPos);
  222. return;
  223. }
  224. if (closest == null)
  225. return;
  226. var timeToSoli = Player.Distance(closest)/E.Speed+E.Delay;
  227. var soliTimeToTarg = closest.Distance(pos)/Q.Speed+Q.Delay;
  228. // if (soliTimeToTarg < timeToSoli && E.IsReady())
  229. // E.CastOnUnit(closest);
  230. // if (Q.IsReady() && soliTimeToTarg > timeToSoli)
  231. // Q.Cast(pos);
  232. //return;
  233. var soliToTarg = closest.Distance(pos);
  234. var playToTarg = Player.Distance(pos);
  235. var playToSoli = Player.Distance(closest);
  236. if (soliToTarg + 250 < playToTarg)
  237. {
  238. if (E.IsReady())
  239. E.CastOnUnit(closest);
  240. }
  241. else
  242. {
  243. if (Q.IsReady())
  244. Q.Cast(pos);
  245. }
  246. if (Player.IsDashing() && playToSoli < 400)
  247. {
  248. if (Q.IsReady())
  249. Q.Cast(pos);
  250. }
  251. else if (soliToTarg >= playToTarg)
  252. {
  253. if (Q.IsReady())
  254. Q.Cast(pos);
  255. }
  256. return;
  257. if ((closest.Distance(pos, true) > dist - 150 * 150))
  258. {
  259. if (E.IsReady())
  260. E.CastOnUnit(closest);
  261. }
  262. else
  263. {
  264. if (E.IsReady() && Q.IsReady(150))
  265. {
  266. E.CastOnUnit(closest);
  267. }
  268. if (Player.IsDashing() && Q.IsReady())
  269. Q.Cast(pos);
  270. }
  271. }
  272. public static void goFullIn(Obj_AI_Hero target)
  273. {
  274. //R logic here!
  275. try
  276. {
  277. if (!R.IsReady() && target.IsDashing())
  278. {
  279. if (W.IsReady())
  280. {
  281. summonSolider(target.GetDashInfo().EndPos.To3D());
  282. }
  283. }
  284. if(E.IsReady())
  285. castETarget(target);
  286. var dist = Player.Distance(target);
  287. if (R.IsReady())
  288. {
  289. Obj_AI_Base tower = ObjectManager.Get<Obj_AI_Turret>().Where(tur => tur.IsAlly && tur.Health > 0).OrderBy(tur => Player.Distance(tur)).First();
  290. if (tower != null)
  291. {
  292. var pol = DeathMath.getPolygonOn(Player.Position.Extend(tower.Position, -155).To2D(), tower.Position.To2D(), 300+R.Level*100,270);
  293. if (
  294. DeathWalker.AllEnemys.Any(
  295. ene => ene.IsValid && !ene.IsDead && pol.pointInside(ene.Position.To2D())))
  296. {
  297. R.Cast(tower.Position);
  298. }
  299. //if(pol.pointInside(target.Position.To2D()))
  300. }
  301. }
  302. var aprTime = dist / E.Speed;
  303. var output = Prediction.GetPrediction(target, aprTime);
  304. if (Player.Distance(output.UnitPosition,true)<1050*1050)
  305. doFlyToMouse(output.UnitPosition.Extend(Player.Position, -75));
  306. }
  307. catch (Exception ex)
  308. {
  309. Console.WriteLine(ex);
  310. }
  311. }
  312. public static void autoRunderTower()
  313. {
  314. if (!R.IsReady())
  315. return;
  316. Obj_AI_Base tower = ObjectManager.Get<Obj_AI_Turret>().Where(tur => tur.IsAlly && tur.Health > 0).OrderBy(tur => Player.Distance(tur)).First();
  317. if (tower != null)
  318. {
  319. var distTower = tower.Distance(Player);
  320. if (distTower < 1200 && distTower > 200 && tower.CountEnemiesInRange(tower.AttackRange) == 0)
  321. {
  322. var pol = DeathMath.getPolygonOn(Player.Position.Extend(tower.Position, -155).To2D(),
  323. tower.Position.To2D(), R.Width, 240);
  324. if (
  325. DeathWalker.AllEnemys.Any(
  326. ene => ene.IsValid && !ene.IsDead && pol.pointInside(ene.Position.To2D())))
  327. {
  328. R.Cast(tower.Position);
  329. }
  330. }
  331. //if(pol.pointInside(target.Position.To2D()))
  332. }
  333. }
  334. public static float getFullDmgOn(Obj_AI_Hero target)
  335. {
  336. float dmg = 0;
  337. if (Qdata.CooldownExpires < Game.Time)
  338. dmg += Q.GetDamage(target);
  339. if (E.IsReady())
  340. dmg += E.GetDamage(target);
  341. if (R.IsReady())
  342. dmg += R.GetDamage(target);
  343. //dmg += DeathWalker.getRealAADmg(target);
  344. return dmg;
  345. }
  346. public static bool interactsOnlyWithTarg(Obj_AI_Hero target,Obj_AI_Base sol, float distColser)
  347. {
  348. foreach (var hero in ObjectManager.Get<Obj_AI_Hero>().Where(obj => obj.IsValid && obj.IsEnemy && obj.NetworkId != target.NetworkId))
  349. {
  350. float myDistToIt = Player.Distance(hero);
  351. PredictionOutput po = Prediction.GetPrediction(hero, myDistToIt/1500f);
  352. if (myDistToIt < distColser &&
  353. interact(sol.Position.To2D(), Player.Position.To2D(), po.UnitPosition.To2D(), 65))
  354. {
  355. return false;
  356. }
  357. }
  358. return true;
  359. }
  360. public static bool interact(Vector2 p1, Vector2 p2, Vector2 pC, float radius)
  361. {
  362. Vector2 p3 = new Vector2();
  363. p3.X = pC.X + radius;
  364. p3.Y = pC.Y + radius;
  365. float m = ((p2.Y - p1.Y) / (p2.X - p1.X));
  366. float Constant = (m * p1.X) - p1.Y;
  367. float b = -(2f * ((m * Constant) + p3.X + (m * p3.Y)));
  368. float a = (1 + (m * m));
  369. float c = ((p3.X * p3.X) + (p3.Y * p3.Y) - (radius * radius) + (2f * Constant * p3.Y) + (Constant * Constant));
  370. float D = ((b * b) - (4f * a * c));
  371. if (D > 0)
  372. {
  373. return true;
  374. }
  375. else
  376. return false;
  377. }
  378. public static float getMiddleDelay(Obj_AI_Hero target)
  379. {
  380. float allRange = 0;
  381. List<Obj_AI_Minion> solis = getUsableSoliders().Where(sol => (sol.Distance(target.ServerPosition)>325
  382. || sol.Distance(Prediction.GetPrediction(target,0.7f).UnitPosition)>325)).ToList();
  383. if (solis.Count == 0)
  384. return -1;
  385. foreach (var sol in solis)
  386. {
  387. //sol.
  388. float dist = sol.Distance(target.ServerPosition);
  389. allRange += dist;
  390. }
  391. return (allRange/(1500f*solis.Count));
  392. }
  393. public static PredictionInput getMyEPred(Obj_AI_Base sol)
  394. {
  395. PredictionInput pi = new PredictionInput();
  396. pi.Aoe = false;
  397. pi.Collision = true;
  398. pi.Delay = 0.0f;
  399. pi.From = Player.ServerPosition;
  400. pi.Radius = 65f;
  401. pi.Range = 1150f;
  402. pi.RangeCheckFrom = Player.ServerPosition;
  403. pi.Speed = 1500f;
  404. pi.Unit = sol;
  405. pi.Type = SkillshotType.SkillshotLine;
  406. pi.UseBoundingRadius = false;
  407. pi.CollisionObjects = new[]{ CollisionableObjects.Heroes};
  408. return pi;
  409. }
  410. public static PredictionInput getSoliderPred(Obj_AI_Base sol, Obj_AI_Hero target)
  411. {
  412. PredictionInput pi = new PredictionInput();
  413. pi.Aoe = true;
  414. pi.Collision = false;
  415. pi.Delay = 0.0f;
  416. pi.From = sol.ServerPosition;
  417. pi.Radius = 65f;
  418. pi.Range = 900f;
  419. pi.RangeCheckFrom = Player.ServerPosition;
  420. pi.Speed = 1500f;
  421. pi.Unit = target;
  422. pi.Type = SkillshotType.SkillshotLine;
  423. pi.UseBoundingRadius = true;
  424. return pi;
  425. }
  426. public static bool solisAreStill()
  427. {
  428. List<Obj_AI_Minion> solis = getUsableSoliders();
  429. foreach (var sol in solis)
  430. {
  431. if (sol.IsWindingUp)
  432. {
  433. // Console.WriteLine("isAuta awdawdAWD");
  434. return false;
  435. }
  436. }
  437. return true;
  438. }
  439. public static bool enemyInAzirRange(Obj_AI_Base ene)
  440. {
  441. var solis = getUsableSoliders();
  442. return solis.Count != 0 && solis.Where(sol => !sol.IsMoving && sol.Distance(Player, true) < 1225 * 1225).Any(sol => ene.Distance(sol) < 325);
  443. }
  444. public static List<Obj_AI_Hero> getEnemiesInSolRange()
  445. {
  446. List<Obj_AI_Minion> solis = getUsableSoliders();
  447. List<Obj_AI_Hero> enemies = DeathWalker.AllEnemys.Where(ene => ene.IsEnemy && ene.IsVisible && !ene.IsDead).ToList();
  448. List<Obj_AI_Hero> inRange = new List<Obj_AI_Hero>();
  449. if (solis.Count == 0)
  450. return null;
  451. foreach (var ene in enemies)
  452. {
  453. foreach (var sol in solis)
  454. {
  455. if (ene.Distance(sol) < 350)
  456. {
  457. inRange.Add(ene);
  458. break;
  459. }
  460. }
  461. }
  462. return inRange;
  463. }
  464. }
  465. }
  466. Status API Training Shop Blog About
  467. © 2016 GitHub, Inc. Terms Privacy Security Contact Help

comments powered by Disqus