Added config to prevent unobtainable Pokemon from being shiny (#4735)

* Added config to prevent unobtainable Pokemon from being shiny

* Added config for disabling shinies if the player has no Poke Balls

* Removed check for adventure started flag
This commit is contained in:
Frank DeBlasio 2024-06-29 16:07:14 -04:00 committed by GitHub
parent d1ca1f667f
commit 103ed85b83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 9 deletions

View file

@ -48,6 +48,8 @@
#define P_TM_LITERACY GEN_LATEST // Since Gen 6, TM illiterate Pokémon can learn TMs that teach moves that are in their level-up learnsets.
#define P_EGG_CYCLE_LENGTH GEN_LATEST // Since Gen 8, egg cycles take half as many steps as before.
#define P_TWO_FRAME_FRONT_SPRITES TRUE // In Pokémon Emerald, Pokémon front sprites always consist of two frames. This config can revert it to only use the first frame, as is the case in the other Gen 3 games.
#define P_ONLY_OBTAINABLE_SHINIES FALSE // If TRUE, Pokémon encountered in the Battle Pyramid won't be shiny.
#define P_NO_SHINIES_WITHOUT_POKEBALLS FALSE // If TRUE, Pokémon encountered when the player is out of Poké Balls won't be shiny
// Learnset helper toggles
#define P_LEARNSET_HELPER_TEACHABLE TRUE // If TRUE, teachable_learnsets.h will be populated by tools/learnset_helpers/teachable.py using the included JSON files based on available TMs and tutors.

View file

@ -44,6 +44,7 @@ u8 *CopyItemNameHandlePlural(u16 itemId, u8 *dst, u32 quantity);
bool8 IsBagPocketNonEmpty(u8 pocket);
bool8 CheckBagHasItem(u16 itemId, u16 count);
bool8 HasAtLeastOneBerry(void);
bool8 HasAtLeastOnePokeBall(void);
bool8 CheckBagHasSpace(u16 itemId, u16 count);
u32 GetFreeSpaceForItemInBag(u16 itemId);
bool8 AddBagItem(u16 itemId, u16 count);

View file

@ -164,6 +164,18 @@ bool8 HasAtLeastOneBerry(void)
return FALSE;
}
bool8 HasAtLeastOnePokeBall(void)
{
u16 i;
for (i = FIRST_BALL; i <= LAST_BALL; i++)
{
if (CheckBagHasItem(i, 1) == TRUE)
return TRUE;
}
return FALSE;
}
bool8 CheckBagHasSpace(u16 itemId, u16 count)
{
if (ItemId_GetPocket(itemId) == POCKET_NONE)

View file

@ -1143,6 +1143,14 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV,
{
isShiny = TRUE;
}
else if (P_ONLY_OBTAINABLE_SHINIES && InBattlePyramid())
{
isShiny = FALSE;
}
else if (P_NO_SHINIES_WITHOUT_POKEBALLS && !HasAtLeastOnePokeBall())
{
isShiny = FALSE;
}
else
{
u32 totalRerolls = 0;