Exemple #1
0
 public static float CalculatedWeight(Item item,
                                      Targets.Item target,
                                      bool simulation    = false,
                                      bool forceRealTime = false)
 {
     try
     {
         var minValue = simulation ? item.SimulationMinValue : item.MinValue;
         var maxValue = simulation ? item.SimulationMaxValue : item.MaxValue;
         if (item.Weight <= MinWeight || maxValue <= 0)
         {
             return(MinWeight);
         }
         var minWeight = minValue > 0 ? item.Weight / (maxValue / minValue) : MinWeight;
         var weight    = item.Inverted
             ? item.Weight - item.Weight * GetValue(item, target, forceRealTime) / maxValue + minWeight
             : item.Weight * GetValue(item, target, forceRealTime) / maxValue;
         return(float.IsNaN(weight) || float.IsInfinity(weight)
             ? MinWeight
             : Math.Min(MaxWeight, Math.Min(item.Weight, Math.Max(MinWeight, Math.Max(weight, minWeight)))));
     }
     catch
     {
         // Ignored
     }
     return(MinWeight);
 }
Exemple #2
0
 public static float GetValue(Item item, Targets.Item target)
 {
     try
     {
         var value = item.GetValueFunc(target.Hero);
         return(value > 1 ? value : 1);
     }
     catch
     {
         return(item.Inverted ? item.MaxValue : item.MinValue);
     }
 }
Exemple #3
0
        public static float CalculatedWeight(Item item, Targets.Item target, bool simulation = false)
        {
            if (item.Weight == 0)
            {
                return(0);
            }
            var weight = item.Weight *
                         (item.Inverted
                             ? (simulation ? item.SimulationMinValue : item.MinValue)
                             : GetValue(item, target)) / (item.Inverted ? GetValue(item, target) : item.MaxValue);

            return(float.IsNaN(weight) || float.IsInfinity(weight) ? MinWeight : weight);
        }
Exemple #4
0
        private static void OnGameUpdate(EventArgs args)
        {
            if (_mainMenu == null || TargetSelector.Mode != ModeType.Weights)
            {
                return;
            }

            var highestEnabled =
                _mainMenu.Item(_mainMenu.Name + ".drawing.weights.highest-target.enabled").GetValue <bool>();
            var weightsSimple = _mainMenu.Item(_mainMenu.Name + ".drawing.weights.simple").GetValue <bool>();

            if (highestEnabled || weightsSimple)
            {
                var enemies = Targets.Items.Where(h => h.Hero.IsValidTarget(Range)).ToList();
                foreach (var weight in Items.Where(w => w.Weight > 0))
                {
                    UpdateMaxMinValue(weight, enemies, true);
                }
                foreach (var target in enemies)
                {
                    var totalWeight = 0f;
                    foreach (var weight in Items.Where(w => w.Weight > 0))
                    {
                        var lastWeight = CalculatedWeight(weight, target, true);
                        if (lastWeight > 0)
                        {
                            if (_mainMenu != null)
                            {
                                var heroMultiplicator =
                                    _mainMenu.Item(_mainMenu.Name + ".weights.heroes." + target.Hero.ChampionName)
                                    .GetValue <Slider>()
                                    .Value;
                                if (heroMultiplicator > 1)
                                {
                                    lastWeight += Average * heroMultiplicator;
                                }
                            }
                            totalWeight += lastWeight;
                        }
                    }
                    target.SimulatedWeight = totalWeight;
                }
                _drawingTargets = enemies.OrderByDescending(t => t.SimulatedWeight).ToList();
                if (Game.Time - _lastBestTargetSwitch >= BestTargetSwitchDelay)
                {
                    _bestTarget           = _drawingTargets.FirstOrDefault();
                    _lastBestTargetSwitch = Game.Time;
                }
            }
        }
Exemple #5
0
 public static float GetValue(Item item, Targets.Item target, bool forceRealTime = false)
 {
     try
     {
         if (ItemCache.MaxAge > 0 && !forceRealTime)
         {
             var cacheValue = ItemCache[item.UniqueName];
             if (cacheValue != null)
             {
                 return((float)cacheValue);
             }
         }
         var value = item.ValueFunction(target.Hero);
         value = Math.Max(0, value);
         ItemCache.AddOrUpdate(item.UniqueName, value);
         return(value);
     }
     catch
     {
         return(item.Inverted ? item.MaxValue : item.MinValue);
     }
 }
