Beispiel #1
0
            /// <summary>
            /// Stasis calculations
            /// </summary>
            /// <param name="spell">The spell.</param>
            internal void Process(Spell spell)
            {
                var arrivalT = PredictionExtensions.GetArrivalTime(spell.From.Distance(this.Unit.PreviousPosition), spell.Delay, spell.Speed) * 1000f;

                if (Variables.TickCount - this.StartTick >= this.Duration - arrivalT)
                {
                    var pred = new PredictionResult
                    {
                        Input        = new PredictionInput(this.Unit, spell.Delay, spell.Speed, spell.Width, spell.Range, spell.Collision, spell.Type, spell.From, spell.RangeCheckFrom),
                        Unit         = this.Unit,
                        CastPosition = this.Unit.PreviousPosition.ToVector2(),
                        UnitPosition = this.Unit.PreviousPosition.ToVector2(),
                        HitChance    = HitChance.VeryHigh
                    };
                    pred.Lock(false);

                    var result = new StasisResult {
                        Spell = spell, Prediction = pred
                    };

                    if (OnGuaranteedHit != null && pred.HitChance != HitChance.Collision &&
                        pred.HitChance != HitChance.OutOfRange)
                    {
                        OnGuaranteedHit(MethodBase.GetCurrentMethod().DeclaringType, result);
                    }

                    this.Processed = true;
                }
            }
