Exemple #1
0
        private void Game_OnIssueOrder(Obj_AI_Base hero, Obj_AI_BaseIssueOrderEventArgs args)
        {
            if (!hero.IsMe)
            {
                return;
            }

            if (!Situation.ShouldDodge())
            {
                return;
            }

            if (args.OrderType == OrderType.MoveTo)
            {
                if (IsDodging && SpellDetector.Spells.Any())
                {
                    var limitDelay = ObjectCache.MenuCache.Cache["TickLimiter"].As <MenuSlider>(); //Tick limiter
                    if (Environment.TickCount - LastTickCount < limitDelay.Value)
                    {
                        LastTickCount     = Environment.TickCount;
                        args.ProcessEvent = false;
                        return;
                    }

                    CheckHeroInDanger();

                    LastBlockedUserMoveTo = new EvadeCommand
                    {
                        Order          = EvadeOrderCommand.MoveTo,
                        TargetPosition = args.Position.To2D(),
                        Timestamp      = Environment.TickCount,
                        IsProcessed    = false
                    };

                    var posInfoTest = EvadeHelper.CanHeroWalkToPos(args.Position.To2D(), ObjectCache.MyHeroCache.MoveSpeed, 0, 0, false);

                    if (posInfoTest.IsDangerousPos)
                    {
                        args.ProcessEvent = false;
                    }
                    else
                    {
                        LastPosInfo.Position = args.Position.To2D();
                        args.ProcessEvent    = true;
                    }
                }
                else
                {
                    var movePos    = args.Position.To2D();
                    var extraDelay = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value;

                    if (EvadeHelper.CheckMovePath(movePos, ObjectCache.GamePing + extraDelay))
                    {
                        LastBlockedUserMoveTo = new EvadeCommand
                        {
                            Order          = EvadeOrderCommand.MoveTo,
                            TargetPosition = args /*.Target*/.Position.To2D(),
                            Timestamp      = Environment.TickCount,
                            IsProcessed    = false
                        };

                        args.ProcessEvent = false;

                        if (Environment.TickCount - LastMovementBlockTime < 500 && LastMovementBlockPos.Distance(args./*Target.*/ Position) < 100)
                        {
                            return;
                        }

                        LastMovementBlockPos  = args./*Target.*/ Position;
                        LastMovementBlockTime = Environment.TickCount;

                        var posInfo = EvadeHelper.GetBestPositionMovementBlock(movePos);
                        if (posInfo != null)
                        {
                            EvadeCommand.MoveTo(posInfo.Position);
                        }
                        return;
                    }
                    LastBlockedUserMoveTo.IsProcessed = true;
                }
            }
            else
            {
                if (IsDodging)
                {
                    args.ProcessEvent = false;
                }
                else
                {
                    if (args.OrderType == OrderType.AttackUnit)
                    {
                        var target = args.Target;
                        if (target != null && target.IsValid)
                        {
                            var baseTarget = target as Obj_AI_Base;
                            if (baseTarget != null && ObjectCache.MyHeroCache.ServerPos2D.Distance(baseTarget.ServerPosition.To2D()) >
                                MyHero.AttackRange + ObjectCache.MyHeroCache.BoundingRadius + baseTarget.BoundingRadius)
                            {
                                var movePos    = args.Position.To2D();
                                var extraDelay = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value;
                                if (EvadeHelper.CheckMovePath(movePos, ObjectCache.GamePing + extraDelay))
                                {
                                    args.ProcessEvent = false;
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            if (!args.ProcessEvent)
            {
                return;
            }

            LastIssueOrderGameTime = Game.ClockTime * 1000;
            LastIssueOrderTime     = Environment.TickCount;
            LastIssueOrderArgs     = args;

            switch (args.OrderType)
            {
            case OrderType.MoveTo:
                LastMoveToPosition  = args /*.Target*/.Position.To2D();
                LastMoveToServerPos = MyHero.ServerPosition.To2D();
                break;

            case OrderType.Stop:
                LastStopPosition = MyHero.ServerPosition.To2D();
                break;
            }
        }
Exemple #2
0
        private void Game_OnCastSpell(Obj_AI_Base sender, SpellBookCastSpellEventArgs args)
        {
            if (!sender.IsMe)
            {
                return;
            }

            var sData = sender.SpellBook.GetSpell(args.Slot);

            if (SpellDetector.ChanneledSpells.TryGetValue(sData.Name, out _))
            {
                LastStopEvadeTime = Environment.TickCount + ObjectCache.GamePing + 100;
            }

            if (EvadeSpell.LastSpellEvadeCommand != null && EvadeSpell.LastSpellEvadeCommand.Timestamp + ObjectCache.GamePing + 150 > Environment.TickCount)
            {
                args.Process = false;
            }

            LastSpellCast     = args.Slot;
            LastSpellCastTime = Environment.TickCount;

            if (Situation.ShouldDodge())
            {
                if (IsDodging && SpellDetector.Spells.Any())
                {
                    if (SpellDetector.WindupSpells.Select(entry => entry.Value).Any(spellData => spellData.SpellKey == args.Slot))
                    {
                        args.Process = false;
                        return;
                    }
                }
            }

            foreach (var evadeSpell in EvadeSpell.EvadeSpells)
            {
                if (evadeSpell.IsItem || evadeSpell.SpellKey != args.Slot || evadeSpell.Untargetable)
                {
                    continue;
                }

                switch (evadeSpell.EvadeType)
                {
                case EvadeType.Blink:
                {
                    var blinkPos = args.Start.To2D();

                    var posInfo = EvadeHelper.CanHeroWalkToPos(blinkPos, evadeSpell.Speed, ObjectCache.GamePing, 0);
                    if (posInfo != null && posInfo.PosDangerLevel == 0)
                    {
                        EvadeCommand.MoveTo(posInfo.Position);
                        LastStopEvadeTime = Environment.TickCount + ObjectCache.GamePing + evadeSpell.SpellDelay;
                    }
                    break;
                }

                case EvadeType.Dash:
                {
                    var dashPos = args.Start.To2D();

                    if (args.Target != null)
                    {
                        dashPos = args.Target.Position.To2D();
                    }

                    if (evadeSpell.FixedRange || dashPos.Distance(MyHero.ServerPosition.To2D()) > evadeSpell.Range)
                    {
                        var dir = (dashPos - MyHero.ServerPosition.To2D()).Normalized();
                        dashPos = MyHero.ServerPosition.To2D() + dir * evadeSpell.Range;
                    }

                    var posInfo = EvadeHelper.CanHeroWalkToPos(dashPos, evadeSpell.Speed, ObjectCache.GamePing, 0);
                    if (posInfo != null && posInfo.PosDangerLevel > 0)
                    {
                        args.Process = false;
                        return;
                    }

                    if (IsDodging || Environment.TickCount < LastDodgingEndTime + 500)
                    {
                        EvadeCommand.MoveTo(Game.CursorPos.To2D());
                        LastStopEvadeTime = Environment.TickCount + ObjectCache.GamePing + 100;
                    }
                    break;
                }
                }

                return;
            }
        }