Example #1
0
        private void Render_OnPresent()
        {
            foreach (var entry in SpellDetector.DrawSpells)
            {
                var spell = entry.Value;

                if (spell.SpellType != SpellType.Line)
                {
                    continue;
                }

                var spellPos = spell.CurrentSpellPosition;

                Render.Circle(new Vector3(spellPos.X, spellPos.Y, MyHero.Position.Z), spell.Info.Radius, 50, Color.White);
            }

            if (TestMenu["(TestHeroPos)"].Enabled)
            {
                var path = MyHero.Path;
                if (path.Length > 0)
                {
                    var heroPos2 = EvadeHelper.GetRealHeroPos(ObjectCache.GamePing + 50);
                    var heroPos1 = ObjectCache.MyHeroCache.ServerPos2D;

                    Render.Circle(new Vector3(heroPos2.X, heroPos2.Y, MyHero.ServerPosition.Z), ObjectCache.MyHeroCache.BoundingRadius, 50, Color.Red);
                    Render.Circle(new Vector3(MyHero.ServerPosition.X, MyHero.ServerPosition.Y, MyHero.ServerPosition.Z), ObjectCache.MyHeroCache.BoundingRadius, 50, Color.White);

                    Render.WorldToScreen(ObjectManager.GetLocalPlayer().Position, out var heroPos);

                    Render.Text($" {(int) heroPos2.Distance(heroPos1)}", new Vector2(heroPos.X - 10, heroPos.Y), RenderTextFlags.Center, Color.Red);

                    Render.Circle(new Vector3(_circleRenderPos.X, _circleRenderPos.Y, MyHero.ServerPosition.Z), 10, 50, Color.Red);
                }
            }

            if (TestMenu["(DrawHeroPos)"].Enabled)
            {
                Render.Circle(new Vector3(MyHero.ServerPosition.X, MyHero.ServerPosition.Y, MyHero.ServerPosition.Z), ObjectCache.MyHeroCache.BoundingRadius, 50, Color.White);
            }

            if (TestMenu["(TestMoveTo)"].As <MenuKeyBind>().Enabled)
            {
                TestMenu["(TestMoveTo)"].As <MenuKeyBind>().Value = false;

                MyHero.IssueOrder(OrderType.MoveTo, Game.CursorPos);

                var dir = (Game.CursorPos - MyHero.Position).Normalized();

                var pos2 = Game.CursorPos.To2D() - dir.To2D() * 75;

                DelayAction.Add(20, () => MyHero.IssueOrder(OrderType.MoveTo, pos2.To3D()));
            }

            if (TestMenu["(TestPath)"].Enabled)
            {
                var tPath = MyHero.GetPath(Game.CursorPos);

                foreach (var point in tPath)
                {
                    var point2D = point.To2D();
                    Render.Circle(new Vector3(point.X, point.Y, point.Z), ObjectCache.MyHeroCache.BoundingRadius, 50, Color.Violet);
                }
            }

            if (TestMenu["(TestPath)"].Enabled)
            {
                foreach (var entry in SpellDetector.Spells)
                {
                    var spell = entry.Value;

                    var to  = Game.CursorPos.To2D();
                    var dir = (to - MyHero.Position.To2D()).Normalized();

                    var cpa = MathUtilsCpa.CPAPointsEx(MyHero.Position.To2D(), dir * ObjectCache.MyHeroCache.MoveSpeed, spell.EndPos, spell.Direction * spell.Info.ProjectileSpeed, to, spell.EndPos);

                    if (cpa < ObjectCache.MyHeroCache.BoundingRadius + spell.Radius)
                    {
                    }
                }
            }

            if (TestMenu["(ShowBuffs)"].Enabled)
            {
                var target = MyHero;

                foreach (var hero in GameObjects.EnemyHeroes)
                {
                    target = hero;
                }

                var buffs = target.Buffs;

                if (!target.IsTargetable)
                {
                    ConsolePrinter.Print("invul" + Environment.TickCount);
                }

                var height = 20;

                foreach (var buff in buffs)
                {
                    if (!buff.IsValid)
                    {
                        continue;
                    }

                    Render.Text(buff.Name, new Vector2(10, height), RenderTextFlags.Center, Color.White);
                    height += 20;

                    ConsolePrinter.Print(buff.Name);
                }
            }

            if (TestMenu["(TestTracker)"].Enabled)
            {
                foreach (var entry in ObjectTracker.ObjTracker)
                {
                    var info = entry.Value;

                    var endPos2 = !info.UsePosition ? info.Obj.Position : info.Position;

                    Render.Circle(new Vector3(endPos2.X, endPos2.Y, MyHero.Position.Z), 50, 50, Color.Green);
                }
            }

            if (!TestMenu["(TestWall)"].Enabled)
            {
                return;
            }

            var       posChecked    = 0;
            const int maxPosToCheck = 50;
            const int posRadius     = 50;
            var       radiusIndex   = 0;

            var heroPoint = ObjectCache.MyHeroCache.ServerPos2D;

            while (posChecked < maxPosToCheck)
            {
                radiusIndex++;

                var curRadius       = radiusIndex * 2 * posRadius;
                var curCircleChecks = (int)Math.Ceiling(2 * Math.PI * curRadius / (2 * (double)posRadius));

                for (var i = 1; i < curCircleChecks; i++)
                {
                    posChecked++;
                    var cRadians = 2 * Math.PI / (curCircleChecks - 1) * i; //check decimals
                    var pos      = new Vector2((float)Math.Floor(heroPoint.X + curRadius * Math.Cos(cRadians)), (float)Math.Floor(heroPoint.Y + curRadius * Math.Sin(cRadians)));

                    if (!EvadeHelper.CheckPathCollision(MyHero, pos))
                    {
                        Render.Circle(new Vector3(pos.X, pos.Y, MyHero.Position.Z), 25, 50, Color.White);
                    }
                }
            }
        }
