Пример #1
0
        private static void Game_OnOnGameUpdate(EventArgs args)
        {
            PlayerPosition = ObjectManager.Player.ServerPosition.To2D();

            //Set evading to false after blinking
            if (PreviousTickPosition.IsValid() &&
                PlayerPosition.Distance(PreviousTickPosition) > 200)
            {
                Evading = false;
            }

            PreviousTickPosition = PlayerPosition;

            //Remove the detected skillshots that have expired.
            DetectedSkillshots.RemoveAll(skillshot => !skillshot.IsActive());

            //Trigger OnGameUpdate on each skillshot.
            foreach (var skillshot in DetectedSkillshots)
            {
                skillshot.Game_OnGameUpdate();
            }

            //Evading disabled
            if (!Config.Menu.Item("Enabled").GetValue <KeyBind>().Active)
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            if (PlayerChampionName == "Olaf" && Config.Menu.Item("DisableEvadeForOlafR").GetValue <bool>() && ObjectManager.Player.HasBuff("OlafRagnarok"))
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            //Avoid sending move/cast packets while dead.
            if (ObjectManager.Player.IsDead)
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            //Avoid sending move/cast packets while channeling interruptable spells that cause hero not being able to move.
            if (ObjectManager.Player.IsCastingInterruptableSpell(true))
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            if (ObjectManager.Player.Spellbook.IsAutoAttacking && !Orbwalking.IsAutoAttack(ObjectManager.Player.LastCastedSpellName()))
            {
                Evading = false;
                return;
            }

            /*Avoid evading while stunned or immobile.*/
            if (Utils.ImmobileTime(ObjectManager.Player) - Utils.TickCount > Game.Ping / 2 + 70)
            {
                Evading = false;
                return;
            }

            /*Avoid evading while dashing.*/
            if (ObjectManager.Player.IsDashing())
            {
                Evading = false;
                return;
            }

            //Don't evade while casting R as sion
            if (PlayerChampionName == "Sion" && ObjectManager.Player.HasBuff("SionR"))
            {
                PathFollower.Stop();
                return;
            }

            //Spell Shielded
            if (ObjectManager.Player.IsSpellShielded())
            {
                PathFollower.Stop();
                return;
            }

            if (NoSolutionFound)
            {
                PathFollower.Stop();
            }

            var currentPath = ObjectManager.Player.Path.ToList().To2D();
            var safeResult  = IsSafe(PlayerPosition);
            var safePath    = IsSafePath(currentPath, 100);

            /*FOLLOWPATH*/
            if (FollowPath && !NoSolutionFound && (Keepfollowing || !Evading) && EvadeToPoint.IsValid() && safeResult.IsSafe)
            {
                if (EvadeSpellDatabase.Spells.Any(evadeSpell => evadeSpell.Name == "Walking" && evadeSpell.Enabled))
                {
                    //if (Utils.TickCount - lastSentMovePacketT2 > 300)
                    //{
                    //    var candidate = Pathfinding.Pathfinding.PathFind(PlayerPosition, EvadeToPoint);
                    //    PathFollower.Follow(candidate);
                    //    lastSentMovePacketT2 = Utils.TickCount;
                    //}
                }
            }
            else
            {
                FollowPath = false;
            }

            NoSolutionFound = false;

            //Continue evading
            if (Evading && IsSafe(EvadePoint).IsSafe)
            {
                if (safeResult.IsSafe)
                {
                    //We are safe, stop evading.
                    Evading = false;
                }
                else
                {
                    if (Utils.TickCount - lastSentMovePacketT > 1000 / 15)
                    {
                        lastSentMovePacketT = Utils.TickCount;
                        ObjectManager.Player.SendMovePacket(EvadePoint);
                    }
                    return;
                }
            }
            //Stop evading if the point is not safe.
            else if (Evading)
            {
                Evading = false;
            }

            //The path is not safe.
            if (!safePath.IsSafe)
            {
                //Inside the danger polygon.
                if (!safeResult.IsSafe)
                {
                    //Search for an evade point:
                    TryToEvade(safeResult.SkillshotList, EvadeToPoint.IsValid() ? EvadeToPoint : Game.CursorPos.To2D());
                }
                //Outside the danger polygon.
                else
                {
                    FollowPath = true;
                    //Stop at the edge of the skillshot.
                    if (EvadeSpellDatabase.Spells.Any(evadeSpell => evadeSpell.Name == "Walking" && evadeSpell.Enabled))
                    {
                        //    ObjectManager.Player.SendMovePacket(safePath.Intersection.Point);
                    }
                }
            }
        }
