From 103ed85b8328683899a573f051ad120af1017790 Mon Sep 17 00:00:00 2001 From: Frank DeBlasio <35279583+fdeblasio@users.noreply.github.com> Date: Sat, 29 Jun 2024 16:07:14 -0400 Subject: [PATCH] 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 --- include/config/pokemon.h | 20 +++++++++++--------- include/item.h | 1 + src/item.c | 12 ++++++++++++ src/pokemon.c | 8 ++++++++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/include/config/pokemon.h b/include/config/pokemon.h index 2697c605c2..d2f12e4abd 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -39,15 +39,17 @@ #define P_ARCEUS_UNIQUE_FORM_ICONS GEN_LATEST // Since Gen 9, Arceus additionally changes its icon to reflect its current form. // Other settings -#define P_CUSTOM_GENDER_DIFF_ICONS TRUE // If TRUE, will give more Pokémon custom icons for their female forms, i.e. Hippopotas and Hippowdon -#define P_FOOTPRINTS TRUE // If TRUE, Pokémon will have footprints (as was the case up to Gen 5 and in BDSP). Disabling this saves some ROM space. -#define P_CRIES_ENABLED TRUE // If TRUE, Pokémon will have cries. Disabling this saves around a LOT of ROM space (over 25%!), but instead we recommend disabling individual unused Pokémon families in include/config/species_enabled.h. -#define P_LEGENDARY_PERFECT_IVS GEN_LATEST // Since Gen 6, Legendaries, Mythicals and Ultra Beasts found in the wild or given through gifts have at least 3 perfect IVs. -#define P_EV_CAP GEN_LATEST // Since Gen 6, the max EVs per stat is 252 instead of 255. -#define P_SHOW_TERA_TYPE GEN_8 // Since Gen 9, the Tera Type is shown on the summary screen. -#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_CUSTOM_GENDER_DIFF_ICONS TRUE // If TRUE, will give more Pokémon custom icons for their female forms, i.e. Hippopotas and Hippowdon +#define P_FOOTPRINTS TRUE // If TRUE, Pokémon will have footprints (as was the case up to Gen 5 and in BDSP). Disabling this saves some ROM space. +#define P_CRIES_ENABLED TRUE // If TRUE, Pokémon will have cries. Disabling this saves around a LOT of ROM space (over 25%!), but instead we recommend disabling individual unused Pokémon families in include/config/species_enabled.h. +#define P_LEGENDARY_PERFECT_IVS GEN_LATEST // Since Gen 6, Legendaries, Mythicals and Ultra Beasts found in the wild or given through gifts have at least 3 perfect IVs. +#define P_EV_CAP GEN_LATEST // Since Gen 6, the max EVs per stat is 252 instead of 255. +#define P_SHOW_TERA_TYPE GEN_8 // Since Gen 9, the Tera Type is shown on the summary screen. +#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. diff --git a/include/item.h b/include/item.h index 0e2c7f8abe..dc1efc68a5 100644 --- a/include/item.h +++ b/include/item.h @@ -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); diff --git a/src/item.c b/src/item.c index 205719fb53..6c3742fd76 100644 --- a/src/item.c +++ b/src/item.c @@ -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) diff --git a/src/pokemon.c b/src/pokemon.c index 926286caff..1dc44508e3 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -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;