Ejemplo n.º 1
0
        private void CheckHeroInDanger()
        {
            var playerInDanger = false;

            foreach (var entry in SpellDetector.spells)
            {
                var spell = entry.Value;

                if (lastPosInfo != null && lastPosInfo.dodgeableSpells.Contains(spell.spellID))
                {
                    if (myHero.ServerPosition.To2D().InSkillShot(spell, ObjectCache.myHeroCache.boundingRadius))
                    {
                        playerInDanger = true;
                        break;
                    }

                    if (ObjectCache.menuCache.cache["EnableEvadeDistance"].As <MenuBool>().Enabled&&
                        EvadeUtils.TickCount < lastPosInfo.endTime)
                    {
                        playerInDanger = true;
                        break;
                    }
                }
            }

            if (isDodging && !playerInDanger)
            {
                lastDodgingEndTime = EvadeUtils.TickCount;
            }

            if (isDodging == false && !Situation.ShouldDodge())
            {
                return;
            }

            isDodging = playerInDanger;
        }
Ejemplo n.º 2
0
        public static bool PreferEvadeSpell()
        {
            if (!Situation.ShouldUseEvadeSpell())
            {
                return(false);
            }

            foreach (var entry in SpellDetector.spells)
            {
                var spell = entry.Value;

                if (!ObjectCache.myHeroCache.serverPos2D.InSkillShot(spell, ObjectCache.myHeroCache.boundingRadius))
                {
                    continue;
                }

                if (ActivateEvadeSpell(spell, true))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        private void DodgeSkillShots()
        {
            if (!Situation.ShouldDodge())
            {
                isDodging = false;
                return;
            }

            /*
             * if (isDodging && playerInDanger == false) //serverpos test
             * {
             *  myHero.IssueOrder(OrderType.HoldPosition, myHero, false);
             * }*/

            if (isDodging)
            {
                if (lastPosInfo != null)
                {
                    /*foreach (KeyValuePair<int, Spell> entry in SpellDetector.spells)
                     * {
                     *  Spell spell = entry.Value;
                     *
                     *  Console.WriteLine("" + (int)(TickCount-spell.startTime));
                     * }*/


                    var lastBestPosition = lastPosInfo.position;

                    if (ObjectCache.menuCache.cache["ClickOnlyOnce"].As <MenuBool>().Value == false ||
                        !(myHero.Path.Count() > 0 && lastPosInfo.position.Distance(myHero.Path.Last().To2D()) < 5))
                    //|| lastPosInfo.timestamp > lastEvadeOrderTime)
                    {
                        // Console.WriteLine("DodgeSkillshots");
                        EvadeCommand.MoveTo(lastBestPosition);
                        lastEvadeOrderTime = EvadeUtils.TickCount;
                    }
                }
            }
            else //if not dodging
            {
                //Check if hero will walk into a skillshot
                var path = myHero.Path;
                //if (path == null)
                //    return;

                if (path.Length > 0)
                {
                    var movePos = path[path.Length - 1].To2D();

                    if (EvadeHelper.CheckMovePath(movePos))
                    {
                        /*if (ObjectCache.menuCache.cache["AllowCrossing"].As<MenuBool>().Enabled)
                         * {
                         *  var extraDelayBuffer = ObjectCache.menuCache.cache["ExtraPingBuffer"]
                         *      .As<MenuSlider>().Value + 30;
                         *  var extraDist = ObjectCache.menuCache.cache["ExtraCPADistance"]
                         *      .As<MenuSlider>().Value + 10;
                         *
                         *  var tPosInfo = EvadeHelper.CanHeroWalkToPos(movePos, ObjectCache.myHeroCache.moveSpeed, extraDelayBuffer + ObjectCache.gamePing, extraDist);
                         *
                         *  if (tPosInfo.posDangerLevel == 0)
                         *  {
                         *      lastPosInfo = tPosInfo;
                         *      return;
                         *  }
                         * }*/

                        var posInfo = EvadeHelper.GetBestPositionMovementBlock(movePos);
                        if (posInfo != null)
                        {
                            EvadeCommand.MoveTo(posInfo.position);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
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)
            //{
            //    var end = args.Position;

            //    var path = myHero.Path;

            //    Console.WriteLine("got path");
            //}


            if (args.OrderType == OrderType.MoveTo)
            {
                if (isDodging && SpellDetector.spells.Any())
                {
                    var limitDelay = ObjectCache.menuCache.cache["TickLimiter"].As <MenuSlider>(); //Tick limiter
                    if (EvadeUtils.TickCount - lastTickCount < limitDelay.Value)
                    {
                        lastTickCount     = EvadeUtils.TickCount;
                        args.ProcessEvent = false;
                        return;
                    }

                    CheckHeroInDanger();

                    lastBlockedUserMoveTo = new EvadeCommand
                    {
                        // fix all the args.Target.Position / args.Position
                        order          = EvadeOrderCommand.MoveTo,
                        targetPosition = args /*.Target*/.Position.To2D(), // NOT SURE IF POSITION OR TARGET.POSITION
                        timestamp      = EvadeUtils.TickCount,
                        isProcessed    = false
                    };
                    //args.ProcessEvent = true;

                    args.ProcessEvent = false;
                }
                else
                {
                    var movePos    = args.Position.To2D();
                    var extraDelay = ObjectCache.menuCache.cache["ExtraPingBuffer"].As <MenuSlider>().Value;

                    if (EvadeHelper.CheckMovePath(movePos, ObjectCache.gamePing + extraDelay))
                    {
                        /*if (ObjectCache.menuCache.cache["AllowCrossing"].As<MenuBool>().Enabled)
                         * {
                         *  var extraDelayBuffer = ObjectCache.menuCache.cache["ExtraPingBuffer"]
                         *      .As<MenuSlider>().Value + 30;
                         *  var extraDist = ObjectCache.menuCache.cache["ExtraCPADistance"]
                         *      .As<MenuSlider>().Value + 10;
                         *  var tPosInfo = EvadeHelper.CanHeroWalkToPos(movePos, ObjectCache.myHeroCache.moveSpeed, extraDelayBuffer + ObjectCache.gamePing, extraDist);
                         *  if (tPosInfo.posDangerLevel == 0)
                         *  {
                         *      lastPosInfo = tPosInfo;
                         *      return;
                         *  }
                         * }*/

                        lastBlockedUserMoveTo = new EvadeCommand
                        {
                            order          = EvadeOrderCommand.MoveTo,
                            targetPosition = args /*.Target*/.Position.To2D(),
                            timestamp      = EvadeUtils.TickCount,
                            isProcessed    = false
                        };

                        args.ProcessEvent = false; //Block the command
                        // args.ProcessEvent = true;

                        if (EvadeUtils.TickCount - lastMovementBlockTime < 500 &&
                            lastMovementBlockPos.Distance(args./*Target.*/ Position) < 100)
                        {
                            return;
                        }

                        lastMovementBlockPos  = args./*Target.*/ Position;
                        lastMovementBlockTime = EvadeUtils.TickCount;

                        var posInfo = EvadeHelper.GetBestPositionMovementBlock(movePos);
                        if (posInfo != null)
                        {
                            EvadeCommand.MoveTo(posInfo.position);
                        }
                        return;
                    }
                    lastBlockedUserMoveTo.isProcessed = true;
                }
            }
            else //need more logic
            {
                if (isDodging)
                {
                    args.ProcessEvent = false; //Block the command
                }
                else
                {
                    if (args.OrderType == OrderType.AttackUnit)
                    {
                        var target = args.Target;
                        if (target != null && target.IsValid)
                        {
                            // fix
                            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 /*.Target*/.Position.To2D();
                                var extraDelay = ObjectCache.menuCache.cache["ExtraPingBuffer"].As <MenuSlider>().Value;
                                if (EvadeHelper.CheckMovePath(movePos, ObjectCache.gamePing + extraDelay))
                                {
                                    args.ProcessEvent = false; //Block the command
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            if (args.ProcessEvent)
            {
                lastIssueOrderGameTime = Game.ClockTime * 1000;
                lastIssueOrderTime     = EvadeUtils.TickCount;
                lastIssueOrderArgs     = args;

                if (args.OrderType == OrderType.MoveTo)
                {
                    lastMoveToPosition  = args /*.Target*/.Position.To2D();
                    lastMoveToServerPos = myHero.ServerPosition.To2D();
                }

                if (args.OrderType == OrderType.Stop)
                {
                    lastStopPosition = myHero.ServerPosition.To2D();
                }
            }
        }
Ejemplo n.º 5
0
        private void Game_OnCastSpell(Obj_AI_Base sender, SpellBookCastSpellEventArgs args)
        {
            if (!sender.IsMe)
            {
                return;
            }

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

            if (SpellDetector.channeledSpells.TryGetValue(sData.Name, out name))
            {
                lastStopEvadeTime = EvadeUtils.TickCount + ObjectCache.gamePing + 100;
            }

            //block spell commmands if evade spell just used
            if (EvadeSpell.lastSpellEvadeCommand != null &&
                EvadeSpell.lastSpellEvadeCommand.timestamp + ObjectCache.gamePing + 150 > EvadeUtils.TickCount)
            {
                args.Process = false;
            }

            lastSpellCast     = args.Slot;
            lastSpellCastTime = EvadeUtils.TickCount;

            //moved from processPacket

            /*if (args.Slot == SpellSlot.Recall)
             * {
             *  lastStopPosition = myHero.ServerPosition.To2D();
             * }*/

            // fix : uncomment all
            if (Situation.ShouldDodge())
            {
                if (isDodging && SpellDetector.spells.Any())
                {
                    foreach (var entry in SpellDetector.windupSpells)
                    {
                        var spellData = entry.Value;

                        if (spellData.spellKey == args.Slot) //check if it's a spell that we should block
                        {
                            args.Process = false;
                            return;
                        }
                    }
                }
            }

            foreach (var evadeSpell in EvadeSpell.evadeSpells)
            {
                if (evadeSpell.isItem == false && evadeSpell.spellKey == args.Slot &&
                    evadeSpell.untargetable == false)
                {
                    if (evadeSpell.evadeType == EvadeType.Blink)
                    {
                        var blinkPos = args.Start.To2D();

                        var posInfo = EvadeHelper.CanHeroWalkToPos(blinkPos, evadeSpell.speed, ObjectCache.gamePing, 0);
                        if (posInfo != null && posInfo.posDangerLevel == 0)
                        {
                            //Console.WriteLine("Evade spell");
                            EvadeCommand.MoveTo(posInfo.position);
                            lastStopEvadeTime = EvadeUtils.TickCount + ObjectCache.gamePing + evadeSpell.spellDelay;
                        }
                    }

                    if (evadeSpell.evadeType == EvadeType.Dash)
                    {
                        var dashPos = args.Start.To2D();
                        // fix : uncommont .target
                        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 || EvadeUtils.TickCount < lastDodgingEndTime + 500)
                        {
                            //Console.WriteLine("Evade Spell 2");
                            EvadeCommand.MoveTo(Game.CursorPos.To2D());
                            lastStopEvadeTime = EvadeUtils.TickCount + ObjectCache.gamePing + 100;
                        }
                    }
                    return;
                }
            }
        }