Example #2
0
        private void Render_OnPresent()
        {
            //PrintTimers();

            //EvadeHelper.CheckMovePath(Game.CursorPos.To2D());

            //TestUnderTurret();


            /*if (EvadeHelper.CheckPathCollision(myHero, Game.CursorPos.To2D()))
             * {
             *  var paths = myHero.GetPath(ObjectCache.myHeroCache.serverPos2DExtra.To3D(), Game.CursorPos);
             *  foreach (var path in paths)
             *  {
             *      Render.Circle.DrawCircle(path, ObjectCache.myHeroCache.boundingRadius, Color.Red, 3);
             *  }
             * }
             * else
             * {
             *  Render.Circle.DrawCircle(Game.CursorPos, ObjectCache.myHeroCache.boundingRadius, Color.White, 3);
             * }*/

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

                if (spell.spellType == SpellType.Line)
                {
                    var spellPos = spell.currentSpellPosition;

                    Render.Circle(new Vector3(spellPos.X, spellPos.Y, myHero.Position.Z), spell.info.radius, 50,
                                  Color.White);

                    /*spellPos = spellPos + spell.Orientation * spell.info.projectileSpeed * (60 / 1000); //move the spellPos by 50 miliseconds forwards
                     * spellPos = spellPos + spell.Orientation * 200; //move the spellPos by 50 units forwards
                     *
                     * Render.Circle.DrawCircle(new Vector3(spellPos.X, spellPos.Y, myHero.Position.Z), spell.info.radius, Color.White, 3);*/
                }
            }

            if (testMenu["(TestHeroPos)"].As <MenuBool>().Enabled)
            {
                var path = myHero.Path;
                if (path.Length > 0)
                {
                    var heroPos2 =
                        EvadeHelper.GetRealHeroPos(ObjectCache.gamePing + 50); // path[path.Length - 1].To2D();
                    var heroPos1 = ObjectCache.myHeroCache.serverPos2D;

                    Render.Circle(new Vector3(heroPos2.X, heroPos2.Y, myHero.ServerPosition.Z),
                                  ObjectCache.myHeroCache.boundingRadius, 50, Color.Red);
                    Render.Circle(
                        new Vector3(myHero.ServerPosition.X, myHero.ServerPosition.Y, myHero.ServerPosition.Z),
                        ObjectCache.myHeroCache.boundingRadius, 50, Color.White);

                    Vector2 heroPos;
                    Render.WorldToScreen(ObjectManager.GetLocalPlayer().Position, out heroPos);
                    //var dimension = Render.GetTextExtent("Evade: ON");
                    Render.Text(heroPos.X - 10, heroPos.Y, Color.Red, "" + (int)heroPos2.Distance(heroPos1));

                    Render.Circle(new Vector3(circleRenderPos.X, circleRenderPos.Y, myHero.ServerPosition.Z), 10, 50,
                                  Color.Red);
                }
            }

            if (testMenu["(DrawHeroPos)"].As <MenuBool>().Enabled)
            {
                Render.Circle(new Vector3(myHero.ServerPosition.X, myHero.ServerPosition.Y, myHero.ServerPosition.Z),
                              ObjectCache.myHeroCache.boundingRadius, 50, Color.White);
            }

            if (testMenu["(TestMoveTo)"].As <MenuKeyBind>().Enabled)
            {
                // fix ? wtf
                var MenuKeyBind = testMenu["(TestMoveTo)"].As <MenuKeyBind>();
                testMenu["(TestMoveTo)"].As <MenuKeyBind>().Value = false;

                /*lastRightMouseClickTime = EvadeUtils.TickCount;
                 * myHero.IssueOrder(OrderType.MoveTo, Game.CursorPos,false);*/

                myHero.IssueOrder(OrderType.MoveTo, Game.CursorPos);

                var dir = (Game.CursorPos - myHero.Position).Normalized();
                //var pos2 = myHero.Position - dir * Game.CursorPos.Distance(myHero.Position);

                //var pos2 = myHero.Position.To2D() - dir.To2D() * 75;
                var pos2 = Game.CursorPos.To2D() - dir.To2D() * 75;

                //Console.WriteLine(myHero.BBox.Maximum.Distance(myHero.Position));

                DelayAction.Add(20, () => myHero.IssueOrder(OrderType.MoveTo, pos2.To3D()));
                //myHero.IssueOrder(OrderType.MoveTo, pos2, false);
            }

            if (testMenu["(TestPath)"].As <MenuBool>().Enabled)
            {
                var tPath     = myHero.GetPath(Game.CursorPos);
                var lastPoint = Vector2.Zero;

                foreach (var point in tPath)
                {
                    var point2D = point.To2D();
                    Render.Circle(new Vector3(point.X, point.Y, point.Z), ObjectCache.myHeroCache.boundingRadius, 50,
                                  Color.Violet);

                    lastPoint = point2D;
                }
            }

            if (testMenu["(TestPath)"].As <MenuBool>().Enabled)
            {
                var tPath     = myHero.GetPath(Game.CursorPos);
                var lastPoint = Vector2.Zero;

                foreach (var point in tPath)
                {
                    var point2D = point.To2D();
                    //Render.Circle.DrawCircle(new Vector3(point.X, point.Y, point.Z), ObjectCache.myHeroCache.boundingRadius, Color.Violet, 3);

                    lastPoint = point2D;
                }

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

                    var     to = Game.CursorPos.To2D();
                    var     dir = (to - myHero.Position.To2D()).Normalized();
                    Vector2 cPos1, cPos2;

                    var cpa = MathUtilsCPA.CPAPointsEx(myHero.Position.To2D(), dir * ObjectCache.myHeroCache.moveSpeed,
                                                       spell.endPos, spell.direction * spell.info.projectileSpeed, to, spell.endPos);
                    var cpaTime = MathUtilsCPA.CPATime(myHero.Position.To2D(), dir * ObjectCache.myHeroCache.moveSpeed,
                                                       spell.endPos, spell.direction * spell.info.projectileSpeed);

                    //ConsolePrinter.Print("" + cpaTime);
                    //Render.Circle.DrawCircle(cPos1.To3D(), ObjectCache.myHeroCache.boundingRadius, Color.Red, 3);

                    if (cpa < ObjectCache.myHeroCache.boundingRadius + spell.radius)
                    {
                    }
                }
            }

            if (testMenu["(ShowBuffs)"].As <MenuBool>().Enabled)
            {
                var target = myHero;

                foreach (var hero in GameObjects.EnemyHeroes)
                {
                    target = hero;
                }

                var buffs = target.Buffs;

                //ConsolePrinter.Print(myHero.ChampionName);

                //if(myHero.IsDead)
                //    ConsolePrinter.Print("dead");

                if (!target.IsTargetable)
                {
                    ConsolePrinter.Print("invul" + EvadeUtils.TickCount);
                }

                var height = 20;

                foreach (var buff in buffs)
                {
                    if (buff.IsValid)
                    {
                        Render.Text(10, height, Color.White, buff.Name);
                        height += 20;

                        ConsolePrinter.Print(buff.Name);
                    }
                }
            }

            if (testMenu["(TestTracker)"].As <MenuBool>().Enabled)
            {
                foreach (var entry in ObjectTracker.objTracker)
                {
                    var info = entry.Value;

                    Vector3 endPos2;
                    if (info.usePosition == false)
                    {
                        endPos2 = info.obj.Position;
                    }
                    else
                    {
                        endPos2 = info.position;
                    }

                    Render.Circle(new Vector3(endPos2.X, endPos2.Y, myHero.Position.Z), 50, 50, Color.Green);
                }
            }

            if (testMenu["(ShowMissileInfo)"].As <MenuBool>().Enabled)
            {
                if (testMissile != null)
                {
                    //Render.Circle.DrawCircle(testMissile.Position, testMissile.BoundingRadius, Color.White, 3);
                }
            }

            if (testMenu["(TestWall)"].As <MenuBool>().Enabled)
            {
                /*foreach (var posInfo in sortedBestPos)
                 * {
                 *  var posOnScreen = Drawing.WorldToScreen(posInfo.position.To3D());
                 *  //Render.Text(posOnScreen.X, posOnScreen.Y, Color.Aqua, "" + (int)posInfo.closestDistance);
                 *
                 *
                 *  if (!posInfo.rejectPosition)
                 *  {
                 *      Render.Text(posOnScreen.X, posOnScreen.Y, Color.Aqua, "" + (int)posInfo.closestDistance);
                 *  }
                 *
                 *  Render.Text(posOnScreen.X, posOnScreen.Y, Color.Aqua, "" + (int)posInfo.closestDistance);
                 *
                 *  if (posInfo.posDangerCount <= 0)
                 *  {
                 *      var pos = posInfo.position;
                 *      Render.Circle.DrawCircle(new Vector3(pos.X, pos.Y, myHero.Position.Z), (float)25, Color.White, 3);
                 *  }
                 * }*/

                var posChecked    = 0;
                var maxPosToCheck = 50;
                var posRadius     = 50;
                var radiusIndex   = 0;

                var heroPoint = ObjectCache.myHeroCache.serverPos2D;
                var posTable  = new List <PositionInfo>();

                while (posChecked < maxPosToCheck)
                {
                    radiusIndex++;

                    var curRadius       = radiusIndex * 2 * posRadius;
                    var curCircleChecks = (int)Math.Ceiling(2 * Math.PI * curRadius / (2 * (double)posRadius));

                    for (var i = 1; i < curCircleChecks; i++)
                    {
                        posChecked++;
                        var cRadians = 2 * Math.PI / (curCircleChecks - 1) * i; //check decimals
                        var pos      = new Vector2((float)Math.Floor(heroPoint.X + curRadius * Math.Cos(cRadians)),
                                                   (float)Math.Floor(heroPoint.Y + curRadius * Math.Sin(cRadians)));

                        if (!EvadeHelper.CheckPathCollision(myHero, pos))
                        {
                            Render.Circle(new Vector3(pos.X, pos.Y, myHero.Position.Z), 25, 50, Color.White);
                        }
                    }
                }
            }
        }
