diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java index 39042014..41a01eb7 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java @@ -98,8 +98,8 @@ public class NumericStatFormula implements RandomStatData, Updatable hasMin = config.contains("min"); hasMax = config.contains("max"); uniform = !config.contains("spread") && !config.contains("scale") && !config.contains("base") && hasMin && hasMax; - min = config.getDouble("min"); - max = config.getDouble("max"); + min = hasMin ? config.getDouble("min") : 0; + max = hasMax ? config.getDouble("max") : 0; } // Error @@ -168,7 +168,7 @@ public class NumericStatFormula implements RandomStatData, Updatable /** * @return When the item has a certain level or tier, this is how much each level shifts - * the peak, so that it is centered at {@code base + scale*level} + * the peak, so that it is centered at {@code base + scale*level} * @see #getBase() */ public double getScale() { @@ -184,15 +184,15 @@ public class NumericStatFormula implements RandomStatData, Updatable /** * @return For gaussian distributions, there always is that INSANELY SMALL - * chance of getting an INSANELY LARGE number. - *

- * For example: At base atk dmg 10, and standard deviation 1: - *

68% of rolls will fall between 9 and 11; - *

95% of rolls will fall between 8 and 12; - *

99.7% of rolls will fall between 7 and 13; - *

10E-42 of a roll that will give you an epic 300 dmg sword - *

- * Whatever, this constrains to a minimum and maximum of output. + * chance of getting an INSANELY LARGE number. + *

+ * For example: At base atk dmg 10, and standard deviation 1: + *

68% of rolls will fall between 9 and 11; + *

95% of rolls will fall between 8 and 12; + *

99.7% of rolls will fall between 7 and 13; + *

10E-42 of a roll that will give you an epic 300 dmg sword + *

+ * Whatever, this constrains to a minimum and maximum of output. */ public double getMaxSpread() { return maxSpread; @@ -227,15 +227,15 @@ public class NumericStatFormula implements RandomStatData, Updatable * the formula is base + (scale*level). * This is the level * @return Legacy formula: ???
- * Let A = {base} + {scale} * lvl, then the returned value is a - * random value taken in respect to a gaussian distribution - * centered on A, with average spread of {spread}%, and with a - * maximum offset of {maxSpread}% (relative to average value) - *

- * Formula: Spread = Standard Deviation - * The mean, the peak is located at {base} + {scale}*lvl.
- * The 'spread' is the standard deviation of the distribution.
- * 'Max Spread' constrains the result of this operation at {mean}±{max spread} + * Let A = {base} + {scale} * lvl, then the returned value is a + * random value taken in respect to a gaussian distribution + * centered on A, with average spread of {spread}%, and with a + * maximum offset of {maxSpread}% (relative to average value) + *

+ * Formula: Spread = Standard Deviation + * The mean, the peak is located at {base} + {scale}*lvl.
+ * The 'spread' is the standard deviation of the distribution.
+ * 'Max Spread' constrains the result of this operation at {mean}±{max spread} */ public double calculate(double levelScalingFactor) { @@ -269,7 +269,7 @@ public class NumericStatFormula implements RandomStatData, Updatable value = RELATIVE_SPREAD ? actualBase * (1 + spreadCoef) : actualBase + spreadCoef; if (hasMin) value = Math.max(min, value); - if (hasMax) value = Math.max(max, value); + if (hasMax) value = Math.min(max, value); } return value;