コード例 #1
0
ファイル: Program.cs プロジェクト: WollfCast/EnsageSharp
        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);
            }
        }
コード例 #2
0
ファイル: Mode.cs プロジェクト: tyljeff9408/EnsageSharp-1
        private async void UseItem(CancellationToken token)
        {
            // SoulRing
            if (SoulRing != null &&
                Config.ItemsToggler.Value.IsEnabled(SoulRing.Item.Name) &&
                SoulRing.CanBeCasted)
            {
                SoulRing.UseAbility();
                await Await.Delay(SoulRing.GetCastDelay(), token);
            }
            else
            {
                Elsecount += 1;
            }

            // MidnightPulse
            if (MidnightPulse != null &&
                Config.AbilityToggler.Value.IsEnabled(MidnightPulse.Ability.Name) &&
                MidnightPulse.CanBeCasted)
            {
                MidnightPulse.UseAbility(Output.CastPosition);
                await Await.Delay(MidnightPulse.GetCastDelay(Output.CastPosition), token);
            }
            else
            {
                Elsecount += 1;
            }

            // GlimmerCape
            if (GlimmerCape != null &&
                Config.ItemsToggler.Value.IsEnabled(GlimmerCape.Item.Name) &&
                GlimmerCape.CanBeCasted)
            {
                GlimmerCape.UseAbility(Owner);
                await Await.Delay(GlimmerCape.GetCastDelay(Owner), token);
            }
            else
            {
                Elsecount += 1;
            }

            // BKB
            if (BKB != null &&
                Config.ItemsToggler.Value.IsEnabled(BKB.Item.Name) &&
                BKB.CanBeCasted)
            {
                BKB.UseAbility();
                await Await.Delay(BKB.GetCastDelay(), token);
            }
            else
            {
                Elsecount += 1;
            }

            // Shivas
            if (Shivas != null &&
                Config.ItemsToggler.Value.IsEnabled(Shivas.Item.Name) &&
                Shivas.CanBeCasted)
            {
                Shivas.UseAbility();
                await Await.Delay(Shivas.GetCastDelay(), token);
            }
            else
            {
                Elsecount += 1;
            }

            // ArcaneBoots
            if (ArcaneBoots != null &&
                Config.ItemsToggler.Value.IsEnabled(ArcaneBoots.Item.Name) &&
                ArcaneBoots.CanBeCasted &&
                Owner.Mana * 100 / Owner.MaximumMana <= 92 &&
                Elsecount == 5)
            {
                ArcaneBoots.UseAbility();
                await Await.Delay(ArcaneBoots.GetCastDelay(), token);
            }

            // Guardian
            if (Guardian != null &&
                Config.ItemsToggler.Value.IsEnabled(Guardian.Item.Name) &&
                Guardian.CanBeCasted &&
                Owner.Mana * 100 / Owner.MaximumMana <= 92 &&
                Elsecount == 5)
            {
                Guardian.UseAbility();
                await Await.Delay(Guardian.GetCastDelay(), token);
            }

            // Veil
            if (Veil != null &&
                Config.ItemsToggler.Value.IsEnabled(Veil.Item.Name) &&
                Veil.CanBeCasted)
            {
                Veil.UseAbility(Output.CastPosition);
                await Await.Delay(Veil.GetCastDelay(Output.CastPosition), token);
            }
            else
            {
                Elsecount += 1;
            }
        }