Esempio n. 1
0
        private List <CardColor> GetBestCard(Obj_AI_Hero target, string mode)
        {
            var cards = new List <CardColor>();

            if (target == null || !target.IsValid)
            {
                return(cards);
            }
            try
            {
                if (IsWKillable(target, 2) && !target.IsDead)
                {
                    cards.Add(CardColor.Gold);
                }
                if (IsWKillable(target) && !target.IsDead)
                {
                    cards.Add(CardColor.Blue);
                }
                if (IsWKillable(target, 1) && !target.IsDead)
                {
                    cards.Add(CardColor.Red);
                }
                if (cards.Any())
                {
                    return(cards);
                }
                var burst = Menu.Item(Menu.Name + ".miscellaneous.mode").GetValue <StringList>().SelectedIndex == 0;
                var red   = 0;
                var blue  = 0;
                var gold  = 0;
                if (!burst &&
                    (mode == "combo" || mode == "harass" && Menu.Item(Menu.Name + ".harass.w-auto").GetValue <bool>()))
                {
                    if (Q.Level == 0)
                    {
                        return(new List <CardColor> {
                            CardColor.Blue
                        });
                    }
                    gold++;
                    if (target.Distance(Player) > W.Range * 0.8f)
                    {
                        gold++;
                    }
                    if (!ManaManager.Check(mode + "-blue"))
                    {
                        blue = 4;
                    }
                    var minRed  = Menu.Item(Menu.Name + ".combo.red-min").GetValue <Slider>().Value;
                    var redHits = GetWHits(target, GameObjects.EnemyHeroes.Cast <Obj_AI_Base>().ToList(), CardColor.Red);
                    red += redHits;
                    if (red > blue && red > gold && redHits >= minRed)
                    {
                        cards.Add(CardColor.Red);
                        if (red == blue)
                        {
                            cards.Add(CardColor.Blue);
                        }
                        if (red == gold)
                        {
                            cards.Add(CardColor.Gold);
                        }
                    }
                    else if (gold > blue && gold > red)
                    {
                        cards.Add(CardColor.Gold);
                        if (gold == blue)
                        {
                            cards.Add(CardColor.Blue);
                        }
                        if (gold == red && redHits >= minRed)
                        {
                            cards.Add(CardColor.Red);
                        }
                    }
                    else if (blue > red && blue > gold)
                    {
                        cards.Add(CardColor.Blue);
                        if (blue == red && redHits >= minRed)
                        {
                            cards.Add(CardColor.Red);
                        }
                        if (blue == gold)
                        {
                            cards.Add(CardColor.Gold);
                        }
                    }
                }
                if (mode == "combo" && !cards.Any())
                {
                    if (Q.Level == 0)
                    {
                        return(new List <CardColor> {
                            CardColor.Blue
                        });
                    }
                    var distance = target.Distance(Player);
                    var damage   = ItemManager.CalculateComboDamage(target) - target.HPRegenRate * 2f - 10;
                    if (HasEBuff())
                    {
                        damage += E.GetDamage(target);
                    }
                    if (Q.IsReady() && (Utils.GetStunTime(target) > 0.5f || distance < Q.Range / 4f))
                    {
                        damage += Q.GetDamage(target);
                    }
                    if (W.GetDamage(target, 2) + damage > target.Health)
                    {
                        cards.Add(CardColor.Gold);
                    }
                    if (distance < Orbwalking.GetRealAutoAttackRange(target) * 0.85f)
                    {
                        if (W.GetDamage(target) + damage > target.Health)
                        {
                            cards.Add(CardColor.Blue);
                        }
                        if (W.GetDamage(target, 1) + damage > target.Health)
                        {
                            cards.Add(CardColor.Red);
                        }
                    }

                    var blueMana1 = (ObjectManager.Player.Mana <(W.Instance.ManaCost + Q.Instance.ManaCost) &&
                                                                ObjectManager.Player.Mana> (Q.Instance.ManaCost - 10));
                    var blueMana2 = (ObjectManager.Player.Mana <(W.Instance.ManaCost + Q.Instance.ManaCost) &&
                                                                ObjectManager.Player.Mana> (Q.Instance.ManaCost - 20));
                    var blueMana3 = (ObjectManager.Player.Mana < (W.Instance.ManaCost + Q.Instance.ManaCost));
                    if (!cards.Any())
                    {
                        if (ObjectManager.Player.HealthPercent <=
                            Menu.Item(Menu.Name + ".combo.gold-percent").GetValue <Slider>().Value)
                        {
                            cards.Add(CardColor.Gold);
                        }
                        else if ((!ManaManager.Check("combo-blue") || (W.Level == 1 && blueMana1) ||
                                  W.Level == 2 && blueMana2) || W.Level > 2 && blueMana3)
                        {
                            cards.Add(CardColor.Blue);
                        }
                        else
                        {
                            var redHits = GetWHits(
                                target, GameObjects.EnemyHeroes.Cast <Obj_AI_Base>().ToList(), CardColor.Red);
                            if (redHits >= Menu.Item(Menu.Name + ".combo.red-min").GetValue <Slider>().Value)
                            {
                                cards.Add(CardColor.Red);
                            }
                        }
                    }
                    if (!cards.Any())
                    {
                        cards.Add(CardColor.Gold);
                    }
                }
                else if (mode == "harass" && !cards.Any())
                {
                    if (Menu.Item(Menu.Name + ".harass.w-auto").GetValue <bool>() && burst)
                    {
                        cards.Add(target.Distance(Player) > W.Range * 0.8f ? CardColor.Gold : CardColor.Blue);
                    }
                    else
                    {
                        var card = !ManaManager.Check("harass-blue")
                            ? CardColor.Blue
                            : GetSelectedCardColor(
                            Menu.Item(Menu.Name + ".harass.w-card").GetValue <StringList>().SelectedIndex);
                        if (card != CardColor.None)
                        {
                            cards.Add(card);
                        }
                    }
                }
                else if (mode == "flee")
                {
                    cards.Add(
                        GetWHits(target, GameObjects.EnemyHeroes.Cast <Obj_AI_Base>().ToList(), CardColor.Red) >= 2
                            ? CardColor.Red
                            : CardColor.Gold);
                }
                if (!cards.Any())
                {
                    cards.Add(CardColor.Gold);
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return(cards);
        }