From ec90df9c58fd3a8679bec7ff0f5e67b200cddca7 Mon Sep 17 00:00:00 2001 From: pimittens Date: Tue, 6 Aug 2024 20:42:23 -0700 Subject: [PATCH] chaos scroll fix The intention of the rand method is to return a pseudorandom uniformly distributed int between lbound and ubound (both inclusive). The previous implementation did not work as intended when the lower bound was negative since java round up instead of down when casting a negative double to an int. Adding the lower bound after the cast rather than before fixes this. Also changed the CHSCROLL_STAT_RANGE from 6 to 5 to be consistent with gms. --- config.yaml | 2 +- src/main/java/tools/Randomizer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.yaml b/config.yaml index 49c4572dca..64658ddf03 100644 --- a/config.yaml +++ b/config.yaml @@ -345,7 +345,7 @@ server: USE_ENHANCED_CRAFTING: false #Apply chaos scroll on every equip crafted. SCROLL_CHANCE_ROLLS: 1 #Number of rolls for success on a scroll, set 1 for default. CHSCROLL_STAT_RATE: 1 #Number of rolls of stat upgrade on a successfully applied chaos scroll, set 1 for default. - CHSCROLL_STAT_RANGE: 6 #Stat upgrade range (-N, N) on chaos scrolls. + CHSCROLL_STAT_RANGE: 5 #Stat upgrade range (-N, N) on chaos scrolls. #Beginner Skills Configuration USE_ULTRA_NIMBLE_FEET: false #Massive speed & jump upgrade. diff --git a/src/main/java/tools/Randomizer.java b/src/main/java/tools/Randomizer.java index 745f80bf55..cf688f0245 100644 --- a/src/main/java/tools/Randomizer.java +++ b/src/main/java/tools/Randomizer.java @@ -35,6 +35,6 @@ public class Randomizer { } public static int rand(final int lbound, final int ubound) { - return (int) ((rand.nextDouble() * (ubound - lbound + 1)) + lbound); + return ((int) (rand.nextDouble() * (ubound - lbound + 1))) + lbound; } } \ No newline at end of file