Пример #1
0
        /// <summary>
        ///     The get stack damage.
        /// </summary>
        /// <param name="hero">
        ///     The hero.
        /// </param>
        /// <param name="inFrontDistance">
        ///     The in front distance.
        /// </param>
        /// <returns>
        ///     The <see cref="Tuple" />.
        /// </returns>
        public static Tuple <float, IEnumerable <RemoteMine> > GetStackDamage(this Unit hero, float inFrontDistance = 0)
        {
            var detonatableMines = new List <RemoteMine>();

            if (Variables.Stacks == null || !Variables.Stacks.Any())
            {
                return(new Tuple <float, IEnumerable <RemoteMine> >(0, detonatableMines));
            }

            var rotSpeed = Prediction.RotSpeedDictionary.ContainsKey(hero.Handle)
                               ? Prediction.RotSpeedDictionary[hero.Handle]
                               : 0;
            var heroPosition = inFrontDistance > 0
                                   ? hero.Position
                               + VectorExtensions.FromPolarCoordinates(
                1f,
                (float)(hero.NetworkRotationRad + rotSpeed)).ToVector3() * inFrontDistance
                                   : hero.Position;

            if (hero.NetworkActivity == NetworkActivity.Move)
            {
                heroPosition +=
                    VectorExtensions.FromPolarCoordinates(1f, (float)(hero.NetworkRotationRad + rotSpeed)).ToVector3()
                    * (float)(Variables.Techies.GetTurnTime(hero) + Game.Ping / 1000) * hero.MovementSpeed;
            }

            var tempDamage   = 0f;
            var nearestStack = Variables.Stacks.MinOrDefault(x => x.Position.Distance(heroPosition));

            if (nearestStack == null || nearestStack.Position.Distance(heroPosition) > 1000)
            {
                return(new Tuple <float, IEnumerable <RemoteMine> >(0, detonatableMines));
            }

            foreach (var landMine in nearestStack.LandMines.Where(x => x.Distance(heroPosition) <= x.Radius))
            {
                if (tempDamage >= hero.Health)
                {
                    return(new Tuple <float, IEnumerable <RemoteMine> >(tempDamage, detonatableMines));
                }

                tempDamage += Variables.Damage.GetLandMineDamage(landMine.Level, hero.ClassID);
            }

            foreach (var remoteMine in nearestStack.RemoteMines.Where(x => x.Distance(heroPosition) <= x.Radius))
            {
                if (tempDamage >= hero.Health)
                {
                    break;
                }

                detonatableMines.Add(remoteMine);
                tempDamage += Variables.Damage.GetRemoteMineDamage(remoteMine.Level, hero.ClassID, hero);
            }

            return(new Tuple <float, IEnumerable <RemoteMine> >(tempDamage, detonatableMines));
        }
Пример #2
0
        public static Vector3 GetBlinkPosition(this Unit unit, Vector3 direction, float remainingTime)
        {
            var angle = (float)(Math.Max(remainingTime, 0) * unit.GetTurnRate() / 0.03);

            var left  = VectorExtensions.FromPolarCoordinates(1, unit.NetworkRotationRad + angle).ToVector3();
            var right = VectorExtensions.FromPolarCoordinates(1, unit.NetworkRotationRad - angle).ToVector3();

            return(unit.Position + (left.Distance2D(direction) < right.Distance2D(direction) ? left : right) * 100);
        }
