Exemple #1
0
        public static bool IsUserInvisibleFor(this AIHeroClient unit, float time)
        {
            if (!Flags.HasFlag(ChampionTrackerFlags.VisibilityTracker))
            {
                return(false);
            }

            var hero = ChampionVisibility.FirstOrDefault(x => (Game.Time * 1000 - x.LastVisibleGameTime * 1000 > time) && (Game.Time * 1000 - x.LastVisibleGameTime * 1000 < 4000) && (x.Hero.NetworkId == unit.NetworkId));

            return((hero != null) && StaticCacheProvider.GetChampions(CachedEntityType.EnemyHero).Any(x => (x.NetworkId == hero.Hero.NetworkId) && !x.IsDead && !x.IsHPBarRendered));
        }
Exemple #2
0
        private static void Game_OnTick(EventArgs args)
        {
            if (!Flags.HasFlag(ChampionTrackerFlags.VisibilityTracker))
            {
                return;
            }

            if (Game.Time * 1000 - _lastTick < 25)
            {
                return;
            }

            foreach (var visibilityTracker in ChampionVisibility.Where(x => Game.Time * 1000 - x.LastVisibleGameTime * 1000 < 1000))
            {
                foreach (var unit in StaticCacheProvider.GetChampions(CachedEntityType.EnemyHero,
                                                                      x => (x.Hero == visibilityTracker.Hero.Hero) && !visibilityTracker.Hero.IsDead && !visibilityTracker.Hero.IsZombie && !visibilityTracker.Hero.IsHPBarRendered))
                {
                    if ((unit.Hero == Champion.KogMaw) && unit.Buffs.Any(x => x.Name.ToLowerInvariant() == "kogmawicathiansurprise"))
                    {
                        return;
                    }

                    OnLoseVisibility?.Invoke(null,
                                             new OnLoseVisibilityEventArgs(unit, visibilityTracker.LastVisibleGameTime,
                                                                           visibilityTracker.LastPosition, GetVisibilityTrackerData(unit)));
                }
            }

            foreach (var aiHeroClient in StaticCacheProvider.GetChampions(CachedEntityType.EnemyHero, x => !x.IsDead && x.IsHPBarRendered))
            {
                var hero = ChampionVisibility.FirstOrDefault(x => x.Hero.NetworkId == aiHeroClient.NetworkId);

                if (hero == null)
                {
                    continue;
                }

                hero.LastPosition        = aiHeroClient.Position;
                hero.LastVisibleGameTime = Game.Time;
                hero.LastPath            = aiHeroClient.Path.Last();
                hero.LastHealth          = aiHeroClient.Health;
                hero.LastHealthPercent   = aiHeroClient.HealthPercent;
                hero.LastBuffs           = aiHeroClient.Buffs;
            }
            _lastTick = Game.Time * 1000;
        }
