コード例 #1
0
        /// <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.To2D2();

            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.Distance7(startPos, true) <= range)
                        {
                            minionCount = subGroup.Count;
                            return(new FarmLocation(circle.Center, minionCount));
                        }
                    }
                }
            }
            else
            {
                foreach (var pos in minionPositions)
                {
                    if (pos.Distance7(startPos, true) <= range)
                    {
                        var count = minionPositions.Count(pos2 => pos.Distance7(pos2, true) <= width * width);

                        if (count >= minionCount)
                        {
                            result      = pos;
                            minionCount = count;
                        }
                    }
                }
            }

            return(new FarmLocation(result, minionCount));
        }
コード例 #2
0
            public static PredictionOutput GetPrediction(PredictionInput input)
            {
                var mainTargetPrediction = Prediction2.GetPrediction(input, false, true);
                var posibleTargets       = new List <PossibleTarget>
                {
                    new PossibleTarget {
                        Position = mainTargetPrediction.UnitPosition.To2D2(), 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.To2D2()) <
                        input.Range * input.Range)
                    {
                        return(new PredictionOutput
                        {
                            AoeTargetsHit = posibleTargets.Select(h => (AIHeroClient)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);
            }