Пример #3
0
        private static void Game_OnUpdate(EventArgs args)
        {
            if (!loaded)
            {
                me = ObjectMgr.LocalHero;
                if (!Game.IsInGame || me == null || me.ClassID != ClassID.CDOTA_Unit_Hero_Techies)
                {
                    return;
                }
                loaded        = true;
                remoteMines   = me.Spellbook.SpellR;
                suicideAttack = me.Spellbook.SpellE;
                landMines     = me.Spellbook.SpellQ;
                forceStaff    = null;
                //enemyHeroes = null;
                players          = null;
                remoteMinesDb    = new Dictionary <Unit, float>();
                heroTopPanel     = new Dictionary <ClassID, double[]>();
                landMinesHeroDmg = new Dictionary <ClassID, double>();
                suicideHeroDmg   = new Dictionary <ClassID, float>();
                enabledHeroes    = new Dictionary <ClassID, bool>();
                var screenSize = new Vector2(Drawing.Width, Drawing.Height);
                monitor = screenSize.X / 1280;
                if (me.AghanimState())
                {
                    var firstOrDefault = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "damage_scepter");
                    if (firstOrDefault != null)
                    {
                        remoteMinesDmg = firstOrDefault.GetValue(remoteMines.Level - 1);
                    }
                }
                else
                {
                    var firstOrDefault = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "damage");
                    if (firstOrDefault != null)
                    {
                        remoteMinesDmg = firstOrDefault.GetValue(remoteMines.Level - 1);
                    }
                }
                foreach (var bomb in
                         ObjectMgr.GetEntities <Unit>()
                         .Where(
                             x =>
                             x.ClassID == ClassID.CDOTA_NPC_TechiesMines && x.Spellbook.Spell1 != null &&
                             x.Spellbook.Spell1.IsValid && x.Spellbook.Spell1.CanBeCasted() && x.IsAlive)
                         .Where(bomb => !remoteMinesDb.ContainsKey(bomb)))
                {
                    remoteMinesDb.Add(bomb, remoteMinesDmg);
                    if (bomb.Health < bomb.Health / 2)
                    {
                        bomb.Spellbook.SpellQ.UseAbility();
                    }
                }
                //enemyHeroes =
                //    ObjectMgr.GetEntities<Hero>()
                //        .Where(x => x != null && x.IsValid && x.Team == me.GetEnemyTeam() && !x.IsIllusion);
                players =
                    ObjectMgr.GetEntities <Player>()
                    .Where(x => x != null && x.Hero != null && x.Hero.Team == me.GetEnemyTeam());
                Game.PrintMessage(
                    "<font face='Tahoma'><font color='#993311'>#TECHIES</font> by MOON<font color='#ff9900'>ES</font> loaded!</font> ",
                    MessageType.LogMessage);
            }
            if (!Game.IsInGame || me == null || me.ClassID != ClassID.CDOTA_Unit_Hero_Techies)
            {
                loaded = false;
                return;
            }

            if (Game.IsPaused)
            {
                return;
            }

            if (forceStaff == null && Menu.Item("useForceStaff").GetValue <bool>()
                )
            {
                forceStaff = me.Inventory.Items.FirstOrDefault(x => x.ClassID == ClassID.CDOTA_Item_ForceStaff);
            }
            var detonate = ObjectMgr.GetEntities <Unit>()
                           .Where(x => x.ClassID == ClassID.CDOTA_NPC_TechiesMines && x.Spellbook.Spell1 != null && x.Spellbook.Spell1.IsValid && x.Spellbook.Spell1.CanBeCasted() && x.Health <= (x.MaximumHealth * 0.6) && x.IsAlive).FirstOrDefault();

            if (detonate != null && Utils.SleepCheck(detonate.Handle.ToString()))
            {
                detonate.Spellbook.SpellQ.UseAbility();
                Utils.Sleep(400, detonate.Handle.ToString());
            }

            var suicideLevel = suicideAttack.Level;

            if (suicideAttackLevel != suicideLevel)
            {
                var firstOrDefault = suicideAttack.AbilityData.FirstOrDefault(x => x.Name == "damage");
                if (firstOrDefault != null)
                {
                    suicideAttackDmg = firstOrDefault.GetValue(suicideLevel - 1);
                }
                var abilityData = suicideAttack.AbilityData.FirstOrDefault(x => x.Name == "small_radius");
                if (abilityData != null)
                {
                    suicideAttackRadius = abilityData.Value;
                }
                suicideAttackLevel = suicideLevel;
            }

            var bombLevel = remoteMines.Level;

            if (remoteMinesLevel != bombLevel)
            {
                if (me.AghanimState())
                {
                    var firstOrDefault = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "damage_scepter");
                    if (firstOrDefault != null)
                    {
                        remoteMinesDmg = firstOrDefault.GetValue(bombLevel - 1);
                    }
                }
                else
                {
                    var firstOrDefault = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "damage");
                    if (firstOrDefault != null)
                    {
                        remoteMinesDmg = firstOrDefault.GetValue(bombLevel - 1);
                    }
                }
                var abilityData = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "radius");
                if (abilityData != null)
                {
                    remoteMinesRadius = abilityData.Value + 20;
                }
                remoteMinesLevel = bombLevel;
            }

            var landMineslvl = landMines.Level;

            if (landMinesLevel != landMineslvl)
            {
                var firstOrDefault = landMines.AbilityData.FirstOrDefault(x => x.Name == "damage");
                if (firstOrDefault != null)
                {
                    landMinesDmg = firstOrDefault.GetValue(landMineslvl - 1);
                }
                landMinesLevel = landMineslvl;
            }

            if (!aghanims && me.AghanimState())
            {
                var firstOrDefault = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "damage_scepter");
                if (firstOrDefault != null)
                {
                    remoteMinesDmg = firstOrDefault.GetValue(bombLevel - 1);
                }
                aghanims = true;
            }
            var bombs =
                remoteMinesDb.Where(
                    x =>
                    x.Key != null && x.Key.IsValid && x.Key.Spellbook.Spell1 != null &&
                    x.Key.Spellbook.Spell1.CanBeCasted() && x.Key.IsAlive);
            var bombsArray = bombs as KeyValuePair <Unit, float>[] ?? bombs.ToArray();
            var eHeroes    =
                ObjectMgr.GetEntities <Hero>()
                .Where(
                    x =>
                    x != null && x.IsValid && !x.IsIllusion && x.Team == me.GetEnemyTeam() && x.IsAlive &&
                    x.IsVisible && !x.IsMagicImmune() &&
                    x.Modifiers.All(y => y.Name != "modifier_abaddon_borrowed_time") &&
                    x.Modifiers.All(y => y.Name != "modifier_dazzle_shallow_grave") &&
                    x.Modifiers.All(y => y.Name != "modifier_templar_assassin_refraction_absorb")

                    && Utils.SleepCheck(x.ClassID.ToString()));

            try
            {
                foreach (var hero in
                         eHeroes)
                {
                    bool enabled;
                    if (!enabledHeroes.TryGetValue(hero.ClassID, out enabled) || !enabled)
                    {
                        continue;
                    }
                    var heroDistance = me.Distance2D(hero);
                    if (Menu.Item("autoDetonate").GetValue <bool>())
                    {
                        var nearbyBombs = bombsArray.Any(x => x.Key.Distance2D(hero) <= remoteMinesRadius + 500);
                        if (nearbyBombs)
                        {
                            CheckBombDamageAndDetonate(hero, bombsArray);
                        }
                    }
                    //Game.PrintMessage((float)me.Health / me.MaximumHealth + " " + (float)Menu.Item("HPTreshold").GetValue<Slider>().Value / 100, MessageType.ChatMessage);
                    var zHeroes =
                        ObjectMgr.GetEntities <Hero>()
                        .Where(
                            x =>
                            x != null && x.IsValid && !x.IsIllusion && x.Team == me.GetEnemyTeam() && x.IsAlive &&
                            x.IsVisible && !x.IsMagicImmune() &&
                            x.Modifiers.All(y => y.Name != "modifier_abaddon_borrowed_time") &&
                            x.Modifiers.All(y => y.Name != "modifier_dazzle_shallow_grave") &&
                            x.Modifiers.All(y => y.Name != "modifier_templar_assassin_refraction_absorb"));
                    foreach (var z in zHeroes)
                    {
                        if (Menu.Item("autoSuicide").GetValue <bool>() && suicideAttack.CanBeCasted() &&
                            (float)me.Health / me.MaximumHealth
                            <= (float)Menu.Item("HPTreshold").GetValue <Slider>().Value / 100 && heroDistance < 400 &&
                            suicideAttackLevel > 0 && me.IsAlive &&
                            z.Modifiers.All(y => y.Name != "modifier_dazzle_shallow_grave"))
                        {
                            SuicideKillSteal(hero);
                        }
                    }
                    if (forceStaff == null || !Menu.Item("useForceStaff").GetValue <bool>() ||
                        !(heroDistance <= forceStaff.CastRange) || !Utils.SleepCheck("forcestaff") ||
                        bombsArray.Any(x => x.Key.Distance2D(hero) <= remoteMinesRadius) ||
                        Prediction.IsTurning(hero) || !forceStaff.CanBeCasted())
                    {
                        continue;
                    }

                    double rotSpeed;
                    if (!Prediction.RotSpeedDictionary.TryGetValue(hero.Handle, out rotSpeed) ||
                        (rotSpeed > 0 && Menu.Item("checkRotating").GetValue <bool>()))
                    {
                        continue;
                    }
                    if (Prediction.StraightTime(hero) / 1000 < Menu.Item("straightTime").GetValue <Slider>().Value)
                    {
                        continue;
                    }
                    var turnTime      = me.GetTurnTime(hero);
                    var forcePosition = hero.Position;
                    if (hero.NetworkActivity == NetworkActivity.Move)
                    {
                        forcePosition = Prediction.InFront(
                            hero,
                            (float)((turnTime + Game.Ping / 1000) * hero.MovementSpeed));
                    }
                    forcePosition +=
                        VectorExtensions.FromPolarCoordinates(1f, (float)(hero.NetworkRotationRad + rotSpeed))
                        .ToVector3() * 600;
                    var possibleBombs = bombsArray.Any(x => x.Key.Distance2D(forcePosition) <= (remoteMinesRadius - 75));
                    if (!possibleBombs)
                    {
                        continue;
                    }
                    var dmg = CheckBombDamage(hero, forcePosition, bombsArray);
                    if (!(dmg >= hero.Health) && hero.Modifiers.All(y => y.Name != "modifier_dazzle_shallow_grave" && y.Name != "modifier_templar_assassin_refraction_absorb"))
                    {
                        continue;
                    }
                    forceStaff.UseAbility(hero);
                    Utils.Sleep(250, "forcestaff");
                }
            }
            catch (Exception)
            {
                //aa
            }

            if (!Menu.Item("autoDetonateCreeps").GetValue <bool>())
            {
                return;
            }
            var creeps =
                ObjectMgr.GetEntities <Creep>()
                .Where(
                    x =>
                    (x.ClassID == ClassID.CDOTA_BaseNPC_Creep_Lane || x.ClassID == ClassID.CDOTA_BaseNPC_Creep_Siege) &&
                    x.IsAlive && x.IsVisible && x.IsSpawned && x.Team == me.GetEnemyTeam());
            var enumerable = creeps as Creep[] ?? creeps.ToArray();

            foreach (var data in (from creep in enumerable
                                  let nearbyBombs =
                                      bombsArray.Any(x => x.Key.Distance2D(creep) <= remoteMinesRadius + 500)
                                      where nearbyBombs
                                      let detonatableBombs = FindDetonatableBombs(creep, creep.Position, bombsArray)
                                                             where detonatableBombs != null
                                                             let nearbyCreeps =
                                          enumerable.Count(
                                              x =>
                                              x.Distance2D(creep) <= remoteMinesRadius &&
                                              CheckBombDamage(x, x.Position, bombsArray) >= x.Health)
                                          where nearbyCreeps > 3
                                          select detonatableBombs).SelectMany(
                         detonatableBombs =>
                         detonatableBombs.Where(data => Utils.SleepCheck(data.Value.Handle.ToString()))))
            {
                data.Value.UseAbility();
                Utils.Sleep(250, data.Value.Handle.ToString());
            }
        }
