Beispiel #1
0
        public override async Task ExecuteAsync(CancellationToken token)
        {
            try
            {
                _target = _targetSelector.Active.GetTargets().FirstOrDefault();



                var unitMaxHp = EntityManager <Unit> .Entities.Where(x =>
                                                                     x.IsValid &&
                                                                     x.IsVisible &&
                                                                     x.IsAlive &&
                                                                     x.IsSpawned &&
                                                                     x.Distance2D(Owner) < 400 &&
                                                                     (x.NetworkName == "CDOTA_BaseNPC_Creep_Neutral" ||
                                                                      x.NetworkName == "CDOTA_BaseNPC_Creep" ||
                                                                      x.NetworkName == "CDOTA_BaseNPC_Creep_Lane" ||
                                                                      x.NetworkName == "CDOTA_BaseNPC_Creep_Siege")).OrderBy(x => x.MaximumHealth).LastOrDefault();

                if (_target == null || _target.IsAttackImmune() || _target.IsInvulnerable())
                {
                    Orbwalker.OrbwalkTo(null);
                    return;
                }


                if (_configuration.AbilityManager.Value.IsEnabled(DeathPact.Ability.Name) && DeathPact.CanBeCasted && !_target.IsEthereal() &&
                    unitMaxHp != null)
                {
                    DeathPact.UseAbility(unitMaxHp);
                    await Await.Delay(DeathPact.GetCastDelay(unitMaxHp), token);
                }


                if (_configuration.AbilityManager.Value.IsEnabled(Strafe.Ability.Name) && Strafe.CanBeCasted && !_target.IsEthereal() &&
                    Owner.IsInAttackRange(_target))
                {
                    Strafe.UseAbility();
                    await Await.Delay(Strafe.GetCastDelay(), token);
                }

                if (_configuration.AbilityManager.Value.IsEnabled(Arrows.Ability.Name) && Arrows.CanBeCasted && !_target.IsEthereal() &&
                    !Arrows.Ability.IsAutoCastEnabled && Owner.IsInAttackRange(_target))
                {
                    Arrows.Ability.ToggleAutocastAbility();
                }


                if (SolarCrest != null && SolarCrest.CanBeCasted && !Owner.IsAttacking() && !_target.IsEthereal() &&
                    _configuration.ItemManager.Value.IsEnabled(SolarCrest.Ability.Name) && !_target.IsMagicImmune() &&
                    Owner.IsInAttackRange(_target))
                {
                    SolarCrest.UseAbility(_target);
                    await Await.Delay(SolarCrest.GetCastDelay(_target), token);
                }

                if (Meddallion != null && Meddallion.CanBeCasted && !Owner.IsAttacking() && !_target.IsEthereal() &&
                    _configuration.ItemManager.Value.IsEnabled(Meddallion.Ability.Name) && !_target.IsMagicImmune() &&
                    Owner.IsInAttackRange(_target))
                {
                    Meddallion.UseAbility(_target);
                    await Await.Delay(Meddallion.GetCastDelay(_target), token);
                }


                if (DiffusalBlade != null && DiffusalBlade.CanBeCasted && !Owner.IsAttacking() && !_target.IsEthereal() &&
                    _configuration.ItemManager.Value.IsEnabled(DiffusalBlade.Ability.Name) && !_target.IsMagicImmune() &&
                    Owner.IsInAttackRange(_target))
                {
                    DiffusalBlade.Ability.UseAbility(_target);
                    await Await.Delay(DiffusalBlade.GetCastDelay(_target), token);
                }

                if (Mjollnir != null && Mjollnir.CanBeCasted && !Owner.IsAttacking() &&
                    Owner.IsInAttackRange(_target) && _configuration.ItemManager.Value.IsEnabled(Mjollnir.Ability.Name))
                {
                    Mjollnir.UseAbility(Owner);
                    await Await.Delay(Mjollnir.GetCastDelay(Owner), token);
                }

                if (Bloodthorn != null && Bloodthorn.CanBeCasted && !Owner.IsAttacking() && !_target.IsMagicImmune() &&
                    _configuration.ItemManager.Value.IsEnabled(Bloodthorn.ToString()) && Owner.IsInAttackRange(_target))
                {
                    Bloodthorn.UseAbility(_target);
                    await Await.Delay(Bloodthorn.GetCastDelay(_target), token);
                }

                if (SheepStick != null && SheepStick.CanBeCasted && !Owner.IsAttacking() && !_target.IsMagicImmune() &&
                    _configuration.ItemManager.Value.IsEnabled(SheepStick.Ability.Name) &&
                    Owner.IsInAttackRange(_target))
                {
                    SheepStick.UseAbility(_target);
                    await Await.Delay(SheepStick.GetCastDelay(_target), token);
                }

                if (Orchid != null && Orchid.CanBeCasted && !Owner.IsAttacking() && !_target.IsMagicImmune() &&
                    _configuration.ItemManager.Value.IsEnabled(Orchid.Ability.Name) && Owner.IsInAttackRange(_target))
                {
                    Orchid.UseAbility(_target);
                    await Await.Delay(Orchid.GetCastDelay(_target), token);
                }


                if (_target != null && (_target.IsInvulnerable() || _target.IsAttackImmune()))
                {
                    Orbwalker.Move(Game.MousePosition);
                }
                else if (_target != null)
                {
                    Orbwalker.OrbwalkTo(_target);
                }
                else
                {
                    Orbwalker.Move(Game.MousePosition);
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Beispiel #2
0
        private static void Game_OnUpdate(EventArgs args)
        {
            if (!loaded)
            {
                me = ObjectMgr.LocalHero;


                if (!Game.IsInGame || Game.IsWatchingGame || me == null || Game.IsChatOpen)
                {
                    return;
                }
                loaded = true;
            }

            if (me == null || !me.IsValid)
            {
                loaded                = false;
                me                    = ObjectMgr.LocalHero;
                supportActive         = false;
                includeSaveSelf       = false;
                shouldCastLotusOrb    = false;
                shouldCastGlimmerCape = false;
                return;
            }

            if (Game.IsPaused)
            {
                return;
            }

            Urn          = me.FindItem("item_urn_of_shadows");
            Meka         = me.FindItem("item_mekansm");
            Guardian     = me.FindItem("item_guardian_greaves");
            Arcane       = me.FindItem("item_arcane_boots");
            LotusOrb     = me.FindItem("item_lotus_orb");
            Medallion    = me.FindItem("item_medallion_of_courage");
            SolarCrest   = me.FindItem("item_solar_crest");
            GlimmerCape  = me.FindItem("item_glimmer_cape");
            Pipe         = me.FindItem("item_pipe");
            CrimsonGuard = me.FindItem("item_crimson_guard");

            needMana              = null;
            needMeka              = null;
            shouldCastLotusOrb    = false;
            shouldCastGlimmerCape = false;

            if (!Game.IsChatOpen)
            {
                if (Game.IsKeyDown(toggleKey) && Utils.SleepCheck("togglingoption"))
                {
                    if (!supportActive)
                    {
                        supportActive = true;
                    }
                    else
                    {
                        supportActive = false;
                    }
                    Utils.Sleep(100 + Game.Ping, "togglingoption");
                }

                if (Game.IsKeyDown(saveSelfKey) && Utils.SleepCheck("togglingoption"))
                {
                    if (!includeSaveSelf)
                    {
                        includeSaveSelf = true;
                    }
                    else
                    {
                        includeSaveSelf = false;
                    }
                    Utils.Sleep(100 + Game.Ping, "togglingoption");
                }
            }

            if (supportActive)
            {
                var allies =
                    ObjectMgr.GetEntities <Hero>()
                    .Where(
                        ally =>
                        ally.Team == me.Team && ally.IsAlive && !ally.IsIllusion && me.Distance2D(ally) <= 1500)
                    .ToList();
                fountain =
                    ObjectMgr.GetEntities <Entity>()
                    .First(entity => entity.ClassID == ClassID.CDOTA_Unit_Fountain && entity.Team == me.Team);


                if (allies.Any())
                {
                    foreach (var ally in allies)
                    {
                        if (!ally.IsIllusion() && ally.IsAlive && ally.Health > 0 && me.IsAlive && !me.IsChanneling() &&
                            me.Distance2D(fountain) > 2000 &&
                            !me.IsInvisible())
                        {
                            if ((ally.MaximumHealth - ally.Health) > (450 + ally.HealthRegeneration * 10) &&
                                me.Distance2D(ally) <= 2000 &&
                                (me.Mana >= 225 || Guardian != null))
                            {
                                if (needMeka == null || (needMeka != null && me.Distance2D(needMeka) <= 750))
                                {
                                    needMeka = ally;
                                }
                            }

                            var enemyTowers =
                                ObjectMgr.GetEntities <Entity>()
                                .Any(
                                    x =>
                                    x.ClassID == ClassID.CDOTA_BaseNPC_Tower && x.Team != me.Team &&
                                    x.IsAlive && ally.Distance2D(x) <= 750);

                            if (me.CanUseItems())
                            {
                                if (Urn != null && Urn.CanBeCasted() && Urn.CurrentCharges > 0 &&
                                    !ally.Modifiers.Any(x => x.Name == "modifier_item_urn_heal") && !enemyTowers)
                                {
                                    if (me.Distance2D(ally) <= 950 && !IsInDanger(ally) && Utils.SleepCheck("Urn") &&
                                        ally.Health <= (ally.MaximumHealth * 0.7))
                                    {
                                        Urn.UseAbility(ally);
                                        Utils.Sleep(100 + Game.Ping, "Urn");
                                    }
                                    if (ally.Modifiers.Any(x => x.Name == "modifier_wisp_tether") &&
                                        (ally.MaximumHealth - ally.Health) >= 600 && Utils.SleepCheck("Urn"))
                                    {
                                        Urn.UseAbility(me);
                                        Utils.Sleep(100 + Game.Ping, "Urn");
                                    }
                                }

                                if (Arcane != null && Arcane.Cooldown == 0)
                                {
                                    if ((ally.MaximumMana - ally.Mana) >= 135 && me.Distance2D(ally) < 2000 &&
                                        me.Mana >= 35)
                                    {
                                        if (needMana == null || (needMana != null && me.Distance2D(needMana) <= 600))
                                        {
                                            needMana = ally;
                                        }
                                    }
                                }

                                /*Pipe and Crimson Guard*/
                                if (((Pipe != null && Pipe.CanBeCasted()) ||
                                     (CrimsonGuard != null && CrimsonGuard.CanBeCasted())) && me.CanUseItems())
                                {
                                    var enemiesInRadius =
                                        ObjectMgr.GetEntities <Hero>()
                                        .Where(
                                            x =>
                                            x.Team != me.Team && x.IsAlive && me.Distance2D(x) <= 1500 &&
                                            !x.IsIllusion).ToList();
                                    var alliesInRadius =
                                        ObjectMgr.GetEntities <Hero>()
                                        .Where(
                                            x =>
                                            x.Team == me.Team && x.IsAlive && me.Distance2D(x) <= 900 &&
                                            !x.IsIllusion).ToList();

                                    if (enemiesInRadius.Any() && alliesInRadius.Any())
                                    {
                                        if (enemiesInRadius.Count >= 2 && alliesInRadius.Count >= 2)
                                        {
                                            if (Pipe != null && Pipe.CanBeCasted() && Utils.SleepCheck("Pipe"))
                                            {
                                                Pipe.UseAbility();
                                                Utils.Sleep(100 + Game.Ping, "Pipe");
                                            }

                                            if (CrimsonGuard != null && CrimsonGuard.CanBeCasted() &&
                                                Utils.SleepCheck("CrimsonGuard"))
                                            {
                                                CrimsonGuard.UseAbility();
                                                Utils.Sleep(100 + Game.Ping, "CrimsonGuard");
                                            }
                                        }
                                    }
                                }

                                var enemyList =
                                    ObjectMgr.GetEntities <Hero>()
                                    .Where(
                                        x =>
                                        x.Team != me.Team && !x.IsIllusion && x.IsAlive && x.CanCast() &&
                                        ally.Distance2D(x) <= 1000)
                                    .ToList();

                                if (enemyList.Any())
                                {
                                    foreach (var enemy in enemyList)
                                    {
                                        var targettedSpell =
                                            enemy.Spellbook.Spells.Any(
                                                x =>
                                                x.TargetTeamType == TargetTeamType.Enemy &&
                                                x.AbilityState == AbilityState.Ready &&
                                                ally.Distance2D(enemy) <= x.CastRange + 50 &&
                                                x.AbilityBehavior == AbilityBehavior.UnitTarget);

                                        var targettedItem =
                                            enemy.Inventory.Items.Any(
                                                x =>
                                                x.TargetTeamType == TargetTeamType.Enemy &&
                                                x.AbilityState == AbilityState.Ready &&
                                                x.AbilityBehavior == AbilityBehavior.UnitTarget &&
                                                ally.Distance2D(enemy) <= x.CastRange + 50);

                                        var enemySkill =
                                            enemy.Spellbook.Spells.Any(
                                                x =>
                                                x.DamageType == DamageType.Magical &&
                                                x.TargetTeamType == TargetTeamType.Enemy &&
                                                x.AbilityState == AbilityState.Ready &&
                                                ally.Distance2D(enemy) <= x.CastRange + 50);

                                        if (enemySkill)
                                        {
                                            shouldCastGlimmerCape = true;
                                        }

                                        if (targettedSpell || targettedItem)
                                        {
                                            shouldCastLotusOrb = true;
                                        }
                                    }
                                }

                                if (LotusOrb != null && LotusOrb.Cooldown == 0 && Utils.SleepCheck("LotusOrb") &&
                                    me.Distance2D(ally) <= LotusOrb.CastRange + 50 &&
                                    (shouldCastLotusOrb || IsInDanger(ally)))
                                {
                                    LotusOrb.UseAbility(ally);
                                    Utils.Sleep(100 + Game.Ping, "LotusOrb");
                                }

                                if (Medallion != null && Medallion.Cooldown == 0 &&
                                    me.Distance2D(ally) <= Medallion.CastRange + 50 && Utils.SleepCheck("Medallion") &&
                                    ally != me && IsInDanger(ally))
                                {
                                    Medallion.UseAbility(ally);
                                    Utils.Sleep(100 + Game.Ping, "Medallion");
                                }

                                if (SolarCrest != null && SolarCrest.Cooldown == 0 &&
                                    me.Distance2D(ally) <= SolarCrest.CastRange + 50 && Utils.SleepCheck("SolarCrest") &&
                                    ally != me && IsInDanger(ally))
                                {
                                    SolarCrest.UseAbility(ally);
                                    Utils.Sleep(100 + Game.Ping, "SolarCrest");
                                }

                                if (GlimmerCape != null && GlimmerCape.Cooldown == 0 &&
                                    me.Distance2D(ally) <= GlimmerCape.CastRange + 50 && Utils.SleepCheck("GlimmerCape") &&
                                    (shouldCastGlimmerCape || IsInDanger(ally)))
                                {
                                    GlimmerCape.UseAbility(ally);
                                    Utils.Sleep(100 + Game.Ping, "GlimmerCape");
                                }
                            }
                        }
                    }
                }

                if (needMeka != null &&
                    ((Guardian != null && Guardian.CanBeCasted()) || (Meka != null && Meka.CanBeCasted())) &&
                    me.Distance2D(needMeka) <= 750)
                {
                    if (Meka != null)
                    {
                        Meka.UseAbility();
                    }
                    else
                    {
                        Guardian.UseAbility();
                    }
                }
                if (needMana != null && Arcane != null && Arcane.CanBeCasted() && me.Distance2D(needMana) <= 600)
                {
                    Arcane.UseAbility();
                }


                if (Support(me.ClassID))
                {
                    switch (me.ClassID)
                    {
                    case ClassID.CDOTA_Unit_Hero_Abaddon:
                        Save(me, me.Spellbook.SpellW, 1000, me.Spellbook.SpellW.CastRange);
                        Heal(me, me.Spellbook.SpellQ, new float[] { 100, 150, 200, 250 },
                             800,
                             1, false);
                        break;

                    case ClassID.CDOTA_Unit_Hero_Chen:
                        Save(me, me.Spellbook.SpellE, 1000, me.Spellbook.SpellE.CastRange);
                        Heal(me, me.Spellbook.SpellR, new float[] { 200, 300, 400 },
                             2200000, 2);
                        break;

                    case ClassID.CDOTA_Unit_Hero_Dazzle:
                        Save(me, me.Spellbook.SpellW, 300, me.Spellbook.SpellW.CastRange);
                        Heal(me, me.Spellbook.SpellE, new float[] { 80, 100, 120, 140 },
                             750,
                             1);
                        break;

                    case ClassID.CDOTA_Unit_Hero_Enchantress:
                        Heal(me, me.Spellbook.SpellE, new float[] { 400, 600, 800, 1000 },
                             275, 2);
                        break;

                    case ClassID.CDOTA_Unit_Hero_Legion_Commander:
                        Heal(me, me.Spellbook.SpellW, new float[] { 150, 200, 250, 300 },
                             800,
                             1);
                        break;

                    case ClassID.CDOTA_Unit_Hero_Necrolyte:
                        Heal(me, me.Spellbook.SpellQ, new float[] { 70, 90, 110, 130 },
                             475,
                             2);
                        break;

                    case ClassID.CDOTA_Unit_Hero_Omniknight:
                        Heal(me, me.Spellbook.SpellQ, new float[] { 90, 180, 270, 360 },
                             950,
                             1);
                        Save(me, me.Spellbook.SpellW, 1570, me.Spellbook.SpellW.CastRange);
                        break;

                    case ClassID.CDOTA_Unit_Hero_Oracle:
                        Save(me, me.Spellbook.SpellR, 1270, me.Spellbook.SpellR.CastRange);
                        Heal(me, me.Spellbook.SpellE, new float[] { 99, 198, 297, 396 },
                             750,
                             1);
                        break;

                    case ClassID.CDOTA_Unit_Hero_Shadow_Demon:
                        Save(me, me.Spellbook.SpellQ, 900,
                             me.Spellbook.SpellQ.CastRange);
                        break;

                    case ClassID.CDOTA_Unit_Hero_Treant:
                        Heal(me, me.Spellbook.SpellE, new float[] { 60, 105, 150, 195 },
                             2200000, 1);
                        break;

                    case ClassID.CDOTA_Unit_Hero_Undying:
                        var unitsAround =
                            ObjectMgr.GetEntities <Entity>()
                            .Where(entity => entity.IsAlive && me.Distance2D(entity) <= 1300).ToList();

                        if (unitsAround.Any())
                        {
                            var unitCount   = unitsAround.Count;
                            var healperUnit = new[] { 18, 22, 36, 30 };

                            Heal(me, me.Spellbook.SpellW,
                                 new float[]
                            {
                                unitCount *healperUnit[me.Spellbook.SpellW.Level - 1],
                                unitCount *healperUnit[me.Spellbook.SpellW.Level - 1],
                                unitCount *healperUnit[me.Spellbook.SpellW.Level - 1],
                                unitCount *healperUnit[me.Spellbook.SpellW.Level - 1]
                            },
                                 750, 1);
                        }
                        break;

                    case ClassID.CDOTA_Unit_Hero_Warlock:
                        Heal(me, me.Spellbook.SpellW, new float[] { 165, 275, 385, 495 },
                             me.Spellbook.SpellW.CastRange, 1);
                        break;

                    case ClassID.CDOTA_Unit_Hero_Winter_Wyvern:
                        Save(me, me.Spellbook.SpellE, 930, me.Spellbook.SpellE.CastRange);
                        break;

                    case ClassID.CDOTA_Unit_Hero_WitchDoctor:
                        Heal(me, me.Spellbook.SpellW, new float[] { 16, 24, 32, 40 }, 500,
                             3);
                        break;
                    }
                }
            }

            if (Game.IsKeyDown(orbwalkKey))
            {
                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))
                    {
                        var bestAa = me.BestAATarget();
                        if (bestAa != null)
                        {
                            target = me.BestAATarget();
                        }
                    }
                }

                Orbwalking.Orbwalk(target, Game.Ping, attackmodifiers: true);
            }
        }