From 8840d0bbf63533d5de38d124dd9e0df9375fceba Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 21 Dec 2022 12:31:59 -0300 Subject: [PATCH 1/7] Refactored incense baby checks into table and added Gen 9 config. --- include/config/pokemon.h | 8 +++++- src/daycare.c | 54 ++++++++++++++++------------------------ 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/include/config/pokemon.h b/include/config/pokemon.h index b2b08d249651..65d467017d46 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -1,14 +1,20 @@ #ifndef GUARD_CONFIG_POKEMON_H #define GUARD_CONFIG_POKEMON_H +// Species data settings #define P_UPDATED_TYPES GEN_LATEST // Since Gen 6, several Pokémon were changed to be partially or fully Fairy type. #define P_UPDATED_STATS GEN_LATEST // Since Gen 6, Pokémon stats are updated with each passing generation. #define P_UPDATED_ABILITIES GEN_LATEST // Since Gen 6, certain Pokémon have their abilities changed. #define P_UPDATED_EGG_GROUPS GEN_LATEST // Since Gen 8, certain Pokémon have gained new egg groups. + +// Breeding settings +#define P_NIDORAN_M_DITTO_BREED GEN_LATEST // Since Gen 5, when Nidoran♂ breeds with Ditto it can produce Nidoran♀ offspring. Before, it would only yield male offspring. This change also applies to Volbeat. +#define P_INCENSE_BREEDING GEN_9 // Since Gen 9, cross-generation Baby Pokémon don't require Incense being held by the parents to be obtained via breeding. + +// Other settings #define P_SHEDINJA_BALL GEN_LATEST // Since Gen 4, Shedinja requires a Poké Ball for its evolution. In Gen 3, Shedinja inherits Nincada's Ball. #define P_LEGENDARY_PERFECT_IVS GEN_LATEST // Since Gen 6, Legendaries, Mythicals and Ultra Beasts found in the wild or given through gifts have at least 3 perfect IVs. #define P_KADABRA_EVERSTONE GEN_LATEST // Since Gen 4, Kadabra can evolve even when holding an Everstone. -#define P_NIDORAN_M_DITTO_BREED GEN_LATEST // Since Gen 5, when Nidoran♂ breeds with Ditto it can produce Nidoran♀ offspring. Before, it would only yield male offspring. This change also applies to Volbeat. #define P_SHINY_BASE_CHANCE GEN_LATEST // Since Gen 6, the base chances of encountering a Shiny Pokémon was raised to 1/4096. This config adds an extra roll to the calculation, which effectively does the same thing. // Flag settings diff --git a/src/daycare.c b/src/daycare.c index a8bdfa0edece..0f17084495cc 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -742,44 +742,32 @@ void RejectEggFromDayCare(void) RemoveEggFromDayCare(&gSaveBlock1Ptr->daycare); } +u16 IncenseBabyTable[][3] = +{ + // Parent species, Incense, Offspring + { SPECIES_WOBBUFFET, ITEM_LAX_INCENSE, SPECIES_WYNAUT }, + { SPECIES_MARILL, ITEM_SEA_INCENSE, SPECIES_AZURILL }, + { SPECIES_SNORLAX, ITEM_FULL_INCENSE, SPECIES_MUNCHLAX }, + { SPECIES_CHANSEY, ITEM_LUCK_INCENSE, SPECIES_HAPPINY }, + { SPECIES_MR_MIME, ITEM_ODD_INCENSE, SPECIES_MIME_JR }, + { SPECIES_CHIMECHO, ITEM_PURE_INCENSE, SPECIES_CHINGLING }, + { SPECIES_SUDOWOODO, ITEM_ROCK_INCENSE, SPECIES_BONSLY }, + { SPECIES_ROSELIA, ITEM_ROSE_INCENSE, SPECIES_BUDEW }, + { SPECIES_MANTINE, ITEM_WAVE_INCENSE, SPECIES_MANTYKE }, +}; + static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare) { + u8 i; u16 motherItem, fatherItem; motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM); fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM); - if (*species == SPECIES_WYNAUT && motherItem != ITEM_LAX_INCENSE && fatherItem != ITEM_LAX_INCENSE) - *species = SPECIES_WOBBUFFET; - else if (*species == SPECIES_AZURILL && motherItem != ITEM_SEA_INCENSE && fatherItem != ITEM_SEA_INCENSE) - *species = SPECIES_MARILL; - #ifdef SPECIES_MUNCHLAX - else if (*species == SPECIES_MUNCHLAX && motherItem != ITEM_FULL_INCENSE && fatherItem != ITEM_FULL_INCENSE) - *species = SPECIES_SNORLAX; - #endif - #ifdef SPECIES_HAPPINY - else if (*species == SPECIES_HAPPINY && motherItem != ITEM_LUCK_INCENSE && fatherItem != ITEM_LUCK_INCENSE) - *species = SPECIES_CHANSEY; - #endif - #ifdef SPECIES_MIME_JR - else if (*species == SPECIES_MIME_JR && motherItem != ITEM_ODD_INCENSE && fatherItem != ITEM_ODD_INCENSE) - *species = SPECIES_MR_MIME; - #endif - #ifdef SPECIES_CHINGLING - else if (*species == SPECIES_CHINGLING && motherItem != ITEM_PURE_INCENSE && fatherItem != ITEM_PURE_INCENSE) - *species = SPECIES_CHIMECHO; - #endif - #ifdef SPECIES_BONSLY - else if (*species == SPECIES_BONSLY && motherItem != ITEM_ROCK_INCENSE && fatherItem != ITEM_ROCK_INCENSE) - *species = SPECIES_SUDOWOODO; - #endif - #ifdef SPECIES_BUDEW - else if (*species == SPECIES_BUDEW && motherItem != ITEM_ROSE_INCENSE && fatherItem != ITEM_ROSE_INCENSE) - *species = SPECIES_ROSELIA; - #endif - #ifdef SPECIES_MANTYKE - else if (*species == SPECIES_MANTYKE && motherItem != ITEM_WAVE_INCENSE && fatherItem != ITEM_WAVE_INCENSE) - *species = SPECIES_MANTINE; - #endif + for (i = 0; i < ARRAY_COUNT(IncenseBabyTable); i++) + { + if (IncenseBabyTable[i][2] == *species && motherItem != IncenseBabyTable[i][1] && fatherItem != IncenseBabyTable[i][1]) + *species = IncenseBabyTable[i][0]; + } } static void GiveVoltTackleIfLightBall(struct Pokemon *mon, struct DayCare *daycare) @@ -856,7 +844,9 @@ static void _GiveEggFromDaycare(struct DayCare *daycare) bool8 isEgg; species = DetermineEggSpeciesAndParentSlots(daycare, parentSlots); +#if P_INCENSE_BREEDING < GEN_9 AlterEggSpeciesWithIncenseItem(&species, daycare); +#endif SetInitialEggData(&egg, species, daycare); InheritIVs(&egg, daycare); BuildEggMoveset(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon); From 339d7943245b21c593ef67d50e41bf611431d34d Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 21 Dec 2022 16:46:32 -0300 Subject: [PATCH 2/7] Fixed compile and made table into struct --- src/daycare.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/daycare.c b/src/daycare.c index 0f17084495cc..ea50bc4f5b22 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -742,18 +742,22 @@ void RejectEggFromDayCare(void) RemoveEggFromDayCare(&gSaveBlock1Ptr->daycare); } -u16 IncenseBabyTable[][3] = -{ - // Parent species, Incense, Offspring - { SPECIES_WOBBUFFET, ITEM_LAX_INCENSE, SPECIES_WYNAUT }, - { SPECIES_MARILL, ITEM_SEA_INCENSE, SPECIES_AZURILL }, - { SPECIES_SNORLAX, ITEM_FULL_INCENSE, SPECIES_MUNCHLAX }, - { SPECIES_CHANSEY, ITEM_LUCK_INCENSE, SPECIES_HAPPINY }, - { SPECIES_MR_MIME, ITEM_ODD_INCENSE, SPECIES_MIME_JR }, - { SPECIES_CHIMECHO, ITEM_PURE_INCENSE, SPECIES_CHINGLING }, - { SPECIES_SUDOWOODO, ITEM_ROCK_INCENSE, SPECIES_BONSLY }, - { SPECIES_ROSELIA, ITEM_ROSE_INCENSE, SPECIES_BUDEW }, - { SPECIES_MANTINE, ITEM_WAVE_INCENSE, SPECIES_MANTYKE }, +static const struct { + u16 noIncenseSpecies; + u16 item; + u16 incenseSpecies; +} IncenseBabyTable[][3] = +{ + // Regular offspring, Item, Incense Offspring + { SPECIES_WOBBUFFET, ITEM_LAX_INCENSE, SPECIES_WYNAUT }, + { SPECIES_MARILL, ITEM_SEA_INCENSE, SPECIES_AZURILL }, + { SPECIES_SNORLAX, ITEM_FULL_INCENSE, SPECIES_MUNCHLAX }, + { SPECIES_CHANSEY, ITEM_LUCK_INCENSE, SPECIES_HAPPINY }, + { SPECIES_MR_MIME, ITEM_ODD_INCENSE, SPECIES_MIME_JR }, + { SPECIES_CHIMECHO, ITEM_PURE_INCENSE, SPECIES_CHINGLING }, + { SPECIES_SUDOWOODO, ITEM_ROCK_INCENSE, SPECIES_BONSLY }, + { SPECIES_ROSELIA, ITEM_ROSE_INCENSE, SPECIES_BUDEW }, + { SPECIES_MANTINE, ITEM_WAVE_INCENSE, SPECIES_MANTYKE }, }; static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare) @@ -765,8 +769,8 @@ static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare for (i = 0; i < ARRAY_COUNT(IncenseBabyTable); i++) { - if (IncenseBabyTable[i][2] == *species && motherItem != IncenseBabyTable[i][1] && fatherItem != IncenseBabyTable[i][1]) - *species = IncenseBabyTable[i][0]; + if (IncenseBabyTable[i]->incenseSpecies == *species && motherItem != IncenseBabyTable[i]->item && fatherItem != IncenseBabyTable[i]->item) + *species = IncenseBabyTable[i]->noIncenseSpecies; } } From 4ed20dca8cfb70b22dc5d212cf1e498754247d2a Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 21 Dec 2022 17:28:24 -0300 Subject: [PATCH 3/7] Forgot to restore config to GEN_LATEST --- include/config/pokemon.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/config/pokemon.h b/include/config/pokemon.h index 65d467017d46..0416de5e2ca5 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -9,7 +9,7 @@ // Breeding settings #define P_NIDORAN_M_DITTO_BREED GEN_LATEST // Since Gen 5, when Nidoran♂ breeds with Ditto it can produce Nidoran♀ offspring. Before, it would only yield male offspring. This change also applies to Volbeat. -#define P_INCENSE_BREEDING GEN_9 // Since Gen 9, cross-generation Baby Pokémon don't require Incense being held by the parents to be obtained via breeding. +#define P_INCENSE_BREEDING GEN_LATEST // Since Gen 9, cross-generation Baby Pokémon don't require Incense being held by the parents to be obtained via breeding. // Other settings #define P_SHEDINJA_BALL GEN_LATEST // Since Gen 4, Shedinja requires a Poké Ball for its evolution. In Gen 3, Shedinja inherits Nincada's Ball. From 28cffda9d4b9152af6fe9d722c86a98e00a73438 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 22 Dec 2022 10:38:54 -0300 Subject: [PATCH 4/7] Hatch level config --- include/config/pokemon.h | 1 + include/constants/daycare.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/config/pokemon.h b/include/config/pokemon.h index 0416de5e2ca5..3970db142ed9 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -10,6 +10,7 @@ // Breeding settings #define P_NIDORAN_M_DITTO_BREED GEN_LATEST // Since Gen 5, when Nidoran♂ breeds with Ditto it can produce Nidoran♀ offspring. Before, it would only yield male offspring. This change also applies to Volbeat. #define P_INCENSE_BREEDING GEN_LATEST // Since Gen 9, cross-generation Baby Pokémon don't require Incense being held by the parents to be obtained via breeding. +#define P_EGG_HATCH_LEVEL GEN_LATEST // Since Gen 4, Pokémon will hatch from eggs at level 1 instead of 5. // Other settings #define P_SHEDINJA_BALL GEN_LATEST // Since Gen 4, Shedinja requires a Poké Ball for its evolution. In Gen 3, Shedinja inherits Nincada's Ball. diff --git a/include/constants/daycare.h b/include/constants/daycare.h index 9af7e6f79c7e..ac48e4f71673 100644 --- a/include/constants/daycare.h +++ b/include/constants/daycare.h @@ -14,7 +14,11 @@ #define DAYCARE_TWO_MONS 3 #define INHERITED_IV_COUNT 3 +#if P_EGG_HATCH_LEVEL >= GEN_4 +#define EGG_HATCH_LEVEL 1 +#else #define EGG_HATCH_LEVEL 5 +#endif #define EGG_GENDER_MALE 0x8000 // used to create a male egg from a female-only parent species (e.g. Nidoran) #define DAYCARE_LEVEL_MENU_EXIT 5 From 9250f8c994bb85fa9181003be8e33b13d7882eff Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 8 Jan 2023 18:35:47 -0300 Subject: [PATCH 5/7] Standarized Pichu/Light Ball/Volt Tackle interaction into their own table, allowing for custom combinations --- src/daycare.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/daycare.c b/src/daycare.c index ea50bc4f5b22..b4325b22808a 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -762,7 +762,7 @@ static const struct { static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare) { - u8 i; + u16 i; u16 motherItem, fatherItem; motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM); fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM); @@ -774,15 +774,31 @@ static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare } } -static void GiveVoltTackleIfLightBall(struct Pokemon *mon, struct DayCare *daycare) +static const struct { + u16 offspring; + u16 item; + u16 move; +} BreedingSpecialMoveItemTable[][3] = { + // Offspring Item Move + { SPECIES_PICHU, ITEM_LIGHT_BALL, MOVE_VOLT_TACKLE }, +}; + +static void GiveMoveIfItem(struct Pokemon *mon, struct DayCare *daycare) +{ + u16 i, species = GetMonData(mon, MON_DATA_SPECIES); u32 motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM); u32 fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM); - if (motherItem == ITEM_LIGHT_BALL || fatherItem == ITEM_LIGHT_BALL) + for (i = 0; i < ARRAY_COUNT(BreedingSpecialMoveItemTable); i++) { - if (GiveMoveToMon(mon, MOVE_VOLT_TACKLE) == MON_HAS_MAX_MOVES) - DeleteFirstMoveAndGiveMoveToMon(mon, MOVE_VOLT_TACKLE); + if (BreedingSpecialMoveItemTable[i]->offspring == species + && (motherItem == BreedingSpecialMoveItemTable[i]->item || + fatherItem == BreedingSpecialMoveItemTable[i]->item)) + { + if (GiveMoveToMon(mon, BreedingSpecialMoveItemTable[i]->move) == MON_HAS_MAX_MOVES) + DeleteFirstMoveAndGiveMoveToMon(mon, BreedingSpecialMoveItemTable[i]->move); + } } } @@ -855,8 +871,7 @@ static void _GiveEggFromDaycare(struct DayCare *daycare) InheritIVs(&egg, daycare); BuildEggMoveset(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon); - if (species == SPECIES_PICHU) - GiveVoltTackleIfLightBall(&egg, daycare); + GiveMoveIfItem(&egg, daycare); isEgg = TRUE; SetMonData(&egg, MON_DATA_IS_EGG, &isEgg); From c5ea97ecc3e60e33204f16c7a577383ad83d779f Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 8 Jan 2023 18:42:39 -0300 Subject: [PATCH 6/7] Review changes --- src/daycare.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/daycare.c b/src/daycare.c index b4325b22808a..19ab0759c179 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -743,9 +743,9 @@ void RejectEggFromDayCare(void) } static const struct { - u16 noIncenseSpecies; + u16 currSpecies; u16 item; - u16 incenseSpecies; + u16 babySpecies; } IncenseBabyTable[][3] = { // Regular offspring, Item, Incense Offspring @@ -769,8 +769,8 @@ static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare for (i = 0; i < ARRAY_COUNT(IncenseBabyTable); i++) { - if (IncenseBabyTable[i]->incenseSpecies == *species && motherItem != IncenseBabyTable[i]->item && fatherItem != IncenseBabyTable[i]->item) - *species = IncenseBabyTable[i]->noIncenseSpecies; + if (IncenseBabyTable[i]->babySpecies == *species && motherItem != IncenseBabyTable[i]->item && fatherItem != IncenseBabyTable[i]->item) + *species = IncenseBabyTable[i]->currSpecies; } } @@ -780,7 +780,7 @@ static const struct { u16 move; } BreedingSpecialMoveItemTable[][3] = { - // Offspring Item Move + // Offspring, Item, Move { SPECIES_PICHU, ITEM_LIGHT_BALL, MOVE_VOLT_TACKLE }, }; From 612ef46d824c581db1c14bdb59ce7d852266f425 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 8 Jan 2023 19:26:34 -0300 Subject: [PATCH 7/7] Forgot to add these suggestions --- src/daycare.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/daycare.c b/src/daycare.c index 19ab0759c179..06f11ba9cf53 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -762,7 +762,7 @@ static const struct { static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare) { - u16 i; + u32 i; u16 motherItem, fatherItem; motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM); fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM); @@ -770,7 +770,10 @@ static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare for (i = 0; i < ARRAY_COUNT(IncenseBabyTable); i++) { if (IncenseBabyTable[i]->babySpecies == *species && motherItem != IncenseBabyTable[i]->item && fatherItem != IncenseBabyTable[i]->item) + { *species = IncenseBabyTable[i]->currSpecies; + break; + } } }