示例#1
0
        private bool SwitchPowerTreads(RecoveryAbility ability)
        {
            var powerTreads = (PowerTreads)this.owner.Hero.Abilities.FirstOrDefault(x => x.Id == AbilityId.item_power_treads);

            if (powerTreads?.CanBeCasted() != true)
            {
                return(false);
            }

            var currentAtt  = powerTreads.ActiveAttribute;
            var requiredAtt = ability.PowerTreadsAttribute;

            if (requiredAtt == Attribute.Invalid || currentAtt == requiredAtt)
            {
                return(false);
            }

            if (!this.powerTreadsChanged)
            {
                this.powerTreadsAttribute = currentAtt;
                this.powerTreadsChanged   = true;
            }

            powerTreads.UseAbility();
            return(true);
        }
示例#2
0
        private void OnExecutePowerTreadsOrder(Player sender, ExecuteOrderEventArgs args)
        {
            try
            {
                if (!args.Process || !args.IsPlayerInput)
                {
                    return;
                }

                if (args.OrderId != OrderId.Ability || args.Ability.Handle != this.powerTreads.Handle)
                {
                    return;
                }

                if (!args.Entities.Contains(this.owner))
                {
                    return;
                }

                if (!this.powerTreads.CanBeCasted())
                {
                    return;
                }

                this.powerTreads.UseAbility();
                this.defaultAttribute = this.powerTreads.ActiveAttribute;
                args.Process          = false;
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
示例#3
0
文件: Program.cs 项目: 7ajlosh/Ensage
        private static void ChangePt(Item pt, Attribute atrb)
        {
            // okay this shit function is really bad
            if (pt == null)
                return;

            //var ptNow = (int) ((Ensage.Items.PowerTreads) pt).ActiveAttribute + 1;
            //var ptTo = (int) atrb + 1;

            var ptNow = 0;
            var ptTo = 0;

            //some random fixes
            switch (((PowerTreads) pt).ActiveAttribute) {
                case Attribute.Intelligence: // agi
                    ptNow = 3;
                    break;
                case Attribute.Strength:
                    ptNow = 1;
                    break;
                case Attribute.Agility: // int
                    ptNow = 2;
                    break;
            }

            // more fixes
            switch (atrb) {
                case Attribute.Intelligence:
                    ptTo = 2;
                    break;
                case Attribute.Strength:
                    ptTo = 1;
                    break;
                case Attribute.Agility:
                    ptTo = 3;
                    break;
            }

            if (ptNow == ptTo)
                return;

            var change = ptTo - ptNow % 3;

            if (ptNow == 2 && ptTo == 1) // another fix
                change = 2;

            for (var i = 0; i < change; i++)
                pt.ToggleAbility(true);

            ptChanged = true;
        }
        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;
        }
示例#5
0
        private void OnAbilityAdded(Ability9 ability)
        {
            try
            {
                if (!ability.Owner.IsMyHero || !(ability is ActiveAbility))
                {
                    return;
                }

                if (ability.Id == AbilityId.item_power_treads)
                {
                    if (this.subscribed)
                    {
                        return;
                    }

                    this.powerTreads      = (Core.Entities.Abilities.Items.PowerTreads)ability;
                    this.defaultAttribute = this.powerTreads.ActiveAttribute;

                    Player.OnExecuteOrder += this.OnExecutePowerTreadsOrder;
                    Player.OnExecuteOrder += this.OnExecuteOrder;
                    UpdateManager.Subscribe(this.OnUpdate, 112);
                    this.eventManager.InvokeForceBlockerResubscribe();
                    this.subscribed = true;
                }
                else if (ability.BaseAbility.GetManaCost(1) > 0 && !this.ignoredAbilities.Contains(ability.Id))
                {
                    this.intToggler.AddAbility(ability.Id);
                    this.agiToggler.AddAbility(ability.Id, false);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
示例#6
0
        private static void ChangePt(Item pt, Attribute atrb, bool changed = true)
        {
            if (pt == null)
            {
                return;
            }

            var hero = ObjectMgr.LocalHero;

            if (hero == null || hero.IsChanneling() || hero.IsInvisible() || !hero.CanUseItems())
            {
                return;
            }

            //var ptNow = (int) ((Ensage.Items.PowerTreads) pt).ActiveAttribute + 1;
            //var ptTo = (int) atrb + 1;

            var ptNow = 0;
            var ptTo  = 0;

            //some random fixes
            switch (((PowerTreads)pt).ActiveAttribute)
            {
            case Attribute.Intelligence:                     // agi
                ptNow = 3;
                break;

            case Attribute.Strength:
                ptNow = 1;
                break;

            case Attribute.Agility:                     // int
                ptNow = 2;
                break;
            }

            // more fixes
            switch (atrb)
            {
            case Attribute.Intelligence:
                ptTo = 2;
                break;

            case Attribute.Strength:
                ptTo = 1;
                break;

            case Attribute.Agility:
                ptTo = 3;
                break;
            }

            if (ptNow == ptTo)
            {
                return;
            }

            var change = ptTo - ptNow % 3;

            if (ptNow == 2 && ptTo == 1)
            {
                change = 2;
            }

            _ptChanged = changed;

            for (var i = 0; i < change; i++)
            {
                pt.UseAbility();
            }
        }
示例#7
0
        private static void Game_OnUpdate(EventArgs args)
        {
            if (Game.IsPaused || !Game.IsInGame || !Utils.SleepCheck("delay"))
            {
                return;
            }

            var hero = ObjectMgr.LocalHero;

            if (hero == null || !hero.IsAlive)
            {
                return;
            }

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

            if (powerTreads == null)
            {
                return;
            }

            if (!_healActive && !_ptChanged)
            {
                switch (((PowerTreads)powerTreads).ActiveAttribute)
                {
                case Attribute.Intelligence:                         // agi
                    _lastPtState = Attribute.Agility;
                    break;

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

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

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

            if (hero.Modifiers.Any(x => HealModifiers.Any(x.Name.Contains)) && !_disableSwitchBack)
            {
                _healActive = true;
                ChangePt(powerTreads, Attribute.Agility);
            }
            else
            {
                _healActive = false;
            }

            if (_ptChanged && !_healActive && !_disableSwitchBack)
            {
                foreach (var spell in hero.Spellbook.Spells.Where(spell => spell.IsInAbilityPhase))
                {
                    Utils.Sleep(spell.FindCastPoint() * 1000 + 300, "delay");
                    return;
                }

                ChangePt(powerTreads, _lastPtState, false);
            }

            Utils.Sleep(200, "delay");
        }
示例#8
0
        private static void ChangePowerTreads(Attribute attribute, bool switchBack = true, bool healing = false) {
            if (powerTreads == null)
                return;

            healActive = healing;

            if (hero.IsChanneling() || !hero.CanUseItems() ||
                hero.Modifiers.Any(x => InvisibilityModifiers.Contains(x.Name)))
                return;

            var ptNow = 0;
            var ptTo = 0;

            switch (powerTreads.ActiveAttribute) {
                case Attribute.Strength:
                    ptNow = 1;
                    break;
                case Attribute.Agility: // int
                    ptNow = 2;
                    break;
                case Attribute.Intelligence: // agi
                    ptNow = 3;
                    break;
            }

            switch (attribute) {
                case Attribute.Strength:
                    ptTo = 1;
                    break;
                case Attribute.Intelligence:
                    ptTo = 2;
                    break;
                case Attribute.Agility:
                    ptTo = 3;
                    break;
            }

            if (ptNow == ptTo)
                return;

            var change = ptTo - ptNow % 3;

            if (ptNow == 2 && ptTo == 1) // random fix
                change = 2;

            ptChanged = switchBack;

            for (var i = 0; i < change; i++)
                powerTreads.UseAbility();
        }
示例#9
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");
        }
示例#10
0
文件: Program.cs 项目: 7ajlosh/Ensage
        private static void Game_OnUpdate(EventArgs args)
        {
            if (Game.IsPaused || !Game.IsInGame || !Utils.SleepCheck("delay"))
                return;

            var hero = ObjectMgr.LocalHero;

            if (hero == null || !hero.IsAlive)
                return;

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

            if (powerTreads == null)
                return;

            if (!_healActive && !_ptChanged) {
                switch (((PowerTreads) powerTreads).ActiveAttribute) {
                    case Attribute.Intelligence: // agi
                        _lastPtState = Attribute.Agility;
                        break;
                    case Attribute.Strength:
                        _lastPtState = Attribute.Strength;
                        break;
                    case Attribute.Agility: // int
                        _lastPtState = Attribute.Intelligence;
                        break;
                }
            }

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

            if (hero.Modifiers.Any(x => HealModifiers.Any(x.Name.Contains)) && !_disableSwitchBack) {
                _healActive = true;
                ChangePt(powerTreads, Attribute.Agility);
            } else {
                _healActive = false;
            }

            if (_ptChanged && !_healActive && !_disableSwitchBack) {

                foreach (var spell in hero.Spellbook.Spells.Where(spell => spell.IsInAbilityPhase)) {
                    Utils.Sleep(spell.FindCastPoint() * 1000 + 300, "delay");
                    return;
                }

                ChangePt(powerTreads, _lastPtState, false);
            }

            Utils.Sleep(200, "delay");
        }
示例#11
0
文件: Program.cs 项目: jucelyn/Ensage
        private static void Game_OnIngameUpdate(EventArgs args)
        {
            if (Game.IsPaused || !_enabled || !Utils.SleepCheck("delay"))
                return;

            var hero = ObjectMgr.LocalHero;

            if (hero == null || !hero.IsAlive)
                return;

            if (hero.Mana == hero.MaximumMana && hero.Health == hero.MaximumHealth)
                return;

            if (hero.NetworkActivity == NetworkActivity.Move || ObjectMgr.GetEntities<Hero>().Any(x => x.IsAlive && x.IsVisible && x.Team == hero.GetEnemyTeam() && x.Distance2D(hero) < 400)) {
                PickUpItems();
                Utils.Sleep(1000, "delay");
                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 powerTreads = hero.FindItem("item_power_treads");
            var meka = hero.FindItem("item_mekansm");
            var urn = hero.FindItem("item_urn_of_shadows");

            if (powerTreads != null && !_ptChanged) {
                //_lastPtState = ((Ensage.Items.PowerTreads) powerTreads).ActiveAttribute;
                switch (((Ensage.Items.PowerTreads) powerTreads).ActiveAttribute) {
                    case Ensage.Attribute.Intelligence: // agi
                        _lastPtState = Ensage.Attribute.Agility;
                    break;
                    case Ensage.Attribute.Strength:
                        _lastPtState = Ensage.Attribute.Strength;
                    break;
                    case Ensage.Attribute.Agility:  // int
                        _lastPtState = Ensage.Attribute.Intelligence;
                    break;
                }
            }

            if (meka != null && meka.CanBeCasted() && hero.Health != hero.MaximumHealth) {
                ChangePt(powerTreads, Ensage.Attribute.Intelligence);
                DropItems(bonusHealth, meka);
                meka.UseAbility(true);
            }

            if (arcaneBoots != null && arcaneBoots.CanBeCasted() && hero.Mana != hero.MaximumMana) {
                ChangePt(powerTreads, Ensage.Attribute.Agility);
                DropItems(bonusMana, arcaneBoots);
                arcaneBoots.UseAbility(true);
            }

            if (greaves != null && greaves.CanBeCasted()) {
                ChangePt(powerTreads, Ensage.Attribute.Agility);
                DropItems(bonusHealth.Concat(bonusMana), greaves);
                greaves.UseAbility(true);
            }

            if (soulRing != null && soulRing.CanBeCasted()) {
                ChangePt(powerTreads, Ensage.Attribute.Strength);
                DropItems(bonusMana);
                soulRing.UseAbility(true);
            }

            if (bottle != null && bottle.CanBeCasted() && bottle.CurrentCharges != 0 && hero.Modifiers.All(x => x.Name != "modifier_bottle_regeneration")) {
                ChangePt(powerTreads, Ensage.Attribute.Agility);

                if (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) {
                ChangePt(powerTreads, Ensage.Attribute.Agility);

                if (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") && hero.Health / hero.MaximumHealth < 0.9) {
                ChangePt(powerTreads, Ensage.Attribute.Agility);
                DropItems(bonusHealth, urn);
                urn.UseAbility(hero, true);
            }

            if (hero.Modifiers.Any(x => (x.Name == "modifier_item_urn_heal" || x.Name == "modifier_flask_healing"))) {
                ChangePt(powerTreads, Ensage.Attribute.Agility);
                DropItems(bonusHealth);
            }

            if (hero.Modifiers.Any(x => x.Name == "modifier_bottle_regeneration")) {
                ChangePt(powerTreads, Ensage.Attribute.Agility);
                if (hero.Health / hero.MaximumHealth < 0.9)
                    DropItems(bonusHealth);
                if (hero.Mana / hero.MaximumMana < 0.9)
                    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) {
                    ChangePt((Ensage.Items.PowerTreads) powerTreads, Ensage.Attribute.Agility);
                    DropItems(bonusMana);
                }

                if (allyMeka != null && allyMeka.AbilityState == AbilityState.Ready) {
                    ChangePt((Ensage.Items.PowerTreads) powerTreads, Ensage.Attribute.Agility);
                    DropItems(bonusHealth);
                }

                if (allyGreaves != null && allyGreaves.AbilityState == AbilityState.Ready) {
                    ChangePt((Ensage.Items.PowerTreads) powerTreads, Ensage.Attribute.Agility);
                    DropItems(bonusMana.Concat(bonusHealth));
                }

            }

            Utils.Sleep(250, "delay");
        }
示例#12
0
文件: Program.cs 项目: 7ajlosh/Ensage
        private static void Game_OnUpdate(EventArgs args)
        {
            if (Game.IsPaused || !Game.IsInGame || !enabled || !Utils.SleepCheck("delay"))
            {
                return;
            }

            var hero = ObjectMgr.LocalHero;

            if (hero == null || !hero.IsAlive)
            {
                return;
            }

            if (hero.Mana == hero.MaximumMana && hero.Health == hero.MaximumHealth)
            {
                return;
            }

            if ((hero.NetworkActivity == NetworkActivity.Move && Menu.Item("moved").GetValue <bool>()) ||
                (ObjectMgr.GetEntities <Hero>()
                 .Any(x => x.IsAlive && x.IsVisible && x.Team == hero.GetEnemyTeam() && x.Distance2D(hero) < 400) &&
                 Menu.Item("enemyNear").GetValue <bool>()))
            {
                PickUpItems();
                Utils.Sleep(1000, "delay");
                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 powerTreads = hero.FindItem("item_power_treads");
            var meka        = hero.FindItem("item_mekansm");
            var urn         = hero.FindItem("item_urn_of_shadows");

            if (powerTreads != null && !ptChanged)
            {
                //_lastPtState = ((Ensage.Items.PowerTreads) powerTreads).ActiveAttribute;
                switch (((PowerTreads)powerTreads).ActiveAttribute)
                {
                case Attribute.Intelligence:                         // agi
                    lastPtState = Attribute.Agility;
                    break;

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

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

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

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

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

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

            if (bottle != null && bottle.CanBeCasted() && bottle.CurrentCharges != 0 &&
                hero.Modifiers.All(x => x.Name != "modifier_bottle_regeneration"))
            {
                ChangePt(powerTreads, Attribute.Agility);

                if (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)
            {
                ChangePt(powerTreads, Attribute.Agility);

                if (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") && hero.Health / hero.MaximumHealth < 0.9)
            {
                ChangePt(powerTreads, Attribute.Agility);
                DropItems(BonusHealth, urn);
                urn.UseAbility(hero, true);
            }

            if (hero.Modifiers.Any(x => (x.Name == "modifier_item_urn_heal" || x.Name == "modifier_flask_healing")))
            {
                ChangePt(powerTreads, Attribute.Agility);
                DropItems(BonusHealth);
            }

            if (hero.Modifiers.Any(x => x.Name == "modifier_bottle_regeneration"))
            {
                ChangePt(powerTreads, Attribute.Agility);

                if (hero.Health / hero.MaximumHealth < 0.9)
                {
                    DropItems(BonusHealth);
                }
                if (hero.Mana / hero.MaximumMana < 0.9)
                {
                    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)
                {
                    ChangePt((PowerTreads)powerTreads, Attribute.Agility);
                    DropItems(BonusMana);
                }

                if (allyMeka != null && allyMeka.AbilityState == AbilityState.Ready)
                {
                    ChangePt((PowerTreads)powerTreads, Attribute.Agility);
                    DropItems(BonusHealth);
                }

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

            Utils.Sleep(250, "delay");
        }
示例#13
0
文件: Program.cs 项目: 7ajlosh/Ensage
        private static void ChangePt(Item pt, Attribute atrb, bool changed = true)
        {
            if (pt == null)
                return;

            var hero = ObjectMgr.LocalHero;

            if (hero == null || hero.IsChanneling() || hero.IsInvisible() || !hero.CanUseItems())
                return;

            //var ptNow = (int) ((Ensage.Items.PowerTreads) pt).ActiveAttribute + 1;
            //var ptTo = (int) atrb + 1;

            var ptNow = 0;
            var ptTo = 0;

            //some random fixes
            switch (((PowerTreads) pt).ActiveAttribute) {
                case Attribute.Intelligence: // agi
                    ptNow = 3;
                    break;
                case Attribute.Strength:
                    ptNow = 1;
                    break;
                case Attribute.Agility: // int
                    ptNow = 2;
                    break;
            }

            // more fixes
            switch (atrb) {
                case Attribute.Intelligence:
                    ptTo = 2;
                    break;
                case Attribute.Strength:
                    ptTo = 1;
                    break;
                case Attribute.Agility:
                    ptTo = 3;
                    break;
            }

            if (ptNow == ptTo)
                return;

            var change = ptTo - ptNow % 3;

            if (ptNow == 2 && ptTo == 1)
                change = 2;

            _ptChanged = changed;

            for (var i = 0; i < change; i++)
                pt.UseAbility();
        }
示例#14
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");
        }
示例#15
0
        public static void SwitchTo(Attribute attribute, bool switchBack = true)
        {
            if (powerTreads == null)//another check
            {
                return;
            }

            if (me.IsChanneling() || !me.CanUseItems() || me.HasModifiers(new[]
            {
                "modifier_clinkz_shadow_walk", "modifier_item_smoke_of_deceit",
            }, false))
            {
                return;//Just for the PlayerOnExecute
            }

            /* and do this fo each attribute, Or now != next need to think of something better
             * if (Treads.ActiveAttribute != Ensage.Attribute.Agility)
             * {
             *   if (Treads.ActiveAttribute == Ensage.Attribute.Strength)
             *      {
             *       Treads.UseAbility();
             *       Treads.UseAbility();
             *      }
             *       else
             *      {
             *      Treads.UseAbility();
             *      }
             *     }
             */
            var now  = 0;
            var next = 0;

            if (powerTreads.ActiveAttribute != Attribute.Strength)
            {
                if (powerTreads.ActiveAttribute != Attribute.Agility)
                {
                    if (powerTreads.ActiveAttribute == Attribute.Intelligence)
                    {
                        now = 2;
                    }
                }
                else
                {
                    now = 3;
                }
            }
            else
            {
                now = 1;
            }

            if (attribute != Attribute.Strength)
            {
                if (attribute != Attribute.Intelligence)
                {
                    if (attribute == Attribute.Agility)
                    {
                        next = 3;
                    }
                }
                else
                {
                    next = 2;
                }
            }
            else
            {
                next = 1;
            }

            if (now == next)
            {
                return;
            }

            var change = next - now % 3;

            if (now == 2 && next == 1)
            {
                change = 2;
            }

            int i;

            for (i = 0; i < change; i++)
            {
                powerTreads.UseAbility();
            }
        }
示例#16
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.
示例#17
0
        private async void PowerTreadsWatcher(Player sender, ExecuteOrderEventArgs args)
        {
            try
            {
                if (!this.config.TogglePowerTreads || !args.IsPlayerInput || !(args.Entities.First() is Hero))
                {
                    return;
                }

                switch (args.OrderId)
                {
                // only block abilities for toggling
                case OrderId.Ability:
                case OrderId.AbilityLocation:
                case OrderId.AbilityTarget:
                case OrderId.AbilityTargetRune:
                    break;

                default:
                    return;
                }

                // if we don't have powertreads or it's already on int, leave it like this
                if (this.PowerTreads == null || this.PowerTreads.ActiveAttribute == Attribute.Intelligence || args.Ability.ManaCost == 0)
                {
                    return;
                }

                try
                {
                    args.Process = false;
                    if (this.toggling)
                    {
                        this.powerTreadsWaiting++;

                        // block order while toggling
                        while (this.toggling)
                        {
                            await Task.Delay(100);
                        }

                        await this.ExecuteOrder(args);

                        return;
                    }

                    // toggle boots
                    this.toggling = true;
                    this.powerTreadsWaiting++;
                    this.powerTreadsAttribute = this.PowerTreads.ActiveAttribute;

                    // while (this.PowerTreads.ActiveAttribute != Attribute.Intelligence)
                    {
                        this.PowerTreads.SwitchAttribute(Attribute.Intelligence);
                        await Task.Delay(100 + (int)Game.Ping);
                    }

                    await this.ExecuteOrder(args);
                }
                finally
                {
                    this.toggling = false;
                    this.powerTreadsWaiting--;

                    // Don't toggle back when casting a channeling ability
                    if (this.powerTreadsWaiting == 0 && ((args.Ability.AbilityBehavior & AbilityBehavior.Channeled) == 0))
                    {
                        // ping protection for invis and charge
                        if (Game.Ping > this.config.PingGuard.Value && this.pingExcludedAbilities.Contains(args.Ability.Id))
                        {
                            Log.Info($"Ignoring toggling back after ability {args.Ability.Name}, because of too high ping {Game.Ping} > {this.config.PingGuard}");
                        }
                        else
                        {
                            // restore power treads attribute
                            // while (this.PowerTreads.ActiveAttribute != this.powerTreadsAttribute)
                            {
                                this.PowerTreads.SwitchAttribute(this.powerTreadsAttribute);
                                await Task.Delay(100 + (int)Game.Ping);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
示例#18
0
        private static void ChangePowerTreads(Attribute attribute, bool switchBack = true, bool healing = false)
        {
            if (powerTreads == null)
            {
                return;
            }

            healActive = healing;

            if (hero.IsChanneling() || hero.IsInvisible() || !hero.CanUseItems())
            {
                return;
            }

            var ptNow = 0;
            var ptTo  = 0;

            switch (powerTreads.ActiveAttribute)
            {
            case Attribute.Strength:
                ptNow = 1;
                break;

            case Attribute.Agility:     // int
                ptNow = 2;
                break;

            case Attribute.Intelligence:     // agi
                ptNow = 3;
                break;
            }

            switch (attribute)
            {
            case Attribute.Strength:
                ptTo = 1;
                break;

            case Attribute.Intelligence:
                ptTo = 2;
                break;

            case Attribute.Agility:
                ptTo = 3;
                break;
            }

            if (ptNow == ptTo)
            {
                return;
            }

            var change = ptTo - ptNow % 3;

            if (ptNow == 2 && ptTo == 1) // random fix
            {
                change = 2;
            }

            ptChanged = switchBack;

            for (var i = 0; i < change; i++)
            {
                powerTreads.UseAbility();
            }
        }
示例#19
0
文件: Program.cs 项目: 7ajlosh/Ensage
        private static void ChangePt(Item pt, Attribute atrb)
        {
            // okay this shit function is really bad
            if (pt == null)
            {
                return;
            }

            //var ptNow = (int) ((Ensage.Items.PowerTreads) pt).ActiveAttribute + 1;
            //var ptTo = (int) atrb + 1;

            var ptNow = 0;
            var ptTo  = 0;

            //some random fixes
            switch (((PowerTreads)pt).ActiveAttribute)
            {
            case Attribute.Intelligence:                     // agi
                ptNow = 3;
                break;

            case Attribute.Strength:
                ptNow = 1;
                break;

            case Attribute.Agility:                     // int
                ptNow = 2;
                break;
            }

            // more fixes
            switch (atrb)
            {
            case Attribute.Intelligence:
                ptTo = 2;
                break;

            case Attribute.Strength:
                ptTo = 1;
                break;

            case Attribute.Agility:
                ptTo = 3;
                break;
            }

            if (ptNow == ptTo)
            {
                return;
            }

            var change = ptTo - ptNow % 3;

            if (ptNow == 2 && ptTo == 1)             // another fix
            {
                change = 2;
            }

            for (var i = 0; i < change; i++)
            {
                pt.ToggleAbility(true);
            }

            ptChanged = true;
        }