示例#1
0
        private void IssueTestMove(int recursionCount)
        {
            var movePos = ObjectCache.MyHeroCache.ServerPos2D;

            var rand = new Random();

            _lastRandomMoveCoeff = !_lastRandomMoveCoeff;
            if (_lastRandomMoveCoeff)
            {
                movePos.X += 65 + rand.Next(0, 20);
            }
            else
            {
                movePos.X -= 65 + rand.Next(0, 20);
            }

            _lastTestMoveToCommand = new EvadeCommand {
                Order = EvadeOrderCommand.MoveTo, TargetPosition = movePos, Timestamp = Environment.TickCount, IsProcessed = false
            };
            MyHero.IssueOrder(OrderType.MoveTo, movePos.To3D());

            if (recursionCount > 1)
            {
                DelayAction.Add(500, () => IssueTestMove(recursionCount - 1));
            }
        }
示例#2
0
        public static bool UseBrokenWings(EvadeSpellData evadeSpell, bool process = false)
        {
            var posInfo = EvadeHelper.GetBestPositionDash(evadeSpell);

            if (posInfo != null)
            {
                EvadeCommand.MoveTo(posInfo.Position);
                DelayAction.Add(50, () => EvadeSpell.CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), process));
                return(true);
            }

            return(false);
        }
示例#3
0
        public static bool UsePounce(EvadeSpellData evadeSpell, bool process = true)
        {
            if (MyHero.UnitSkinName != "Nidalee")
            {
                var posInfo = EvadeHelper.GetBestPositionDash(evadeSpell);
                if (posInfo != null)
                {
                    EvadeSpell.CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), process);
                    return(true);
                }
            }

            return(false);
        }
示例#4
0
        private static void DodgeSkillShots()
        {
            if (!Situation.ShouldDodge())
            {
                IsDodging = false;
                return;
            }

            if (IsDodging)
            {
                if (LastPosInfo == null)
                {
                    return;
                }

                var lastBestPosition = LastPosInfo.Position;

                if (!ObjectCache.MenuCache.Cache["ClickOnlyOnce"].Enabled && MyHero.Path.Count() > 0 && LastPosInfo.Position.Distance(MyHero.Path.Last().To2D()) < 5)
                {
                    return;
                }

                EvadeCommand.MoveTo(lastBestPosition);
                LastEvadeOrderTime = Environment.TickCount;
            }
            else
            {
                //Check if hero will walk into a skillshot
                var path = MyHero.Path;

                if (path.Length <= 0)
                {
                    return;
                }

                var movePos = path[path.Length - 1].To2D();

                if (!EvadeHelper.CheckMovePath(movePos))
                {
                    return;
                }

                var posInfo = EvadeHelper.GetBestPositionMovementBlock(movePos);
                if (posInfo != null)
                {
                    EvadeCommand.MoveTo(posInfo.Position);
                }
            }
        }
示例#5
0
        public static bool UseEkkoE2(EvadeSpellData evadeSpell, bool process = true)
        {
            if (MyHero.HasBuff("ekkoeattackbuff"))
            {
                var posInfo = EvadeHelper.GetBestPositionTargetedDash(evadeSpell);
                if (posInfo != null && posInfo.Target != null)
                {
                    EvadeSpell.CastEvadeSpell(() => EvadeCommand.Attack(evadeSpell, posInfo.Target), process);
                    //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D()));
                    return(true);
                }
            }

            return(false);
        }
示例#6
0
        public static bool UseEkkoR(EvadeSpellData evadeSpell, bool process = true)
        {
            foreach (var obj in ObjectManager.Get <Obj_AI_Minion>())
            {
                if (obj != null && obj.IsValid && !obj.IsDead && obj.Name == "Ekko" && obj.IsAlly)
                {
                    Vector2 blinkPos = obj.ServerPosition.To2D();
                    if (!blinkPos.CheckDangerousPos(10))
                    {
                        EvadeSpell.CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), process);
                        //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D()));
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#7
0
        public static bool UseRappel(EvadeSpellData evadeSpell, bool process = true)
        {
            if (MyHero.UnitSkinName != "Elise")
            {
                EvadeSpell.CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, MyHero), process);
                return(true);
            }

            if (MyHero.UnitSkinName == "Elise")
            {
                if (MyHero.SpellBook.CanUseSpell(SpellSlot.R))
                {
                    MyHero.SpellBook.CastSpell(SpellSlot.R);
                }
            }

            return(false);
        }
