From 8cc289ef35137eaf879935d4d2e17c9fe919604b Mon Sep 17 00:00:00 2001 From: i0brendan0 <19826742+i0brendan0@users.noreply.github.com> Date: Thu, 8 May 2025 04:28:00 -0500 Subject: [PATCH] Fix rerolls overwriting Fixed Personality (#6774) --- src/pokemon.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pokemon.c b/src/pokemon.c index 9cb9430690..a317ccdc37 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1105,7 +1105,7 @@ void CreateMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFix void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) { u8 speciesName[POKEMON_NAME_LENGTH + 1]; - u32 personality; + u32 personality = Random32(); u32 value; u16 checksum; u8 i; @@ -1115,11 +1115,6 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, ZeroBoxMonData(boxMon); - if (hasFixedPersonality) - personality = fixedPersonality; - else - personality = Random32(); - // Determine original trainer ID if (otIdType == OT_ID_RANDOM_NO_SHINY) { @@ -1129,7 +1124,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, else if (otIdType == OT_ID_PRESET) { value = fixedOtId; - isShiny = GET_SHINY_VALUE(value, personality) < SHINY_ODDS; + isShiny = GET_SHINY_VALUE(value, hasFixedPersonality ? fixedPersonality : personality) < SHINY_ODDS; } else // Player is the OT { @@ -1175,6 +1170,9 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, isShiny = GET_SHINY_VALUE(value, personality) < SHINY_ODDS; } } + + if (hasFixedPersonality) + personality = fixedPersonality; SetBoxMonData(boxMon, MON_DATA_PERSONALITY, &personality); SetBoxMonData(boxMon, MON_DATA_OT_ID, &value);