add shiny charm check to handle FLAG_SHINY_CREATION

This commit is contained in:
ghoulslash 2021-08-07 12:29:40 -04:00
parent 53e6ba1c48
commit 1898a1c2e5

View file

@ -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);
}
}