From 1b0ce96e12f876821333f43ce555552e0ff3f65d Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Mon, 9 Jan 2023 02:16:29 -0300 Subject: [PATCH 1/3] Config for ball inheritence when breeding --- include/config/pokemon.h | 1 + src/daycare.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/config/pokemon.h b/include/config/pokemon.h index a44a7c8e0a12..f406da7e0f6e 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -11,6 +11,7 @@ #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. +#define P_BALL_INHERITING GEN_LATEST // Since Gen 6, Eggs from the Daycare will inherit the Poké Ball from their mother. From Gen7 onwards, the father can pass it down as well, as long as it's of the same evolution family as the offspring. // 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/src/daycare.c b/src/daycare.c index 06f11ba9cf53..08ca31da0c54 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -609,6 +609,33 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare) } } +static void InheritPokeball(struct Pokemon *egg, struct BoxPokemon *father, struct BoxPokemon *mother) +{ + u16 inheritBall = ITEM_POKE_BALL; + u16 fatherBall = GetBoxMonData(father, MON_DATA_POKEBALL); + u16 motherBall = GetBoxMonData(mother, MON_DATA_POKEBALL); + u16 fatherSpecies = GetBoxMonData(father, MON_DATA_SPECIES); + u16 motherSpecies = GetBoxMonData(mother, MON_DATA_SPECIES); + + if (fatherBall == ITEM_MASTER_BALL || fatherBall == ITEM_CHERISH_BALL) + fatherBall = ITEM_POKE_BALL; + + if (motherBall == ITEM_MASTER_BALL || motherBall == ITEM_CHERISH_BALL) + motherBall = ITEM_POKE_BALL; + +#if P_BALL_INHERITING >= GEN_7 + if (fatherSpecies == motherSpecies) + inheritBall = (Random32() % 2 == 0 ? motherBall : fatherBall); + else if (motherSpecies != SPECIES_DITTO) + inheritBall = motherBall; + else + inheritBall = fatherBall; +#elif P_BALL_INHERITING == GEN_6 + inheritBall = motherBall; +#endif + SetMonData(egg, MON_DATA_POKEBALL, &inheritBall); +} + // Counts the number of egg moves a pokemon learns and stores the moves in // the given array. static u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves) @@ -872,6 +899,7 @@ static void _GiveEggFromDaycare(struct DayCare *daycare) #endif SetInitialEggData(&egg, species, daycare); InheritIVs(&egg, daycare); + InheritPokeball(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon); BuildEggMoveset(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon); GiveMoveIfItem(&egg, daycare); From f8c9e7af40cada3c7edb5019dc9625e5fc6e87f7 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Mon, 9 Jan 2023 11:06:27 -0300 Subject: [PATCH 2/3] Fixed config comment --- 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 f406da7e0f6e..4cb2271d5a5e 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -11,7 +11,7 @@ #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. -#define P_BALL_INHERITING GEN_LATEST // Since Gen 6, Eggs from the Daycare will inherit the Poké Ball from their mother. From Gen7 onwards, the father can pass it down as well, as long as it's of the same evolution family as the offspring. +#define P_BALL_INHERITING GEN_LATEST // Since Gen 6, Eggs from the Daycare will inherit the Poké Ball from their mother. From Gen7 onwards, the father can pass it down as well, as long as it's of the same species as the mother. // 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 77cc4073867cb5d5d1b9250ac3d88684c1d0013c Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 12 Jan 2023 23:44:34 -0300 Subject: [PATCH 3/3] Review change --- src/daycare.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daycare.c b/src/daycare.c index 08ca31da0c54..aeeded43d3ac 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -625,7 +625,7 @@ static void InheritPokeball(struct Pokemon *egg, struct BoxPokemon *father, stru #if P_BALL_INHERITING >= GEN_7 if (fatherSpecies == motherSpecies) - inheritBall = (Random32() % 2 == 0 ? motherBall : fatherBall); + inheritBall = (Random() % 2 == 0 ? motherBall : fatherBall); else if (motherSpecies != SPECIES_DITTO) inheritBall = motherBall; else