Exemple #3
0
        /// <summary>
        /// Gets the safe position
        /// </summary>
        /// <param name="start">Start vector</param>
        /// <param name="maxDistance">Max distance from start vector</param>
        /// <param name="enemyScanRangge">Max distance from start to enemies</param>
        /// <param name="enemyRange">Range of an enemy</param>
        /// <returns>Safe position</returns>
        public static Dictionary <Vector2, int> GetSafePosition(Vector2 start, float maxDistance, float enemyScanRangge, float enemyRange)
        {
            var list = new Dictionary <Vector2, int>();

            try
            {
                var sortedChampions = StaticCacheProvider.GetChampions(CachedEntityType.EnemyHero, unit => !unit.IsDead && unit.Distance(start) <= enemyScanRangge)
                                      .OrderBy(unit => unit.HealthPercent)
                                      .ToList(); //DangerLevel from lowest

                var pointsInRange = PointsInRange(start, maxDistance);

                var inRange = pointsInRange as IList <Vector2> ?? pointsInRange.ToList();

                if (!sortedChampions.Any())
                {
                    var dic = new Dictionary <Vector2, int>();
                    foreach (var pos in inRange.Where(pos => !dic.Keys.Contains(pos)))
                    {
                        dic.Add(pos, 0);
                    }
                    return(dic);
                }

                foreach (var location in inRange)
                {
                    if (location.Distance(start) > maxDistance)
                    {
                        continue;
                    }

                    foreach (var sortedChampion in sortedChampions)
                    {
                        if (location.IsInRangeCached(sortedChampion, enemyRange)) // location is inside enemy range
                        {
                            var index = sortedChampions.FindIndex(p => p == sortedChampion);

                            if (index > sortedChampions.Count && index != 0)
                            {
                                if (!list.ContainsKey(location))
                                {
                                    list.Add(location, index + 1 + location.CountEnemiesInRangeCached(enemyRange - location.Distance(start)));
                                }
                            }
                            else if (!list.ContainsKey(location))
                            {
                                list.Add(location, 1 + location.CountEnemiesInRangeCached(enemyRange - location.Distance(start)));
                            }
                        }
                        else if (!list.ContainsKey(location))
                        {
                            list.Add(location, 0);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(list);
        }
Exemple #4
0
        private static void DrawingOnEndScene(EventArgs args)
        {
            if (DamageDelegate == null)
            {
                return;
            }

            if (IncludeJungleMobs)
            {
                foreach (
                    var unit in
                    EntityManager.MinionsAndMonsters.GetJungleMonsters(Player.Instance.Position, DrawingRange)
                    .Where(x => x.IsValidTarget() && x.IsHPBarRendered && Drawing.WorldToScreen(x.Position).IsOnScreen()))
                {
                    if (DamageDelegate(unit) <= 0)
                    {
                        return;
                    }

                    int height;
                    int width;

                    int xOffset;
                    int yOffset;

                    if ((unit.Name.Contains("Blue") || unit.Name.Contains("Red")) && !unit.Name.Contains("Mini"))
                    {
                        height  = 9;
                        width   = 142;
                        xOffset = -4;
                        yOffset = 7;
                    }
                    else if (unit.Name.Contains("Dragon"))
                    {
                        height  = 10;
                        width   = 143;
                        xOffset = -4;
                        yOffset = 8;
                    }
                    else if (unit.Name.Contains("Baron"))
                    {
                        height  = 12;
                        width   = 191;
                        xOffset = -29;
                        yOffset = 6;
                    }
                    else if (unit.Name.Contains("Herald"))
                    {
                        height  = 10;
                        width   = 142;
                        xOffset = -4;
                        yOffset = 7;
                    }
                    else if ((unit.Name.Contains("Razorbeak") || unit.Name.Contains("Murkwolf")) &&
                             !unit.Name.Contains("Mini"))
                    {
                        width   = 74;
                        height  = 3;
                        xOffset = 30;
                        yOffset = 7;
                    }
                    else if (unit.Name.Contains("Krug") && !unit.Name.Contains("Mini"))
                    {
                        width   = 80;
                        height  = 3;
                        xOffset = 27;
                        yOffset = 7;
                    }
                    else if (unit.Name.Contains("Gromp"))
                    {
                        width   = 86;
                        height  = 3;
                        xOffset = 24;
                        yOffset = 6;
                    }
                    else if (unit.Name.Contains("Crab"))
                    {
                        width   = 61;
                        height  = 2;
                        xOffset = 36;
                        yOffset = 21;
                    }
                    else if (unit.Name.Contains("RedMini") || unit.Name.Contains("BlueMini") ||
                             unit.Name.Contains("RazorbeakMini"))
                    {
                        height  = 2;
                        width   = 49;
                        xOffset = 42;
                        yOffset = 6;
                    }
                    else if (unit.Name.Contains("KrugMini") || unit.Name.Contains("MurkwolfMini"))
                    {
                        height  = 2;
                        width   = 55;
                        xOffset = 39;
                        yOffset = 6;
                    }
                    else
                    {
                        continue;
                    }

                    var damageAfter   = Math.Max(0, unit.Health - DamageDelegate(unit)) / unit.MaxHealth;
                    var currentHealth = unit.Health / unit.MaxHealth;

                    var start = unit.HPBarPosition.X + xOffset + (damageAfter * width);
                    var end   = unit.HPBarPosition.X + xOffset + (currentHealth * width);

                    Drawing.DrawLine(start, unit.HPBarPosition.Y + yOffset, end, unit.HPBarPosition.Y + yOffset, height, System.Drawing.Color.FromArgb(JungleColor.A, JungleColor.R, JungleColor.G, JungleColor.B));
                }
            }


            foreach (var unit in
                     StaticCacheProvider.GetChampions(CachedEntityType.EnemyHero,
                                                      index => index.IsHPBarRendered && index.IsValidTarget(DrawingRange) && index.Position.IsOnScreen()))
            {
                if (DamageDelegate(unit) <= 0)
                {
                    return;
                }

                const int height = 10;
                const int width  = 106;

                int xOffset;
                int yOffset;

                switch (unit.Hero)
                {
                case Champion.Annie:
                    xOffset = -9;
                    yOffset = -3;
                    break;

                case Champion.Jhin:
                    xOffset = -9;
                    yOffset = -5;
                    break;

                default:
                    xOffset = 2;
                    yOffset = 9;
                    break;
                }

                var damageAfter   = Math.Max(0, unit.TotalHealthWithShields() - DamageDelegate(unit)) / unit.MaxHealth;
                var currentHealth = unit.TotalHealthWithShields() / unit.MaxHealth;

                var start = new Vector2(unit.HPBarPosition.X + xOffset + damageAfter * width, unit.HPBarPosition.Y + yOffset);
                var end   = new Vector2(unit.HPBarPosition.X + currentHealth * width, unit.HPBarPosition.Y + yOffset);

                Line.DrawLine(System.Drawing.Color.FromArgb(Color.A, Color.R, Color.G, Color.B), height, start, end);
            }
        }