Beispiel #1
0
        private static void TryToEvade(List <Skillshot> HitBy, Vector2 to)
        {
            var dangerLevel = 0;

            foreach (var skillshot in HitBy)
            {
                dangerLevel = Math.Max(dangerLevel, skillshot.GetDanger());
            }

            foreach (var evadeSpell in EvadeSpellDatabase.Spells)
            {
                if (!evadeSpell.Enabled || evadeSpell.DangerLevel > dangerLevel)
                {
                    continue;
                }
                if (evadeSpell.IsSpellShield && GameObjects.Player.Spellbook.CanUseSpell(evadeSpell.Slot) == SpellState.Ready)
                {
                    if (IsAboutToHit(GameObjects.Player, evadeSpell.Delay))
                    {
                        GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, GameObjects.Player);
                    }

                    NoSolutionFound = true;

                    return;
                }

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

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

                            if (evadeSpell.IsSummonerSpell)
                            {
                                GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, GameObjects.Player);
                            }
                            else
                            {
                                GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, GameObjects.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 closestTarget = Utils.Closest(targets, to);

                                EvadePoint = closestTarget.ServerPosition.ToVector2();
                                Evading    = true;

                                if (evadeSpell.IsSummonerSpell)
                                {
                                    GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, closestTarget);
                                }
                                else
                                {
                                    GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, closestTarget);
                                }

                                return;
                            }

                            if (Utils.TickCount - LastWardJumpAttempt < 250)
                            {
                                NoSolutionFound = true;

                                return;
                            }
                        }
                        else
                        {
                            var points = Evader.GetEvadePoints(evadeSpell.Speed, evadeSpell.Delay);

                            points.RemoveAll(item => item.Distance(GameObjects.Player.ServerPosition) > 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 (!IsSafe(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(RandomN.Next(k) - 100, 0);

                                    var extended = points[i] + k * (points[i] - PlayerPosition).Normalized();

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

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

                                if (!evadeSpell.Invert)
                                {
                                    if (evadeSpell.RequiresPreMove)
                                    {
                                        var theSpell = evadeSpell;

                                        DelayAction.Add(Game.Ping / 2 + 100,
                                                        delegate
                                        {
                                            GameObjects.Player.Spellbook.CastSpell(theSpell.Slot, EvadePoint.ToVector3());
                                        });
                                    }
                                    else
                                    {
                                        GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, EvadePoint.ToVector3());
                                    }
                                }
                                else
                                {
                                    var castPoint = PlayerPosition - (EvadePoint - PlayerPosition);

                                    GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, castPoint.ToVector3());
                                }

                                return;
                            }
                        }
                    }

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

                            if (targets.Count > 0)
                            {
                                if (IsAboutToHit(GameObjects.Player, evadeSpell.Delay))
                                {
                                    var closestTarget = Utils.Closest(targets, to);

                                    EvadePoint = closestTarget.ServerPosition.ToVector2();
                                    Evading    = true;

                                    if (evadeSpell.IsSummonerSpell)
                                    {
                                        GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, closestTarget);
                                    }
                                    else
                                    {
                                        GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, closestTarget);
                                    }
                                }

                                NoSolutionFound = true;

                                return;
                            }

                            if (Utils.TickCount - LastWardJumpAttempt < 250)
                            {
                                NoSolutionFound = true;

                                return;
                            }
                        }
                        else
                        {
                            var points = Evader.GetEvadePoints(int.MaxValue, evadeSpell.Delay, true);

                            points.RemoveAll(item => item.Distance(GameObjects.Player.ServerPosition) > evadeSpell.MaxRange);

                            for (var i = 0; i < points.Count; i++)
                            {
                                var k = (int)(evadeSpell.MaxRange - PlayerPosition.Distance(points[i]));

                                k = k - new Random(Utils.TickCount).Next(k);

                                var extended = points[i] + k * (points[i] - PlayerPosition).Normalized();

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

                            if (points.Count > 0)
                            {
                                if (IsAboutToHit(GameObjects.Player, evadeSpell.Delay))
                                {
                                    EvadePoint = to.Closest(points);
                                    Evading    = true;

                                    if (evadeSpell.IsSummonerSpell)
                                    {
                                        GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, EvadePoint.ToVector3());
                                    }
                                    else
                                    {
                                        GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, EvadePoint.ToVector3());
                                    }
                                }

                                NoSolutionFound = true;

                                return;
                            }
                        }
                    }

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

                            if (targets.Count > 0)
                            {
                                if (IsAboutToHit(GameObjects.Player, evadeSpell.Delay))
                                {
                                    var closestTarget = Utils.Closest(targets, to);

                                    EvadePoint = closestTarget.ServerPosition.ToVector2();
                                    Evading    = true;
                                    GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, closestTarget);
                                }

                                NoSolutionFound = true;
                                return;
                            }
                        }
                        else
                        {
                            if (IsAboutToHit(GameObjects.Player, evadeSpell.Delay))
                            {
                                if (evadeSpell.SelfCast)
                                {
                                    GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot);
                                }
                                else
                                {
                                    GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, GameObjects.Player.ServerPosition);
                                }
                            }
                        }

                        NoSolutionFound = true;
                        return;
                    }
                }

                if (!evadeSpell.IsShield ||
                    GameObjects.Player.Spellbook.CanUseSpell(evadeSpell.Slot) != SpellState.Ready)
                {
                    continue;
                }
                if (IsAboutToHit(GameObjects.Player, evadeSpell.Delay))
                {
                    GameObjects.Player.Spellbook.CastSpell(evadeSpell.Slot, GameObjects.Player);
                }

                NoSolutionFound = true;
                return;
            }

            NoSolutionFound = true;
        }
