public static Vector3 GetFarmingPosition() { var lasthittable = Minions.GetMinionsInLane(SessionBasedData.EnemyTeam, SessionBasedData.MyLane) .OrderBy(m => m.Health) .FirstOrDefault(m => m.Health > 1 && m.Health < ObjectManager.Player.GetAutoAttackDamage(m) * 2); var farthestTurret = Turrets.GetTurretsPosition(ObjectManager.Player.Team, SessionBasedData.CurrentLane).Last(); if (lasthittable != null) { return(GetLastHitPosition(lasthittable)); } var ourMinion = ObjectManager.Get <Obj_AI_Minion>().Where(m => m.IsAlly && !m.IsDead && m.Position.IsInside(SessionBasedData.CurrentLanePolygon)).OrderBy(m => m.Distance(GameObjects.AllyNexus)) .LastOrDefault(); if (ourMinion != null && ourMinion is Obj_AI_Minion) { return (new Geometry.Circle(ourMinion .ServerPosition.Extend(GameObjects.AllyNexus.Position, Math.Min(Utility.Random.GetRandomInteger(100, 350) + GetMinDistanceFromEnemies(), 1350)).ToVector2(), Utility.Random.GetRandomInteger(100, 350)).ToPolygon().GetRandomPointInPolygon()); } return(Game.CursorPos); }
public static Geometry.Polygon GetLanePolygonExtendedToFarthestMinion(GameObjectTeam laneZoneTeam, Lane lane, GameObjectTeam minionTeam, int maxFieldDistance = 1000) { var farthestTurret = Turrets.GetTurretsPosition(laneZoneTeam, lane).Last(); var mostdamaged = Minions.GetMostDamagedMinion(minionTeam, lane); var farthestMinion = mostdamaged != null ? mostdamaged : Minions.GetMinionsInLane(minionTeam, lane) .OrderBy(m => m.Distance(farthestTurret)) .FirstOrDefault(); if (farthestMinion != null) { return (new Geometry.Rectangle(farthestMinion.ServerPosition.ToVector2(), farthestMinion.ServerPosition.ToVector2().Extend(farthestTurret, maxFieldDistance), 700).ToPolygon()); } return(GetLanePolygon(laneZoneTeam, lane)); }
static StaticData() { foreach (var lane in Enum.GetValues(typeof(Lane))) { var laneCastedAsLane = (Lane)lane; // for order var orderTurretsList = Turrets.GetTurretsPosition(GameObjectTeam.Order, laneCastedAsLane).ToArray(); var orderPolygons = new List <Geometry.Polygon>(); for (var i = 0; i < orderTurretsList.Length - 1; i++) { // circle around turrets orderPolygons.Add(new Geometry.Circle(orderTurretsList[i], 950).ToPolygon()); // rectangle from this turret to next one orderPolygons.Add(new Geometry.Rectangle(orderTurretsList[i], orderTurretsList[i + 1], 700).ToPolygon()); } // add a circle around last turret too orderPolygons.Add(new Geometry.Circle(orderTurretsList.LastOrDefault(), 950).ToPolygon()); _teamOrderLaneZones.Add(laneCastedAsLane, orderPolygons.ClipperUnion().PathsToPolygon()); // for team chaos var chaosTurretsList = Turrets.GetTurretsPosition(GameObjectTeam.Chaos, laneCastedAsLane).ToArray(); var chaosPolygons = new List <Geometry.Polygon>(); for (var i = 0; i < chaosTurretsList.Length - 1; i++) { // circle around turrets chaosPolygons.Add(new Geometry.Circle(chaosTurretsList[i], 950).ToPolygon()); // rectangle from this turret to next one chaosPolygons.Add(new Geometry.Rectangle(chaosTurretsList[i], chaosTurretsList[i + 1], 700).ToPolygon()); } // add a circle around last turret too chaosPolygons.Add(new Geometry.Circle(chaosTurretsList.LastOrDefault(), 950).ToPolygon()); _teamChaosLaneZones.Add(laneCastedAsLane, chaosPolygons.ClipperUnion().PathsToPolygon()); // for neutral zones if (laneCastedAsLane != Lane.Base) { var neutralCenter = Turrets.GetTurretsPosition(GameObjectTeam.Neutral, laneCastedAsLane).LastOrDefault(); //#TODO should probably get the polygon end-point but cba var blueTeamTurretPos = Turrets.GetTurretsPosition(GameObjectTeam.Order, laneCastedAsLane) .LastOrDefault() .Extend(neutralCenter, 880); var redTeamTurretPos = Turrets.GetTurretsPosition(GameObjectTeam.Chaos, laneCastedAsLane) .LastOrDefault() .Extend(neutralCenter, 880); var poly1 = new Geometry.Rectangle(blueTeamTurretPos, neutralCenter, 700); var poly2 = new Geometry.Rectangle(neutralCenter, redTeamTurretPos, 700); var union = new List <Geometry.Polygon> { poly1.ToPolygon(), poly2.ToPolygon() }.ClipperUnion(); _teamNeutralLaneZones.Add(laneCastedAsLane, union.PathsToPolygon()); } } // add a polygon for each lane, without minding the team. foreach (var lane in Enum.GetValues(typeof(Lane))) { var laneCastedAsLane = (Lane)lane; if (laneCastedAsLane == Lane.Mid || laneCastedAsLane == Lane.Bot || laneCastedAsLane == Lane.Top) { var polygons = new List <Geometry.Polygon>(); polygons.Add(_teamNeutralLaneZones.FirstOrDefault(entry => entry.Key == laneCastedAsLane).Value); polygons.Add(_teamOrderLaneZones.FirstOrDefault(entry => entry.Key == laneCastedAsLane).Value); polygons.Add(_teamChaosLaneZones.FirstOrDefault(entry => entry.Key == laneCastedAsLane).Value); _wholeLanePolygon.Add(laneCastedAsLane, polygons.ClipperUnion().PathsToPolygon()); } } /* * // Here we WIPE the turret out from our lane if it's DELETED * GameObject.OnDelete += (sender, deleteArgs) => * { * if (sender == null) * { * Logging.Log("[Polygon Cache] Turret was deleted but sender was null"); * } * if (sender is Obj_AI_Turret) * { * Logging.Log("[Polygon Cache] A turret was deleted"); * // we gather some information about the dead turret * var teamLaneTuple = Turrets.GetTurretTeamAndLaneByPosition(sender.ServerPosition); * var team = teamLaneTuple.Item1; * var lane = teamLaneTuple.Item2; * var position = teamLaneTuple.Item3; * // check if its worth editing the lane poly * if (lane == Lane.Base || lane == Lane.Unknown) * { * // escape null refs produced by the code below :roto2_think: * return; * } * // we backup the lane to perform operations on its polygon * var backup = GetLanePolygon(team, lane); * if (backup != null) * { * Logging.Log("[Polygon Cache] backup of a deleted turret was created"); * } * // do the work for each team separately (cuz when we wipe a team's region it should become neutral) * // first blue * if (team == GameObjectTeam.Order) * { * Logging.Log( * "[Polygon Cache] Attempting to remove lane from team order, the collection currently has " + * _teamChaosLaneZones.Count + " lanes"); * * _teamChaosLaneZones.Remove(lane); * * Logging.Log("[Polygon Cache] Removed lane from team order, the collection currently has " + * _teamChaosLaneZones.Count + " lanes"); * // we first cut the first circle poly: * var turretCircle = new Geometry.Circle(position, 850).ToPolygon(); * Logging.Log("[Polygon Cache] Trying to execute XOR"); * try * { * var step1 = backup.ClipperXor(turretCircle).PathsToPolygon(); * Logging.Log("[Polygon Cache] XOR executed succesfuly"); * * var allTurretsInLane = Turrets.GetTurretsPosition(team, lane); * var thisTurretIndex = allTurretsInLane.IndexOf(position); * // and add it to neutral zone * _teamNeutralLaneZones.Add(lane, turretCircle); * // then we remove the space between the removed turret and the one that should still be alive (if any) * if (thisTurretIndex - 1 >= 0) * { * var rectFromThisToNextAlive = new Geometry.Rectangle(position, * allTurretsInLane[thisTurretIndex - 1], 700).ToPolygon(); * var step2 = step1.ClipperXor(rectFromThisToNextAlive).PathsToPolygon(); * _teamOrderLaneZones.Add(lane, step2); * _teamNeutralLaneZones.Add(lane, rectFromThisToNextAlive); * return; * } * _teamOrderLaneZones.Add(lane, step1); * } * catch (Exception e) * { * Logging.Log("[Polygon Cache] Caught Exception: " + e); * } * } * // then red * if (team == GameObjectTeam.Chaos) * { * _teamChaosLaneZones.Remove(lane); * * // we first cut the first circle poly: * var turretCircle = new Geometry.Circle(position, 850).ToPolygon(); * try * { * var step1 = backup.ClipperXor(turretCircle).PathsToPolygon(); * var allTurretsInLane = Turrets.GetTurretsPosition(team, lane); * var thisTurretIndex = allTurretsInLane.IndexOf(position); * // and add it to neutral zone * _teamNeutralLaneZones.Add(lane, turretCircle); * // then we remove the space between the removed turret and the one that should still be alive (if any) * if (thisTurretIndex - 1 >= 0) * { * var rectFromThisToNextAlive = new Geometry.Rectangle(position, * allTurretsInLane[thisTurretIndex - 1], 700).ToPolygon(); * var step2 = step1.ClipperXor(rectFromThisToNextAlive).PathsToPolygon(); * _teamChaosLaneZones.Add(lane, step2); * _teamNeutralLaneZones.Add(lane, rectFromThisToNextAlive); * return; * } * _teamChaosLaneZones.Add(lane, step1); * } * catch (Exception e) * { * Logging.Log("[Polygon Cache] Caugh Exception: " + e); * } * } * } * };*/ }
public static Geometry.Polygon GetLastTurretInLanePolygon(GameObjectTeam team, Lane lane) { var turret = Turrets.GetTurretsPosition(team, lane); return(new Geometry.Circle(turret.LastOrDefault(), 500).ToPolygon()); }