示例#8
0
        private void ContinueLastBlockedCommand()
        {
            if (ConfigValue.ContinueMovement.GetBool() && Situation.ShouldDodge())
            {
                var movePos    = LastBlockedUserMoveTo.TargetPosition;
                var extraDelay = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);

                if (IsDodging == false && LastBlockedUserMoveTo.IsProcessed == false && EvadeUtils.TickCount - LastEvadeCommand.Timestamp > Game.Ping + extraDelay && EvadeUtils.TickCount - LastBlockedUserMoveTo.Timestamp < 1500)
                {
                    movePos = movePos + (movePos - GameData.HeroInfo.ServerPos2D).Normalized() * EvadeUtils.Random.NextFloat(1, 65);

                    if (!EvadeHelper.CheckMovePath(movePos, Game.Ping + extraDelay))
                    {
                        //ConsoleDebug.WriteLine("Continue Movement");
                        //GameData.MyHero.IssueOrder(GameObjectOrder.MoveTo, movePos.To3D());
                        ConsoleDebug.WriteLineColor("Continuing Last Blocked Command", ConsoleColor.Yellow);
                        EvadeCommand.MoveTo(movePos);
                        LastBlockedUserMoveTo.IsProcessed = true;
                    }
                }
            }
        }
示例#9
0
        public static bool ActivateEvadeSpell(Spell spell, bool checkSpell = false)
        {
            if (spell.Info.SpellName.Contains("_trap"))
            {
                return(false);
            }

            var sortedEvadeSpells = EvadeSpells.OrderBy(s => s.Dangerlevel);

            var extraDelayBuffer    = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value;
            var spellActivationTime = ObjectCache.MenuCache.Cache["SpellActivationTime"].As <MenuSlider>().Value + ObjectCache.GamePing + extraDelayBuffer;

            if (ObjectCache.MenuCache.Cache["CalculateWindupDelay"].Enabled)
            {
                var extraWindupDelay = Evade.LastWindupTime - Environment.TickCount;
                if (extraWindupDelay > 0)
                {
                    return(false);
                }
            }

            foreach (var evadeSpell in sortedEvadeSpells)
            {
                var processSpell = true;

                if (!Evade.EvadeSpellMenu[evadeSpell.CharName + evadeSpell.Name + "EvadeSpellSettings"][evadeSpell.Name + "UseEvadeSpell"].Enabled ||
                    GetSpellDangerLevel(evadeSpell) > spell.GetSpellDangerLevel() || !MyHero.SpellBook.CanUseSpell(evadeSpell.SpellKey) ||
                    evadeSpell.CheckSpellName && MyHero.SpellBook.GetSpell(evadeSpell.SpellKey).Name != evadeSpell.SpellName)
                {
                    continue;
                }

                spell.CanHeroEvade(MyHero, out var evadeTime, out var spellHitTime);

                var finalEvadeTime = spellHitTime - evadeTime;

                if (checkSpell)
                {
                    var mode = Evade.EvadeSpellMenu[evadeSpell.CharName + evadeSpell.Name + "EvadeSpellSettings"][evadeSpell.Name + "EvadeSpellMode"].As <MenuList>().Value;

                    switch (mode)
                    {
                    case 0: continue;

                    case 1:
                        if (spellActivationTime < finalEvadeTime)
                        {
                            continue;
                        }
                        break;
                    }
                }
                else
                {
                    if (evadeSpell.SpellDelay <= 50 && evadeSpell.EvadeType != EvadeType.Dash)
                    {
                        var path = MyHero.Path;
                        if (path.Length > 0)
                        {
                            var movePos = path[path.Length - 1].To2D();
                            var posInfo = EvadeHelper.CanHeroWalkToPos(movePos, ObjectCache.MyHeroCache.MoveSpeed, 0, 0);

                            if (GetSpellDangerLevel(evadeSpell) > posInfo.PosDangerLevel)
                            {
                                continue;
                            }
                        }
                    }
                }

                if (evadeSpell.EvadeType != EvadeType.Dash && spellHitTime > evadeSpell.SpellDelay + 100 + Game.Ping + ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value)
                {
                    processSpell = false;

                    if (checkSpell == false)
                    {
                        continue;
                    }
                }

                if (evadeSpell.IsSpecial)
                {
                    if (evadeSpell.UseSpellFunc == null)
                    {
                        continue;
                    }
                    if (evadeSpell.UseSpellFunc(evadeSpell, processSpell))
                    {
                        return(true);
                    }
                }
                else
                {
                    switch (evadeSpell.EvadeType)
                    {
                    case EvadeType.Blink:
                        if (evadeSpell.CastType == CastType.Position)
                        {
                            var posInfo = EvadeHelper.GetBestPositionBlink();
                            if (posInfo != null)
                            {
                                if (processSpell)
                                {
                                    MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Position.To3D());
                                }
                                //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell);
                                //DelayAction.Add(50, () => myHero.IssueOrder(OrderType.MoveTo, posInfo.position.To3D()));
                                return(true);
                            }
                        }
                        else if (evadeSpell.CastType == CastType.Target)
                        {
                            var posInfo = EvadeHelper.GetBestPositionTargetedDash(evadeSpell);
                            if (posInfo != null && posInfo.Target != null && posInfo.PosDangerLevel == 0)
                            {
                                if (processSpell)
                                {
                                    MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Target);
                                }
                                //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.target), processSpell);
                                //DelayAction.Add(50, () => myHero.IssueOrder(OrderType.MoveTo, posInfo.position.To3D()));
                                return(true);
                            }
                        }
                        break;

                    case EvadeType.Dash:
                        if (evadeSpell.CastType == CastType.Position)
                        {
                            var posInfo = EvadeHelper.GetBestPositionDash(evadeSpell);
                            if (posInfo != null && CompareEvadeOption(posInfo, checkSpell))
                            {
                                if (evadeSpell.IsReversed)
                                {
                                    var dir   = (posInfo.Position - ObjectCache.MyHeroCache.ServerPos2D).Normalized();
                                    var range = ObjectCache.MyHeroCache.ServerPos2D.Distance(posInfo.Position);
                                    var pos   = ObjectCache.MyHeroCache.ServerPos2D - dir * range;

                                    posInfo.Position = pos;
                                }

                                if (processSpell)
                                {
                                    MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Position.To3D());
                                }

                                return(true);
                            }
                        }
                        else if (evadeSpell.CastType == CastType.Target)
                        {
                            var posInfo = EvadeHelper.GetBestPositionTargetedDash(evadeSpell);
                            if (posInfo != null && posInfo.Target != null && posInfo.PosDangerLevel == 0)
                            {
                                if (processSpell)
                                {
                                    MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Target);
                                }

                                return(true);
                            }
                        }
                        break;

                    case EvadeType.WindWall:
                        if (spell.HasProjectile() || evadeSpell.SpellName == "FioraW")
                        {
                            var dir = (spell.StartPos - ObjectCache.MyHeroCache.ServerPos2D).Normalized();
                            var pos = ObjectCache.MyHeroCache.ServerPos2D + dir * 100;

                            if (processSpell)
                            {
                                MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, pos.To3D());
                            }

                            return(true);
                        }
                        break;

                    case EvadeType.SpellShield:
                        if (evadeSpell.IsItem)
                        {
                            if (processSpell)
                            {
                                MyHero.SpellBook.CastSpell(evadeSpell.SpellKey);
                            }
                            //CastEvadeSpell(() => myHero.SpellBook.CastSpell(evadeSpell.spellKey), processSpell);
                            return(true);
                        }

                        switch (evadeSpell.CastType)
                        {
                        case CastType.Target:
                            if (processSpell)
                            {
                                MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, MyHero);
                            }
                            // CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, myHero), processSpell);
                            return(true);

                        case CastType.Self:
                            if (processSpell)
                            {
                                MyHero.SpellBook.CastSpell(evadeSpell.SpellKey);
                            }
                            //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell);
                            return(true);
                        }

                        break;

                    case EvadeType.MovementSpeedBuff:
                        if (evadeSpell.IsItem)
                        {
                            var posInfo = EvadeHelper.GetBestPosition();
                            if (posInfo != null)
                            {
                                if (processSpell)
                                {
                                    MyHero.SpellBook.CastSpell(evadeSpell.SpellKey);
                                }
                                //CastEvadeSpell(() => myHero.SpellBook.CastSpell(evadeSpell.spellKey), processSpell);
                                DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.Position));
                                return(true);
                            }
                        }
                        else
                        {
                            switch (evadeSpell.CastType)
                            {
                            case CastType.Self:
                            {
                                var posInfo = EvadeHelper.GetBestPosition();
                                if (posInfo != null)
                                {
                                    if (processSpell)
                                    {
                                        MyHero.SpellBook.CastSpell(evadeSpell.SpellKey);
                                    }
                                    //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell);
                                    DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.Position));
                                    return(true);
                                }
                                break;
                            }

                            case CastType.Position:
                            {
                                var posInfo = EvadeHelper.GetBestPosition();
                                if (posInfo != null)
                                {
                                    if (processSpell)
                                    {
                                        MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Position.To3D());
                                    }
                                    //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell);
                                    DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.Position));
                                    return(true);
                                }
                                break;
                            }

                            case CastType.Target: break;

                            default: throw new ArgumentOutOfRangeException();
                            }
                        }
                        break;
                    }
                }
            }

            return(false);
        }
