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

            if (target == null || !target.IsValid || target.IsDead)
            {
                return(cards);
            }
            try
            {
                if (IsWKillable(target, 2))
                {
                    cards.Add(CardColor.Gold);
                }
                if (IsWKillable(target))
                {
                    cards.Add(CardColor.Blue);
                }
                if (IsWKillable(target, 1))
                {
                    cards.Add(CardColor.Red);
                }
                if (cards.Any())
                {
                    return(cards);
                }
                var selectedCard =
                    GetSelectedCardColor(Menu.Item(Menu.Name + ".harass.w-card").GetValue <StringList>().SelectedIndex);
                var burst = Menu.Item(Menu.Name + ".miscellaneous.mode").GetValue <StringList>().SelectedIndex == 0;
                var red   = 0;
                var blue  = 0;
                var gold  = 0;

                var shouldBlue = Player.Mana <W.ManaCost + Q.ManaCost &&
                                              Player.Mana + (25 + 25 * W.Level)> Q.ManaCost + W.ManaCost;

                if (!burst && (mode == "combo" || mode == "harass" && selectedCard == CardColor.None))
                {
                    if (Q.Level == 0)
                    {
                        return(new List <CardColor> {
                            CardColor.Blue
                        });
                    }
                    gold++;
                    if (target.Distance(Player) > W.Range * 0.8f)
                    {
                        gold++;
                    }
                    if (mode == "combo" && (Player.ManaPercent < 10 || shouldBlue) ||
                        mode == "harass" && !ResourceManager.Check("harass-blue"))
                    {
                        return(new List <CardColor> {
                            CardColor.Blue
                        });
                    }
                    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.GetImmobileTime(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);
                        }
                    }

                    if (!cards.Any())
                    {
                        if (ObjectManager.Player.HealthPercent <=
                            Menu.Item(Menu.Name + ".combo.gold-percent").GetValue <Slider>().Value)
                        {
                            cards.Add(CardColor.Gold);
                        }
                        else if (Player.ManaPercent < 10 || shouldBlue)
                        {
                            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 (selectedCard == CardColor.None && burst)
                    {
                        cards.Add(target.Distance(Player) > W.Range * 0.8f ? CardColor.Gold : CardColor.Blue);
                    }
                    else
                    {
                        var card = !ResourceManager.Check("harass-blue") ? CardColor.Blue : selectedCard;
                        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);
        }