Пример #4
0
        private static void Game_OnUpdate(EventArgs args)
        {
            if (!loaded)
            {
                me = ObjectMgr.LocalHero;
                if (!Game.IsInGame || me == null || me.ClassID != ClassID.CDOTA_Unit_Hero_Techies)
                {
                    return;
                }
                loaded        = true;
                remoteMines   = me.Spellbook.SpellR;
                suicideAttack = me.Spellbook.SpellE;
                landMines     = me.Spellbook.SpellQ;
                forceStaff    = null;
                //enemyHeroes = null;
                players          = null;
                remoteMinesDb    = new Dictionary <Unit, float>();
                heroTopPanel     = new Dictionary <ClassID, double[]>();
                landMinesHeroDmg = new Dictionary <ClassID, double>();
                suicideHeroDmg   = new Dictionary <ClassID, float>();
                enabledHeroes    = new Dictionary <ClassID, bool>();
                var screenSize = new Vector2(Drawing.Width, Drawing.Height);
                monitor = screenSize.X / 1280;
                if (me.AghanimState())
                {
                    var firstOrDefault = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "damage_scepter");
                    if (firstOrDefault != null)
                    {
                        remoteMinesDmg = firstOrDefault.GetValue(remoteMines.Level - 1);
                    }
                }
                else
                {
                    var firstOrDefault = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "damage");
                    if (firstOrDefault != null)
                    {
                        remoteMinesDmg = firstOrDefault.GetValue(remoteMines.Level - 1);
                    }
                }
                foreach (var bomb in
                         ObjectMgr.GetEntities <Unit>()
                         .Where(
                             x =>
                             x.ClassID == ClassID.CDOTA_NPC_TechiesMines && x.Spellbook.Spell1 != null &&
                             x.Spellbook.Spell1.IsValid && x.Spellbook.Spell1.CanBeCasted() && x.IsAlive)
                         .Where(bomb => !remoteMinesDb.ContainsKey(bomb)))
                {
                    remoteMinesDb.Add(bomb, remoteMinesDmg);
                }
                //enemyHeroes =
                //    ObjectMgr.GetEntities<Hero>()
                //        .Where(x => x != null && x.IsValid && x.Team == me.GetEnemyTeam() && !x.IsIllusion);
                players =
                    ObjectMgr.GetEntities <Player>()
                    .Where(x => x != null && x.Hero != null && x.Hero.Team == me.GetEnemyTeam());
                Console.WriteLine("#Techies: Loaded!");
            }
            if (!Game.IsInGame || me == null || me.ClassID != ClassID.CDOTA_Unit_Hero_Techies)
            {
                loaded = false;
                Console.WriteLine("#Techies: Unloaded!");
                return;
            }

            if (Game.IsPaused)
            {
                return;
            }

            if (forceStaff == null)
            {
                forceStaff = me.Inventory.Items.FirstOrDefault(x => x.ClassID == ClassID.CDOTA_Item_ForceStaff);
            }

            var suicideLevel = suicideAttack.Level;

            if (suicideAttackLevel != suicideLevel)
            {
                var firstOrDefault = suicideAttack.AbilityData.FirstOrDefault(x => x.Name == "damage");
                if (firstOrDefault != null)
                {
                    suicideAttackDmg = firstOrDefault.GetValue(suicideLevel - 1);
                }
                var abilityData = suicideAttack.AbilityData.FirstOrDefault(x => x.Name == "small_radius");
                if (abilityData != null)
                {
                    suicideAttackRadius = abilityData.Value;
                }
                suicideAttackLevel = suicideLevel;
            }

            var bombLevel = remoteMines.Level;

            if (remoteMinesLevel != bombLevel)
            {
                if (me.AghanimState())
                {
                    var firstOrDefault = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "damage_scepter");
                    if (firstOrDefault != null)
                    {
                        remoteMinesDmg = firstOrDefault.GetValue(bombLevel - 1);
                    }
                }
                else
                {
                    var firstOrDefault = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "damage");
                    if (firstOrDefault != null)
                    {
                        remoteMinesDmg = firstOrDefault.GetValue(bombLevel - 1);
                    }
                }
                var abilityData = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "radius");
                if (abilityData != null)
                {
                    remoteMinesRadius = abilityData.Value + 20;
                }
                remoteMinesLevel = bombLevel;
            }

            var landMineslvl = landMines.Level;

            if (landMinesLevel != landMineslvl)
            {
                var firstOrDefault = landMines.AbilityData.FirstOrDefault(x => x.Name == "damage");
                if (firstOrDefault != null)
                {
                    landMinesDmg = firstOrDefault.GetValue(landMineslvl - 1);
                }
                landMinesLevel = landMineslvl;
            }

            if (!aghanims && me.AghanimState())
            {
                var firstOrDefault = remoteMines.AbilityData.FirstOrDefault(x => x.Name == "damage_scepter");
                if (firstOrDefault != null)
                {
                    remoteMinesDmg = firstOrDefault.GetValue(bombLevel - 1);
                }
                aghanims = true;
            }

            var bombs =
                remoteMinesDb.Where(
                    x =>
                    x.Key != null && x.Key.IsValid && x.Key.Spellbook.Spell1 != null &&
                    x.Key.Spellbook.Spell1.CanBeCasted() && x.Key.IsAlive);
            var bombsArray = bombs as KeyValuePair <Unit, float>[] ?? bombs.ToArray();
            var eHeroes    =
                ObjectMgr.GetEntities <Hero>()
                .Where(
                    x =>
                    x != null && x.IsValid && !x.IsIllusion && x.Team == me.GetEnemyTeam() && x.IsAlive &&
                    x.IsVisible && !x.IsMagicImmune() &&
                    x.Modifiers.All(y => y.Name != "modifier_abaddon_borrowed_time") &&
                    Utils.SleepCheck(x.ClassID.ToString()));

            try
            {
                foreach (var hero in
                         eHeroes)
                {
                    bool enabled;
                    if (!enabledHeroes.TryGetValue(hero.ClassID, out enabled) || !enabled)
                    {
                        continue;
                    }
                    var heroDistance = me.Distance2D(hero);
                    var nearbyBombs  = bombsArray.Any(x => x.Key.Distance2D(hero) <= remoteMinesRadius + 500);
                    if (nearbyBombs)
                    {
                        CheckBombDamageAndDetonate(hero, bombsArray);
                    }
                    if (heroDistance < 400 && suicideAttackLevel > 0 && me.IsAlive && (Case == 2 || Case == 3))
                    {
                        SuicideKillSteal(hero);
                    }
                    if (forceStaff == null || !(heroDistance <= forceStaff.CastRange) || !Utils.SleepCheck("forcestaff") ||
                        bombsArray.Any(x => x.Key.Distance2D(hero) <= remoteMinesRadius) ||
                        Prediction.IsTurning(hero) || !forceStaff.CanBeCasted())
                    {
                        continue;
                    }

                    var data =
                        Prediction.TrackTable.ToArray()
                        .FirstOrDefault(
                            unitData => unitData.UnitName == hero.Name || unitData.UnitClassID == hero.ClassID);
                    if (data == null)
                    {
                        continue;
                    }
                    var turnTime      = me.GetTurnTime(hero);
                    var forcePosition = hero.Position;
                    if (hero.NetworkActivity == NetworkActivity.Move)
                    {
                        forcePosition = Prediction.InFront(
                            hero,
                            (float)((turnTime + Game.Ping / 1000) * hero.MovementSpeed));
                    }
                    forcePosition +=
                        VectorExtensions.FromPolarCoordinates(1f, hero.NetworkRotationRad + data.RotSpeed).ToVector3()
                        * 600;
                    var possibleBombs = bombsArray.Any(x => x.Key.Distance2D(forcePosition) <= (remoteMinesRadius - 75));
                    if (!possibleBombs)
                    {
                        continue;
                    }
                    var dmg = CheckBombDamage(hero, forcePosition, bombsArray);
                    if (!(dmg >= hero.Health))
                    {
                        continue;
                    }
                    forceStaff.UseAbility(hero);
                    Utils.Sleep(250, "forcestaff");
                }
            }
            catch (Exception)
            {
                //aa
            }
            if (!(Case == 2 || Case == 4))
            {
                return;
            }
            var creeps =
                ObjectMgr.GetEntities <Creep>()
                .Where(
                    x =>
                    (x.ClassID == ClassID.CDOTA_BaseNPC_Creep_Lane || x.ClassID == ClassID.CDOTA_BaseNPC_Creep_Siege) &&
                    x.IsAlive && x.IsVisible && x.IsSpawned && x.Team == me.GetEnemyTeam());

            var enumerable = creeps as Creep[] ?? creeps.ToArray();

            foreach (var data in (from creep in enumerable
                                  let nearbyBombs =
                                      bombsArray.Any(x => x.Key.Distance2D(creep) <= remoteMinesRadius + 500)
                                      where nearbyBombs
                                      let detonatableBombs = FindDetonatableBombs(creep, creep.Position, bombsArray)
                                                             where detonatableBombs != null
                                                             let nearbyCreeps =
                                          enumerable.Count(
                                              x =>
                                              x.Distance2D(creep) <= remoteMinesRadius &&
                                              CheckBombDamage(x, x.Position, bombsArray) >= x.Health)
                                          where nearbyCreeps > 3
                                          select detonatableBombs).SelectMany(
                         detonatableBombs =>
                         detonatableBombs.Where(data => Utils.SleepCheck(data.Value.Handle.ToString()))))
            {
                data.Value.UseAbility();
                Utils.Sleep(250, data.Value.Handle.ToString());
            }
        }
