From e579333427db46576d44c759ff803ced2bc3b11d Mon Sep 17 00:00:00 2001 From: hedara90 <90hedara@gmail.com> Date: Fri, 20 Dec 2024 11:23:51 +0100 Subject: [PATCH] Egg cycle length fix (#5828) Co-authored-by: Hedara Co-authored-by: Bassoonian --- include/config/pokemon.h | 2 +- include/global.h | 3 +-- src/daycare.c | 8 +++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/config/pokemon.h b/include/config/pokemon.h index 23015614c0bc..259ad3c117de 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -55,7 +55,7 @@ #define P_SHOW_TERA_TYPE GEN_8 // Since Gen 9, the Tera Type is shown on the summary screen. #define P_TM_LITERACY GEN_LATEST // Since Gen 6, TM illiterate Pokémon can learn TMs that teach moves that are in their level-up learnsets. #define P_CAN_FORGET_HIDDEN_MOVE FALSE // If TRUE, Pokémon can forget any move, even if it is a Hidden Move. -#define P_EGG_CYCLE_LENGTH GEN_LATEST // Since Gen 8, egg cycles take half as many steps as before. +#define P_EGG_CYCLE_LENGTH GEN_LATEST // Since Gen 8, egg cycles take half as many steps as before. Previous Gens have some varied step counts around 255. #define P_ONLY_OBTAINABLE_SHINIES FALSE // If TRUE, Pokémon encountered in the Battle Pyramid won't be shiny. #define P_NO_SHINIES_WITHOUT_POKEBALLS FALSE // If TRUE, Pokémon encountered when the player is out of Poké Balls won't be shiny #define P_SHOW_DYNAMIC_TYPES FALSE // If TRUE, all moves with dynamic type changes will be reflected as their current type in battle/summary screens instead of just select ones like in vanilla. diff --git a/include/global.h b/include/global.h index 5846f09359d0..687281eaa7d8 100644 --- a/include/global.h +++ b/include/global.h @@ -815,8 +815,7 @@ struct DayCare { struct DaycareMon mons[DAYCARE_MON_COUNT]; u32 offspringPersonality; - u8 stepCounter; - //u8 padding[3]; + u32 stepCounter; }; struct LilycoveLadyQuiz diff --git a/src/daycare.c b/src/daycare.c index 013e0b05ba99..912537af567a 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -1154,11 +1154,17 @@ static bool8 TryProduceOrHatchEgg(struct DayCare *daycare) } // Try to hatch Egg - if (++daycare->stepCounter == ((P_EGG_CYCLE_LENGTH >= GEN_8) ? 127 : 255)) + daycare->stepCounter++; + if (((P_EGG_CYCLE_LENGTH <= GEN_3 || P_EGG_CYCLE_LENGTH == GEN_7) && daycare->stepCounter >= 256) + || (P_EGG_CYCLE_LENGTH == GEN_4 && daycare->stepCounter >= 255) + || ((P_EGG_CYCLE_LENGTH == GEN_5 || P_EGG_CYCLE_LENGTH == GEN_6) && daycare->stepCounter >= 257) + || (P_EGG_CYCLE_LENGTH >= GEN_8 && daycare->stepCounter >= 128)) { u32 eggCycles; u8 toSub = GetEggCyclesToSubtract(); + daycare->stepCounter = 0; + for (i = 0; i < gPlayerPartyCount; i++) { if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))