From 05ff7cef1ced59fafafc05d1799433e1f28a053e Mon Sep 17 00:00:00 2001 From: tertu Date: Wed, 31 Jul 2024 12:51:47 -0500 Subject: [PATCH] Tweak IV generation slightly (#4876) With HQ_RANDOM on, this means that the generator now only consumes one RNG output when generating IVs. Without HQ_RANDOM on, IV generation should be unchanged. --- src/pokemon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pokemon.c b/src/pokemon.c index 0a47ebf7bc..2b731ef13c 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1206,7 +1206,8 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, else { u32 iv; - value = Random(); + u32 ivRandom = Random32(); + value = (u16)ivRandom; iv = value & MAX_IV_MASK; SetBoxMonData(boxMon, MON_DATA_HP_IV, &iv); @@ -1215,7 +1216,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, iv = (value & (MAX_IV_MASK << 10)) >> 10; SetBoxMonData(boxMon, MON_DATA_DEF_IV, &iv); - value = Random(); + value = (u16)(ivRandom >> 16); iv = value & MAX_IV_MASK; SetBoxMonData(boxMon, MON_DATA_SPEED_IV, &iv);