Skip to content

Commit

Permalink
Config for ball inheritence when breeding
Browse files Browse the repository at this point in the history
  • Loading branch information
AsparagusEduardo committed Jan 9, 2023
1 parent 05e9bfe commit 1b0ce96
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/config/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 28 additions & 0 deletions src/daycare.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1b0ce96

Please sign in to comment.