private async Task OnAutoRegeneration(PowerTreads treads)
        {
            var unitsWithinRange = ObjectManager.GetEntities <Unit>().Any(
                u => u.IsValid && u.IsAlive && u.Team != _hero.Team &&
                _hero.Distance2D(u) < _hero.GetAttackRange() + (_hero.IsMelee ? 300 : 100));

            if (IsLowHealth)
            {
                await SetBootsAttributeAsync(treads, Ensage.Attribute.Strength);

                return;
            }

            if (unitsWithinRange ||
                _hero.Animation.Name.Contains("attack") ||
                _hero.IsAttacking() ||
                _hero.Target != null)
            {
                return;
            }


            if (_configs.SwitchingDelay.Value > 0)
            {
                await Task.Delay(_configs.SwitchingDelay.Value * 1000);
            }
            if (IsFullManaAndHealth)
            {
                await SetBootsAttributeAsync(treads, _hero.PrimaryAttribute);

                return;
            }

            if (!_hero.Mana.Equals(_hero.MaximumMana))
            {
                await SetBootsAttributeAsync(treads, Ensage.Attribute.Intelligence);
            }
            else
            {
                await SetBootsAttributeAsync(treads, Ensage.Attribute.Strength);
            }
        }
        private async Task SetBootsAttributeAsync(PowerTreads boots, Ensage.Attribute targetAttribute)
        {
            if (boots.ActiveAttribute == targetAttribute || _isSwitching)
            {
                return;
            }

            while (boots.ActiveAttribute != targetAttribute)
            {
                if (_hero.IsInvisible() && _hero.HeroId != HeroId.npc_dota_hero_riki)
                {
                    _isSwitching = false;
                    break;
                }
                _isSwitching = true;
                boots.UseAbility();
                await Task.Delay(_configs.SwitchingSpeed.Value + (_configs.RandomizeSwitches ? _random.Next(5, 50) : 0)); //Randomize this a bit..
            }
            _isSwitching = false;
        }
Exemple #3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="PowerTreadsSwitcher" /> class.
 /// </summary>
 /// <param name="powerTreads">
 ///     The power treads.
 /// </param>
 public PowerTreadsSwitcher(PowerTreads powerTreads)
 {
     this.PowerTreads = powerTreads;
 }
