public static void CastW(Vector2 location) { if (!Spells.W.IsReady()) return; if (Player.Instance.Distance(location) <= Spells.W.Range) { Spells.W.Cast(location.To3DWorld()); } }
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 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 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 bool IsPathSafeEx(Vector2 end, AIHeroClient hero = null) { hero = hero ?? Player.Instance; return IsPathSafeEx(hero.GetPath(end.To3DWorld(), true).ToVector2(), hero); }
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(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(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(); }
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 static bool CheckPathCollision(Obj_AI_Base unit, Vector2 movePos) { var path = unit.GetPath(ObjectCache.myHeroCache.serverPos2D.To3DWorld(), movePos.To3DWorld()); if (path.Length > 0) { if (movePos.Distance(path[path.Length - 1].To2D()) > 5 || path.Length > 2) { return true; } } return false; }
private static void CastW(Vector2 location) { if (!_w.IsReady()) return; if (Player.Instance.Distance(location) <= _w.Range) { _w.Cast(location.To3DWorld()); } }
public static bool CheckPathCollision(Obj_AI_Base unit, Vector2 movePos) { //var path = unit.Path; var path = unit.GetPath(GameData.HeroInfo.ServerPos2D.To3DWorld(), movePos.To3DWorld()); if (path.Length > 0) { if (movePos.Distance(path[path.Length - 1].To2D()) > 5 || path.Length > 2) { return true; } } return false; }
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; } }