Beispiel #2
0
        /// <summary>
        /// Gets Prediction result while unit is immobile
        /// </summary>
        /// <param name="target">Target for spell</param>
        /// <param name="width">Spell width</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="range">Spell range</param>
        /// <param name="collisionable">Spell collisionable</param>
        /// <param name="type">Spell skillshot type</param>
        /// <param name="from">Spell casted position</param>
        /// <returns></returns>
        public static PredictionResult GetImmobilePrediction(AIBaseClient target, float width, float delay, float missileSpeed, float range, bool collisionable, SpellType type, Vector2 from, Vector2 rangeCheckFrom)
        {
            var result = new PredictionResult
            {
                Input        = new PredictionInput(target, delay, missileSpeed, width, range, collisionable, type, from.ToVector3World(), rangeCheckFrom.ToVector3World()),
                Unit         = target,
                CastPosition = target.PreviousPosition.ToVector2()
            };

            result.UnitPosition = result.CastPosition;

            //calculate spell arrival time
            var t = delay + Game.Ping / 2000f;

            if (missileSpeed != 0)
            {
                t += from.Distance(target.PreviousPosition) / missileSpeed;
            }

            if (type == SpellType.Circle)
            {
                t += width / target.MoveSpeed / 2f;
            }

            if (t >= target.LeftImmobileTime())
            {
                result.HitChance = HitChance.Immobile;
                result.Lock();

                return(result);
            }

            if (target is AIHeroClient hero)
            {
                result.HitChance = PredictionExtensions.GetHitChance(t - hero.LeftImmobileTime(), hero.AvgMovChangeTime(), 0, 0, 0);
            }
            else
            {
                result.HitChance = HitChance.High;
            }

            result.Lock();

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Gets Prediction result while unit is dashing
        /// </summary>
        /// <param name="target">Target for spell</param>
        /// <param name="width">Spell width</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="range">Spell range</param>
        /// <param name="collisionable">Spell collisionable</param>
        /// <param name="type">Spell skillshot type</param>
        /// <param name="from">Spell casted position</param>
        /// <returns></returns>
        public static PredictionResult GetDashingPrediction(AIBaseClient target, float width, float delay, float missileSpeed, float range, bool collisionable, SpellType type, Vector2 from, Vector2 rangeCheckFrom)
        {
            var result = new PredictionResult
            {
                Input = new PredictionInput(target, delay, missileSpeed, width, range, collisionable, type, from.ToVector3World(), rangeCheckFrom.ToVector3World()),
                Unit  = target
            };

            if (target.IsDashing())
            {
                var dashInfo = target.GetDashInfo();
                result.CastPosition = GetFastUnitPosition(target, dashInfo.Path, delay, missileSpeed, from, dashInfo.Speed);
                result.HitChance    = HitChance.Dash;

                result.Lock(false);
            }
            else
            {
                result = GetPrediction(target, width, delay, missileSpeed, range, collisionable, type, target.GetWaypoints(), 0, 0, 0, 0, from, rangeCheckFrom);
                result.Lock(false);
            }
            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// Gets Prediction result
        /// </summary>
        /// <param name="target">Target for spell</param>
        /// <param name="width">Spell width</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="range">Spell range</param>
        /// <param name="collisionable">Spell collisionable</param>
        /// <param name="type">Spell skillshot type</param>
        /// <param name="path">Waypoints of target</param>
        /// <param name="avgt">Average reaction time (in ms)</param>
        /// <param name="movt">Passed time from last movement change (in ms)</param>
        /// <param name="avgp">Average Path Lenght</param>
        /// <param name="from">Spell casted position</param>
        /// <param name="rangeCheckFrom"></param>
        /// <returns>Prediction result as <see cref="PredictionResult"/></returns>
        public static PredictionResult GetPrediction(AIBaseClient target, float width, float delay, float missileSpeed, float range, bool collisionable, SpellType type, List <Vector2> path, float avgt, float movt, float avgp, float anglediff, Vector2 from, Vector2 rangeCheckFrom)
        {
            var result = new PredictionResult();
            var input  = new PredictionInput(target, delay, missileSpeed, width, range, collisionable, type, from.ToVector3World(), rangeCheckFrom.ToVector3World());

            result.Input = input;
            result.Unit  = target;

            try
            {
                if (type == SpellType.Circle)
                {
                    range += width;
                }

                //to do: hook logic ? by storing average movement direction etc
                if (path.Count <= 1 && movt > 100 && (Environment.TickCount - PathTracker.EnemyInfo[target.NetworkId].LastAATick > 300 || !Program.CheckAAWindUp)) //if target is not moving, easy to hit (and not aaing)
                {
                    result.HitChance    = HitChance.VeryHigh;
                    result.CastPosition = target.PreviousPosition.ToVector2();
                    result.UnitPosition = result.CastPosition;
                    result.Lock();

                    return(result);
                }

                if (target is AIHeroClient hero)
                {
                    if (hero.IsCastingImporantSpell())
                    {
                        result.HitChance    = HitChance.VeryHigh;
                        result.CastPosition = hero.PreviousPosition.ToVector2();
                        result.UnitPosition = result.CastPosition;
                        result.Lock();

                        return(result);
                    }

                    if (Environment.TickCount - PathTracker.EnemyInfo[hero.NetworkId].LastAATick < 300 && Program.CheckAAWindUp)
                    {
                        if (hero.AttackCastDelay * 1000 + PathTracker.EnemyInfo[hero.NetworkId].AvgOrbwalkTime + avgt - width / 2f / hero.MoveSpeed >= PredictionExtensions.GetArrivalTime(hero.PreviousPosition.ToVector2().Distance(from), delay, missileSpeed))
                        {
                            result.HitChance    = HitChance.High;
                            result.CastPosition = hero.PreviousPosition.ToVector2();
                            result.UnitPosition = result.CastPosition;
                            result.Lock();

                            return(result);
                        }
                    }

                    //to do: find a fuking logic
                    if (avgp < 400 && movt < 100 && path.PathLength() <= avgp)
                    {
                        result.HitChance    = HitChance.High;
                        result.CastPosition = path.Last();
                        result.UnitPosition = result.CastPosition;
                        result.Lock();

                        return(result);
                    }
                }

                if (target.IsDashing()) //if unit is dashing
                {
                    return(GetDashingPrediction(target, width, delay, missileSpeed, range, collisionable, type, from, rangeCheckFrom));
                }

                if (target.IsImmobileTarget()) //if unit is immobile
                {
                    return(GetImmobilePrediction(target, width, delay, missileSpeed, range, collisionable, type, from, rangeCheckFrom));
                }

                result       = WaypointAnlysis(target, width, delay, missileSpeed, range, collisionable, type, path, avgt, movt, avgp, anglediff, from);
                result.Input = input;

                var d = result.CastPosition.Distance(target.PreviousPosition.ToVector2());
                if (d >= (avgt - movt) * target.MoveSpeed && d >= avgp)
                {
                    result.HitChance = HitChance.Medium;
                }

                result.Lock();

                return(result);
            }
            finally
            {
                //check if movement changed while prediction calculations
                if (!target.GetWaypoints().SequenceEqual(path))
                {
                    result.HitChance = HitChance.Medium;
                }
            }
        }