Exemple #4
0
        private static void Game_OnUpdate(EventArgs args)
        {
            if (!Utils.SleepCheck("HpMpAbuseDelay"))
            {
                return;
            }

            if (!inGame)
            {
                hero = ObjectMgr.LocalHero;

                if (!Game.IsInGame || hero == null)
                {
                    Utils.Sleep(1000, "HpMpAbuseDelay");
                    return;
                }

                AbilitiesPT.Clear();
                AbilitiesSR.Clear();
                AbilitiesMC.Clear();
                ItemSlots.Clear();

                lastPtAttribute = Attribute.Strength;
                stopAttack      = true;
                ptChanged       = healActive = disableSwitchBack = attacking = enabledRecovery = false;

                if (autoDisablePT)
                {
                    PTMenu.Item("enabledPT").SetValue(true).DontSave();
                    autoDisablePT = false;
                }

                inGame = true;
            }

            if (!Game.IsInGame)
            {
                inGame = false;
                return;
            }

            if (!hero.IsAlive || Game.IsPaused)
            {
                Utils.Sleep(Menu.Item("checkPTdelay").GetValue <Slider>().Value, "HpMpAbuseDelay");
                return;
            }

            var reloadMenu = false;

            foreach (var spell in hero.Spellbook.Spells.Where(CheckAbility))
            {
                if (spell.ClassID != ClassID.CDOTA_Ability_SkeletonKing_Reincarnation)
                {
                    AbilitiesPT.Add(spell.Name, true);
                    AbilitiesSR.Add(spell.Name, true);
                }
                AbilitiesMC.Add(spell.Name, false);
                reloadMenu = true;
            }

            foreach (var item in hero.Inventory.Items.Where(CheckAbility))
            {
                AbilitiesPT.Add(item.Name, true);
                AbilitiesSR.Add(item.Name, true);
                AbilitiesMC.Add(item.Name, false);
                reloadMenu = true;
            }

            if (reloadMenu)
            {
                PTMenu.Item("enabledPTAbilities").SetValue((new AbilityToggler(AbilitiesPT))).DontSave();
                SoulRingMenu.Item("enabledSRAbilities").SetValue((new AbilityToggler(AbilitiesSR))).DontSave();
                ManaCheckMenu.Item("enabledMCAbilities").SetValue((new AbilityToggler(AbilitiesMC))).DontSave();
            }

            if (!autoDisablePT && Game.GameTime / 60 > PTMenu.Item("autoPTdisable").GetValue <Slider>().Value&&
                PTMenu.Item("autoPTdisable").GetValue <Slider>().Value != 0 && PTMenu.Item("enabledPT").GetValue <bool>())
            {
                PTMenu.Item("enabledPT").SetValue(false).DontSave();
                autoDisablePT = true;
            }

            if (autoDisablePT && PTMenu.Item("enabledPT").GetValue <bool>())
            {
                autoDisablePT = false;
            }

            powerTreads = (PowerTreads)hero.FindItem("item_power_treads");

            if (powerTreads != null && !ptChanged && !attacking)
            {
                switch (powerTreads.ActiveAttribute)
                {
                case Attribute.Intelligence:     // agi
                    lastPtAttribute = Attribute.Agility;
                    break;

                case Attribute.Strength:
                    lastPtAttribute = Attribute.Strength;
                    break;

                case Attribute.Agility:     // int
                    lastPtAttribute = Attribute.Intelligence;
                    break;
                }
            }

            if (attacking)
            {
                ChangePtOnAction("switchPTonAttack", true);
            }

            if (ManaCheckMenu.Item("enabledMC").GetValue <bool>())
            {
                var heroMana = hero.Mana;

                var manaCost = (from ability in AbilitiesMC
                                where ManaCheckMenu.Item("enabledMCAbilities")
                                .GetValue <AbilityToggler>()
                                .IsEnabled(ability.Key)
                                select hero.FindSpell(ability.Key) ?? hero.FindItem(ability.Key))
                               .Aggregate <Ability, uint>(0,
                                                          (current, spell) => current + spell.ManaCost);

                if (powerTreads != null && lastPtAttribute != Attribute.Intelligence &&
                    ManaCheckMenu.Item("mcPTcalculations").GetValue <bool>())
                {
                    heroMana += heroMana / hero.MaximumMana * 117;
                }

                manaLeft = (int)Math.Ceiling(heroMana - manaCost);
            }

            if (enabledRecovery && (hero.Mana < hero.MaximumMana || hero.Health < hero.MaximumHealth))
            {
                if (ObjectMgr.GetEntities <Hero>().Any(x =>
                                                       x.IsAlive && x.IsVisible && x.Team == hero.GetEnemyTeam() &&
                                                       x.Distance2D(hero) <= RecoveryMenu.Item("forcePickEnemyNearDistance").GetValue <Slider>().Value))
                {
                    PickUpItems();
                    Utils.Sleep(1000, "HpMpAbuseDelay");
                    return;
                }

                var arcaneBoots = hero.FindItem("item_arcane_boots");
                var greaves     = hero.FindItem("item_guardian_greaves");
                var soulRing    = hero.FindItem("item_soul_ring");
                var bottle      = hero.FindItem("item_bottle");
                var stick       = hero.FindItem("item_magic_stick") ?? hero.FindItem("item_magic_wand");
                var meka        = hero.FindItem("item_mekansm");
                var urn         = hero.FindItem("item_urn_of_shadows");

                if (meka != null && meka.CanBeCasted() && hero.Health != hero.MaximumHealth)
                {
                    ChangePowerTreads(Attribute.Intelligence);
                    DropItems(BonusHealth, meka);
                    meka.UseAbility(true);
                }

                if (arcaneBoots != null && arcaneBoots.CanBeCasted() && hero.Mana < hero.MaximumMana)
                {
                    ChangePowerTreads(Attribute.Agility);
                    DropItems(BonusMana, arcaneBoots);
                    arcaneBoots.UseAbility(true);
                }

                if (greaves != null && greaves.CanBeCasted())
                {
                    ChangePowerTreads(Attribute.Agility);
                    DropItems(BonusHealth.Concat(BonusMana), greaves);
                    greaves.UseAbility(true);
                }

                if (soulRing != null && soulRing.CanBeCasted())
                {
                    ChangePowerTreads(Attribute.Strength);
                    DropItems(BonusMana);
                    soulRing.UseAbility(true);
                }

                var bottleRegen = hero.Modifiers.FirstOrDefault(x => x.Name == "modifier_bottle_regeneration");

                if (bottle != null && bottle.CanBeCasted() && bottle.CurrentCharges != 0 &&
                    (bottleRegen == null || bottleRegen.RemainingTime < 0.2))
                {
                    if ((float)hero.Health / hero.MaximumHealth < 0.9)
                    {
                        DropItems(BonusHealth);
                    }
                    if (hero.Mana / hero.MaximumMana < 0.9)
                    {
                        DropItems(BonusMana);
                    }

                    bottle.UseAbility(true);
                }

                if (stick != null && stick.CanBeCasted() && stick.CurrentCharges != 0)
                {
                    ChangePowerTreads(Attribute.Agility);

                    if ((float)hero.Health / hero.MaximumHealth < 0.9)
                    {
                        DropItems(BonusHealth, stick);
                    }
                    if (hero.Mana / hero.MaximumMana < 0.9)
                    {
                        DropItems(BonusMana, stick);
                    }

                    stick.UseAbility(true);
                }

                if (urn != null && urn.CanBeCasted() && urn.CurrentCharges != 0 &&
                    hero.Modifiers.All(x => x.Name != "modifier_item_urn_heal") &&
                    (float)hero.Health / hero.MaximumHealth < 0.9)
                {
                    DropItems(BonusHealth, urn);
                    urn.UseAbility(hero, true);
                }

                if (hero.Modifiers.Any(x => HealModifiers.Any(x.Name.Equals)))
                {
                    if ((float)hero.Health / hero.MaximumHealth < 0.9)
                    {
                        DropItems(BonusHealth);
                    }
                    if (hero.Mana / hero.MaximumMana < 0.9 && bottleRegen != null)
                    {
                        DropItems(BonusMana);
                    }
                }

                var allies =
                    ObjectMgr.GetEntities <Hero>()
                    .Where(x => x.Distance2D(hero) <= 900 && x.IsAlive && x.Team == hero.Team);

                foreach (var ally in allies)
                {
                    var allyArcaneBoots = ally.FindItem("item_arcane_boots");
                    var allyMeka        = ally.FindItem("item_mekansm");
                    var allyGreaves     = ally.FindItem("item_guardian_greaves");

                    if (allyArcaneBoots != null && allyArcaneBoots.AbilityState == AbilityState.Ready)
                    {
                        ChangePowerTreads(Attribute.Agility);
                        DropItems(BonusMana);
                    }

                    if (allyMeka != null && allyMeka.AbilityState == AbilityState.Ready)
                    {
                        ChangePowerTreads(Attribute.Agility);
                        DropItems(BonusHealth);
                    }

                    if (allyGreaves != null && allyGreaves.AbilityState == AbilityState.Ready)
                    {
                        ChangePowerTreads(Attribute.Agility);
                        DropItems(BonusMana.Concat(BonusHealth));
                    }
                }
            }

            if (powerTreads == null)
            {
                Utils.Sleep(Menu.Item("checkPTdelay").GetValue <Slider>().Value, "HpMpAbuseDelay");
                return;
            }

            disableSwitchBack = hero.Modifiers.Any(x => DisableSwitchBackModifiers.Any(x.Name.Equals));

            if (hero.Modifiers.Any(x => HealModifiers.Any(x.Name.Equals)) && !disableSwitchBack &&
                (PTMenu.Item("switchPTHeal").GetValue <bool>() && PTMenu.Item("enabledPT").GetValue <bool>() ||
                 enabledRecovery))
            {
                if (hero.Modifiers.Any(
                        x => (x.Name == "modifier_bottle_regeneration" || x.Name == "modifier_clarity_potion")))
                {
                    if (hero.Mana / hero.MaximumMana < 0.9 && (float)hero.Health / hero.MaximumHealth > 0.9)
                    {
                        if (lastPtAttribute == Attribute.Intelligence)
                        {
                            ChangePowerTreads(Attribute.Strength, true, true);
                        }
                        else
                        {
                            healActive = false;
                        }
                    }
                    else if (hero.Mana / hero.MaximumMana > 0.9 && (float)hero.Health / hero.MaximumHealth < 0.9)
                    {
                        if (lastPtAttribute == Attribute.Strength)
                        {
                            if (hero.PrimaryAttribute == Attribute.Agility)
                            {
                                ChangePowerTreads(Attribute.Agility, true, true);
                            }
                            else if (hero.PrimaryAttribute == Attribute.Intelligence)
                            {
                                ChangePowerTreads(Attribute.Intelligence, true, true);
                            }
                        }
                        else
                        {
                            healActive = false;
                        }
                    }
                    else if (hero.Mana / hero.MaximumMana < 0.9 && (float)hero.Health / hero.MaximumHealth < 0.9)
                    {
                        ChangePowerTreads(Attribute.Agility, true, true);
                    }
                    else
                    {
                        healActive = false;
                    }
                }
                else
                {
                    if ((float)hero.Health / hero.MaximumHealth < 0.9)
                    {
                        if (lastPtAttribute == Attribute.Strength)
                        {
                            if (hero.PrimaryAttribute == Attribute.Agility)
                            {
                                ChangePowerTreads(Attribute.Agility, true, true);
                            }
                            else if (hero.PrimaryAttribute == Attribute.Intelligence)
                            {
                                ChangePowerTreads(Attribute.Intelligence, true, true);
                            }
                        }
                        else
                        {
                            healActive = false;
                        }
                    }
                    else if (hero.Health == hero.MaximumHealth && healActive)
                    {
                        healActive = false;
                    }
                }
            }
            else
            {
                healActive = false;
            }

            if (ptChanged && !healActive && !disableSwitchBack && !enabledRecovery && !attacking)
            {
                foreach (var spell in hero.Spellbook.Spells.Where(spell => spell.IsInAbilityPhase))
                {
                    Utils.Sleep(
                        spell.FindCastPoint() * 1000 + PTMenu.Item("switchbackPTdelay").GetValue <Slider>().Value,
                        "HpMpAbuseDelay");
                    return;
                }

                ChangePowerTreads(lastPtAttribute, false);
            }

            Utils.Sleep(Menu.Item("checkPTdelay").GetValue <Slider>().Value, "HpMpAbuseDelay");
        }
