Allow pests and weeds interaction
This commit is contained in:
parent
36befdcdf8
commit
3e1c04cc26
@ -190,6 +190,12 @@ BerryTree_EventScript_ItemUsePlantBerry::
|
||||
end
|
||||
|
||||
BerryTree_EventScript_WantToWater::
|
||||
.if OW_BERRY_PESTS == TRUE
|
||||
call BerryTree_EventScript_CheckForPests
|
||||
.endif
|
||||
.if OW_BERRY_WEEDS == TRUE
|
||||
call BerryTree_EventScript_CheckForWeed
|
||||
.endif
|
||||
checkitem ITEM_WAILMER_PAIL
|
||||
goto_if_eq VAR_RESULT, FALSE, BerryTree_EventScript_DontWater
|
||||
special ObjectEventInteractionGetBerryName
|
||||
@ -373,6 +379,11 @@ BerryTree_Text_ScatteredMulch:
|
||||
.endif
|
||||
|
||||
.if OW_BERRY_WEEDS == TRUE
|
||||
BerryTree_EventScript_CheckForWeed::
|
||||
specialvar VAR_RESULT, ObjectEventInteractionBerryHasWeed
|
||||
call_if_eq VAR_RESULT, TRUE, BerryTree_EventScript_WeedIsGrowing
|
||||
return
|
||||
|
||||
BerryTree_EventScript_WeedIsGrowing::
|
||||
msgbox BerryTree_Text_WeedIsGrowing, MSGBOX_YESNO
|
||||
goto_if_eq VAR_RESULT, YES, BerryTree_EventScript_PullOutWeed
|
||||
@ -394,6 +405,18 @@ BerryTree_Text_PulledOutTheWeed:
|
||||
.endif
|
||||
|
||||
.if OW_BERRY_PESTS == TRUE
|
||||
BerryTree_EventScript_CheckForPests::
|
||||
specialvar VAR_RESULT, ObjectEventInteractionBerryHasPests
|
||||
call_if_eq VAR_RESULT, TRUE, BerryTree_EventScript_EncounterPests
|
||||
return
|
||||
|
||||
BerryTree_EventScript_EncounterPests::
|
||||
message BerryTree_Text_APokemonAppeared
|
||||
waitmessage
|
||||
waitbuttonpress
|
||||
dowildbattle
|
||||
return
|
||||
|
||||
BerryTree_Text_APokemonAppeared:
|
||||
.string "A Pokémon appeared!$"
|
||||
.endif
|
||||
|
||||
@ -545,3 +545,5 @@ gSpecials::
|
||||
def_special ObjectEventInteractionApplyMulch
|
||||
def_special ObjectEventInteractionPullBerryWeed
|
||||
def_special ObjectEventInteractionClearBerryPests
|
||||
def_special ObjectEventInteractionBerryHasWeed
|
||||
def_special ObjectEventInteractionBerryHasPests
|
||||
|
||||
26
src/berry.c
26
src/berry.c
@ -9,6 +9,7 @@
|
||||
#include "item_menu.h"
|
||||
#include "main.h"
|
||||
#include "random.h"
|
||||
#include "script_pokemon_util.h"
|
||||
#include "string_util.h"
|
||||
#include "text.h"
|
||||
#include "constants/event_object_movement.h"
|
||||
@ -26,6 +27,7 @@ static u16 GetStageDurationByBerryType(u8);
|
||||
static u16 GetDrainRateByBerryType(u8);
|
||||
static void SetTreeMutations(u8 id, u8 berry);
|
||||
static u8 GetTreeMutationValue(u8 id);
|
||||
static u16 GetBerryPestSpecies(u8 berryId);
|
||||
static void TryForWeeds(struct BerryTree *tree);
|
||||
static void TryForPests(struct BerryTree *tree);
|
||||
|
||||
@ -1746,7 +1748,7 @@ void BerryTreeTimeUpdate(s32 minutes)
|
||||
s32 time = minutes;
|
||||
|
||||
// Check moisture gradient, pests and weeds
|
||||
while (time > 0)
|
||||
while (time > 0 && tree->stage != BERRY_STAGE_BERRIES)
|
||||
{
|
||||
tree->moistureClock += 1;
|
||||
time -= 1;
|
||||
@ -2063,6 +2065,24 @@ bool8 PlayerHasBerries(void)
|
||||
return IsBagPocketNonEmpty(POCKET_BERRIES);
|
||||
}
|
||||
|
||||
bool8 ObjectEventInteractionBerryHasWeed(void)
|
||||
{
|
||||
return gSaveBlock1Ptr->berryTrees[GetObjectEventBerryTreeId(gSelectedObjectEvent)].weeds;
|
||||
}
|
||||
|
||||
bool8 ObjectEventInteractionBerryHasPests(void)
|
||||
{
|
||||
u16 species;
|
||||
if (!OW_BERRY_PESTS || !gSaveBlock1Ptr->berryTrees[GetObjectEventBerryTreeId(gSelectedObjectEvent)].pests)
|
||||
return FALSE;
|
||||
species = GetBerryPestSpecies(gSaveBlock1Ptr->berryTrees[GetObjectEventBerryTreeId(gSelectedObjectEvent)].berry);
|
||||
if (species == SPECIES_NONE)
|
||||
return FALSE;
|
||||
CreateScriptedWildMon(species, 14 + Random() % 3, ITEM_NONE);
|
||||
gSaveBlock1Ptr->berryTrees[GetObjectEventBerryTreeId(gSelectedObjectEvent)].pests = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Berry tree growth is frozen at their initial stage (usually, fully grown) until the player has seen the tree
|
||||
// For all berry trees on screen, allow normal growth
|
||||
void SetBerryTreesSeen(void)
|
||||
@ -2224,9 +2244,9 @@ static void SetTreeMutations(u8 id, u8 berry)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if OW_BERRY_PESTS == TRUE
|
||||
static u16 GetBerryPestSpecies(u8 berryId)
|
||||
{
|
||||
#if OW_BERRY_PESTS == TRUE
|
||||
const struct Berry *berry = GetBerryInfo(berryId);
|
||||
switch(berry->color)
|
||||
{
|
||||
@ -2249,9 +2269,9 @@ static u16 GetBerryPestSpecies(u8 berryId)
|
||||
return SPECIES_SPEWPA;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return SPECIES_NONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define BERRY_WEEDS_CHANCE 15
|
||||
#define BERRY_PESTS_CHANCE 15
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user