Beispiel #2
0
        private static void ObjAiHeroOnOnIssueOrder(Obj_AI_Base sender, PlayerIssueOrderEventArgs args)
        {
            if (!sender.IsMe)
            {
                return;
            }

            if (args.Order == GameObjectOrder.MoveTo || args.Order == GameObjectOrder.AttackTo)
            {
                EvadeToPoint.X = args.TargetPosition.X;
                EvadeToPoint.Y = args.TargetPosition.Y;
            }
            else
            {
                EvadeToPoint = Vector2.Zero;
            }

            if (DetectedSkillshots.Count == 0)
            {
                ForcePathFollowing = false;
            }

            if (NoSolutionFound)
            {
                return;
            }

            if (!Config.Menu["Enabled"].GetValue <MenuKeyBind>().Active)
            {
                return;
            }

            if (GameObjects.Player.IsSpellShielded())
            {
                return;
            }

            var myPath     = GameObjects.Player.GetPath(new Vector3(args.TargetPosition.X, args.TargetPosition.Y, GameObjects.Player.ServerPosition.Z)).To2DList();
            var safeResult = IsSafe(PlayerPosition);

            if (Evading || !safeResult.IsSafe)
            {
                var rcSafePath = IsSafePath(myPath, Config.EvadingRouteChangeTimeOffset);

                if (args.Order == GameObjectOrder.MoveTo)
                {
                    var willMove = false;

                    if (Evading && Utils.TickCount - Config.LastEvadePointChangeT > Config.EvadePointChangeInterval)
                    {
                        var points = Evader.GetEvadePoints(-1, 0, false, true);

                        if (points.Count > 0)
                        {
                            var to = new Vector2(args.TargetPosition.X, args.TargetPosition.Y);

                            EvadePoint = to.Closest(points);
                            Evading    = true;
                            Config.LastEvadePointChangeT = Utils.TickCount;
                            willMove = true;
                        }
                    }

                    if (rcSafePath.IsSafe && IsSafe(myPath[myPath.Count - 1]).IsSafe&& args.Order == GameObjectOrder.MoveTo)
                    {
                        EvadePoint = myPath[myPath.Count - 1];
                        Evading    = true;
                        willMove   = true;
                    }

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

                args.Process = false;
                return;
            }

            var safePath = IsSafePath(myPath, Config.CrossingTimeOffset);

            if (!safePath.IsSafe && args.Order != GameObjectOrder.AttackUnit)
            {
                if (safePath.Intersection.Valid)
                {
                    if (GameObjects.Player.Distance(safePath.Intersection.Point) > 75)
                    {
                        ForcePathFollowing = true;
                    }
                }

                ForcePathFollowing = true;
                args.Process       = false;
            }

            if (safePath.IsSafe || args.Order != GameObjectOrder.AttackUnit)
            {
                return;
            }
            var target = args.Target;

            if (!(target is Obj_AI_Base) || !target.IsVisible)
            {
                return;
            }
            if (PlayerPosition.Distance(((Obj_AI_Base)target).ServerPosition) > GameObjects.Player.AttackRange + GameObjects.Player.BoundingRadius + target.BoundingRadius)
            {
                args.Process = false;
            }
        }