コード例 #1
0
            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));
                }
                if (list.Count > 1)
                {
                    List <Vector2> list2 = new List <Vector2>();
                    foreach (AoePrediction.PossibleTarget possibleTarget in list)
                    {
                        Vector2[] candidates = AoePrediction.Line.GetCandidates(input.From.ToVector2(), possibleTarget.Position, input.Radius, input.Range);
                        list2.AddRange(candidates);
                    }
                    var            num    = -1;
                    var            vector = default(Vector2);
                    List <Vector2> list3  = new List <Vector2>();
                    List <Vector2> list4  = (from t in list
                                             select t.Position).ToList <Vector2>();
                    foreach (Vector2 vector2 in list2)
                    {
                        if (AoePrediction.Line.GetHits(input.From.ToVector2(), vector2, (double)(input.Radius + input.Unit.BoundingRadius / 3f - 10f), new List <Vector2>
                        {
                            list[0].Position
                        }).Count <Vector2>() == 1)
                        {
                            List <Vector2> list5 = AoePrediction.Line.GetHits(input.From.ToVector2(), vector2, (double)input.Radius, list4).ToList <Vector2>();
                            int            count = list5.Count;
                            if (count >= num)
                            {
                                num    = count;
                                vector = vector2;
                                list3  = list5.ToList <Vector2>();
                            }
                        }
                    }
                    if (num > 1)
                    {
                        float   num2  = -1f;
                        Vector2 left  = default(Vector2);
                        Vector2 right = default(Vector2);
                        for (int i = 0; i < list3.Count; i++)
                        {
                            for (int j = 0; j < list3.Count; j++)
                            {
                                Vector2 segmentStart    = input.From.ToVector2();
                                Vector2 segmentEnd      = vector;
                                var     projectionInfo  = list4[i].ProjectOn(segmentStart, segmentEnd);
                                var     projectionInfo2 = list4[j].ProjectOn(segmentStart, segmentEnd);
                                float   num3            = Vector2.DistanceSquared(list3[i], projectionInfo.LinePoint) + Vector2.DistanceSquared(list3[j], projectionInfo2.LinePoint);
                                if (num3 >= num2 && (projectionInfo.LinePoint - list4[i]).AngleBetween(projectionInfo2.LinePoint - list4[j]) > 90f)
                                {
                                    num2  = num3;
                                    left  = list4[i];
                                    right = list4[j];
                                }
                            }
                        }
                        return(new PredictionOutput
                        {
                            Hitchance = prediction.Hitchance,
                            _aoeTargetsHitCount = num,
                            UnitPosition = prediction.UnitPosition,
                            CastPosition = ((left + right) * 0.5f).ToVector3(),
                            Input = input
                        });
                    }
                }
                return(prediction);
            }
