Пример #1
0
        public void OnUpdate()
        {
            if (Sleeper.Sleeping("Main"))
            {
                return;
            }

            Sleeper.Sleep(100, "Main");

            if (!Hero.IsAlive || !Hero.CanUseItems() || Game.IsPaused)
            {
                return;
            }

            if (!Sleeper.Sleeping("ManaCheck") && Menu.ManaChecker.Enabled)
            {
                var heroMana = Hero.Mana;

                var manaCost =
                    Hero.Spellbook.Spells.Concat(Hero.Inventory.Items)
                    .Where(x => Menu.ManaChecker.AbilityEnabled(x.StoredName()))
                    .Aggregate(0u, (current, ability) => current + ability.ManaCost);

                if (itemManager.PowerTreads.IsValid() &&
                    itemManager.PowerTreads.DefaultAttribute != Attribute.Intelligence &&
                    Menu.ManaChecker.IncludePtCalcualtions)
                {
                    heroMana += heroMana / Hero.MaximumMana * 117;
                }

                manaLeft = (int)Math.Ceiling(heroMana - manaCost);
                Sleeper.Sleep(1000, "ManaCheck");
            }

            var healing = false;

            if ((Menu.Recovery.Active || (Menu.PowerTreads.Enabled && Menu.PowerTreads.SwitchOnHeal)) &&
                Hero.HasModifiers(Modifiers.Heal, false) &&
                (Hero.Health < Hero.MaximumHealth || Hero.Mana < Hero.MaximumMana))
            {
                var attribute = itemManager.Bottle.GetPowerTreadsAttribute();
                if (attribute != Attribute.Invalid)
                {
                    itemManager.PowerTreads.SwitchTo(attribute);
                }
                healing = true;
            }

            if (Menu.Recovery.Active && itemManager.UsableItems.Any(x => x.CanBeCasted()))
            {
                if (EnemyNear())
                {
                    itemManager.PickUpItems();
                    return;
                }

                if (Hero.NetworkActivity != NetworkActivity.Idle)
                {
                    Hero.Stop();
                }

                if (itemManager.StashBottle.CanBeCasted() && !itemManager.StashBottleTaken)
                {
                    itemManager.TakeBottleFromStash();
                }

                foreach (var item in itemManager.UsableItems.Where(x => x.CanBeCasted()))
                {
                    itemManager.PowerTreads.SwitchTo(item.GetPowerTreadsAttribute());
                    itemManager.DropItems(item.GetDropItemStats(), item.Item);
                    item.Use();
                }

                Sleeper.Sleep(80 * itemManager.DroppedItemsCount() + Game.Ping, "Used", true);
            }
            else if ((!healing && !itemManager.StashBottleTaken) || !Menu.Recovery.Active)
            {
                if (Sleeper.Sleeping("Used"))
                {
                    return;
                }

                if (!Menu.TranquilBoots.DropActive)
                {
                    itemManager.PickUpItems();
                }
            }

            if (Menu.TranquilBoots.DropActive)
            {
                if (EnemyNear())
                {
                    itemManager.PickUpItems();
                    return;
                }
                if (itemManager.TranquilBoots.IsValid())
                {
                    itemManager.DropItem(itemManager.TranquilBoots.Item, false);
                    Sleeper.Sleep(200 + Game.Ping, "Main");
                }
                return;
            }

            if (!Menu.Recovery.Active && fountain.BottleCanBeRefilled() && itemManager.Bottle.CanBeAutoCasted())
            {
                var ignoreAllies = Menu.Recovery.BottleAtFountainIgnoreAllies;

                var bottleTarget =
                    Heroes.GetByTeam(heroTeam)
                    .OrderBy(x => x.FindModifier(Modifiers.BottleRegeneration)?.RemainingTime)
                    .FirstOrDefault(
                        x =>
                        (!ignoreAllies || x.Equals(Hero)) && x.IsAlive && !x.IsInvul() && !x.IsIllusion &&
                        (x.Health < x.MaximumHealth || x.Mana < x.MaximumMana) &&
                        x.Distance2D(Hero) <= itemManager.Bottle.CastRange);

                if (bottleTarget != null)
                {
                    itemManager.Bottle.Use(bottleTarget.Equals(Hero) ? null : bottleTarget);
                }
            }

            if (Menu.TranquilBoots.CombineEnabled && !Menu.Recovery.Active)
            {
                if (itemManager.TranquilBoots.IsValid() && itemManager.TranquilBoots.AssembleTime(10))
                {
                    Menu.TranquilBoots.DisableCombine();
                    return;
                }

                var regen = Hero.FindItem("item_ring_of_regen");

                if (Menu.TranquilBoots.CombineActive)
                {
                    if (itemManager.TranquilBoots.IsValid())
                    {
                        if (itemManager.TranquilBoots.AssembleTime(8))
                        {
                            itemManager.TranquilBoots.Disassemble();
                        }
                    }
                    else if (regen != null)
                    {
                        if (regen.IsCombineLocked)
                        {
                            regen.UnlockCombining();
                        }
                    }
                    else
                    {
                        itemManager.PickUpItems("item_boots", "item_ring_of_protection", "item_ring_of_regen");
                        Sleeper.Sleep(300 + Game.Ping, "Main");
                    }
                }
                else
                {
                    if (itemManager.TranquilBoots.IsValid())
                    {
                        itemManager.TranquilBoots.Disassemble();
                        Sleeper.Sleep(200 + Game.Ping, "Main");
                        return;
                    }
                    if (regen != null && !regen.IsCombineLocked)
                    {
                        regen.LockCombining();
                    }
                    else if (regen == null)
                    {
                        itemManager.PickUpItems("item_ring_of_regen");
                        Sleeper.Sleep(200 + Game.Ping, "Main");
                    }
                    else
                    {
                        if (Hero.FindItem("item_boots") == null || Hero.FindItem("item_ring_of_protection") == null)
                        {
                            itemManager.PickUpItems("item_boots", "item_ring_of_protection");
                            Sleeper.Sleep(200 + Game.Ping, "Main");
                        }
                    }
                }
            }

            if (!Menu.PowerTreads.Enabled || !itemManager.PowerTreads.IsValid())
            {
                return;
            }

            if (!Sleeper.Sleeping("SwitchBackPT") && !itemManager.PowerTreads.DelaySwitch() &&
                itemManager.PowerTreads.ActiveAttribute != itemManager.PowerTreads.DefaultAttribute && !healing)
            {
                if (heroAttacking)
                {
                    var attribute = Menu.PowerTreads.Attributes.ElementAt(Menu.PowerTreads.SwitchOnAttack).Value;
                    if (itemManager.PowerTreads.ActiveAttribute != attribute)
                    {
                        itemManager.PowerTreads.SwitchTo(attribute);
                    }
                }
                else
                {
                    itemManager.PowerTreads.SwitchTo(itemManager.PowerTreads.DefaultAttribute);
                }
            }
        }