Exemple #6
0
 public Item(AIHeroClient sender, Targets.Item target)
 {
     Sender    = sender;
     Target    = target;
     Timestamp = Game.Time;
 }
Exemple #7
0
        private static void OnGameUpdate(EventArgs args)
        {
            if (_mainMenu == null || TargetSelector.Mode != ModeType.Weights)
            {
                return;
            }

            var highestEnabled =
                _mainMenu.Item(_mainMenu.Name + ".drawing.weights.highest-target.enabled").GetValue<bool>();
            var weightsSimple = _mainMenu.Item(_mainMenu.Name + ".drawing.weights.simple").GetValue<bool>();
            if (highestEnabled || weightsSimple)
            {
                var enemies = Targets.Items.Where(h => h.Hero.IsValidTarget(Range)).ToList();
                foreach (var weight in Items.Where(w => w.Weight > 0))
                {
                    UpdateMaxMinValue(weight, enemies, true);
                }
                foreach (var target in enemies)
                {
                    var totalWeight = 0f;
                    foreach (var weight in Items.Where(w => w.Weight > 0))
                    {
                        var lastWeight = CalculatedWeight(weight, target, true);
                        if (lastWeight > 0)
                        {
                            if (_mainMenu != null)
                            {
                                var heroMultiplicator =
                                    _mainMenu.Item(_mainMenu.Name + ".weights.heroes." + target.Hero.ChampionName)
                                        .GetValue<Slider>()
                                        .Value;
                                if (heroMultiplicator > 1)
                                {
                                    lastWeight += Average * heroMultiplicator;
                                }
                            }
                            totalWeight += lastWeight;
                        }
                    }
                    target.SimulatedWeight = totalWeight;
                }
                _drawingTargets = enemies.OrderByDescending(t => t.SimulatedWeight).ToList();
                if (Game.Time - _lastBestTargetSwitch >= BestTargetSwitchDelay)
                {
                    _bestTarget = _drawingTargets.FirstOrDefault();
                    _lastBestTargetSwitch = Game.Time;
                }
            }
        }
Exemple #8
0
 public Item(Obj_AI_Hero sender, Targets.Item target)
 {
     Sender    = sender;
     Target    = target;
     Timestamp = Game.Time;
 }
            private static void OnGameUpdate(EventArgs args)
            {
                if (MainMenu == null || Modes.Current.Mode != Mode.Weights)
                {
                    return;
                }

                var highestEnabled =
                    MainMenu.Item(MainMenu.Name + ".drawing.weights.highest-target.enabled").GetValue<bool>();
                var weightsSimple = MainMenu.Item(MainMenu.Name + ".drawing.weights.simple").GetValue<bool>();
                if (highestEnabled || weightsSimple)
                {
                    var enemies = Targets.Items.Where(h => h.Hero.IsValidTarget(Range)).ToList();
                    foreach (var weight in Items.Where(w => w.Weight > 0))
                    {
                        UpdateMaxMinValue(weight, enemies, true);
                    }
                    foreach (var target in enemies)
                    {
                        var totalWeight = Items.Where(w => w.Weight > 0).Sum(w => CalculatedWeight(w, target, true));

                        if (MainMenu != null)
                        {
                            var heroPercent =
                                MainMenu.Item(MainMenu.Name + ".weights.heroes." + target.Hero.ChampionName)
                                    .GetValue<Slider>()
                                    .Value;

                            totalWeight = heroPercent > 0 ? totalWeight / 100 * heroPercent : 0;
                        }

                        target.SimulatedWeight = totalWeight;
                    }
                    _drawingTargets = enemies.OrderByDescending(t => t.SimulatedWeight).ToList();
                    if (Game.Time - _lastBestTargetSwitch >= BestTargetSwitchDelay)
                    {
                        _bestTarget = _drawingTargets.FirstOrDefault();
                        _lastBestTargetSwitch = Game.Time;
                    }
                }
            }