コード例 #2
0
        public static PredictionOutput GetPrediction(PredictionInput input, bool ft, bool checkCollision)
        {
            PredictionOutput predictionOutput = null;

            if (!input.Unit.IsValidTarget(float.MaxValue, false))
            {
                return(new PredictionOutput());
            }
            if (ft)
            {
                input.Delay += Game.Ping / 2000f + 0.06f;
                if (input.Aoe)
                {
                    return(AoePrediction.GetPrediction(input));
                }
            }
            if (Math.Abs(input.Range - 3.40282347E+38f) > 1.401298E-45f && (double)input.Unit.DistanceSquared(input.RangeCheckFrom) > Math.Pow((double)input.Range * 1.5, 2.0))
            {
                return(new PredictionOutput
                {
                    Input = input
                });
            }
            if (input.Unit.IsDashing())
            {
                predictionOutput = Prediction.GetDashingPrediction(input);
            }
            else
            {
                double num = Prediction.UnitIsImmobileUntil(input.Unit);
                if (num >= 0.0)
                {
                    predictionOutput = Prediction.GetImmobilePrediction(input, num);
                }
                else
                {
                    input.Range = input.Range * item.Value / 100f;
                }
            }
            if (predictionOutput == null)
            {
                predictionOutput = Prediction.GetStandardPrediction(input);
            }
            if (Math.Abs(input.Range - 3.40282347E+38f) > 1.401298E-45f)
            {
                if (predictionOutput.Hitchance >= HitChance.High && (double)input.RangeCheckFrom.DistanceSquared(input.Unit.Position) > Math.Pow((double)(input.Range + input.RealRadius * 3f / 4f), 2.0))
                {
                    predictionOutput.Hitchance = HitChance.Medium;
                }
                if ((double)input.RangeCheckFrom.DistanceSquared(predictionOutput.UnitPosition) > Math.Pow((double)(input.Range + ((input.Type == SkillshotType.SkillshotCircle) ? input.RealRadius : 0f)), 2.0))
                {
                    predictionOutput.Hitchance = HitChance.OutOfRange;
                }
                if ((double)input.RangeCheckFrom.DistanceSquared(predictionOutput.CastPosition) > Math.Pow((double)input.Range, 2.0))
                {
                    if (predictionOutput.Hitchance != HitChance.OutOfRange)
                    {
                        predictionOutput.CastPosition = input.RangeCheckFrom + input.Range * (predictionOutput.UnitPosition - input.RangeCheckFrom).ToVector2().Normalized().ToVector3();
                    }
                    else
                    {
                        predictionOutput.Hitchance = HitChance.OutOfRange;
                    }
                }
            }
            if (checkCollision && input.Collision)
            {
                var positions = new List <Vector3>
                {
                    predictionOutput.UnitPosition,
                    predictionOutput.CastPosition
                };
                AIBaseClient originalUnit = input.Unit;
                predictionOutput.CollisionObjects = Collision.GetCollision(positions, input);
                predictionOutput.CollisionObjects.RemoveAll(x => x.NetworkId == originalUnit.NetworkId);
                predictionOutput.Hitchance = ((predictionOutput.CollisionObjects.Count > 0) ? HitChance.Collision : predictionOutput.Hitchance);
            }
            if (input.CollisionYasuoWall && predictionOutput.Hitchance > HitChance.Impossible && new List <Vector3>
            {
                predictionOutput.UnitPosition,
                predictionOutput.CastPosition,
                input.Unit.Position
            }.GetYasuoWallCollision(input.From))
            {
                predictionOutput.Hitchance = HitChance.Collision;
            }
            if (predictionOutput.Hitchance == HitChance.High || predictionOutput.Hitchance == HitChance.VeryHigh)
            {
                List <Vector2> waypoints = input.Unit.GetWaypoints();
                if (waypoints.Count > 1 != input.Unit.IsMoving)
                {
                    predictionOutput.Hitchance = HitChance.Medium;
                }
                else if (waypoints.Count > 0)
                {
                    Vector3 v    = waypoints.Last <Vector2>().ToVector3();
                    float   num2 = v.Distance(input.Unit.Position);
                    float   num3 = input.From.Distance(input.Unit.Position);
                    float   num4 = v.Distance(input.From);
                    float   num5 = num3 / input.Speed;
                    if (Math.Abs(input.Speed - 3.40282347E+38f) < 1.401298E-45f)
                    {
                        num5 = 0f;
                    }
                    float num6 = num5 + input.Delay;
                    float num7 = input.Unit.MoveSpeed * num6 * 0.35f;
                    if (input.Type == SkillshotType.SkillshotCircle)
                    {
                        num7 -= input.Radius / 2f;
                    }
                    if (num4 <= num3 && num3 > input.Range - num7)
                    {
                        predictionOutput.Hitchance = HitChance.Medium;
                    }
                    if (num2 > 0f && num2 < 100f)
                    {
                        predictionOutput.Hitchance = HitChance.Medium;
                    }
                }
            }
            return(predictionOutput);
        }
コード例 #3
0
            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));
                }
                if (list.Count > 1)
                {
                    List <Vector2> list2 = new List <Vector2>();
                    foreach (AoePrediction.PossibleTarget possibleTarget in list)
                    {
                        possibleTarget.Position -= input.From.ToVector2();
                    }
                    for (int i = 0; i < list.Count; i++)
                    {
                        for (int j = 0; j < list.Count; j++)
                        {
                            if (i != j)
                            {
                                Vector2 item = (list[i].Position + list[j].Position) * 0.5f;
                                if (!list2.Contains(item))
                                {
                                    list2.Add(item);
                                }
                            }
                        }
                    }
                    int            num    = -1;
                    Vector2        vector = default(Vector2);
                    List <Vector2> points = (from t in list
                                             select t.Position).ToList <Vector2>();
                    foreach (Vector2 vector2 in list2)
                    {
                        int hits = AoePrediction.Cone.GetHits(vector2, (double)input.Range, input.Radius, points);
                        if (hits > num)
                        {
                            vector = vector2;
                            num    = hits;
                        }
                    }
                    vector += input.From.ToVector2();
                    if (num > 1 && input.From.ToVector2().DistanceSquared(vector) > 2500f)
                    {
                        return(new PredictionOutput
                        {
                            Hitchance = prediction.Hitchance,
                            _aoeTargetsHitCount = num,
                            UnitPosition = prediction.UnitPosition,
                            CastPosition = vector.ToVector3(),
                            Input = input
                        });
                    }
                }
                return(prediction);
            }