Exemplo n.º 1
0
        private static void Game_OnOnGameUpdate(EventArgs args)
        {
            PlayerPosition = ObjectManager.Player.ServerPosition.To2D();

            //Set evading to false after blinking
            if (PreviousTickPosition.IsValid() &&
                PlayerPosition.Distance(PreviousTickPosition) > 200)
            {
                Evading = false;
            }

            PreviousTickPosition = PlayerPosition;

            //Remove the detected skillshots that have expired.
            DetectedSkillshots.RemoveAll(skillshot => !skillshot.IsActive());

            //Trigger OnGameUpdate on each skillshot.
            foreach (var skillshot in DetectedSkillshots)
            {
                skillshot.Game_OnGameUpdate();
            }

            //Evading disabled
            if (!Config.Menu.Item("Enabled").GetValue <KeyBind>().Active)
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            if (PlayerChampionName == "Olaf" && Config.Menu.Item("DisableEvadeForOlafR").GetValue <bool>() && ObjectManager.Player.HasBuff("OlafRagnarok"))
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            //Avoid sending move/cast packets while dead.
            if (ObjectManager.Player.IsDead)
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            //Avoid sending move/cast packets while channeling interruptable spells that cause hero not being able to move.
            if (ObjectManager.Player.IsCastingInterruptableSpell(true))
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            if (ObjectManager.Player.Spellbook.IsAutoAttacking && !Orbwalking.IsAutoAttack(ObjectManager.Player.LastCastedSpellName()))
            {
                Evading = false;
                return;
            }

            /*Avoid evading while stunned or immobile.*/
            if (Utils.ImmobileTime(ObjectManager.Player) - Utils.TickCount > Game.Ping / 2 + 70)
            {
                Evading = false;
                return;
            }

            /*Avoid evading while dashing.*/
            if (ObjectManager.Player.IsDashing())
            {
                Evading = false;
                return;
            }

            //Don't evade while casting R as sion
            if (PlayerChampionName == "Sion" && ObjectManager.Player.HasBuff("SionR"))
            {
                PathFollower.Stop();
                return;
            }

            //Spell Shielded
            if (ObjectManager.Player.IsSpellShielded())
            {
                PathFollower.Stop();
                return;
            }

            if (NoSolutionFound)
            {
                PathFollower.Stop();
            }

            var currentPath = ObjectManager.Player.Path.ToList().To2D();
            var safeResult  = IsSafe(PlayerPosition);
            var safePath    = IsSafePath(currentPath, 100);

            /*FOLLOWPATH*/
            if (FollowPath && !NoSolutionFound && (Keepfollowing || !Evading) && EvadeToPoint.IsValid() && safeResult.IsSafe)
            {
                if (EvadeSpellDatabase.Spells.Any(evadeSpell => evadeSpell.Name == "Walking" && evadeSpell.Enabled))
                {
                    //if (Utils.TickCount - lastSentMovePacketT2 > 300)
                    //{
                    //    var candidate = Pathfinding.Pathfinding.PathFind(PlayerPosition, EvadeToPoint);
                    //    PathFollower.Follow(candidate);
                    //    lastSentMovePacketT2 = Utils.TickCount;
                    //}
                }
            }
            else
            {
                FollowPath = false;
            }

            NoSolutionFound = false;

            //Continue evading
            if (Evading && IsSafe(EvadePoint).IsSafe)
            {
                if (safeResult.IsSafe)
                {
                    //We are safe, stop evading.
                    Evading = false;
                }
                else
                {
                    if (Utils.TickCount - lastSentMovePacketT > 1000 / 15)
                    {
                        lastSentMovePacketT = Utils.TickCount;
                        ObjectManager.Player.SendMovePacket(EvadePoint);
                    }
                    return;
                }
            }
            //Stop evading if the point is not safe.
            else if (Evading)
            {
                Evading = false;
            }

            //The path is not safe.
            if (!safePath.IsSafe)
            {
                //Inside the danger polygon.
                if (!safeResult.IsSafe)
                {
                    //Search for an evade point:
                    TryToEvade(safeResult.SkillshotList, EvadeToPoint.IsValid() ? EvadeToPoint : Game.CursorPos.To2D());
                }
                //Outside the danger polygon.
                else
                {
                    FollowPath = true;
                    //Stop at the edge of the skillshot.
                    if (EvadeSpellDatabase.Spells.Any(evadeSpell => evadeSpell.Name == "Walking" && evadeSpell.Enabled))
                    {
                        //    ObjectManager.Player.SendMovePacket(safePath.Intersection.Point);
                    }
                }
            }
        }