diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index dd813e509..5898eba5c 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -351,6 +351,7 @@ #define FLAG_HISUIAN_FORM (1 << 5) #define FLAG_GENDER_DIFFERENCE (1 << 6) #define FLAG_ALL_PERFECT_IVS (1 << 7) +#define FLAG_SHINY_LOCKED (1 << 8) #define LEGENDARY_PERFECT_IV_COUNT 3 diff --git a/src/pokemon.c b/src/pokemon.c index 9b760dbb9..30e22bd6a 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3301,14 +3301,23 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, } else // Player is the OT { + u32 shinyValue; value = gSaveBlock2Ptr->playerTrainerId[0] | (gSaveBlock2Ptr->playerTrainerId[1] << 8) | (gSaveBlock2Ptr->playerTrainerId[2] << 16) | (gSaveBlock2Ptr->playerTrainerId[3] << 24); - if (CheckBagHasItem(ITEM_SHINY_CHARM, 1)) + if (gBaseStats[species].flags & FLAG_SHINY_LOCKED) + { + do + { + // Choose random personalities until one that results in a non-shiny Pokémon + personality = Random32(); + shinyValue = HIHALF(value) ^ LOHALF(value) ^ HIHALF(personality) ^ LOHALF(personality); + } while (shinyValue < SHINY_ODDS); + } + else if (CheckBagHasItem(ITEM_SHINY_CHARM, 1)) { - u32 shinyValue; u32 rolls = 0; do {