diff options
author | hondew <pokehondew@gmail.com> | 2020-05-02 11:46:12 -0400 |
---|---|---|
committer | hondew <pokehondew@gmail.com> | 2020-05-02 11:51:49 -0400 |
commit | 49184cd799e083b3b612f216da68ccafeb2cfb4f (patch) | |
tree | d72a01c43142c79c2f0b7a5e7b26a058838e0222 /src | |
parent | cb5b8da77b9ba6837fcc8c5163bedc5008b12c2c (diff) |
Document berry yield
fix wording
Diffstat (limited to 'src')
-rw-r--r-- | src/berry.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/berry.c b/src/berry.c index 7a8ab37fa..3f59639ad 100644 --- a/src/berry.c +++ b/src/berry.c @@ -1200,6 +1200,15 @@ static u8 GetNumStagesWateredByBerryTreeId(u8 id) return BerryTreeGetNumStagesWatered(GetBerryTreeInfo(id)); } +// Berries can be watered at 4 stages of growth. This function is likely meant +// to divide the berry yield range equally into quartiles. If you watered the +// tree n times, your yield is a random number in the nth quartile. +// +// However, this function actually skews towards higher berry yields, because +// it rounds `extraYield` to the nearest whole number. +// +// See resulting yields: https://pastebin.com/RLGnP9Ng, and +// bug fix: https://pastebin.com/cDjnUWL0. static u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water) { u32 randMin; @@ -1215,10 +1224,11 @@ static u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water) randMax = (max - min) * (water); rand = randMin + Random() % (randMax - randMin + 1); - if ((rand & 3) > 1) - extraYield = rand / 4 + 1; + // Round upwards + if ((rand % NUM_BERRY_STAGES) >= NUM_BERRY_STAGES / 2) + extraYield = rand / NUM_BERRY_STAGES + 1; else - extraYield = rand / 4; + extraYield = rand / NUM_BERRY_STAGES; return extraYield + min; } } |