public static void Init()
        {
            // Clears and adds new HealthRelics and bardhealthshrines.
            HealthRelics.Clear();
            foreach (var hr in ObjectManager.Get <GameObject>().Where(o => o != null && o.Name.ToLower().Contains("healthrelic") && o.IsValid && !o.IsDead))
            {
                HealthRelics.Add(hr);
            }

            // Clears and adds new EnemyTraps.
            EnemyTraps.Clear();
            foreach (var trap in ObjectManager.Get <Obj_AI_Minion>().Where(trap => trap.IsEnemy && !trap.IsDead && trap.IsValid))
            {
                if (TrapsNames.Contains(trap.Name))
                {
                    var ttrap = new traps {
                        Trap = trap, IsSpecial = false
                    };
                    EnemyTraps.Add(ttrap);
                } /*
                   * if (SpecialTrapsNames.Contains(trap.Name))
                   * {
                   * var ttrap = new traps { Trap = trap, IsSpecial = true };
                   * EnemyTraps.Add(ttrap);
                   * }*/
            }

            Game.OnTick += delegate
            {
                HealthRelics.AddRange(
                    ObjectManager.Get <GameObject>()
                    .Where(o => o.Name.Equals("bardhealthshrine", StringComparison.CurrentCultureIgnoreCase) && o.IsAlly && o.IsValid && !o.IsDead)
                    .Where(hr => hr != null && !HealthRelics.Contains(hr) && Logger.Send("Added " + hr.Name, Logger.LogLevel.Info)));

                // Removes HealthRelics and Enemy Traps.

                HealthRelics.RemoveAll(h => h == null || !h.IsValid || h.IsDead || EntityManager.Heroes.AllHeroes.Any(a => !a.IsDead && a.IsValidTarget() && a.Distance(h) <= a.BoundingRadius + h.BoundingRadius));
                EnemyTraps.RemoveAll(t => t.Trap == null || !t.Trap.IsValid || t.Trap.IsDead || EntityManager.Heroes.Allies.Any(a => !a.IsDead && a.IsValidTarget() && a.Distance(t.Trap) <= a.BoundingRadius + t.Trap.BoundingRadius));
            };

            GameObject.OnCreate += GameObject_OnCreate;
            GameObject.OnDelete += GameObject_OnDelete;
        }
Exemple #2
0
        public static void Init()
        {
            // Clears and adds new HealthRelics and bardhealthshrines.
            HealthRelics.Clear();
            foreach (var hr in ObjectManager.Get <GameObject>().Where(o => o != null && o.Name.ToLower().Contains("healthrelic") && o.IsValid && !o.IsDead))
            {
                var validrelic = ObjectManager.GetUnitByNetworkId <Obj_AI_Base>((uint)hr.NetworkId)?.PredictHealth() > 0;
                if (validrelic)
                {
                    HealthRelics.Add(hr);
                }
            }

            // Clears and adds new EnemyTraps.
            EnemyTraps.Clear();
            foreach (var trap in ObjectManager.Get <Obj_AI_Minion>().Where(trap => trap.IsEnemy && !trap.IsDead && trap.IsValid))
            {
                if (TrapsNames.Contains(trap.Name))
                {
                    var ttrap = new traps {
                        Trap = trap, IsSpecial = false
                    };
                    EnemyTraps.Add(ttrap);
                } /*
                   * if (SpecialTrapsNames.Contains(trap.Name))
                   * {
                   * var ttrap = new traps { Trap = trap, IsSpecial = true };
                   * EnemyTraps.Add(ttrap);
                   * }*/
            }

            var lastupdate = 0f;

            Game.OnTick += delegate
            {
                if (Core.GameTickCount - lastupdate > Misc.ProtectFPS + 200)
                {
                    foreach (var bardhs in ObjectManager.Get <GameObject>()
                             .Where(o => o.Name.Equals("bardhealthshrine", StringComparison.CurrentCultureIgnoreCase) && o.IsAlly && o.IsValid && !o.IsDead && !HealthRelics.Contains(o)))
                    {
                        HealthRelics.Add(bardhs);
                        Logger.Send("Added " + bardhs.Name);
                    }

                    // Removes HealthRelics and Enemy Traps.
                    HealthRelics.RemoveAll(h => h == null || !h.IsValid || h.IsDead || EntityManager.Heroes.AllHeroes.Any(a => a.IsValidTarget() && a.Distance(h) <= a.BoundingRadius + h.BoundingRadius));
                    EnemyTraps.RemoveAll(t => t.Trap == null || !t.Trap.IsValid || t.Trap.IsDead || EntityManager.Heroes.Allies.Any(a => a.IsValidTarget() && a.Distance(t.Trap) <= a.BoundingRadius + t.Trap.BoundingRadius));
                    lastupdate = Core.GameTickCount;
                    ZacPassives.RemoveAll(p => p.IsDead || !p.IsValid);
                }
            };

            GameObject.OnCreate += GameObject_OnCreate;
            GameObject.OnDelete += GameObject_OnDelete;
        }