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; } }
public static float CalculatedWeight(Item item, Targets.Item target, bool simulation = false) { try { 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; } catch (Exception ex) { Global.Logger.AddItem(new LogItem(ex)); } return 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; } }
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; }
public Item(Obj_AI_Hero sender, Targets.Item target) { Sender = sender; Target = target; Timestamp = Game.Time; }
public static float CalculatedWeight(Item item, Targets.Item target, bool simulation = false) { try { if (item.Weight == 0) { return 0; } return item.Inverted ? item.Weight - (item.Weight * (GetValue(item, target) - (simulation ? item.SimulationMinValue : item.MinValue)) / (simulation ? item.SimulationMaxValue : item.MaxValue)) : item.Weight * GetValue(item, target) / (simulation ? item.SimulationMaxValue : item.MaxValue); } catch (Exception ex) { Global.Logger.AddItem(new LogItem(ex)); } return 0; }