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 point = Evader.GetBestPoint(to); if (point.IsValid()) { evadePoint1 = point; var pos = evadePoint1.Extend(PlayerPosition, -100); if (pos.IsPathSafe(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 point = Evader.GetBestPoint(to, (int)evadeSpell.MoveSpeedTotalAmount(), evadeSpell.Delay); if (point.IsValid()) { evadePoint1 = point; 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; * }*/ var target = Evader.GetBestTarget(to, evadeSpell); if (target != null) { 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; * }*/ var point = Evader.GetBestPointDash(to, evadeSpell.Speed, evadeSpell.Delay, 600); if (point.IsValid()) { ObjectManager.Player.Spellbook.CastSpell(ward.SpellSlot, point.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(); * 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; * }*/ var point = Evader.GetBestPointDash( to, evadeSpell.Speed, evadeSpell.Delay, evadeSpell.MaxRange, evadeSpell.FixedRange); if (point.IsValid()) { evadePoint1 = point; 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; * }*/ var target = Evader.GetBestTarget(to, evadeSpell); if (target != null) { if (IsAboutToHit(evadeSpell.Delay)) { 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; * }*/ var point = Evader.GetBestPointBlink(to, evadeSpell.Delay, 600); if (point.IsValid()) { ObjectManager.Player.Spellbook.CastSpell(ward.SpellSlot, point.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; * }*/ var point = Evader.GetBestPointBlink(to, evadeSpell.Delay, evadeSpell.MaxRange); if (point.IsValid()) { if (IsAboutToHit(evadeSpell.Delay)) { evadePoint1 = point; 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; * }*/ var target = Evader.GetBestTarget(to, evadeSpell); if (target != null) { if (IsAboutToHit(evadeSpell.Delay)) { 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; }
private static void OnIssueOrder(Obj_AI_Base sender, PlayerIssueOrderEventArgs args) { if (!sender.IsMe) { return; } evadePoint2 = args.Order == GameObjectOrder.MoveTo || args.Order == GameObjectOrder.AttackTo ? args.TargetPosition.To2D() : Vector2.Zero; if (DetectedSpells.Count == 0) { forceFollowPath = false; } if (haveSolution) { return; } if (!Configs.Enabled || !EvadeSpellDatabase.Spells.Any(i => i.MenuName == "Walking" && i.Enabled) || Util.ShieldCheck) { return; } var paths = ObjectManager.Player.GetPath(args.TargetPosition).ToList().To2D(); if (Evading || !PlayerPosition.IsPointSafe().IsSafe) { if (args.Order == GameObjectOrder.MoveTo) { var willMove = false; if (Evading && Utils.GameTimeTickCount - lastEvadePointChangeTick > Configs.EvadePointChangeTime) { var point = Evader.GetBestPointBlock(args.TargetPosition.To2D()); if (point.IsValid()) { evadePoint1 = point; Evading = true; willMove = true; lastEvadePointChangeTick = Utils.GameTimeTickCount; } } if (paths.IsPathSafe(Configs.EvadingRouteChangeTime).IsSafe && paths[paths.Count - 1].IsPointSafe().IsSafe) { evadePoint1 = paths[paths.Count - 1]; Evading = true; willMove = true; } if (!willMove) { forceFollowPath = true; } } args.Process = false; return; } var checkPath = paths.IsPathSafe(Configs.CrossingTime); if (checkPath.IsSafe) { return; } if (args.Order != GameObjectOrder.AttackUnit) { forceFollowPath = true; args.Process = false; } else { var target = args.Target as AttackableUnit; if (target == null || !target.IsValid || !target.IsVisible || PlayerPosition.Distance(target.Position) <= Orbwalking.GetRealAutoAttackRange(target)) { return; } if (checkPath.Intersect.Valid) { checkPath.Intersect.Point.Move(); } args.Process = false; } }