示例#10
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;
            }
        }
示例#11
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;
            }
        }
示例#12
0
        private void DodgeSkillShots()
        {
            if (!Situation.ShouldDodge())
            {
                IsDodging = false;
                return;
            }

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

            if (IsDodging)
            {
                ConsoleDebug.WriteLineColor("Dodging Skill Shots by walking", ConsoleColor.Green);
                if (LastPosInfo != null)
                {
                    /*foreach (KeyValuePair<int, Spell> entry in SpellDetector.spells)
                     * {
                     *  Spell spell = entry.Value;
                     *
                     *  ConsoleDebug.WriteLine("" + (int)(TickCount-spell.startTime));
                     * }*/


                    Vector2 lastBestPosition = LastPosInfo.Position;

                    if (!ConfigValue.ClickOnlyOnce.GetBool() || !(GameData.MyHero.Path.Length > 0 && LastPosInfo.Position.Distance(GameData.MyHero.Path.Last().To2D()) < 5))
                    //|| lastPosInfo.timestamp > lastEvadeOrderTime)
                    {
                        EvadeCommand.MoveTo(lastBestPosition);
                        LastEvadeOrderTime = EvadeUtils.TickCount;
                    }
                }
            }
            else //if not dodging
            {
                //Check if hero will walk into a skillshot
                var path = GameData.MyHero.Path;
                if (path.Length > 0)
                {
                    var movePos = path[path.Length - 1].To2D();

                    if (EvadeHelper.CheckMovePath(movePos))
                    {
                        /*if (() Properties.Properties.Data["AllowCrossing"].Cast<CheckBox>().CurrentValue)
                         * {
                         *  var extraDelayBuffer = () Properties.Properties.Data["ExtraPingBuffer"]
                         + 30;
                         +  var extraDist = () Properties.Properties.Data["ExtraCPADistance"]
                         + 10;
                         +
                         +  var tPosInfo = EvadeHelper.CanHeroWalkToPos(movePos, GameData.HeroInfo.moveSpeed, extraDelayBuffer + Game.Ping, extraDist);
                         +
                         +  if (tPosInfo.posDangerLevel == 0)
                         +  {
                         +      lastPosInfo = tPosInfo;
                         +      return;
                         +  }
                         + }*/

                        var posInfo = EvadeHelper.GetBestPositionMovementBlock(movePos);
                        if (posInfo != null)
                        {
                            EvadeCommand.MoveTo(posInfo.Position);
                        }
                        return;
                    }
                }
            }
        }
