Пример #1
0
        private static void TryToEvade(List <SpellInstance> spells, Vector2 to)
        {
            var dangerLvl = spells.Select(i => i.GetValue <Slider>("DangerLvl").Value).Concat(new[] { 0 }).Max();

            foreach (var evadeSpell in EvadeSpellDatabase.Spells.Where(i => i.Enabled && dangerLvl >= i.DangerLevel))
            {
                if (evadeSpell.MenuName == "Walking")
                {
                    var points = Evader.GetEvadePoints();

                    if (points.Count > 0)
                    {
                        evadePoint1 = to.Closest(points);
                        var pos = evadePoint1.Extend(PlayerPosition, -100);

                        if (
                            IsSafePath(
                                ObjectManager.Player.GetPath(pos.To3D()).ToList().To2D(),
                                Configs.EvadingSecondTime,
                                -1,
                                100).IsSafe)
                        {
                            evadePoint1 = pos;
                        }

                        Evading = true;

                        return;
                    }
                }

                if (evadeSpell.IsReady)
                {
                    if (evadeSpell.IsSpellShield)
                    {
                        if (IsAboutToHit(evadeSpell.Delay))
                        {
                            ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, ObjectManager.Player);
                        }

                        haveSolution = true;

                        return;
                    }

                    if (evadeSpell.IsMovementSpeedBuff)
                    {
                        var points = Evader.GetEvadePoints((int)evadeSpell.MoveSpeedTotalAmount(), evadeSpell.Delay);

                        if (points.Count > 0)
                        {
                            evadePoint1 = to.Closest(points);
                            Evading     = true;
                            ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, ObjectManager.Player);

                            return;
                        }
                    }

                    if (evadeSpell.IsDash)
                    {
                        if (evadeSpell.IsTargetted)
                        {
                            var targets = Evader.GetEvadeTargets(
                                evadeSpell.ValidTargets,
                                evadeSpell.Speed,
                                evadeSpell.Delay,
                                evadeSpell.MaxRange);

                            if (targets.Count > 0)
                            {
                                var target = targets.MinOrDefault(i => i.Distance(to));
                                evadePoint1 = target.ServerPosition.To2D();
                                Evading     = true;
                                ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, target);

                                return;
                            }

                            if (Utils.GameTimeTickCount - LastWardJumpTick < 250)
                            {
                                haveSolution = true;

                                return;
                            }

                            if (evadeSpell.ValidTargets.Contains(SpellValidTargets.AllyWards) &&
                                Configs.Menu.Item("ES" + evadeSpell.MenuName + "_WardJump").GetValue <bool>())
                            {
                                var ward = Items.GetWardSlot();

                                if (ward != null)
                                {
                                    var points = Evader.GetEvadePoints(evadeSpell.Speed, evadeSpell.Delay);
                                    points.RemoveAll(i => i.Distance(PlayerPosition) > 600);

                                    if (points.Count > 0)
                                    {
                                        for (var i = 0; i < points.Count; i++)
                                        {
                                            var k = (int)(600 - PlayerPosition.Distance(points[i]));
                                            k -= Util.Random.Next(k);
                                            var extend = points[i] + k * (points[i] - PlayerPosition).Normalized();

                                            if (IsSafePoint(extend).IsSafe)
                                            {
                                                points[i] = extend;
                                            }
                                        }

                                        ObjectManager.Player.Spellbook.CastSpell(
                                            ward.SpellSlot,
                                            to.Closest(points).To3D());
                                        LastWardJumpTick = Utils.GameTimeTickCount;
                                        haveSolution     = true;

                                        return;
                                    }
                                }
                            }
                        }
                        else
                        {
                            var points = Evader.GetEvadePoints(evadeSpell.Speed, evadeSpell.Delay);
                            points.RemoveAll(i => i.Distance(PlayerPosition) > evadeSpell.MaxRange);

                            if (evadeSpell.FixedRange)
                            {
                                for (var i = 0; i < points.Count; i++)
                                {
                                    points[i] = PlayerPosition.Extend(points[i], evadeSpell.MaxRange);
                                }

                                for (var i = points.Count - 1; i > 0; i--)
                                {
                                    if (!IsSafePoint(points[i]).IsSafe)
                                    {
                                        points.RemoveAt(i);
                                    }
                                }
                            }
                            else
                            {
                                for (var i = 0; i < points.Count; i++)
                                {
                                    var k = (int)(evadeSpell.MaxRange - PlayerPosition.Distance(points[i]));
                                    k -= Math.Max(Util.Random.Next(k) - 100, 0);
                                    var extend = points[i] + k * (points[i] - PlayerPosition).Normalized();

                                    if (IsSafePoint(extend).IsSafe)
                                    {
                                        points[i] = extend;
                                    }
                                }
                            }

                            if (points.Count > 0)
                            {
                                evadePoint1 = to.Closest(points);
                                Evading     = true;

                                if (!evadeSpell.Invert)
                                {
                                    if (evadeSpell.RequiresPreMove)
                                    {
                                        evadePoint1.Move();
                                        LeagueSharp.Common.Utility.DelayAction.Add(
                                            Game.Ping / 2 + 100,
                                            () =>
                                            ObjectManager.Player.Spellbook.CastSpell(
                                                evadeSpell.Slot,
                                                evadePoint1.To3D()));
                                    }
                                    else
                                    {
                                        ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, evadePoint1.To3D());
                                    }
                                }
                                else
                                {
                                    ObjectManager.Player.Spellbook.CastSpell(
                                        evadeSpell.Slot,
                                        (PlayerPosition - (evadePoint1 - PlayerPosition)).To3D());
                                }

                                return;
                            }
                        }
                    }

                    if (evadeSpell.IsBlink)
                    {
                        if (evadeSpell.IsTargetted)
                        {
                            var targets = Evader.GetEvadeTargets(
                                evadeSpell.ValidTargets,
                                0,
                                evadeSpell.Delay,
                                evadeSpell.MaxRange,
                                true);

                            if (targets.Count > 0)
                            {
                                if (IsAboutToHit(evadeSpell.Delay))
                                {
                                    var target = targets.MinOrDefault(i => i.Distance(to));
                                    evadePoint1 = target.ServerPosition.To2D();
                                    Evading     = true;
                                    ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, target);
                                }

                                haveSolution = true;

                                return;
                            }

                            if (Utils.GameTimeTickCount - LastWardJumpTick < 250)
                            {
                                haveSolution = true;

                                return;
                            }

                            if (evadeSpell.ValidTargets.Contains(SpellValidTargets.AllyWards) &&
                                Configs.Menu.Item("ES" + evadeSpell.MenuName + "_WardJump").GetValue <bool>())
                            {
                                var ward = Items.GetWardSlot();

                                if (ward != null)
                                {
                                    var points = Evader.GetEvadePoints(0, evadeSpell.Delay, true);
                                    points.RemoveAll(i => i.Distance(PlayerPosition) > 600);

                                    if (points.Count > 0)
                                    {
                                        for (var i = 0; i < points.Count; i++)
                                        {
                                            var k = (int)(600 - PlayerPosition.Distance(points[i]));
                                            k -= Util.Random.Next(k);
                                            var extend = points[i] + k * (points[i] - PlayerPosition).Normalized();

                                            if (IsSafePoint(extend).IsSafe)
                                            {
                                                points[i] = extend;
                                            }
                                        }

                                        ObjectManager.Player.Spellbook.CastSpell(
                                            ward.SpellSlot,
                                            to.Closest(points).To3D());
                                        LastWardJumpTick = Utils.GameTimeTickCount;
                                        haveSolution     = true;

                                        return;
                                    }
                                }
                            }
                        }
                        else
                        {
                            var points = Evader.GetEvadePoints(0, evadeSpell.Delay, true);
                            points.RemoveAll(i => i.Distance(PlayerPosition) > evadeSpell.MaxRange);

                            if (points.Count > 0)
                            {
                                if (IsAboutToHit(evadeSpell.Delay))
                                {
                                    for (var i = 0; i < points.Count; i++)
                                    {
                                        var k = (int)(evadeSpell.MaxRange - PlayerPosition.Distance(points[i]));
                                        k -= Util.Random.Next(k);
                                        var extend = points[i] + k * (points[i] - PlayerPosition).Normalized();

                                        if (IsSafePoint(extend).IsSafe)
                                        {
                                            points[i] = extend;
                                        }
                                    }

                                    evadePoint1 = to.Closest(points);
                                    Evading     = true;
                                    ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, evadePoint1.To3D());
                                }

                                haveSolution = true;

                                return;
                            }
                        }
                    }

                    if (evadeSpell.IsInvulnerability)
                    {
                        if (evadeSpell.IsTargetted)
                        {
                            var targets = Evader.GetEvadeTargets(
                                evadeSpell.ValidTargets,
                                0,
                                0,
                                evadeSpell.MaxRange,
                                true,
                                false,
                                true);

                            if (targets.Count > 0)
                            {
                                if (IsAboutToHit(evadeSpell.Delay))
                                {
                                    var target = targets.MinOrDefault(i => i.Distance(to));
                                    evadePoint1 = target.ServerPosition.To2D();
                                    Evading     = true;
                                    ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, target);
                                }

                                haveSolution = true;

                                return;
                            }
                        }
                        else
                        {
                            if (IsAboutToHit(evadeSpell.Delay))
                            {
                                if (evadeSpell.SelfCast)
                                {
                                    ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot);
                                }
                                else
                                {
                                    ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, PlayerPosition.To3D());
                                }
                            }

                            haveSolution = true;

                            return;
                        }
                    }
                }

                if (evadeSpell.MenuName == "Zhonyas" && Items.CanUseItem("ZhonyasHourglass"))
                {
                    if (IsAboutToHit(100))
                    {
                        Items.UseItem("ZhonyasHourglass");
                    }

                    haveSolution = true;

                    return;
                }

                if (evadeSpell.IsReady && evadeSpell.IsShield)
                {
                    if (IsAboutToHit(evadeSpell.Delay))
                    {
                        ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, ObjectManager.Player);
                    }

                    haveSolution = true;

                    return;
                }
            }

            //haveSolution = true;
        }
