コード例 #1
0
ファイル: Weights.cs プロジェクト: waldow90/PortAIO
 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);
 }
コード例 #2
0
        private static void OnCorePreUpdate(EventArgs args)
        {
            try
            {
                if (_mainMenu == null || TargetSelector.Mode != TargetSelectorModeType.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;
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
コード例 #3
0
ファイル: Weights.cs プロジェクト: 47110572/LeagueSharp-Dev
 public static float GetValue(Item item, Targets.Item target)
 {
     try
     {
         var value = item.GetValueFunc(target.Hero);
         return(value > 1 ? value : 1);
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
         return(item.Inverted ? item.MaxValue : item.MinValue);
     }
 }
コード例 #4
0
ファイル: Weights.cs プロジェクト: 47110572/LeagueSharp-Dev
        public static float CalculatedWeight(Item item, Targets.Item target, bool simulation = false)
        {
            try
            {
                if (item.Weight == 0)
                {
                    return(0);
                }

                return(item.Weight *
                       (item.Inverted ? (simulation ? item.SimulationMinValue : item.MinValue) : GetValue(item, target)) /
                       (item.Inverted ? GetValue(item, target) : item.MaxValue));
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return(0);
        }
コード例 #5
0
ファイル: Weights.cs プロジェクト: waldow90/PortAIO
 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);
     }
 }
コード例 #6
0
ファイル: Weights.cs プロジェクト: 47110572/LeagueSharp-Dev
        private static void OnDrawingDraw(EventArgs args)
        {
            try
            {
                if (_mainMenu == null)
                {
                    return;
                }

                var highestEnabled =
                    _mainMenu.Item(_mainMenu.Name + ".drawing.weights.highest-target.enabled").GetValue <bool>();
                var highestRadius =
                    _mainMenu.Item(_mainMenu.Name + ".drawing.weights.highest-target.radius").GetValue <Slider>().Value;
                var highestColor =
                    _mainMenu.Item(_mainMenu.Name + ".drawing.weights.highest-target.color").GetValue <Color>();

                var weightsSimple   = _mainMenu.Item(_mainMenu.Name + ".drawing.weights.simple").GetValue <bool>();
                var weightsAdvanced = _mainMenu.Item(_mainMenu.Name + ".drawing.weights.advanced").GetValue <bool>();

                var circleThickness =
                    _mainMenu.Item(_mainMenu.Name + ".drawing.circle-thickness").GetValue <Slider>().Value;

                if ((highestEnabled || weightsSimple || weightsAdvanced) &&
                    TargetSelector.Mode == TargetSelectorModeType.Weights)
                {
                    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);
                    }
                    Targets.Item bestTarget       = null;
                    var          bestTargetWeight = float.MinValue;
                    foreach (var target in enemies)
                    {
                        var onScreen    = target.Hero.Position.IsOnScreen();
                        var position    = Drawing.WorldToScreen(target.Hero.Position);
                        var totalWeight = 0f;
                        var offset      = 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;
                                    }
                                }
                                if (weightsAdvanced && onScreen)
                                {
                                    Drawing.DrawText(
                                        position.X + target.Hero.BoundingRadius, position.Y - 100 + offset, Color.White,
                                        lastWeight.ToString("0.0").Replace(",", ".") + " - " + weight.DisplayName);
                                    offset += 17f;
                                }
                                totalWeight += lastWeight;
                            }
                        }
                        if (weightsSimple && onScreen)
                        {
                            Drawing.DrawText(
                                target.Hero.HPBarPosition.X + 55f, target.Hero.HPBarPosition.Y - 20f, Color.White,
                                totalWeight.ToString("0.0").Replace(",", "."));
                        }
                        if (highestEnabled)
                        {
                            if (totalWeight > bestTargetWeight)
                            {
                                bestTargetWeight = totalWeight;
                                bestTarget       = target;
                            }
                        }
                    }
                    if (highestEnabled && bestTarget != null && enemies.Count(e => e.Hero.Position.IsOnScreen()) >= 2)
                    {
                        Render.Circle.DrawCircle(
                            bestTarget.Hero.Position, bestTarget.Hero.BoundingRadius + highestRadius, highestColor,
                            circleThickness, true);
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
コード例 #7
0
 public Item(AIHeroClient sender, Targets.Item target)
 {
     Sender    = sender;
     Target    = target;
     Timestamp = Game.Time;
 }
コード例 #8
0
            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;
                    }
                }
            }
コード例 #9
0
ファイル: Aggro.cs プロジェクト: batuta95/LeagueSharp-Dev
 public Item(Obj_AI_Hero sender, Targets.Item target)
 {
     Sender    = sender;
     Target    = target;
     Timestamp = Game.Time;
 }
コード例 #10
0
ファイル: Weights.cs プロジェクト: jayblah/Lizzaran
        private static void OnCorePreUpdate(EventArgs args)
        {
            try
            {
                if (_mainMenu == null || TargetSelector.Mode != TargetSelectorModeType.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;
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }