Flsec


SUBMITTED BY: Alerand

DATE: May 4, 2016, 9:23 a.m.

FORMAT: Text only

SIZE: 7.4 kB

HITS: 18555

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using LeagueSharp;
  5. using LeagueSharp.Common;
  6. using Color = System.Drawing.Color;
  7. using SharpDX;
  8. namespace HoolaFlsec
  9. {
  10. public class Program
  11. {
  12. private static Menu Menu;
  13. private static Obj_AI_Hero Player = ObjectManager.Player;
  14. static SpellSlot Flash = Player.GetSpellSlot("summonerFlash");
  15. private static Vector3 insecPos;
  16. public static Vector2 InsecLinePos;
  17. public static bool isNullInsecPos = true;
  18. private static bool ToAlly { get { return Menu.Item("ToAlly").GetValue<KeyBind>().Active; } }
  19. private static bool ToDraw { get { return Menu.Item("ToDraw").GetValue<bool>(); } }
  20. static bool ToWhere { get { return Menu.Item("ToWhere").GetValue<KeyBind>().Active; } }
  21. static void Main()
  22. {
  23. CustomEvents.Game.OnGameLoad += OnGameLoad;
  24. }
  25. static void OnGameLoad(EventArgs args)
  26. {
  27. if (Player.ChampionName != "LeeSin") return;
  28. Game.PrintChat("Hoola Flsec - Loaded Successfully, Good Luck! :)");
  29. OnMenuLoad();
  30. Drawing.OnDraw += OnDraw;
  31. Obj_AI_Base.OnProcessSpellCast += OnCast;
  32. }
  33. private static List<Obj_AI_Hero> GetAllyHeroes(Obj_AI_Hero position, int range)
  34. {
  35. var temp = new List<Obj_AI_Hero>();
  36. foreach (var hero in ObjectManager.Get<Obj_AI_Hero>())
  37. {
  38. if (hero.IsAlly && !hero.IsMe && !hero.IsDead && hero.Distance(position) < range)
  39. {
  40. temp.Add(hero);
  41. }
  42. }
  43. return temp;
  44. }
  45. private static Vector3 InterceptionPoint(List<Obj_AI_Hero> heroes)
  46. {
  47. var result = new Vector3();
  48. foreach (var hero in heroes)
  49. {
  50. result += hero.Position;
  51. }
  52. result.X /= heroes.Count;
  53. result.Y /= heroes.Count;
  54. return result;
  55. }
  56. private static void OnCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
  57. {
  58. if (!sender.IsMe || !args.SData.Name.Contains("BlindMonkRKick")) return;
  59. var target = (Obj_AI_Hero)args.Target;
  60. if (ToAlly && target.IsValid)
  61. {
  62. var turrets = (from tower in ObjectManager.Get<Obj_Turret>()
  63. where
  64. tower.IsAlly && !tower.IsDead
  65. && target.Distance(tower.Position)
  66. < 1500 && tower.Health > 0
  67. select tower).ToList();
  68. if (GetAllyHeroes(target, 2000).Count > 0 && (!turrets.Any() || !ToWhere))
  69. {
  70. var insecPosition =
  71. InterceptionPoint(
  72. GetAllyInsec(
  73. GetAllyHeroes(target, 2000)));
  74. InsecLinePos = Drawing.WorldToScreen(insecPosition);
  75. insecPos = insecPosition;
  76. if (Flash != SpellSlot.Unknown && Flash.IsReady())
  77. {
  78. Player.Spellbook.CastSpell(Flash, target.Position.Extend(insecPos, -200));
  79. }
  80. }
  81. if (turrets.Any())
  82. {
  83. var insecPosition = turrets[0].Position;
  84. insecPos = insecPosition;
  85. if (Flash != SpellSlot.Unknown && Flash.IsReady())
  86. {
  87. Player.Spellbook.CastSpell(Flash, target.Position.Extend(insecPos, -200));
  88. }
  89. }
  90. if (GetAllyHeroes(target, 2000).Count == 0 && !turrets.Any())
  91. {
  92. var insecPosition = Player.Position;
  93. insecPos = insecPosition;
  94. if (Flash != SpellSlot.Unknown && Flash.IsReady())
  95. {
  96. Player.Spellbook.CastSpell(Flash, target.Position.Extend(insecPos, -200));
  97. }
  98. }
  99. }
  100. }
  101. private static List<Obj_AI_Hero> GetAllyInsec(List<Obj_AI_Hero> heroes)
  102. {
  103. byte alliesAround = 0;
  104. var tempObject = new Obj_AI_Hero();
  105. foreach (var hero in heroes)
  106. {
  107. var localTemp =
  108. GetAllyHeroes(hero, 500).Count;
  109. if (localTemp > alliesAround)
  110. {
  111. tempObject = hero;
  112. alliesAround = (byte)localTemp;
  113. }
  114. }
  115. return GetAllyHeroes(tempObject, 500);
  116. }
  117. private static void OnDraw(EventArgs args)
  118. {
  119. var target = TargetSelector.GetTarget(1400, TargetSelector.DamageType.Physical);
  120. if (ToAlly && target.IsValid)
  121. {
  122. var turrets = (from tower in ObjectManager.Get<Obj_Turret>()
  123. where
  124. tower.IsAlly && !tower.IsDead
  125. && target.Distance(tower.Position)
  126. < 1500 && tower.Health > 0
  127. select tower).ToList();
  128. if (GetAllyHeroes(target, 2000).Count > 0 && (!turrets.Any() || !ToWhere))
  129. {
  130. var insecPosition =
  131. InterceptionPoint(
  132. GetAllyInsec(
  133. GetAllyHeroes(target, 2000)));
  134. InsecLinePos = Drawing.WorldToScreen(insecPosition);
  135. insecPos = insecPosition;
  136. if (ToDraw) Render.Circle.DrawCircle(target.Position.Extend(insecPos, -200), 70, Color.Red);
  137. }
  138. if (turrets.Any())
  139. {
  140. var insecPosition = turrets[0].Position;
  141. insecPos = insecPosition;
  142. if (ToDraw) Render.Circle.DrawCircle(target.Position.Extend(insecPos, -200), 70, Color.Red);
  143. }
  144. if (GetAllyHeroes(target, 2000).Count == 0 && !turrets.Any())
  145. {
  146. var insecPosition = Player.Position;
  147. insecPos = insecPosition;
  148. if (ToDraw) Render.Circle.DrawCircle(target.Position.Extend(Player.Position, -200), 70, Color.Red);
  149. }
  150. }
  151. }
  152. private static void OnMenuLoad()
  153. {
  154. Menu = new Menu("Hoola Flsec", "hoolaflsec", true);
  155. var FlashInSec = new Menu("FlashInSec", "FlashInSec");
  156. FlashInSec.AddItem(new MenuItem("ToAlly", "Flash Insec On (Toggle)").SetValue(new KeyBind('G', KeyBindType.Toggle)));
  157. FlashInSec.AddItem(new MenuItem("ToDraw", "Draw Flash Position").SetValue(true));
  158. FlashInSec.AddItem(new MenuItem("ToWhere", "Priorize to (On = Tower, Off = Ally)").SetValue(new KeyBind('T', KeyBindType.Toggle)));
  159. Menu.AddSubMenu(FlashInSec);
  160. Menu.AddToMainMenu();
  161. }
  162. }
  163. }

comments powered by Disqus