private static void TryToEvade(List <SpellInstance> spells, Vector2 to) { var dangerLvl = spells.Select(i => i.GetValue <Slider>("DangerLvl").Value).Concat(new[] { 0 }).Max(); foreach (var evadeSpell in EvadeSpellDatabase.Spells.Where(i => i.Enabled && dangerLvl >= i.DangerLevel)) { if (evadeSpell.MenuName == "Walking") { var points = Evader.GetEvadePoints(); if (points.Count > 0) { evadePoint1 = to.Closest(points); var pos = evadePoint1.Extend(PlayerPosition, -100); if ( IsSafePath( ObjectManager.Player.GetPath(pos.To3D()).ToList().To2D(), Configs.EvadingSecondTime, -1, 100).IsSafe) { evadePoint1 = pos; } Evading = true; return; } } if (evadeSpell.IsReady) { if (evadeSpell.IsSpellShield) { if (IsAboutToHit(evadeSpell.Delay)) { ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, ObjectManager.Player); } haveSolution = true; return; } if (evadeSpell.IsMovementSpeedBuff) { var points = Evader.GetEvadePoints((int)evadeSpell.MoveSpeedTotalAmount(), evadeSpell.Delay); if (points.Count > 0) { evadePoint1 = to.Closest(points); Evading = true; ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, ObjectManager.Player); return; } } if (evadeSpell.IsDash) { if (evadeSpell.IsTargetted) { var targets = Evader.GetEvadeTargets( evadeSpell.ValidTargets, evadeSpell.Speed, evadeSpell.Delay, evadeSpell.MaxRange); if (targets.Count > 0) { var target = targets.MinOrDefault(i => i.Distance(to)); evadePoint1 = target.ServerPosition.To2D(); Evading = true; ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, target); return; } if (Utils.GameTimeTickCount - LastWardJumpTick < 250) { haveSolution = true; return; } if (evadeSpell.ValidTargets.Contains(SpellValidTargets.AllyWards) && Configs.Menu.Item("ES" + evadeSpell.MenuName + "_WardJump").GetValue <bool>()) { var ward = Items.GetWardSlot(); if (ward != null) { var points = Evader.GetEvadePoints(evadeSpell.Speed, evadeSpell.Delay); points.RemoveAll(i => i.Distance(PlayerPosition) > 600); if (points.Count > 0) { for (var i = 0; i < points.Count; i++) { var k = (int)(600 - PlayerPosition.Distance(points[i])); k -= Util.Random.Next(k); var extend = points[i] + k * (points[i] - PlayerPosition).Normalized(); if (IsSafePoint(extend).IsSafe) { points[i] = extend; } } ObjectManager.Player.Spellbook.CastSpell( ward.SpellSlot, to.Closest(points).To3D()); LastWardJumpTick = Utils.GameTimeTickCount; haveSolution = true; return; } } } } else { var points = Evader.GetEvadePoints(evadeSpell.Speed, evadeSpell.Delay); points.RemoveAll(i => i.Distance(PlayerPosition) > evadeSpell.MaxRange); if (evadeSpell.FixedRange) { for (var i = 0; i < points.Count; i++) { points[i] = PlayerPosition.Extend(points[i], evadeSpell.MaxRange); } for (var i = points.Count - 1; i > 0; i--) { if (!IsSafePoint(points[i]).IsSafe) { points.RemoveAt(i); } } } else { for (var i = 0; i < points.Count; i++) { var k = (int)(evadeSpell.MaxRange - PlayerPosition.Distance(points[i])); k -= Math.Max(Util.Random.Next(k) - 100, 0); var extend = points[i] + k * (points[i] - PlayerPosition).Normalized(); if (IsSafePoint(extend).IsSafe) { points[i] = extend; } } } if (points.Count > 0) { evadePoint1 = to.Closest(points); Evading = true; if (!evadeSpell.Invert) { if (evadeSpell.RequiresPreMove) { evadePoint1.Move(); LeagueSharp.Common.Utility.DelayAction.Add( Game.Ping / 2 + 100, () => ObjectManager.Player.Spellbook.CastSpell( evadeSpell.Slot, evadePoint1.To3D())); } else { ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, evadePoint1.To3D()); } } else { ObjectManager.Player.Spellbook.CastSpell( evadeSpell.Slot, (PlayerPosition - (evadePoint1 - PlayerPosition)).To3D()); } return; } } } if (evadeSpell.IsBlink) { if (evadeSpell.IsTargetted) { var targets = Evader.GetEvadeTargets( evadeSpell.ValidTargets, 0, evadeSpell.Delay, evadeSpell.MaxRange, true); if (targets.Count > 0) { if (IsAboutToHit(evadeSpell.Delay)) { var target = targets.MinOrDefault(i => i.Distance(to)); evadePoint1 = target.ServerPosition.To2D(); Evading = true; ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, target); } haveSolution = true; return; } if (Utils.GameTimeTickCount - LastWardJumpTick < 250) { haveSolution = true; return; } if (evadeSpell.ValidTargets.Contains(SpellValidTargets.AllyWards) && Configs.Menu.Item("ES" + evadeSpell.MenuName + "_WardJump").GetValue <bool>()) { var ward = Items.GetWardSlot(); if (ward != null) { var points = Evader.GetEvadePoints(0, evadeSpell.Delay, true); points.RemoveAll(i => i.Distance(PlayerPosition) > 600); if (points.Count > 0) { for (var i = 0; i < points.Count; i++) { var k = (int)(600 - PlayerPosition.Distance(points[i])); k -= Util.Random.Next(k); var extend = points[i] + k * (points[i] - PlayerPosition).Normalized(); if (IsSafePoint(extend).IsSafe) { points[i] = extend; } } ObjectManager.Player.Spellbook.CastSpell( ward.SpellSlot, to.Closest(points).To3D()); LastWardJumpTick = Utils.GameTimeTickCount; haveSolution = true; return; } } } } else { var points = Evader.GetEvadePoints(0, evadeSpell.Delay, true); points.RemoveAll(i => i.Distance(PlayerPosition) > evadeSpell.MaxRange); if (points.Count > 0) { if (IsAboutToHit(evadeSpell.Delay)) { for (var i = 0; i < points.Count; i++) { var k = (int)(evadeSpell.MaxRange - PlayerPosition.Distance(points[i])); k -= Util.Random.Next(k); var extend = points[i] + k * (points[i] - PlayerPosition).Normalized(); if (IsSafePoint(extend).IsSafe) { points[i] = extend; } } evadePoint1 = to.Closest(points); Evading = true; ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, evadePoint1.To3D()); } haveSolution = true; return; } } } if (evadeSpell.IsInvulnerability) { if (evadeSpell.IsTargetted) { var targets = Evader.GetEvadeTargets( evadeSpell.ValidTargets, 0, 0, evadeSpell.MaxRange, true, false, true); if (targets.Count > 0) { if (IsAboutToHit(evadeSpell.Delay)) { var target = targets.MinOrDefault(i => i.Distance(to)); evadePoint1 = target.ServerPosition.To2D(); Evading = true; ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, target); } haveSolution = true; return; } } else { if (IsAboutToHit(evadeSpell.Delay)) { if (evadeSpell.SelfCast) { ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot); } else { ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, PlayerPosition.To3D()); } } haveSolution = true; return; } } } if (evadeSpell.MenuName == "Zhonyas" && Items.CanUseItem("ZhonyasHourglass")) { if (IsAboutToHit(100)) { Items.UseItem("ZhonyasHourglass"); } haveSolution = true; return; } if (evadeSpell.IsReady && evadeSpell.IsShield) { if (IsAboutToHit(evadeSpell.Delay)) { ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, ObjectManager.Player); } haveSolution = true; return; } } //haveSolution = true; }