Пример #5
0
        /// <summary>
        ///     The get stack damage.
        /// </summary>
        /// <param name="hero">
        ///     The hero.
        /// </param>
        /// <param name="inFrontDistance">
        ///     The in front distance.
        /// </param>
        /// <returns>
        ///     The <see cref="Tuple" />.
        /// </returns>
        public static Tuple <float, IEnumerable <RemoteMine>, Stack> GetStackDamage(
            this Unit hero,
            float inFrontDistance = 0)
        {
            var detonatableMines = new List <RemoteMine>();

            if (Variables.Stacks == null || !Variables.Stacks.Any())
            {
                return(new Tuple <float, IEnumerable <RemoteMine>, Stack>(0, detonatableMines, null));
            }

            var rotSpeed = Prediction.RotSpeedDictionary.ContainsKey(hero.Handle)
                               ? Prediction.RotSpeedDictionary[hero.Handle]
                               : 0;
            var heroPosition = inFrontDistance > 0
                                   ? hero.Position
                               + (VectorExtensions.FromPolarCoordinates(
                                      1f,
                                      (float)(hero.NetworkRotationRad + rotSpeed)).ToVector3() * inFrontDistance)
                                   : hero.Position;
            var prediction = heroPosition;

            if (hero.NetworkActivity == NetworkActivity.Move)
            {
                prediction +=
                    VectorExtensions.FromPolarCoordinates(1f, (float)(hero.NetworkRotationRad + rotSpeed)).ToVector3()
                    * ((float)(Variables.Techies.GetTurnTime(hero) + (Game.Ping / 500)) * hero.MovementSpeed);
            }

            var tempDamage   = 0f;
            var nearestStack = Variables.Stacks.MinOrDefault(x => x.Position.Distance(heroPosition));

            if (nearestStack == null || nearestStack.Position.Distance(heroPosition) > 1000)
            {
                return(new Tuple <float, IEnumerable <RemoteMine>, Stack>(0, detonatableMines, nearestStack));
            }

            if (inFrontDistance == 0 &&
                Variables.Menu.DetonationMenu.Item("Techies.DetonateWhenOnEdge").GetValue <bool>() &&
                (prediction.Distance2D(nearestStack.Position) <= hero.Position.Distance2D(nearestStack.Position) ||
                 prediction.Distance2D(nearestStack.Position)
                 < 425 - hero.HullRadius - 50
                 - ((float)(Variables.Techies.GetTurnTime(hero) + (Game.Ping / 500)) * hero.MovementSpeed) ||
                 hero.NetworkActivity != NetworkActivity.Move))
            {
                return(new Tuple <float, IEnumerable <RemoteMine>, Stack>(0, detonatableMines, nearestStack));
            }

            foreach (var landMine in
                     nearestStack.LandMines.Where(
                         x => x.Distance(heroPosition) <= x.Radius && x.Distance(prediction) <= x.Radius))
            {
                if (tempDamage >= hero.Health)
                {
                    return(new Tuple <float, IEnumerable <RemoteMine>, Stack>(tempDamage, detonatableMines, nearestStack));
                }

                tempDamage += Variables.Damage.GetLandMineDamage(landMine.Level, hero.Handle);
            }

            foreach (var remoteMine in
                     nearestStack.RemoteMines.Where(
                         x => x.Distance(heroPosition) <= x.Radius && x.Distance(prediction) <= x.Radius))
            {
                if (tempDamage >= hero.Health)
                {
                    if (!(hero is Hero) || !(nearestStack.MinEnemiesKill > 1))
                    {
                        return(new Tuple <float, IEnumerable <RemoteMine>, Stack>(
                                   tempDamage,
                                   Variables.Menu.DetonationMenu.Item("detonateAllMines").GetValue <bool>()
                                ? nearestStack.RemoteMines
                                : detonatableMines,
                                   nearestStack));
                    }

                    var count =
                        (from hero2 in
                         Heroes.GetByTeam(Variables.EnemyTeam)
                         .Where(
                             x =>
                             x.IsAlive && !x.IsIllusion && x.IsVisible && !x.Equals(hero) &&
                             Utils.SleepCheck(x.ClassID + "Techies.AutoDetonate") &&
                             x.Distance2D(nearestStack.Position) < 420)
                         let tempDamage2 =
                             detonatableMines.Sum(
                                 x => Variables.Damage.GetRemoteMineDamage(x.Level, hero2.Handle, hero2))
                             where tempDamage2 >= hero2.Health
                             select hero2).Count();
                    if (count + 1 >= nearestStack.MinEnemiesKill)
                    {
                        return(new Tuple <float, IEnumerable <RemoteMine>, Stack>(
                                   tempDamage,
                                   Variables.Menu.DetonationMenu.Item("detonateAllMines").GetValue <bool>()
                                ? nearestStack.RemoteMines
                                : detonatableMines,
                                   nearestStack));
                    }

                    detonatableMines.Add(remoteMine);
                    tempDamage += Variables.Damage.GetRemoteMineDamage(remoteMine.Level, hero.Handle, hero);
                    continue;
                }

                detonatableMines.Add(remoteMine);
                tempDamage += Variables.Damage.GetRemoteMineDamage(remoteMine.Level, hero.Handle, hero);
            }

            if (!(tempDamage >= hero.Health))
            {
                return(new Tuple <float, IEnumerable <RemoteMine>, Stack>(0, detonatableMines, nearestStack));
            }
            {
                if (!(hero is Hero) || !(nearestStack.MinEnemiesKill > 1))
                {
                    return(new Tuple <float, IEnumerable <RemoteMine>, Stack>(
                               tempDamage,
                               Variables.Menu.DetonationMenu.Item("detonateAllMines").GetValue <bool>()
                            ? nearestStack.RemoteMines
                            : detonatableMines,
                               nearestStack));
                }

                var count =
                    (from hero2 in
                     Heroes.GetByTeam(Variables.EnemyTeam)
                     .Where(
                         x =>
                         x.IsAlive && !x.IsIllusion && x.IsVisible && !x.Equals(hero) &&
                         Utils.SleepCheck(x.ClassID + "Techies.AutoDetonate") &&
                         x.Distance2D(nearestStack.Position) < 420)
                     let tempDamage2 =
                         detonatableMines.Sum(x => Variables.Damage.GetRemoteMineDamage(x.Level, hero2.Handle, hero2))
                         where tempDamage2 >= hero2.Health
                         select hero2).Count();
                return(count + 1 >= nearestStack.MinEnemiesKill
                           ? new Tuple <float, IEnumerable <RemoteMine>, Stack>(
                           tempDamage,
                           Variables.Menu.DetonationMenu.Item("detonateAllMines").GetValue <bool>()
                                     ? nearestStack.RemoteMines
                                     : detonatableMines,
                           nearestStack)
                           : new Tuple <float, IEnumerable <RemoteMine>, Stack>(0, detonatableMines, nearestStack));
            }
        }