Add Ability inheritance

This commit is contained in:
Bassoonian 2023-04-30 12:58:18 +02:00
parent 21fa91b80b
commit 8f75844ece
2 changed files with 33 additions and 1 deletions

View File

@ -15,7 +15,7 @@
#define P_TM_INHERITANCE GEN_LATEST // Since Gen 6, the father no longer passes down TMs to the baby.
#define P_MOTHER_EGG_MOVE_INHERITANCE GEN_LATEST // Since Gen 6, the mother can also pass down Egg Moves.
#define P_NATURE_INHERITANCE GEN_LATEST // In Gen 3, Everstone grants Ditto and mothers a 50% chance to pass on Nature. Since Gen 4, anyone can pass on nature. Since Gen 5, the chance is 100%.
#define P_ABILITY_INHERITANCE GEN_LATEST // TODO: In B2W2, a female Pokémon has an 80% chance of passing down their ability if bred with a male. Since Gen 6, the chance is 80% for normal ability and 60% for Hidden Ability, and anyone can pass down their abilities if bred with Ditto. NOTE: BW's effect: 60% chance to pass down HA and random for normal ability has been omitted.
#define P_ABILITY_INHERITANCE GEN_LATEST // In B2W2, a female Pokémon has an 80% chance of passing down their ability if bred with a male. Since Gen 6, the chance is 80% for normal ability and 60% for Hidden Ability, and anyone can pass down their abilities if bred with Ditto. NOTE: BW's effect: 60% chance to pass down HA and random for normal ability has been omitted.
#define P_EGG_MOVE_TRANSFER GEN_LATEST // Starting in Gen 8, if two Pokémon of the same species are together in the Daycare, one knows an Egg Move, and the other has an empty slot, the other Pokémon will receive the Egg Move in the empty slot. In Gen 9, if a Pokémon holds a Mirror Herb, it will receive Egg Moves from the other regardless of species.
// Species-specific settings

View File

@ -712,6 +712,35 @@ static void InheritPokeball(struct Pokemon *egg, struct BoxPokemon *father, stru
SetMonData(egg, MON_DATA_POKEBALL, &inheritBall);
}
static void InheritAbility(struct Pokemon *egg, struct BoxPokemon *father, struct BoxPokemon *mother)
{
u8 fatherAbility = GetBoxMonData(father, MON_DATA_ABILITY_NUM);
u8 motherAbility = GetBoxMonData(mother, MON_DATA_ABILITY_NUM);
u8 motherSpecies = GetBoxMonData(mother, MON_DATA_SPECIES);
u8 inheritAbility = motherAbility;
if (motherSpecies == SPECIES_DITTO)
#if P_ABILITY_INHERITANCE < GEN_6
return;
#else
inheritAbility = fatherAbility;
#endif
if (inheritAbility < 2 && (Random() % 10 < 8))
{
SetMonData(egg, MON_DATA_ABILITY_NUM, &inheritAbility);
}
#if P_ABILITY_INHERITANCE < GEN_6
else if (Random() % 10 < 8)
#else
else if (Random() % 10 < 6)
#endif
{
// Hidden Abilities have a different chance of being passed down
SetMonData(egg, MON_DATA_ABILITY_NUM, &inheritAbility);
}
}
// 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)
@ -1000,6 +1029,9 @@ static void _GiveEggFromDaycare(struct DayCare *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);
#if P_ABILITY_INHERITANCE >= GEN_8
InheritAbility(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon);
#endif
GiveMoveIfItem(&egg, daycare);