From af12697845f83b2a9984556af436c9668a938c5a Mon Sep 17 00:00:00 2001 From: psf <77138753+pkmnsnfrn@users.noreply.github.com> Date: Tue, 20 Aug 2024 04:23:33 -0700 Subject: [PATCH] Adds OW_BERRY_IMMORTAL (#5187) * Added OW_BERRY_IMMORTAL Added cases for OW_BERRY_IMMORTAL * removed one preproc * removed other preproc * Fixed identation * Set config to FALSE * Update include/config/overworld.h per https://github.com/rh-hideout/pokeemerald-expansion/pull/5187#discussion_r1720747388 Co-authored-by: Bassoonian * Reordered condition per https://github.com/rh-hideout/pokeemerald-expansion/pull/5187\#discussion_r1720747652 * Update include/config/overworld.h --------- Co-authored-by: Bassoonian --- include/config/overworld.h | 1 + src/berry.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/config/overworld.h b/include/config/overworld.h index b47cef5c5082..63479f18317c 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -33,6 +33,7 @@ #define OW_BERRY_GROWTH_RATE GEN_3 // Presets for how long each Berry plant takes to grow. #define OW_BERRY_YIELD_RATE GEN_3 // Presets for how many Berries each plant can yield. #define OW_BERRY_DRAIN_RATE GEN_6_ORAS // If OW_BERRY_MOISTURE is enabled, this setting changes how fast the soil dries out. GEN_4 uses a Berry-dependent drain rate, GEN_6_XY dries out in 24 hours (4 hours with the relevant Mulch) and GEN_6_ORAS dries out in 4 hours. Other values are illegal. +#define OW_BERRY_IMMORTAL FALSE // If enabled, once a Berry tree has grown a Berry, the tree will not disappear until picked by the player. // Overworld Pokémon #define OW_POKEMON_OBJECT_EVENTS TRUE // Adds Object Event fields for every species. Can be used for NPCs using the OBJ_EVENT_GFX_SPECIES macro (eg. OBJ_EVENT_GFX_SPECIES(BULBASAUR)) diff --git a/src/berry.c b/src/berry.c index 9f187bd1e239..1a1c3b7f1f6b 100644 --- a/src/berry.c +++ b/src/berry.c @@ -1817,6 +1817,8 @@ bool32 BerryTreeGrow(struct BerryTree *tree) tree->stage = BERRY_STAGE_BERRIES; break; case BERRY_STAGE_BERRIES: + if (OW_BERRY_IMMORTAL) + break; tree->watered = 0; tree->berryYield = 0; tree->stage = BERRY_STAGE_SPROUTED; @@ -1842,16 +1844,16 @@ static u16 GetMulchAffectedGrowthRate(u16 berryDuration, u8 mulch, u8 stage) void BerryTreeTimeUpdate(s32 minutes) { int i; - u8 drainVal; + u32 drainVal; struct BerryTree *tree; for (i = 0; i < BERRY_TREES_COUNT; i++) { tree = &gSaveBlock1Ptr->berryTrees[i]; - if (tree->berry && tree->stage && !tree->stopGrowth) + if (tree->berry && tree->stage && !tree->stopGrowth && (!OW_BERRY_IMMORTAL || tree->stage != BERRY_STAGE_BERRIES)) { - if (minutes >= GetStageDurationByBerryType(tree->berry) * 71) + if ((!OW_BERRY_IMMORTAL) && (minutes >= GetStageDurationByBerryType(tree->berry) * 71)) { *tree = gBlankBerryTree; }