Skip to content

Commit

Permalink
Adds OW_BERRY_IMMORTAL (#5187)
Browse files Browse the repository at this point in the history
* 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 #5187 (comment)

Co-authored-by: Bassoonian <iasperbassoonian@gmail.com>

* Reordered condition per https://github.com/rh-hideout/pokeemerald-expansion/pull/5187\#discussion_r1720747652

* Update include/config/overworld.h

---------

Co-authored-by: Bassoonian <iasperbassoonian@gmail.com>
  • Loading branch information
pkmnsnfrn and Bassoonian authored Aug 20, 2024
1 parent 8ca234d commit af12697
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/config/overworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 5 additions & 3 deletions src/berry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit af12697

Please sign in to comment.