diff --git a/src/pokemon.c b/src/pokemon.c index 775e8db1b9..607499e77f 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2195,11 +2195,24 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, } else //Player is the OT { + #ifdef ITEM_SHINY_CHARM + u32 shinyRolls = (CheckBagHasItem(ITEM_SHINY_CHARM, 1)) ? 3 : 1; + #else + u32 shinyRolls = 1; + #endif + u32 i; + value = gSaveBlock2Ptr->playerTrainerId[0] | (gSaveBlock2Ptr->playerTrainerId[1] << 8) | (gSaveBlock2Ptr->playerTrainerId[2] << 16) | (gSaveBlock2Ptr->playerTrainerId[3] << 24); + for (i = 0; i < shinyRolls; i++) + { + if (Random() < SHINY_ODDS) + FlagSet(FLAG_SHINY_CREATION); // use a flag bc of CreateDexNavWildMon + } + if (FlagGet(FLAG_SHINY_CREATION)) { u8 nature = personality % NUM_NATURES; // keep current nature @@ -2207,6 +2220,9 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, personality = Random32(); personality = ((((Random() % SHINY_ODDS) ^ (HIHALF(value) ^ LOHALF(value))) ^ LOHALF(personality)) << 16) | LOHALF(personality); } while (nature != GetNatureFromPersonality(personality)); + + // clear the flag after use + FlagClear(FLAG_SHINY_CREATION); } }