/// <summary> /// Returns the point where, when casted, the circular spell with hit the maximum amount of minions. /// </summary> public static FarmLocation GetBestCircularFarmLocation(List <Vector2> minionPositions, float width, float range, int useMECMax = 9) { var result = new Vector2(); var minionCount = 0; var startPos = ObjectManager.Player.ServerPosition.To2D(); range = range * range; if (minionPositions.Count == 0) { return(new FarmLocation(result, minionCount)); } /* Use MEC to get the best positions only when there are less than 9 positions because it causes lag with more. */ if (minionPositions.Count <= useMECMax) { var subGroups = GetCombinations(minionPositions); foreach (var subGroup in subGroups) { if (subGroup.Count > 0) { var circle = MEC.GetMec(subGroup); if (circle.Radius <= width && circle.Center.Distance(startPos, true) <= range) { minionCount = subGroup.Count; return(new FarmLocation(circle.Center, minionCount)); } } } } else { foreach (var pos in minionPositions) { if (pos.Distance(startPos, true) <= range) { var count = minionPositions.Count(pos2 => pos.Distance(pos2, true) <= width * width); if (count >= minionCount) { result = pos; minionCount = count; } } } } return(new FarmLocation(result, minionCount)); }
public static PredictionOutput GetPrediction(PredictionInput input) { var mainTargetPrediction = Prediction.GetPrediction(input, false, true); var posibleTargets = new List <PossibleTarget> { new PossibleTarget { Position = mainTargetPrediction.UnitPosition.To2D(), Unit = input.Unit } }; if (mainTargetPrediction.Hitchance >= HitChance.Medium) { //Add the posible targets in range: posibleTargets.AddRange(GetPossibleTargets(input)); } while (posibleTargets.Count > 1) { var mecCircle = MEC.GetMec(posibleTargets.Select(h => h.Position).ToList()); if (mecCircle.Radius <= input.RealRadius - 10 && Vector2.DistanceSquared(mecCircle.Center, input.RangeCheckFrom.To2D()) < input.Range * input.Range) { return(new PredictionOutput { AoeTargetsHit = posibleTargets.Select(h => (Obj_AI_Hero)h.Unit).ToList(), CastPosition = mecCircle.Center.To3D(), UnitPosition = mainTargetPrediction.UnitPosition, Hitchance = mainTargetPrediction.Hitchance, Input = input, _aoeTargetsHitCount = posibleTargets.Count }); } float maxdist = -1; var maxdistindex = 1; for (var i = 1; i < posibleTargets.Count; i++) { var distance = Vector2.DistanceSquared(posibleTargets[i].Position, posibleTargets[0].Position); if (distance > maxdist || maxdist.CompareTo(-1) == 0) { maxdistindex = i; maxdist = distance; } } posibleTargets.RemoveAt(maxdistindex); } return(mainTargetPrediction); }