private static void OnTick(EventArgs args) { State state = MyController.GetState(); float x = state.Gamepad.LeftThumbX; if (x < 500 && x > -500) { x = 0; } float y = state.Gamepad.LeftThumbY; if (y < 500 && y > -500) { y = 0; //Deadzone. Dont move if the movement is super minute } const int rangeMax = 32767; if (x != 0 && y != 0) { Vector2 move = new Vector2(Player.Instance.Position.X + 300 * (x / rangeMax), Player.Instance.Position.Y + 300 * (y / rangeMax)); if ( !(NavMesh.GetCollisionFlags(move) == CollisionFlags.Building || NavMesh.GetCollisionFlags(move) == CollisionFlags.Wall)) { Orbwalker.DisableMovement = false; Orbwalker.MoveTo(move.To3DWorld()); Orbwalker.DisableMovement = true; } } if ((state.Gamepad.Buttons & GamepadButtonFlags.A) != 0) { Orbwalker.ActiveModesFlags = Orbwalker.ActiveModes.Combo; } else { if ((state.Gamepad.Buttons & GamepadButtonFlags.B) != 0) { Orbwalker.ActiveModesFlags = Orbwalker.ActiveModes.LaneClear; } else { if ((state.Gamepad.Buttons & GamepadButtonFlags.X) != 0) { Orbwalker.ActiveModesFlags = Orbwalker.ActiveModes.LastHit; } else { if ((state.Gamepad.Buttons & GamepadButtonFlags.Y) != 0) { Orbwalker.ActiveModesFlags = Orbwalker.ActiveModes.Harass; } else { Orbwalker.ActiveModesFlags = Orbwalker.ActiveModes.None; } } } } }
public static void Permactive() { if (Spells.R.IsReady() && Player.Instance.Distance(Dragon) < Spells.R.Range && Rmenu["r.dragon"].Cast <KeyBind>().CurrentValue) { Spells.R.Cast(Dragon.To3DWorld()); } if (Spells.R.IsReady() && Player.Instance.Distance(Baron) < Spells.R.Range && Rmenu["r.baron"].Cast <KeyBind>().CurrentValue) { Spells.R.Cast(Baron.To3DWorld()); } if (Spells.E.IsReady() && Extension.GetCheckBoxValue(ComboMenu, "Combo.E") && ObjectManager.Player.HealthPercent <= Extension.GetSliderValue(ComboMenu, "Combo.E.Hp") && Extensions.CountEnemyChampionsInRange(Player.Instance.Position, 900) >= 1) { Spells.E.Cast(); } if (Extension.GetCheckBoxValue(SaveMenu, "enableSaving") && !Extension.Swallowed && Spells.WSwallow.IsReady()) { var allytosave = EntityManager.Allies.FirstOrDefault( ally => !ally.IsMe && !ally.IsMinion && !ally.IsDead && ally.HealthPercent <= Extension.GetSliderValue(SaveMenu, "save.allies.hp") && ObjectManager.Player.Distance(ally) < 500); if (allytosave != null) { Player.IssueOrder(GameObjectOrder.MoveTo, allytosave.ServerPosition); Spells.WSwallow.Cast(allytosave); } } }
public Vector2[] CreatePath(Vector2 start, Vector2 end) { var path = Player.Instance.GetPath(end.To3DWorld(), true); var polygons = Evade.ClippedPolygons.OrderByDescending(p => p.CenterOfPolygon().Distance(Player.Instance, true)).Reverse().ToArray(); for (var i = 0; i < path.Length - 1; i++) { var lineStart = path[i]; var lineEnd = path[i + 1]; foreach (var pol in polygons) { var points = pol.GetIntersectionPointsWithLineSegment(lineStart.To2D(), lineEnd.To2D()); if (points.Length > 0) { var endPoint = points.OrderByDescending(p => p.Distance(Player.Instance, true)) .Last() .Extend(Player.Instance.ServerPosition, Player.Instance.HitBoxRadius()); return(new[] { Player.Instance.ServerPosition.To2D(), endPoint }); } } } return(path.ToVector2()); }
/// <summary> /// Randomize Vector3. /// </summary> public static Vector3 Random(this Vector2 pos2) { var pos = pos2.To3DWorld(); var rnd = new Random(); var X = rnd.Next((int)(pos.X - 200), (int)(pos.X + 200)); var Y = rnd.Next((int)(pos.Y - 200), (int)(pos.Y + 200)); return new Vector3(X, Y, pos.Z); }
public static void Flee() { if (Program.E.IsReady()) { Vector2 dashPos = Renekton.ServerPosition.Extend(Game.CursorPos, Program.E.Range * Program.Random.NextFloat(0, 0.05f)); Program.E.Cast(dashPos.To3DWorld()); } }
public bool MoveTo(Vector2 point, bool limit = true) { if (limit && EvadeIssurOrderTime + IssueOrderTickLimit > Environment.TickCount) { return(false); } EvadeIssurOrderTime = Environment.TickCount; Player.IssueOrder(GameObjectOrder.MoveTo, point.To3DWorld(), false); return(true); }
public static void CastW(Vector2 location) { if (!Spells.W.IsReady()) { return; } if (Player.Instance.Distance(location) <= Spells.W.Range) { Spells.W.Cast(location.To3DWorld()); } }
public static int Get_Rate_Position(Vector2 Pos) { var Rate = 0; if (NavMesh.IsWallOfGrass(Pos.To3DWorld(), Player.Instance.BoundingRadius)) { Rate += 3; } if (Pos.CountAlliesInRange(1000) > Pos.CountEnemiesInRange(1000)) { Rate += Pos.CountAlliesInRange(1000) - Pos.CountEnemiesInRange(1000); } return(Rate); }
public static Vector3 RotatedAround(this Vector3 rotated, Vector3 around, float angle) { double s = Math.Sin(angle); double c = Math.Cos(angle); Vector2 ret = new Vector2(rotated.X - around.X, rotated.Y - around.Y); double xnew = ret.X * c - ret.Y * s; double ynew = ret.X * s + ret.Y * c; ret.X = (float)xnew + around.X; ret.Y = (float)ynew + around.Y; return(ret.To3DWorld()); }
public static ELocation GetCircularBoxLocation(this Spell.Skillshot spell, IEnumerable <AIHeroClient> entities, float radius, int range, Vector2?sourcePosition = null) { AIHeroClient[] array = entities.ToArray <AIHeroClient>(); switch (array.Length) { case 0: return(default(ELocation)); case 1: return(new ELocation { CastPosition = array[0].ServerPosition, HitNumber = 1 }); default: { Vector2 startPos = sourcePosition ?? Player.Instance.ServerPosition.To2D(); int num = 0; Vector2 vector = Vector2.Zero; Vector2[] array2 = (from a in array select a.ServerPosition.To2D() into a where a.IsInRange(startPos, (float)range) select a).ToArray <Vector2>(); Vector2[] array3 = array2; for (int i = 0; i < array3.Length; i++) { Vector2 pos = array3[i]; int num2 = array2.Count((Vector2 a) => a.IsInRange(pos, radius / 2f)); if (num2 >= num) { vector = pos; num = num2; } } return(new ELocation { CastPosition = vector.To3DWorld(), HitNumber = num }); } } }
private void CastQr() { if (Q.IsReady && R.IsReady) { Q.CachedPredictions.Clear(); var qWidth = Q.Width; var qCastDelay = Q.CastDelay; Q.CastDelay = R.CastDelay + qCastDelay; Q.Width = R.Range; var list = (from enemy in UnitManager.ValidEnemyHeroes select Q.GetPrediction(enemy) into pred where pred.HitChancePercent >= R.HitChancePercent / 2f select pred.CastPosition.To2D()).ToList(); if (list.Count >= ComboMenu.Slider("R.Hit")) { var bestCount = -1; var bestPoint = new Vector2(0, 0); var result = Enumerable.Range(1, (1 << list.Count) - 1).Select(index => list.Where((item, idx) => ((1 << idx) & index) != 0).ToList()).ToList(); foreach (var points in result) { var polygon = new Geometry.Polygon(); polygon.Points.AddRange(points); var center = polygon.CenterOfPolygon(); var count = list.Count(v => center.IsInRange(v, R.Range * 1.4f)); if (count > bestCount) { bestCount = count; bestPoint = center; } } if (bestCount >= ComboMenu.Slider("R.Hit")) { Q.Cast(bestPoint.To3DWorld()); } } Q.CachedPredictions.Clear(); Q.CastDelay = qCastDelay; Q.Width = qWidth; } }
private void CastQr() { if (Q.IsReady && R.IsReady) { Q.CachedPredictions.Clear(); var qWidth = Q.Width; var qCastDelay = Q.CastDelay; Q.CastDelay = R.CastDelay + qCastDelay; Q.Width = R.Range; var list = (from enemy in UnitManager.ValidEnemyHeroesInRange select Q.GetPrediction(enemy) into pred where pred.HitChancePercent >= R.HitChancePercent / 2f select pred.CastPosition.To2D()).ToList(); if (list.Count > 0) { var bestCount = -1; var bestPoint = new Vector2(0, 0); foreach (var point in list) { var count = list.Count(v => point.Distance(v, true) <= (R.Range * 1.4f).Pow()); if (count > bestCount) { bestCount = count; bestPoint = point; } } if (bestCount >= ComboMenu.Slider("R.Hit")) { Q.Cast(bestPoint.To3DWorld()); } } Q.CachedPredictions.Clear(); Q.CastDelay = qCastDelay; Q.Width = qWidth; } }
public Vector2[] GetPath(Vector2 start, Vector2 end) { const int extraWidth = 50; var walkPolygons = Geometry.ClipPolygons(Skillshots.Select(c => c.ToPolygon(extraWidth))).ToPolygons(); //if (walkPolygons.Any(pol => pol.IsInside(start))) //{ // Chat.Print("start"); // var polPoints = // Geometry.ClipPolygons( // SkillshotDetector.DetectedSkillshots.Where(c => c.IsValid) // .Select(c => c.ToPolygon(extraWidth)) // .ToList()) // .ToPolygons() // .Where(pol => pol.IsInside(start)) // .SelectMany(pol => pol.Points) // .ToList(); // polPoints.Sort((p1, p2) => p1.Distance(start, true).CompareTo(p2.Distance(start, true))); // start = polPoints.First().Extend(start, -150); //} if (walkPolygons.Any(pol => pol.IsInside(end))) { var polPoints = Geometry.ClipPolygons( SkillshotDetector.DetectedSkillshots.Where(c => c.IsValid) .Select(c => c.ToPolygon(extraWidth)) .ToList()) .ToPolygons() .Where(pol => pol.IsInside(end)) .SelectMany(pol => pol.Points) .ToList(); polPoints.Sort((p1, p2) => p1.Distance(end, true).CompareTo(p2.Distance(end, true))); end = polPoints.First().Extend(end, -extraWidth); } var ritoPath = Player.Instance.GetPath(end.To3DWorld(), true).ToArray().ToVector2().ToList(); //Player.Instance.GetPath(start.To3DWorld(), end.To3DWorld()).ToArray().ToVector2().ToList(); var pathPoints = new List <Vector2>(); var polygonDictionary = new Dictionary <Vector2, Geometry.Polygon>(); for (var i = 0; i < ritoPath.Count - 1; i++) { var lineStart = ritoPath[i]; var lineEnd = ritoPath[i + 1]; foreach (var pol in walkPolygons) { var intersectionPoints = pol.GetIntersectionPointsWithLineSegment(lineStart, lineEnd); foreach (var p in intersectionPoints) { if (!polygonDictionary.ContainsKey(p)) { polygonDictionary.Add(p, pol); pathPoints.Add(p); } } } } ritoPath.RemoveAll(p => walkPolygons.Any(pol => pol.IsInside(p))); pathPoints.AddRange(ritoPath); pathPoints.SortPath(Player.Instance.ServerPosition.To2D()); //start var path = new List <Vector2>(); while (pathPoints.Count > 0) { if (pathPoints.Count == 1) { path.Add(pathPoints[0]); break; } var current = pathPoints[0]; var next = pathPoints[1]; Geometry.Polygon pol1; Geometry.Polygon pol2; if (polygonDictionary.TryGetValue(current, out pol1) && polygonDictionary.TryGetValue(next, out pol2) && pol1.Equals(pol2)) { var detailedPolygon = pol1.ToDetailedPolygon(); detailedPolygon.Points.Sort( (p1, p2) => p1.Distance(current, true).CompareTo(p2.Distance(current, true))); current = detailedPolygon.Points.First(); detailedPolygon.Points.Sort((p1, p2) => p1.Distance(next, true).CompareTo(p2.Distance(next, true))); next = detailedPolygon.Points.First(); detailedPolygon = pol1.ToDetailedPolygon(); var index = detailedPolygon.Points.FindIndex(p => p == current); var linkedList = new LinkedList <Vector2>(detailedPolygon.Points, index); var nextPath = new List <Vector2>(); var previousPath = new List <Vector2>(); var nextLength = 0F; var previousLength = 0F; var nextWall = false; var previousWall = false; while (true) { var c = linkedList.Next(); if (c.IsWall()) { nextWall = true; break; } nextPath.Add(c); if (nextPath.Count > 1) { nextLength += nextPath[nextPath.Count - 2].Distance(c, true); } if (c == next) { break; } } linkedList.Index = index; while (true) { var c = linkedList.Previous(); if (c.IsWall()) { previousWall = true; break; } previousPath.Add(c); if (previousPath.Count > 1) { previousLength += previousPath[previousPath.Count - 2].Distance(c, true); } if (c == next) { break; } } var shortest = nextWall && previousWall ? (nextLength > previousLength ? nextPath : previousPath) : (nextWall || previousWall ? (nextWall ? previousPath : nextPath) : nextLength < previousLength ? nextPath : previousPath); path.AddRange(shortest); if (previousWall && nextWall) { break; } } else { path.Add(current); path.Add(next); } pathPoints.RemoveRange(0, 2); } return(path.ToArray()); }
public static int CountEnemyHeros(this Vector2 Pos, float range = 1200, int time = 250) { return(Pos.To3DWorld().CountEnemyHeros(range, time)); }
public static bool IsNotDangerPosition(Vector2 Pos) { return(IsNotDangerPosition(Pos.To3DWorld())); }
private void DrawWayPoints() { if (!_menuhandler.GetValue <bool>(_menu, "draw_waypoints")) { return; } foreach (var enemy in ObjectManager.Heroes.Enemies) { var waypoints = enemy.GetWaypoints(); var movement_speed = enemy.MovementSpeed; double distance = 0; var nearest_waypoint = new Vector2(); for (var i = 2; i < waypoints.Count; i++) { var vector2 = waypoints[i]; if (nearest_waypoint == null || enemy.Distance(vector2.To3DWorld()) < enemy.Distance(nearest_waypoint)) { nearest_waypoint = vector2; } } var max = Math.Min(_menuhandler.GetValue <int>(_menu, "max_shown"), waypoints.Count); for (var i = 2; i < max; i++) { var current = waypoints[i]; var prev = waypoints[i - 1]; if (i == 2) { distance += nearest_waypoint.To3DWorld().Distance(enemy); } else { distance += prev.To3DWorld().Distance(current.To3DWorld()); } var time = distance / movement_speed; if (time > 0.3) { if (i == max - 1) { Drawing.DrawCircle(current.To3DWorld(), 30, red, 2); } else { Drawing.DrawCircle(current.To3DWorld(), 20, 1); } if (i % 2 == 0 || i + 2 == max) { if (_menuhandler.GetValue <bool>(_menu, "time")) { Drawing.DrawText(current.To3DWorld().WorldToScreen(), white, enemy.ChampionName + " : " + Math.Round(time)); } else { Drawing.DrawText(current.To3DWorld().WorldToScreen(), white, enemy.ChampionName); } } else { if (_menuhandler.GetValue <bool>(_menu, "time")) { Drawing.DrawText(current.To3DWorld().WorldToScreen(), white, Math.Round(time).ToString()); } } if (_menuhandler.GetValue <bool>(_menu, "lines")) { if (i == 2) { Drawing.DrawLine(enemy.Position, nearest_waypoint.To3DWorld(), 1, white); } else { Drawing.DrawLine(prev.To3DWorld(), current.To3DWorld(), 1, white); } } } } } }
public static bool IsMovingTowards(this Obj_AI_Base unit, Vector2 position) { return(unit.IsMovingTowards(position.To3DWorld())); }
public static int Count_Monster_In_Range(this Vector2 Position, float range) { return(EntityManager.MinionsAndMonsters.GetJungleMonsters(Position.To3DWorld(), range).Count()); }
public static bool IsUnderEnemyTurret(this Vector2 Pos) { return(Pos.To3DWorld().IsUnderEnemyTurret()); }
public static void Combo() { bool QCheck = Program.ComboMenu["CQ"].Cast <CheckBox>().CurrentValue; bool WCheck = Program.ComboMenu["CW"].Cast <CheckBox>().CurrentValue; bool ECheck = Program.ComboMenu["CE"].Cast <CheckBox>().CurrentValue; bool RCheck = Program.ComboMenu["CR"].Cast <CheckBox>().CurrentValue; bool QReady = Program.Q.IsReady(); bool WReady = Program.W.IsReady(); bool EReady = Program.E.IsReady(); bool RReady = Program.R.IsReady(); if (Program.ComboMenu["CI"].Cast <CheckBox>().CurrentValue) { UseItems(Mode.Combo); } if (Renekton.CountEnemiesInRange(Renekton.GetAutoAttackRange()) >= 3 || Renekton.Health <= Renekton.MaxHealth * 0.2f && RCheck && RReady) { Program.R.Cast(); } if (inFullCombo || (QReady && WReady && EReady && QCheck && WCheck && ECheck)) { if (comboEnemy == null) { comboEnemy = (AIHeroClient)GetEnemy(Abilities.Slice, GameObjectType.AIHeroClient); if (comboEnemy == null) { inFullCombo = false; return; } inFullCombo = true; } //engage if (Program.E.Name == "RenektonSliceAndDice" && EReady) { beginningComboPosition = Renekton.Position; //Vector2 dashPos = Renekton.ServerPosition.Extend(comboEnemy, Program.E.Range * Program.Random.NextFloat(0, 0.05f)); Program.E.Cast(beginningComboPosition); } if (QReady && comboEnemy.Distance(Renekton) <= Program.QRange) { Program.Q.Cast(); } else if (WReady && !Renekton.HasBuffOfType(BuffType.Blind)) { Program.W.Cast(); Orbwalker.ForcedTarget = comboEnemy; } else if (Program.E.Name == "RenektonDice" && EReady && !WReady && Renekton.CanMove) { Vector2 dashPos = Renekton.ServerPosition.Extend(comboEnemy, Program.E.Range); Program.E.Cast(dashPos.To3DWorld()); inFullCombo = false; beginningComboPosition = Vector3.Zero; comboEnemy = null; } if (comboEnemy == null || comboEnemy.IsDead || comboEnemy.IsInvulnerable || comboEnemy.Distance(Renekton) >= Program.E.Range) { beginningComboPosition = Vector3.Zero; inFullCombo = false; comboEnemy = null; } } else { if (QCheck && QReady) { AIHeroClient enemy = (AIHeroClient)GetEnemy(Abilities.Q, GameObjectType.AIHeroClient); if (enemy != null) { Program.Q.Cast(); } } if (WCheck && WReady && Renekton.CanAttack && !Renekton.HasBuffOfType(BuffType.Blind)) { AIHeroClient enemy = (AIHeroClient)GetEnemy(Abilities.W, GameObjectType.AIHeroClient); if (enemy != null) { Program.W.Cast(); Orbwalker.ForcedTarget = enemy; } } if (ECheck && EReady) { AIHeroClient enemy = (AIHeroClient)GetEnemy(Abilities.Slice, GameObjectType.AIHeroClient); if (enemy != null) { //Vector2 dashPos = Renekton.ServerPosition.Extend(enemy, Program.E.Range * Program.Random.NextFloat(0, 0.05f)); Program.E.Cast(enemy); } } } }
public Vector2[] CreatePathOld(Vector2 start, Vector2 end) { const int extraWidth = 30; var walkPolygons = Geometry.ClipPolygons(Evade.Skillshots.Select(c => c.ToPolygon(extraWidth))).ToPolygons(); //if (walkPolygons.Any(pol => pol.IsInside(start))) //{ // var polPoints = // Geometry.ClipPolygons( // Evade.SkillshotDetector.DetectedSkillshots.Where(c => c.IsValid) // .Select(c => c.ToPolygon(extraWidth)) // .ToList()) // .ToPolygons() // .Where(pol => pol.IsInside(start)) // .SelectMany(pol => pol.Points) // .ToList(); // polPoints.Sort((p1, p2) => p1.Distance(start, true).CompareTo(p2.Distance(start, true))); // start = polPoints.First().Extend(start, -150); //} //if (walkPolygons.Any(pol => pol.IsInside(end))) //{ // var polPoints = // Geometry.ClipPolygons( // Evade.SkillshotDetector.DetectedSkillshots.Where(c => c.IsValid) // .Select(c => c.ToPolygon(extraWidth)) // .ToList()) // .ToPolygons() // .Where(pol => pol.IsInside(end)) // .SelectMany(pol => pol.Points) // .ToList(); // polPoints.Sort((p1, p2) => p1.Distance(end, true).CompareTo(p2.Distance(end, true))); // end = polPoints.First().Extend(end, -extraWidth); //} var ritoPath = Player.Instance.GetPath(end.To3DWorld()).ToArray().ToVector2().ToList(); //start.To3DWorld(), var pathPoints = new List<Vector2>(); var polygonDictionary = new Dictionary<Vector2, Geometry.Polygon>(); for (var i = 0; i < ritoPath.Count - 1; i++) { var lineStart = ritoPath[i]; var lineEnd = ritoPath[i + 1]; foreach (var pol in walkPolygons) { var intersectionPoints = pol.GetIntersectionPointsWithLineSegment(lineStart, lineEnd); foreach (var p in intersectionPoints) { if (!polygonDictionary.ContainsKey(p)) { polygonDictionary.Add(p, pol); pathPoints.Add(p); } } } } ritoPath.RemoveAll(p => walkPolygons.Any(pol => pol.IsInside(p))); pathPoints.AddRange(ritoPath); pathPoints.SortPath(Player.Instance.ServerPosition.To2D()); var path = new List<Vector2>(); while (pathPoints.Count > 0) { if (pathPoints.Count == 1) { path.Add(pathPoints[0]); break; } var current = pathPoints[0]; var next = pathPoints[1]; Geometry.Polygon pol1; Geometry.Polygon pol2; if (polygonDictionary.TryGetValue(current, out pol1) && polygonDictionary.TryGetValue(next, out pol2) && pol1.Equals(pol2)) { var detailedPolygon = pol1.ToDetailedPolygon(); detailedPolygon.Points.Sort( (p1, p2) => p1.Distance(current, true).CompareTo(p2.Distance(current, true))); current = detailedPolygon.Points.First(); detailedPolygon.Points.Sort((p1, p2) => p1.Distance(next, true).CompareTo(p2.Distance(next, true))); next = detailedPolygon.Points.First(); detailedPolygon = pol1.ToDetailedPolygon(); var index = detailedPolygon.Points.FindIndex(p => p == current); var linkedList = new LinkedList<Vector2>(detailedPolygon.Points, index); var nextPath = new List<Vector2>(); var previousPath = new List<Vector2>(); var nextLength = 0F; var previousLength = 0F; var nextWall = false; var previousWall = false; while (true) { var c = linkedList.Next(); if (c.IsWall()) { nextWall = true; break; } nextPath.Add(c); if (nextPath.Count > 1) nextLength += nextPath[nextPath.Count - 2].Distance(c, true); if (c == next) break; } linkedList.Index = index; while (true) { var c = linkedList.Previous(); if (c.IsWall()) { previousWall = true; break; } previousPath.Add(c); if (previousPath.Count > 1) previousLength += previousPath[previousPath.Count - 2].Distance(c, true); if (c == next) break; } var shortest = nextWall && previousWall ? (nextLength > previousLength ? nextPath : previousPath) : (nextWall || previousWall ? (nextWall ? previousPath : nextPath) : nextLength < previousLength ? nextPath : previousPath); path.AddRange(shortest); if (previousWall && nextWall) break; } else { path.Add(current); path.Add(next); } pathPoints.RemoveRange(0, 2); } return path.ToArray(); }
public bool IsPathSafeEx(Vector2 end, AIHeroClient hero = null) { hero = hero ?? Player.Instance; return(IsPathSafeEx(hero.GetPath(end.To3DWorld(), true).ToVector2(), hero)); }
public Vector2[] CreatePath(Vector2 start, Vector2 end) { var path = Player.Instance.GetPath(end.To3DWorld(), true); var polygons = Evade.ClippedPolygons.OrderByDescending(p => p.CenterOfPolygon().Distance(Player.Instance, true)).Reverse().ToArray(); for (var i = 0; i < path.Length - 1; i++) { var lineStart = path[i]; var lineEnd = path[i + 1]; foreach (var pol in polygons) { var points = pol.GetIntersectionPointsWithLineSegment(lineStart.To2D(), lineEnd.To2D()); if (points.Length > 0) { var endPoint = points.OrderByDescending(p => p.Distance(Player.Instance, true)) .Last() .Extend(Player.Instance.ServerPosition, Player.Instance.HitBoxRadius()); return new[] { Player.Instance.ServerPosition.To2D(), endPoint }; } } } return path.ToVector2(); }