Exemple #5
0
        private static void Game_OnUpdate(EventArgs args) {
            if (!Utils.SleepCheck("HpMpAbuseDelay"))
                return;

            if (!inGame) {
                hero = ObjectMgr.LocalHero;

                if (!Game.IsInGame || hero == null) {
                    Utils.Sleep(1000, "HpMpAbuseDelay");
                    return;
                }

                AbilitiesPT.Clear();
                AbilitiesSR.Clear();
                AbilitiesMC.Clear();
                ItemSlots.Clear();

                lastPtAttribute = Attribute.Strength;
                stopAttack = true;
                ptChanged = healActive = disableSwitchBack = attacking = enabledRecovery = false;

                if (autoDisablePT) {
                    PTMenu.Item("enabledPT").SetValue(true).DontSave();
                    autoDisablePT = false;
                }

                inGame = true;
            }

            if (!Game.IsInGame) {
                inGame = false;
                return;
            }

            if (!hero.IsAlive || Game.IsPaused) {
                Utils.Sleep(Menu.Item("checkPTdelay").GetValue<Slider>().Value, "HpMpAbuseDelay");
                return;
            }

            var reloadMenu = false;

            foreach (var spell in hero.Spellbook.Spells.Where(CheckAbility)) {
                if (spell.ClassID != ClassID.CDOTA_Ability_SkeletonKing_Reincarnation) {
                    AbilitiesPT.Add(spell.Name, true);
                    AbilitiesSR.Add(spell.Name, true);
                }
                AbilitiesMC.Add(spell.Name, false);
                reloadMenu = true;
            }

            foreach (var item in hero.Inventory.Items.Where(CheckAbility)) {
                AbilitiesPT.Add(item.Name, true);
                AbilitiesSR.Add(item.Name, true);
                AbilitiesMC.Add(item.Name, false);
                reloadMenu = true;
            }

            if (reloadMenu) {
                PTMenu.Item("enabledPTAbilities").SetValue((new AbilityToggler(AbilitiesPT))).DontSave();
                SoulRingMenu.Item("enabledSRAbilities").SetValue((new AbilityToggler(AbilitiesSR))).DontSave();
                ManaCheckMenu.Item("enabledMCAbilities").SetValue((new AbilityToggler(AbilitiesMC))).DontSave();
            }

            if (!autoDisablePT && Game.GameTime / 60 > PTMenu.Item("autoPTdisable").GetValue<Slider>().Value &&
                PTMenu.Item("autoPTdisable").GetValue<Slider>().Value != 0 && PTMenu.Item("enabledPT").GetValue<bool>()) {
                PTMenu.Item("enabledPT").SetValue(false).DontSave();
                autoDisablePT = true;
            }

            if (autoDisablePT && PTMenu.Item("enabledPT").GetValue<bool>())
                autoDisablePT = false;

            powerTreads = hero.FindItem("item_power_treads") as PowerTreads;

            if (powerTreads != null && !ptChanged && !attacking) {
                switch (powerTreads.ActiveAttribute) {
                    case Attribute.Intelligence: // agi
                        lastPtAttribute = Attribute.Agility;
                        break;
                    case Attribute.Strength:
                        lastPtAttribute = Attribute.Strength;
                        break;
                    case Attribute.Agility: // int
                        lastPtAttribute = Attribute.Intelligence;
                        break;
                }
            }

            if (attacking)
                ChangePtOnAction("switchPTonAttack", true);

            if (ManaCheckMenu.Item("enabledMC").GetValue<bool>()) {
                var heroMana = hero.Mana;

                var manaCost = (from ability in AbilitiesMC
                                where ManaCheckMenu.Item("enabledMCAbilities")
                                    .GetValue<AbilityToggler>()
                                    .IsEnabled(ability.Key)
                                select hero.FindSpell(ability.Key) ?? hero.FindItem(ability.Key))
                    .Aggregate<Ability, uint>(0,
                        (current, spell) => current + spell.ManaCost);

                if (powerTreads != null && lastPtAttribute != Attribute.Intelligence &&
                    ManaCheckMenu.Item("mcPTcalculations").GetValue<bool>()) {
                    heroMana += heroMana / hero.MaximumMana * 117;
                }

                manaLeft = (int) Math.Ceiling(heroMana - manaCost);
            }

            if (enabledRecovery && (hero.Mana < hero.MaximumMana || hero.Health < hero.MaximumHealth)) {
                if (ObjectMgr.GetEntities<Hero>().Any(x =>
                    x.IsAlive && x.IsVisible && x.Team == hero.GetEnemyTeam() &&
                    x.Distance2D(hero) <= RecoveryMenu.Item("forcePickEnemyNearDistance").GetValue<Slider>().Value)) {
                    PickUpItems();
                    Utils.Sleep(1000, "HpMpAbuseDelay");
                    return;
                }

                var arcaneBoots = hero.FindItem("item_arcane_boots");
                var greaves = hero.FindItem("item_guardian_greaves");
                var soulRing = hero.FindItem("item_soul_ring");
                var bottle = hero.FindItem("item_bottle");
                var stick = hero.FindItem("item_magic_stick") ?? hero.FindItem("item_magic_wand");
                var meka = hero.FindItem("item_mekansm");
                var urn = hero.FindItem("item_urn_of_shadows");

                if (meka != null && meka.CanBeCasted() && hero.Health != hero.MaximumHealth) {
                    ChangePowerTreads(Attribute.Intelligence);
                    DropItems(BonusHealth, meka);
                    meka.UseAbility(true);
                }

                if (arcaneBoots != null && arcaneBoots.CanBeCasted() && hero.Mana < hero.MaximumMana) {
                    ChangePowerTreads(Attribute.Agility);
                    DropItems(BonusMana, arcaneBoots);
                    arcaneBoots.UseAbility(true);
                }

                if (greaves != null && greaves.CanBeCasted()) {
                    ChangePowerTreads(Attribute.Agility);
                    DropItems(BonusHealth.Concat(BonusMana), greaves);
                    greaves.UseAbility(true);
                }

                if (soulRing != null && soulRing.CanBeCasted()) {
                    if (((float) hero.Health / hero.MaximumHealth) * 100 >=
                        SoulRingMenu.Item("soulringHPThreshold").GetValue<Slider>().Value &&
                        hero.Mana / hero.MaximumMana * 100 <=
                        SoulRingMenu.Item("soulringMPThreshold").GetValue<Slider>().Value) {
                        ChangePowerTreads(Attribute.Strength);
                        DropItems(BonusMana);
                        soulRing.UseAbility(true);
                    }
                }

                var bottleRegen = hero.Modifiers.FirstOrDefault(x => x.Name == "modifier_bottle_regeneration");

                if (bottle != null && bottle.CanBeCasted() && bottle.CurrentCharges != 0 &&
                    (bottleRegen == null || bottleRegen.RemainingTime < 0.2)) {
                    if ((float) hero.Health / hero.MaximumHealth < 0.9)
                        DropItems(BonusHealth);
                    if (hero.Mana / hero.MaximumMana < 0.9)
                        DropItems(BonusMana);

                    bottle.UseAbility(true);
                }

                if (stick != null && stick.CanBeCasted() && stick.CurrentCharges != 0) {
                    ChangePowerTreads(Attribute.Agility);

                    if ((float) hero.Health / hero.MaximumHealth < 0.9)
                        DropItems(BonusHealth, stick);
                    if (hero.Mana / hero.MaximumMana < 0.9)
                        DropItems(BonusMana, stick);

                    stick.UseAbility(true);
                }

                if (urn != null && urn.CanBeCasted() && urn.CurrentCharges != 0 &&
                    hero.Modifiers.All(x => x.Name != "modifier_item_urn_heal") &&
                    (float) hero.Health / hero.MaximumHealth < 0.9) {
                    DropItems(BonusHealth, urn);
                    urn.UseAbility(hero, true);
                }

                if (hero.Modifiers.Any(x => HealModifiers.Any(x.Name.Equals))) {
                    if ((float) hero.Health / hero.MaximumHealth < 0.9)
                        DropItems(BonusHealth);
                    if (hero.Mana / hero.MaximumMana < 0.9 && bottleRegen != null)
                        DropItems(BonusMana);
                }

                var allies =
                    ObjectMgr.GetEntities<Hero>()
                        .Where(x => x.Distance2D(hero) <= 900 && x.IsAlive && x.Team == hero.Team);

                foreach (var ally in allies) {
                    var allyArcaneBoots = ally.FindItem("item_arcane_boots");
                    var allyMeka = ally.FindItem("item_mekansm");
                    var allyGreaves = ally.FindItem("item_guardian_greaves");

                    if (allyArcaneBoots != null && allyArcaneBoots.AbilityState == AbilityState.Ready) {
                        ChangePowerTreads(Attribute.Agility);
                        DropItems(BonusMana);
                    }

                    if (allyMeka != null && allyMeka.AbilityState == AbilityState.Ready) {
                        ChangePowerTreads(Attribute.Agility);
                        DropItems(BonusHealth);
                    }

                    if (allyGreaves != null && allyGreaves.AbilityState == AbilityState.Ready) {
                        ChangePowerTreads(Attribute.Agility);
                        DropItems(BonusMana.Concat(BonusHealth));
                    }
                }
            }

            if (powerTreads == null) {
                Utils.Sleep(Menu.Item("checkPTdelay").GetValue<Slider>().Value, "HpMpAbuseDelay");
                return;
            }

            disableSwitchBack = hero.Modifiers.Any(x => DisableSwitchBackModifiers.Contains(x.Name));

            if (hero.Modifiers.Any(x => HealModifiers.Any(x.Name.Equals)) && !disableSwitchBack &&
                (PTMenu.Item("switchPTHeal").GetValue<bool>() && PTMenu.Item("enabledPT").GetValue<bool>() ||
                 enabledRecovery)) {
                if (hero.Modifiers.Any(
                    x => (x.Name == "modifier_bottle_regeneration" || x.Name == "modifier_clarity_potion"))) {
                    if (hero.Mana / hero.MaximumMana < 0.9 && (float) hero.Health / hero.MaximumHealth > 0.9) {
                        if (lastPtAttribute == Attribute.Intelligence) {
                            ChangePowerTreads(Attribute.Strength, true, true);
                        } else {
                            healActive = false;
                        }
                    } else if (hero.Mana / hero.MaximumMana > 0.9 && (float) hero.Health / hero.MaximumHealth < 0.9) {
                        if (lastPtAttribute == Attribute.Strength) {
                            if (hero.PrimaryAttribute == Attribute.Agility)
                                ChangePowerTreads(Attribute.Agility, true, true);
                            else if (hero.PrimaryAttribute == Attribute.Intelligence)
                                ChangePowerTreads(Attribute.Intelligence, true, true);
                        } else {
                            healActive = false;
                        }
                    } else if (hero.Mana / hero.MaximumMana < 0.9 && (float) hero.Health / hero.MaximumHealth < 0.9) {
                        ChangePowerTreads(Attribute.Agility, true, true);
                    } else {
                        healActive = false;
                    }
                } else {
                    if ((float) hero.Health / hero.MaximumHealth < 0.9) {
                        if (lastPtAttribute == Attribute.Strength) {
                            if (hero.PrimaryAttribute == Attribute.Agility)
                                ChangePowerTreads(Attribute.Agility, true, true);
                            else if (hero.PrimaryAttribute == Attribute.Intelligence)
                                ChangePowerTreads(Attribute.Intelligence, true, true);
                        } else {
                            healActive = false;
                        }
                    } else if (hero.Health == hero.MaximumHealth && healActive) {
                        healActive = false;
                    }
                }
            } else {
                healActive = false;
            }

            if (ptChanged && !healActive && !disableSwitchBack && !enabledRecovery && !attacking) {
                foreach (var spell in hero.Spellbook.Spells.Where(spell => spell.IsInAbilityPhase)) {
                    Utils.Sleep(spell.FindCastPoint() * 1000 + PTMenu.Item("switchbackPTdelay").GetValue<Slider>().Value,
                        "HpMpAbuseDelay");
                    return;
                }

                ChangePowerTreads(lastPtAttribute, false);
            }

            Utils.Sleep(Menu.Item("checkPTdelay").GetValue<Slider>().Value, "HpMpAbuseDelay");
        }
 public void Refresh()
 {
     powerTreads = manager.MyHero.UsableAbilities.FirstOrDefault(x => x.Id == AbilityId) as PowerTreads;
 }