Example #3
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();
                }
            }
        }
Example #4
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;
                    }
                }
            }
        }
Example #5
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);
                        }
                    }
                }
            }
        }
Example #6
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;
                }
            }
        }
Example #7
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();
                }
            }
        }
Example #8
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;
                }
            }
        }
Example #9
0
        private void SpellDetector_OnProcessDetectedSpells()
        {
            ObjectCache.myHeroCache.UpdateInfo();

            if (ObjectCache.menuCache.cache["DodgeSkillShots"].As <MenuKeyBind>().Enabled == false)
            {
                lastPosInfo = PositionInfo.SetAllUndodgeable();
                EvadeSpell.UseEvadeSpell();
                return;
            }

            if (ObjectCache.myHeroCache.serverPos2D.CheckDangerousPos(0) ||
                ObjectCache.myHeroCache.serverPos2DExtra.CheckDangerousPos(0))
            {
                if (EvadeSpell.PreferEvadeSpell())
                {
                    lastPosInfo = PositionInfo.SetAllUndodgeable();
                }
                else
                {
                    var posInfo          = EvadeHelper.GetBestPosition();
                    var calculationTimer = EvadeUtils.TickCount;
                    var caculationTime   = EvadeUtils.TickCount - calculationTimer;
                    //computing time

                    /*if (numCalculationTime > 0)
                     * {
                     *  sumCalculationTime += caculationTime;
                     *  avgCalculationTime = sumCalculationTime / numCalculationTime;
                     * }
                     * numCalculationTime += 1;*/

                    //Console.WriteLine("CalculationTime: " + caculationTime);

                    /*if (EvadeHelper.GetHighestDetectedSpellID() > EvadeHelper.GetHighestSpellID(posInfo))
                     * {
                     *  return;
                     * }*/
                    if (posInfo != null)
                    {
                        lastPosInfo = posInfo.CompareLastMovePos();

                        var travelTime = ObjectCache.myHeroCache.serverPos2DPing.Distance(lastPosInfo.position) /
                                         myHero.MoveSpeed;

                        lastPosInfo.endTime = EvadeUtils.TickCount + travelTime * 1000 - 100;
                    }

                    CheckHeroInDanger();

                    if (EvadeUtils.TickCount > lastStopEvadeTime)
                    {
                        DodgeSkillShots(); //walking
                    }
                    CheckLastMoveTo();
                    EvadeSpell.UseEvadeSpell(); //using spells
                }
            }
            else
            {
                lastPosInfo = PositionInfo.SetAllDodgeable();
                CheckLastMoveTo();
            }


            //Console.WriteLine("SkillsDodged: " + lastPosInfo.dodgeableSpells.Count + " DangerLevel: " + lastPosInfo.undodgeableSpells.Count);
        }
