Пример #1
0
        public static bool Check(string mode,
                                 int min,
                                 List <Obj_AI_Hero> hits,
                                 Func <Obj_AI_Hero, float> calcDamage = null)
        {
            try
            {
                if (_menu == null || hits == null || !hits.Any())
                {
                    return(false);
                }

                if (_force && HeroListManager.Enabled("ultimate-force"))
                {
                    var killable   = _menu.Item(_menu.Name + ".ultimate.force.combo-killable").GetValue <bool>();
                    var additional = _menu.Item(_menu.Name + ".ultimate.force.additional").GetValue <Slider>().Value;
                    if (
                        hits.Any(
                            hit =>
                            HeroListManager.Check("ultimate-force", hit) &&
                            (!killable || calcDamage == null || calcDamage(hit) > hit.Health)) &&
                        hits.Count >= additional + 1)
                    {
                        return(true);
                    }
                }

                if (_required && HeroListManager.Enabled("ultimate-required-" + mode))
                {
                    var minReq        = _menu.Item(_menu.Name + ".ultimate.required." + mode + ".min").GetValue <Slider>().Value;
                    var range         = _menu.Item(_menu.Name + ".ultimate.required.range-check").GetValue <Slider>().Value;
                    var enabledHeroes = HeroListManager.GetEnabledHeroes("ultimate-required-" + mode);
                    var count         =
                        enabledHeroes.Where(e => !e.IsDead && e.IsVisible && e.Distance(ObjectManager.Player) <= range)
                        .Count(e => hits.Any(h => h.NetworkId.Equals(e.NetworkId)));
                    if (count < minReq)
                    {
                        return(false);
                    }
                }

                return(hits.Count >= min);
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return(false);
        }
 public bool Check(UltimateModeType mode, List <Obj_AI_Hero> hits)
 {
     try
     {
         var modeString = GetModeString(mode, true);
         if (_menu == null || hits == null || !hits.Any(h => h.IsValidTarget()))
         {
             return(false);
         }
         if (IsActive(mode))
         {
             if (mode != UltimateModeType.Gapcloser && mode != UltimateModeType.Interrupt)
             {
                 if (Force && HeroListManager.Enabled("ultimate-force"))
                 {
                     var dmgCheck = DamageCalculation != null &&
                                    _menu.Item(_menu.Name + ".ultimate.force.damage-check").GetValue <bool>();
                     var additional =
                         _menu.Item(_menu.Name + ".ultimate.force.additional").GetValue <Slider>().Value + 1;
                     if (
                         hits.Any(
                             hit =>
                             HeroListManager.Check("ultimate-force", hit) && hits.Count >= additional &&
                             (!dmgCheck || GetDamage(hit, mode, additional) >= hit.Health)))
                     {
                         return(true);
                     }
                 }
                 if (Required && HeroListManager.Enabled("ultimate-required-" + modeString))
                 {
                     var minReq =
                         _menu.Item(_menu.Name + ".ultimate.required." + modeString + ".min")
                         .GetValue <Slider>()
                         .Value;
                     var enabledHeroes = HeroListManager.GetEnabledHeroes("ultimate-required-" + modeString);
                     if (minReq > 0 && enabledHeroes.Count > 0)
                     {
                         var count =
                             enabledHeroes.Where(
                                 e => !e.IsDead && e.IsVisible && e.Distance(ObjectManager.Player) <= 2000)
                             .Count(e => hits.Any(h => h.NetworkId.Equals(e.NetworkId)));
                         if (count < minReq)
                         {
                             return(false);
                         }
                     }
                 }
                 if (DamageCalculation != null &&
                     _menu.Item(_menu.Name + ".ultimate." + modeString + ".damage-check").GetValue <bool>())
                 {
                     if (hits.All(h => GetDamage(h, mode, hits.Count) < h.Health))
                     {
                         return(false);
                     }
                 }
                 return(hits.Count >= GetMinHits(mode));
             }
             return(true);
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return(false);
 }