Пример #2
0
        private void OnGameWndProc(WndEventArgs args)
        {
            try
            {
                if (!Menu.Item(Name + "Clickable").GetValue <bool>())
                {
                    return;
                }

                var index = 0;

                var hudWidth  = (float)Math.Ceiling(HudWidth * _scale);
                var hudHeight = (float)Math.Ceiling(HudHeight * _scale);

                var spacing =
                    (float)
                    Math.Ceiling((10f + Menu.Item(Menu.Name + "DrawingSpacing").GetValue <Slider>().Value) * _scale) +
                    hudHeight;

                var offsetTop   = Menu.Item(Menu.Name + "DrawingOffsetTop").GetValue <Slider>().Value + hudHeight / 2;
                var offsetRight = Drawing.Width - Menu.Item(Menu.Name + "DrawingOffsetRight").GetValue <Slider>().Value -
                                  (hudWidth + (float)Math.Ceiling(4 * _scale)) / 2f;

                if (args.Msg == (uint)WindowsMessages.WM_RBUTTONUP ||
                    args.Msg == (uint)WindowsMessages.WM_LBUTTONDBLCLK)
                {
                    var pos = Utils.GetCursorPos();
                    foreach (var enemy in _enemyObjects)
                    {
                        var offset = spacing * index;
                        if (args.Msg == (uint)WindowsMessages.WM_LBUTTONDBLCLK)
                        {
                            var spellData = _spellDatas[enemy.Unit.NetworkId];
                            for (var i = 0; spellData.Count > i; i++)
                            {
                                var spell = spellData[i];
                                if (spell != null)
                                {
                                    if (Utils.IsUnderRectangle(
                                            pos, offsetRight + hudWidth * 0.359f - SummonerWidth / 2f,
                                            offsetTop - hudHeight * 0.28f + offset + (float)Math.Ceiling(26 * _scale) * i -
                                            SummonerHeight / 2f, SummonerWidth, SummonerHeight))
                                    {
                                        var teleportCd = 0f;
                                        if (spell.Name.Contains("Teleport", StringComparison.OrdinalIgnoreCase) &&
                                            _teleports.ContainsKey(enemy.Unit.NetworkId))
                                        {
                                            _teleports.TryGetValue(enemy.Unit.NetworkId, out teleportCd);
                                        }
                                        var time = (teleportCd > 0.1f ? teleportCd : spell.CooldownExpires) - Game.Time;
                                        if (time > 0 && Environment.TickCount > _lastChatSend + 1500)
                                        {
                                            _lastChatSend = Environment.TickCount;
                                            var sName = ReadableSummonerName(spell.Name);
                                            Game.Say(
                                                string.Format(
                                                    "{0} {1} {2}", enemy.Unit.ChampionName, sName,
                                                    ((float)(Math.Round(time * 2f, MidpointRounding.AwayFromZero) / 2f))
                                                    .FormatTime()));
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (enemy.Unit.IsVisible && !enemy.Unit.IsDead &&
                                Utils.IsUnderRectangle(
                                    pos, offsetRight - hudWidth / 2f + hudWidth * 0.1f,
                                    offsetTop + offset - hudHeight / 2f, hudWidth, hudHeight))
                            {
                                ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo, enemy.Unit);
                            }
                        }
                        index++;
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
Пример #3
0
 /// <summary>
 ///     Saves the specificed entry.
 /// </summary>
 /// <param name="name">
 ///     The name of the entry.
 /// </param>
 /// <param name="entires">
 ///     The entires.
 /// </param>
 public static void Save(string name, Dictionary<string, byte[]> entires)
 {
     try
     {
         Directory.CreateDirectory(MenuSettings.MenuConfigPath);
         File.WriteAllBytes(Path.Combine(MenuSettings.MenuConfigPath, name + ".bin"), Utils.Serialize(entires));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }