From 8840d0bbf63533d5de38d124dd9e0df9375fceba Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 21 Dec 2022 12:31:59 -0300 Subject: [PATCH] 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 b2b08d249..65d467017 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 a8bdfa0ed..0f1708449 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);