コード例 #1
0
ファイル: Base.cs プロジェクト: sadnecc/EnsoulSharp-2
    public static bool UnderAllyTurret(this AIMinionClient target)
    {
        if (target == null)
        {
            return(false);
        }
        var turret = GameObjects.AllyTurrets.OrderBy(x => x.Distance(target.Position)).FirstOrDefault();

        if (turret != null)
        {
            return(target.Distance(turret.Position) < turret.AttackRange);
        }
        else
        {
            return(false);
        }
    }
コード例 #2
0
ファイル: Mechanics.cs プロジェクト: thienha1/EnsoulSharp
        /// <summary>
        ///     Process Karma Lane Clear
        /// </summary>
        public static void ProcessLaneClear()
        {
            // Get minions list
            var minions = ObjectManager.Get <AIMinionClient>().Where(m => m.IsValidTarget(Instances.Range));

            if (minions.Count() == 0)
            {
                // If no minions, ignore.
                return;
            }

            // player local value
            var player = Instances.Player;

            // Using menu & spells a lot, copy to local value.
            var menu   = Instances.Menu;
            var spells = Instances.Spells;

            var manaPercent = player.ManaPercent;

            #region Lane Clear - Q

            if (spells[SpellSlot.Q].IsReady())
            {
                #region Lane Clear - R + Q

                // Check if R is ready, we allowed R+Q in menu, we have more or equal mana percent than what we placed in menu and if we have enough minions in lane.
                if (spells[SpellSlot.R].IsReady() && menu.Item("l33t.karma.farming.lcrq").GetValue <bool>() &&
                    manaPercent >= menu.Item("l33t.karma.farming.lcminmpq").GetValue <Slider>().Value&&
                    minions.Count() >= menu.Item("l33t.karma.farming.lcminminions").GetValue <Slider>().Value)
                {
                    // Best minion
                    var minion = minions.FirstOrDefault();

                    // How many targets get hit by last minion because of AoE
                    var targeted = 0;

                    // Search for minion
                    foreach (var m in minions)
                    {
                        // Find all minions that are not our minion and check how many minions would it hit.
                        var lTargeted = minions.Where(lm => lm != m).Count(om => om.Distance(m) < 250f);

                        // If more minions it would hit than our last minion, continue with prediction.
                        if (lTargeted > targeted)
                        {
                            // Prediction
                            var pred = spells[SpellSlot.R].GetPrediction(m);

                            // Check if Q doesn't hit anything in travel
                            if (pred.CollisionObjects.Count == 0)
                            {
                                // Update minion if passes checks
                                minion   = m;
                                targeted = lTargeted;
                            }
                        }
                    }

                    // If minion is valid for our range
                    if (minion != null && (minion.IsValidTarget(spells[SpellSlot.R].Range)))
                    {
                        // Prediction
                        var pred = spells[SpellSlot.R].GetPrediction(minion);

                        // Casting
                        spells[SpellSlot.R].Cast();
                        spells[SpellSlot.Q].Cast(pred.CastPosition);
                        return;
                    }
                }

                #endregion

                #region Lane Clear - Solo Q

                // Check if we allowed Q in menu and we have enough mana by what we placed inside the menu
                if (menu.Item("l33t.karma.farming.lcq").GetValue <bool>() &&
                    manaPercent >= menu.Item("l33t.karma.farming.lcminmpq").GetValue <Slider>().Value)
                {
                    // Best minion
                    AIMinionClient minion = null;

                    // Search for minion
                    foreach (var m in
                             from m in minions
                             let pred = spells[SpellSlot.Q].GetPrediction(m)
                                        where pred.CollisionObjects.Count == 0
                                        select m)
                    {
                        if (minion == null)
                        {
                            var healthPred = HealthPrediction.GetHealthPrediction(
                                m, (int)((player.AttackDelay * 1000) * 3));
                            if (healthPred < Damages.GetDamage(m, SpellSlot.Q, false) ||
                                healthPred > Damages.GetDamage(m, SpellSlot.Q, false) + player.GetAutoAttackDamage(m))
                            {
                                minion = m;
                            }
                        }
                        else if (minion.Health > m.Health)
                        {
                            minion = m;
                        }
                    }

                    // If minion is valid for our range
                    if (minion != null && (minion.IsValidTarget(spells[SpellSlot.Q].Range)) &&
                        minion.Distance(player.PreviousPosition) > player.AttackRange)
                    {
                        // Prediction
                        var pred = spells[SpellSlot.Q].GetPrediction(minion);

                        // Cast
                        spells[SpellSlot.Q].Cast(pred.CastPosition);
                    }
                }

                #endregion
            }

            #endregion
        }