Пример #1
0
        private void OnUpdate()
        {
            if (Game.IsPaused || recoveryMenu.IsActive || !bottle.CanBeAutoCasted() || !BottleCanBeRefilled() ||
                !manager.MyHero.CanUseItems())
            {
                return;
            }

            var useOnAllies = menu.AutoAllyBottle;
            var useOnSelf   = menu.AutoSelfBottle;

            var bottleTarget = EntityManager <Hero> .Entities
                               .Where(
                x => x.IsValid && x.IsAlive && x.Team == manager.MyHero.Team && !x.IsIllusion &&
                x.Distance2D(manager.MyHero.Position) <= bottle.GetCastRange() && !x.IsInvul())
                               .OrderBy(x => x.FindModifier(ModifierUtils.BottleRegeneration)?.RemainingTime)
                               .FirstOrDefault(
                x => (useOnAllies && x.Handle != manager.MyHero.Handle ||
                      useOnSelf && x.Handle == manager.MyHero.Handle) &&
                (x.Health < x.MaximumHealth || x.Mana < x.MaximumMana));

            if (bottleTarget != null)
            {
                if (bottleTarget.Handle == manager.MyHero.Handle)
                {
                    bottle.Use();
                }
                else
                {
                    bottle.Use(bottleTarget);
                }

                bottle.SetSleep(200);
            }
        }