Example #10
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"].As <MenuBool>().Enabled)
            {
                var extraWindupDelay = Evade.lastWindupTime - EvadeUtils.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"].As <MenuBool>().Value == false ||
                    GetSpellDangerLevel(evadeSpell) > spell.GetSpellDangerLevel() ||
                    !myHero.SpellBook.CanUseSpell(evadeSpell.spellKey) || 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);

                var finalEvadeTime = spellHitTime - evadeTime;

                if (checkSpell)
                {
                    var mode =
                        Evade.evadeSpellMenu[evadeSpell.charName + evadeSpell.name + "EvadeSpellSettings"][
                            evadeSpell.name + "EvadeSpellMode"]
                        .As <MenuList>().Value;

                    if (mode == 0)
                    {
                        continue;
                    }
                    if (mode == 1)
                    {
                        if (spellActivationTime < finalEvadeTime)
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    //if (Evade.menu[evadeSpell.name + "LastResort"].As<MenuBool>().Enabled)
                    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)
                    {
                        if (evadeSpell.useSpellFunc(evadeSpell, processSpell))
                        {
                            return(true);
                        }
                    }
                }
                else if (evadeSpell.evadeType == 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);
                        }
                    }
                }
                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 - 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());
                            }
                            //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);
                        }
                    }
                }
                else if (evadeSpell.evadeType == EvadeType.WindWall)
                {
                    if (spell.hasProjectile() || evadeSpell.spellName == "FioraW") //temp fix, don't have fiora :'(
                    {
                        var dir = (spell.startPos - ObjectCache.myHeroCache.serverPos2D).Normalized();
                        var pos = ObjectCache.myHeroCache.serverPos2D + dir * 100;

                        if (processSpell)
                        {
                            myHero.SpellBook.CastSpell(evadeSpell.spellKey, pos.To3D());
                        }
                        //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, pos), processSpell);
                        return(true);
                    }
                }
                else if (evadeSpell.evadeType == EvadeType.SpellShield)
                {
                    if (evadeSpell.isItem)
                    {
                        if (processSpell)
                        {
                            myHero.SpellBook.CastSpell(evadeSpell.spellKey);
                        }
                        //CastEvadeSpell(() => myHero.SpellBook.CastSpell(evadeSpell.spellKey), processSpell);
                        return(true);
                    }

                    if (evadeSpell.castType == CastType.Target)
                    {
                        if (processSpell)
                        {
                            myHero.SpellBook.CastSpell(evadeSpell.spellKey, myHero);
                        }
                        // CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, myHero), processSpell);
                        return(true);
                    }

                    if (evadeSpell.castType == CastType.Self)
                    {
                        if (processSpell)
                        {
                            myHero.SpellBook.CastSpell(evadeSpell.spellKey);
                        }
                        //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell);
                        return(true);
                    }
                }
                else if (evadeSpell.evadeType == 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
                    {
                        if (evadeSpell.castType == 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);
                            }
                        }

                        else if (evadeSpell.castType == 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);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Example #11
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);
        }