Exemple #7
0
        public static void Game_OnUpdate(EventArgs args)
        {
            if (!Game.IsInGame || Game.IsPaused || Game.IsWatchingGame)
            {
                return;
            }

            me = ObjectManager.LocalHero;
            if (me == null || me.ClassID != ClassID.CDOTA_Unit_Hero_Clinkz)
            {
                return;
            }

            if (strafe == null)
            {
                strafe = me.Spellbook.SpellQ;
            }

            if (arrows == null)
            {
                arrows = me.Spellbook.SpellW;
            }

            if (dpAbility == null)
            {
                dpAbility = me.Spellbook.SpellR;
            }

            if (bkb == null)
            {
                bkb = me.FindItem("item_black_king_bar");
            }

            if (hex == null)
            {
                hex = me.FindItem("item_sheepstick");
            }

            if (orchid == null)
            {
                orchid = me.FindItem("item_orchid");
            }

            if (bloodthorn == null)
            {
                bloodthorn = me.FindItem("item_bloodthorn");
            }

            if (medallion == null)
            {
                medallion = me.FindItem("item_medallion_of_courage");
            }

            if (bladeMail == null)
            {
                bladeMail = me.FindItem("item_blade_mail");
            }

            if (solar == null)
            {
                solar = me.FindItem("item_solar_crest");
            }

            if (powerTreads == null)
            {
                powerTreads = me.FindItem("item_power_treads") as PowerTreads;
            }

            dragonLance = me.HasModifier("modifier_item_dragon_lance");

            attackRange = dragonLance ? 760 : 630;


            if (!itemTogglerSet)
            {
                itemToggler    = Menu.Item("Items").GetValue <AbilityToggler>();
                itemTogglerSet = true;
            }

            if (!menuSkillSet)
            {
                skillToggler = Menu.Item("Skills").GetValue <AbilityToggler>();
                menuSkillSet = true;
            }

            ultBool = dpAbility != null && skillToggler.IsEnabled("clinkz_death_pact");

            const int DPrange = 0x190;

            if (powerTreads != null)
            {
                lastAttribute = powerTreads.ActiveAttribute;
            }


            var creepR =
                ObjectManager.GetEntities <Unit>()
                .Where(
                    creep =>
                    (creep.ClassID == ClassID.CDOTA_BaseNPC_Creep_Lane ||
                     creep.ClassID == ClassID.CDOTA_BaseNPC_Creep_Neutral) &&
                    creep.IsAlive && creep.IsVisible && creep.IsSpawned &&
                    creep.Team != me.Team && creep.Position.Distance2D(me.Position) <= DPrange &&
                    me.Spellbook.SpellR.CanBeCasted()).ToList();

            var enemies = ObjectManager.GetEntities <Hero>().Where(x => x.IsAlive && x.Team != me.Team && !x.IsIllusion).ToList();


            if (autoKillz && Menu.Item("enable").GetValue <bool>())
            {
                target = me.ClosestToMouseTarget(1001);

                //orbwalk
                if (target != null && (!target.IsValid || !target.IsVisible || !target.IsAlive || target.Health <= 0))
                {
                    target = null;
                }
                var canCancel = Orbwalking.CanCancelAnimation();
                if (canCancel)
                {
                    if (target != null && !target.IsVisible && !Orbwalking.AttackOnCooldown(target))
                    {
                        target = me.ClosestToMouseTarget();
                    }
                    else if (target == null || !Orbwalking.AttackOnCooldown(target) && target.HasModifiers(new[]
                    {
                        "modifier_dazzle_shallow_grave", "modifier_item_blade_mail_reflect",
                    }, false))
                    {
                        var bestAa = me.BestAATarget();
                        if (bestAa != null)
                        {
                            target = me.BestAATarget();
                        }
                    }
                }

                if (target != null && target.IsAlive && !target.IsInvul() && !target.IsIllusion)
                {
                    if (me.CanAttack() && me.CanCast() && !me.IsChanneling())
                    {
                        TargetDistance = me.Position.Distance2D(target);

                        if (Menu.Item("orbwalk").GetValue <bool>())
                        {
                            if (!Utils.SleepCheck("attacking"))
                            {
                                if (lastAttribute != Attribute.Agility && Utils.SleepCheck("powerTreadsSwitch"))
                                {
                                    SwitchTo(Attribute.Agility);
                                    Utils.Sleep(400, "powerTreadsSwitch");
                                }
                            }
                            Orbwalking.Orbwalk(target, Game.Ping, attackmodifiers: true);
                            Utils.Sleep(400, "attacking");
                        }
                        else if (!Menu.Item("orbwalk").GetValue <bool>())
                        {
                            if (arrows != null && arrows.IsValid && arrows.CanBeCasted() && !Utils.SleepCheck("attacking"))
                            {
                                arrows.UseAbility(target);
                            }
                            Utils.Sleep(200, "attacking");
                        }

                        if (creepR.Count > 0 && !me.Modifiers.ToList().Exists(x => x.Name == "modifier_clinkz_death_pact") && skillToggler.IsEnabled(dpAbility.Name))
                        {
                            var creepmax = creepR.MaxOrDefault(x => x.Health);
                            if (lastAttribute != Attribute.Intelligence && Utils.SleepCheck("powerTreadsSwitch"))
                            {
                                SwitchTo(Attribute.Intelligence);
                                Utils.Sleep(400, "powerTreadsSwitch");
                            }
                            dpAbility.UseAbility(creepmax);
                        }

                        if (strafe != null && strafe.IsValid && strafe.CanBeCasted() && me.CanCast() && me.Distance2D(target) <= attackRange + 90 && Utils.SleepCheck("strafe") && skillToggler.IsEnabled(strafe.Name))
                        {
                            if (lastAttribute != Attribute.Intelligence && Utils.SleepCheck("powerTreadsSwitch"))
                            {
                                SwitchTo(Attribute.Intelligence);
                                Utils.Sleep(400, "powerTreadsSwitch");
                            }
                            strafe.UseAbility();
                            Utils.Sleep(100 + Game.Ping, "strafe");
                        }

                        if (bladeMail != null && bladeMail.IsValid && Utils.SleepCheck("blademail") && itemToggler.IsEnabled(bladeMail.Name) && me.Distance2D(target) <= attackRange + 90)
                        {
                            bladeMail.UseAbility();
                            Utils.Sleep(50 + Game.Ping, "blademail");
                        }

                        if (medallion != null && medallion.IsValid && medallion.CanBeCasted() && Utils.SleepCheck("medallion") && itemToggler.IsEnabled(medallion.Name) && me.Distance2D(target) <= attackRange + 90)
                        {
                            medallion.UseAbility(target);
                            Utils.Sleep(50 + Game.Ping, "medallion");
                        }

                        if (solar != null && solar.IsValid && solar.CanBeCasted() && Utils.SleepCheck("solar") && itemToggler.IsEnabled(solar.Name))
                        {
                            solar.UseAbility(target);
                            Utils.Sleep(50 + Game.Ping, "solar");
                        }


                        if (bkb != null && bkb.IsValid && bkb.CanBeCasted() && Utils.SleepCheck("bkb") && itemToggler.IsEnabled(bkb.Name) && (enemies.Count(x => x.Distance2D(me) <= 650) >= (Menu.Item("bkblogic").GetValue <Slider>().Value)))
                        {
                            bkb.UseAbility();
                            Utils.Sleep(150 + Game.Ping, "bkb");
                        }

                        if (hex != null && hex.IsValid && hex.CanBeCasted() && Utils.SleepCheck("hex") && itemToggler.IsEnabled(hex.Name))
                        {
                            hex.CastStun(target);
                            Utils.Sleep(250 + Game.Ping, "hex");
                            return;
                        }

                        if (orchid != null && orchid.IsValid && orchid.CanBeCasted() && Utils.SleepCheck("orchid") && itemToggler.IsEnabled(orchid.Name))
                        {
                            orchid.CastStun(target);
                            Utils.Sleep(250 + Game.Ping, "orchid");
                            return;
                        }

                        if (bloodthorn != null && bloodthorn.IsValid && bloodthorn.CanBeCasted() && Utils.SleepCheck("bloodthorn") && itemToggler.IsEnabled(bloodthorn.Name))
                        {
                            bloodthorn.CastStun(target);
                            Utils.Sleep(250 + Game.Ping, "orchid");
                            return;
                        }

                        if (!me.IsAttacking() && me.Distance2D(target) >= attackRange && Utils.SleepCheck("follow"))
                        {
                            me.Move(Game.MousePosition);
                            Utils.Sleep(150 + Game.Ping, "follow");
                        }
                    }
                }
                else
                {
                    me.Move(Game.MousePosition);
                }
            }
        }//gameOnUpdate Close.