Пример #2
0
        private static void OnIssueOrder(Obj_AI_Base sender, PlayerIssueOrderEventArgs args)
        {
            if (!sender.IsMe)
            {
                return;
            }

            evadePoint2 = args.Order == GameObjectOrder.MoveTo || args.Order == GameObjectOrder.AttackTo
                              ? args.TargetPosition.To2D()
                              : Vector2.Zero;

            if (DetectedSpells.Count == 0)
            {
                forceFollowPath = false;
            }

            if (haveSolution)
            {
                return;
            }

            if (!Configs.Menu.Item("Enabled").GetValue <KeyBind>().Active ||
                !EvadeSpellDatabase.Spells.Any(i => i.MenuName == "Walking" && i.Enabled) || Util.ShieldCheck)
            {
                return;
            }

            var paths = ObjectManager.Player.GetPath(args.TargetPosition).ToList().To2D();

            if (Evading || !IsSafePoint(PlayerPosition).IsSafe)
            {
                if (args.Order == GameObjectOrder.MoveTo)
                {
                    var willMove = false;

                    if (Evading && Utils.GameTimeTickCount - lastEvadePointChangeTick > Configs.EvadePointChangeTime)
                    {
                        var points = Evader.GetEvadePoints(-1, 0, false, true);

                        if (points.Count > 0)
                        {
                            evadePoint1 = args.TargetPosition.To2D().Closest(points);
                            Evading     = true;
                            willMove    = true;
                            lastEvadePointChangeTick = Utils.GameTimeTickCount;
                        }
                    }

                    if (IsSafePath(paths, Configs.EvadingRouteChangeTime).IsSafe &&
                        IsSafePoint(paths[paths.Count - 1]).IsSafe)
                    {
                        evadePoint1 = paths[paths.Count - 1];
                        Evading     = true;
                        willMove    = true;
                    }

                    if (!willMove)
                    {
                        forceFollowPath = true;
                    }
                }

                args.Process = false;

                return;
            }

            var checkPath = IsSafePath(paths, Configs.CrossingTime);

            if (checkPath.IsSafe)
            {
                return;
            }

            if (args.Order != GameObjectOrder.AttackUnit)
            {
                forceFollowPath = true;
                args.Process    = false;
            }
            else
            {
                var target = args.Target as AttackableUnit;

                if (target == null || !target.IsValid || !target.IsVisible ||
                    PlayerPosition.Distance(target.Position) <= Orbwalking.GetRealAutoAttackRange(target))
                {
                    return;
                }

                if (checkPath.Intersect.Valid)
                {
                    checkPath.Intersect.Point.Move();
                }

                args.Process = false;
            }
        }