示例#13
0
        private void Game_OnIssueOrder(Obj_AI_Base hero, PlayerIssueOrderEventArgs args)
        {
            if (!hero.IsMe)
            {
                return;
            }

            if (!Situation.ShouldDodge())
            {
                return;
            }
            //DebugIssueOrders(args);

            if (args.Order == GameObjectOrder.MoveTo)
            {
                //movement block code goes in here
                if (IsDodging && SpellDetector.Spells.Count > 0)
                {
                    ConsoleDebug.WriteLineColor("Issue Order detected while spells exist", ConsoleColor.Yellow);
                    CheckHeroInDanger();

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

                    args.Process = false; //Block the command
                    ConsoleDebug.WriteLineColor("   Blocked Movement Command", ConsoleColor.Red);
                }
                else
                {
                    var movePos    = args.TargetPosition.To2D();
                    var extraDelay = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);
                    if (EvadeHelper.CheckMovePath(movePos, Game.Ping + extraDelay))
                    {
                        ConsoleDebug.WriteLineColor("Move Path is colliding with spell", ConsoleColor.Yellow);

                        /*if (() Properties.Properties.Data["AllowCrossing"].Cast<CheckBox>().CurrentValue)
                         * {
                         *  var extraDelayBuffer = () Properties.Properties.Data["ExtraPingBuffer"]
                         + 30;
                         +  var extraDist = () Properties.Properties.Data["ExtraCPADistance"]
                         + 10;
                         +
                         +  var tPosInfo = EvadeHelper.CanHeroWalkToPos(movePos, GameData.HeroInfo.moveSpeed, extraDelayBuffer + Game.Ping, extraDist);
                         +
                         +  if (tPosInfo.posDangerLevel == 0)
                         +  {
                         +      lastPosInfo = tPosInfo;
                         +      return;
                         +  }
                         + }*/

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

                        args.Process = false; //Block the command
                        ConsoleDebug.WriteLineColor("   Blocked Movement Command", ConsoleColor.Red);
                        if (EvadeUtils.TickCount - LastMovementBlockTime < 500 && LastMovementBlockPos.Distance(args.TargetPosition) < 100)
                        {
                            return;
                        }

                        LastMovementBlockPos  = args.TargetPosition;
                        LastMovementBlockTime = EvadeUtils.TickCount;

                        var posInfo = EvadeHelper.GetBestPositionMovementBlock(movePos);
                        if (posInfo != null)
                        {
                            EvadeCommand.MoveTo(posInfo.Position);
                        }
                        return;
                    }
                    else
                    {
                        LastBlockedUserMoveTo.IsProcessed = true;
                    }
                }
            }
            else //need more logic
            {
                if (IsDodging)
                {
                    args.Process = false; //Block the command
                    ConsoleDebug.WriteLineColor("   Blocked IssueOrder(" + args.Order + ") Command", ConsoleColor.Red);
                }
                else
                {
                    if (args.Order == GameObjectOrder.AttackUnit)
                    {
                        var target = args.Target;
                        if (target != null && target.GetType() == typeof(Obj_AI_Base))
                        {
                            var baseTarget = (Obj_AI_Base)target;
                            if (baseTarget.IsValid())
                            {
                                if (GameData.HeroInfo.ServerPos2D.Distance(baseTarget.ServerPosition.To2D()) > GameData.MyHero.AttackRange + GameData.HeroInfo.BoundingRadius + baseTarget.BoundingRadius)
                                {
                                    var movePos    = args.TargetPosition.To2D();
                                    var extraDelay = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);
                                    if (EvadeHelper.CheckMovePath(movePos, Game.Ping + extraDelay))
                                    {
                                        args.Process = false; //Block the command
                                        ConsoleDebug.WriteLineColor("   Blocked Attack Unit Command", ConsoleColor.Red);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (args.Process == true)
            {
                LastIssueOrderGameTime = Game.Time * 1000;
                LastIssueOrderTime     = EvadeUtils.TickCount;
                LastIssueOrderArgs     = args;

                if (args.Order == GameObjectOrder.MoveTo)
                {
                    LastMoveToPosition  = args.TargetPosition.To2D();
                    LastMoveToServerPos = GameData.MyHero.ServerPosition.To2D();
                }

                if (args.Order == GameObjectOrder.Stop)
                {
                    LastStopPosition = GameData.MyHero.ServerPosition.To2D();
                }
            }
        }
示例#14
0
        private void Game_OnCastSpell(Spellbook spellbook, SpellbookCastSpellEventArgs args)
        {
            if (!spellbook.Owner.IsMe)
            {
                return;
            }

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

            if (SpellDetector.ChanneledSpells.TryGetValue(sData.Name, out name))
            {
                //Evade.isChanneling = true;
                //Evade.channelPosition = GameData.HeroInfo.serverPos2D;
                LastStopEvadeTime = EvadeUtils.TickCount + Game.Ping + 100;
            }

            if (EvadeSpell.LastSpellEvadeCommand != null &&
                EvadeSpell.LastSpellEvadeCommand.Timestamp + Game.Ping + 150 > EvadeUtils.TickCount)
            {
                args.Process = false;
            }

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

            //moved from processPacket

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

            if (Situation.ShouldDodge())
            {
                if (IsDodging && SpellDetector.Spells.Count() > 0)
                {
                    foreach (KeyValuePair <String, SpellData> entry in SpellDetector.WindupSpells)
                    {
                        SpellData 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)
                {
                    if (evadeSpell.EvadeType == EvadeType.Blink ||
                        evadeSpell.EvadeType == EvadeType.Dash)
                    {
                        //Block spell cast if flashing/blinking into spells
                        if (args.EndPosition.To2D().CheckDangerousPos(6, true)) //for blink + dash
                        {
                            args.Process = false;
                            return;
                        }

                        if (evadeSpell.EvadeType == EvadeType.Dash)
                        {
                            var extraDelayBuffer = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);
                            var extraDist        = Config.Properties.GetInt(ConfigValue.ExtraCpaDistance);

                            var dashPos = Game.CursorPos.To2D(); //real pos?

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

                            //Draw.RenderObjects.Add(new Draw.RenderPosition(dashPos, 1000));

                            var posInfo = EvadeHelper.CanHeroWalkToPos(dashPos, evadeSpell.Speed,
                                                                       extraDelayBuffer + Game.Ping, extraDist);

                            if (posInfo.PosDangerLevel > 0)
                            {
                                args.Process = false;
                                return;
                            }
                        }

                        LastPosInfo = PositionInfo.SetAllUndodgeable(); //really?

                        if (IsDodging || EvadeUtils.TickCount < LastDodgingEndTime + 500)
                        {
                            EvadeCommand.MoveTo(Game.CursorPos.To2D()); //block moveto
                            LastStopEvadeTime = EvadeUtils.TickCount + Game.Ping + 100;
                        }
                    }
                    return;
                }
            }
        }
示例#15
0
        public static bool ActivateEvadeSpell(Spell spell, bool checkSpell = false)
        {
            var sortedEvadeSpells = EvadeSpells.OrderBy(s => s.Dangerlevel);

            var   extraDelayBuffer    = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);
            float spellActivationTime = ConfigValue.SpellActivationTime.GetInt() + Game.Ping + extraDelayBuffer;

            if (ConfigValue.CalculateWindupDelay.GetBool())
            {
                var extraWindupDelay = ezEvade.LastWindupTime - EvadeUtils.TickCount;
                if (extraWindupDelay > 0)
                {
                    return(false);
                }
            }

            foreach (var evadeSpell in sortedEvadeSpells)
            {
                var processSpell = true;
                if (!Config.Properties.GetEvadeSpell(evadeSpell.Name).Use ||
                    ((int)GetSpellDangerLevel(evadeSpell) > (int)spell.GetSpellDangerLevel()) ||
                    (!evadeSpell.IsItem && MyHero.Spellbook.CanUseSpell(evadeSpell.SpellKey) != SpellState.Ready) ||
                    (evadeSpell.IsItem && !(Items.CanUseItem((int)evadeSpell.ItemId))) ||
                    (evadeSpell.CheckSpellName &&
                     MyHero.Spellbook.GetSpell(evadeSpell.SpellKey).Name != evadeSpell.SpellName))
                {
                    continue; //can't use spell right now
                }


                float evadeTime, spellHitTime;
                spell.CanHeroEvade(MyHero, out evadeTime, out spellHitTime);

                float finalEvadeTime = (spellHitTime - evadeTime);

                if (checkSpell)
                {
                    var mode = Config.Properties.GetEvadeSpell(evadeSpell.Name).SpellMode;

                    switch (mode)
                    {
                    case SpellModes.Undodgeable:
                        continue;

                    case SpellModes.ActivationTime:
                        if (spellActivationTime < finalEvadeTime)
                        {
                            continue;
                        }
                        break;
                    }
                }
                else
                {
                    //if (ObjectCache.menuCache.cache[evadeSpell.name + "LastResort"].Cast<CheckBox>().CurrentValue)
                    if (evadeSpell.SpellDelay <= 50 && evadeSpell.EvadeType != EvadeType.Dash)
                    {
                        var path = MyHero.Path;
                        if (path.Length > 0)
                        {
                            var movePos = path[path.Length - 1].To2D();
                            var posInfo = EvadeHelper.CanHeroWalkToPos(movePos, GameData.HeroInfo.MoveSpeed, 0, 0);

                            if ((int)GetSpellDangerLevel(evadeSpell) > (int)posInfo.PosDangerLevel)
                            {
                                continue;
                            }
                        }
                    }
                }

                if (evadeSpell.EvadeType != EvadeType.Dash && spellHitTime > evadeSpell.SpellDelay + 100 + Game.Ping +
                    Config.Properties.GetInt(ConfigValue.ExtraPingBuffer))
                {
                    processSpell = false;

                    if (checkSpell == false)
                    {
                        continue;
                    }
                }

                if (evadeSpell.IsSpecial)
                {
                    if (evadeSpell.UseSpellFunc != null)
                    {
                        if (evadeSpell.UseSpellFunc(evadeSpell, processSpell))
                        {
                            return(true);
                        }
                    }
                    continue;
                }

                if (evadeSpell.EvadeType == EvadeType.Blink)
                {
                    if (evadeSpell.CastType == CastType.Position)
                    {
                        var posInfo = EvadeHelper.GetBestPositionBlink();
                        if (posInfo != null)
                        {
                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Position), processSpell);
                            //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D()));
                            return(true);
                        }
                    }
                    else if (evadeSpell.CastType == CastType.Target)
                    {
                        var posInfo = EvadeHelper.GetBestPositionTargetedDash(evadeSpell);
                        if (posInfo != null && posInfo.Target != null && posInfo.PosDangerLevel == 0)
                        {
                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Target), processSpell);
                            //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D()));
                            return(true);
                        }
                    }
                }
                else if (evadeSpell.EvadeType == EvadeType.Dash)
                {
                    if (evadeSpell.CastType == CastType.Position)
                    {
                        var posInfo = EvadeHelper.GetBestPositionDash(evadeSpell);
                        if (posInfo != null && CompareEvadeOption(posInfo, checkSpell))
                        {
                            if (evadeSpell.IsReversed)
                            {
                                var dir   = (posInfo.Position - GameData.HeroInfo.ServerPos2D).Normalized();
                                var range = GameData.HeroInfo.ServerPos2D.Distance(posInfo.Position);
                                var pos   = GameData.HeroInfo.ServerPos2D - dir * range;

                                posInfo.Position = pos;
                            }

                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Position), processSpell);
                            //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D()));
                            return(true);
                        }
                    }
                    else if (evadeSpell.CastType == CastType.Target)
                    {
                        var posInfo = EvadeHelper.GetBestPositionTargetedDash(evadeSpell);
                        if (posInfo != null && posInfo.Target != null && posInfo.PosDangerLevel == 0)
                        {
                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Target), processSpell);
                            //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D()));
                            return(true);
                        }
                    }
                }
                else if (evadeSpell.EvadeType == EvadeType.WindWall)
                {
                    if (spell.HasProjectile() || evadeSpell.SpellName == "FioraW") //TODO: temp fix, don't have fiora :'(
                    {
                        var dir = (spell.StartPos - GameData.HeroInfo.ServerPos2D).Normalized();
                        var pos = GameData.HeroInfo.ServerPos2D + dir * 100;

                        CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, pos), processSpell);
                        return(true);
                    }
                }
                else if (evadeSpell.EvadeType == EvadeType.SpellShield)
                {
                    if (evadeSpell.IsItem)
                    {
                        CastEvadeSpell(() => Items.UseItem((int)evadeSpell.ItemId), processSpell);
                        return(true);
                    }
                    else
                    {
                        if (evadeSpell.CastType == CastType.Target)
                        {
                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, MyHero), processSpell);
                            return(true);
                        }
                        else if (evadeSpell.CastType == CastType.Self)
                        {
                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell);
                            return(true);
                        }
                    }
                }
                else if (evadeSpell.EvadeType == EvadeType.MovementSpeedBuff)
                {
                }
            }

            return(false);
        }