public static PredictionOutput GetCirclePrediction(PredictionInput input) { var mainTargetPrediction = Prediction.Instance.GetPrediction(input, false, true); var posibleTargets = new List <PossibleTarget> { new PossibleTarget { Position = (Vector2)mainTargetPrediction.UnitPosition, Unit = input.Unit } }; if (mainTargetPrediction.HitChance >= HitChance.Medium) { posibleTargets.AddRange(AoePrediction.GetPossibleTargets(input)); } while (posibleTargets.Count > 1) { var mecCircle = Mec.GetMec(posibleTargets.Select(h => h.Position).ToList()); if (mecCircle.Radius <= input.RealRadius - 10 && mecCircle.Center.DistanceSquared(input.RangeCheckFrom) < input.Range * input.Range) { return(new PredictionOutput { AoeTargetsHit = posibleTargets.Select(h => (Obj_AI_Hero)h.Unit).ToList(), CastPosition = (Vector3)mecCircle.Center, UnitPosition = mainTargetPrediction.UnitPosition, HitChance = mainTargetPrediction.HitChance, Input = input, AoeHitCount = posibleTargets.Count }); } float maxdist = -1; var maxdistindex = 1; for (var i = 1; i < posibleTargets.Count; i++) { var distance = posibleTargets[i].Position.DistanceSquared(posibleTargets[0].Position); if (!(distance > maxdist) && maxdist.CompareTo(-1) != 0) { continue; } maxdistindex = i; maxdist = distance; } posibleTargets.RemoveAt(maxdistindex); } return(mainTargetPrediction); }
public static PredictionOutput GetPrediction(PredictionInput input) { PredictionOutput prediction = Prediction.GetPrediction(input, false, true); List <AoePrediction.PossibleTarget> list = new List <AoePrediction.PossibleTarget> { new AoePrediction.PossibleTarget { Position = prediction.UnitPosition.ToVector2(), Unit = input.Unit } }; if (prediction.Hitchance >= HitChance.Medium) { list.AddRange(AoePrediction.GetPossibleTargets(input)); } while (list.Count > 1) { var mec = Mec.GetMec((from h in list select h.Position).ToList <Vector2>()); if (mec.Radius <= input.RealRadius - 10f && Vector2.DistanceSquared(mec.Center, input.RangeCheckFrom.ToVector2()) < input.Range * input.Range) { PredictionOutput predictionOutput = new PredictionOutput(); predictionOutput.AoeTargetsHit = (from hero in list select hero.Unit).ToList <AIBaseClient>(); predictionOutput.CastPosition = mec.Center.ToVector3(); predictionOutput.UnitPosition = prediction.UnitPosition; predictionOutput.Hitchance = prediction.Hitchance; predictionOutput.Input = input; predictionOutput._aoeTargetsHitCount = list.Count; return(predictionOutput); } float num = -1f; int index = 1; for (int i = 1; i < list.Count; i++) { float num2 = Vector2.DistanceSquared(list[i].Position, list[0].Position); if (num2 > num || num.CompareTo(-1f) == 0) { index = i; num = num2; } } list.RemoveAt(index); } return(prediction); }
public static Result GetCircleAoePrediction(this Spell spell, Obj_AI_Hero target, HitChance hitChance, bool boundingRadius = true, bool extended = true, Vector3?sourcePosition = null) { try { if (spell == null || target == null) { return(new Result(Vector3.Zero, new List <Obj_AI_Hero>())); } var fromPosition = sourcePosition ?? ObjectManager.GetLocalPlayer().ServerPosition; var hits = new List <Obj_AI_Hero>(); var center = Vector3.Zero; var radius = float.MaxValue; var range = spell.Range + (extended ? spell.Width * 0.85f : 0) + (boundingRadius ? target.BoundingRadius * BoundingRadiusMultiplicator : 0); var positions = (from t in GameObjects.EnemyHeroes where t.IsValidTarget(range * 1.5f, false, false, fromPosition) let prediction = spell.GetPrediction(t) where prediction.HitChance >= hitChance select new Position(t, prediction.UnitPosition)).ToList(); var spellWidth = spell.Width; if (positions.Any()) { var mainTarget = positions.FirstOrDefault(p => p.Hero.NetworkId == target.NetworkId); var possibilities = ProduceEnumeration( positions.Where( p => p.UnitPosition.Distance(mainTarget.UnitPosition) <= spell.Width * 0.85f).ToList()) .Where(p => p.Count > 0 && p.Any(t => t.Hero.NetworkId == mainTarget.Hero.NetworkId)) .ToList(); foreach (var possibility in possibilities) { var mec = Mec.GetMec(possibility.Select(p => p.UnitPosition.To2D()).ToList()); var distance = spell.From.Distance(mec.Center.To3D()); if (mec.Radius < spellWidth && distance < range) { var lHits = new List <Obj_AI_Hero>(); var circle = new MyPolygon.Circle( spell.From.Extend( mec.Center.To3D(), spell.Range > distance ? distance : spell.Range), spell.Width); if (boundingRadius) { lHits.AddRange( from position in positions where new MyPolygon.Circle( position.UnitPosition, position.Hero.BoundingRadius * BoundingRadiusMultiplicator).Points.Any( p => circle.IsInside(p)) select position.Hero); } else { lHits.AddRange( from position in positions where circle.IsInside(position.UnitPosition) select position.Hero); } if ((lHits.Count > hits.Count || lHits.Count == hits.Count && mec.Radius < radius || lHits.Count == hits.Count && spell.From.Distance(circle.Center.To3D()) < spell.From.Distance(center)) && lHits.Any(p => p.NetworkId == target.NetworkId)) { center = To3D2(circle.Center); radius = mec.Radius; hits.Clear(); hits.AddRange(lHits); } } } if (!center.Equals(Vector3.Zero)) { return(new Result(center, hits)); } } } catch (Exception ex) { Console.WriteLine(ex); } return(new Result(Vector3.Zero, new List <Obj_AI_Hero>())); }