Fixed regional variant inheritance and pokeball inheritance (#4695)

* fixed regional variant inheritance  and pokeball inheritance

* species inheritance: consider cases with different evolutions but same base species e.g. Persian and Perrserker
ball inheritance: fix inheritance for regional forms
This commit is contained in:
cawtds 2024-06-02 14:04:00 +02:00 committed by GitHub
parent 085c2f3d43
commit 9b10e13336
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 4 deletions

View file

@ -697,7 +697,7 @@ static void InheritPokeball(struct Pokemon *egg, struct BoxPokemon *father, stru
if (P_BALL_INHERITING >= GEN_7)
{
if (fatherSpecies == motherSpecies)
if (GET_BASE_SPECIES_ID(fatherSpecies) == GET_BASE_SPECIES_ID(motherSpecies))
inheritBall = (Random() % 2 == 0 ? motherBall : fatherBall);
else if (motherSpecies != SPECIES_DITTO)
inheritBall = motherBall;
@ -1024,7 +1024,8 @@ static u16 DetermineEggSpeciesAndParentSlots(struct DayCare *daycare, u8 *parent
{
u16 i;
u16 species[DAYCARE_MON_COUNT];
u16 eggSpecies;
u16 eggSpecies, parentSpecies;
bool8 hasMotherEverstone, hasFatherEverstone;
for (i = 0; i < DAYCARE_MON_COUNT; i++)
{
@ -1041,7 +1042,18 @@ static u16 DetermineEggSpeciesAndParentSlots(struct DayCare *daycare, u8 *parent
}
}
eggSpecies = GetEggSpecies(species[parentSlots[0]]);
hasMotherEverstone = ItemId_GetHoldEffect(GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM)) == HOLD_EFFECT_PREVENT_EVOLVE;
hasFatherEverstone = ItemId_GetHoldEffect(GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM)) == HOLD_EFFECT_PREVENT_EVOLVE;
if (hasMotherEverstone)
parentSpecies = species[parentSlots[0]];
else if (hasFatherEverstone && GET_BASE_SPECIES_ID(GetEggSpecies(species[parentSlots[0]])) == GET_BASE_SPECIES_ID(GetEggSpecies(species[parentSlots[1]])))
parentSpecies = species[parentSlots[1]];
else
parentSpecies = GET_BASE_SPECIES_ID(GetEggSpecies(species[parentSlots[0]]));
eggSpecies = GetEggSpecies(parentSpecies);
if (eggSpecies == SPECIES_NIDORAN_F && daycare->offspringPersonality & EGG_GENDER_MALE)
eggSpecies = SPECIES_NIDORAN_M;
else if (eggSpecies == SPECIES_ILLUMISE && daycare->offspringPersonality & EGG_GENDER_MALE)

View file

@ -313,7 +313,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
{
u16 species;
u32 personality, pokerus;
u8 i, friendship, language, gameMet, markings, isModernFatefulEncounter;
u8 i, friendship, language, gameMet, markings, isModernFatefulEncounter, ball;
u16 moves[MAX_MON_MOVES];
u32 ivs[NUM_STATS];
@ -333,6 +333,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
markings = GetMonData(egg, MON_DATA_MARKINGS);
pokerus = GetMonData(egg, MON_DATA_POKERUS);
isModernFatefulEncounter = GetMonData(egg, MON_DATA_MODERN_FATEFUL_ENCOUNTER);
ball = GetMonData(egg, MON_DATA_POKEBALL);
CreateMon(temp, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, TRUE, personality, OT_ID_PLAYER_ID, 0);
@ -351,6 +352,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
SetMonData(temp, MON_DATA_FRIENDSHIP, &friendship);
SetMonData(temp, MON_DATA_POKERUS, &pokerus);
SetMonData(temp, MON_DATA_MODERN_FATEFUL_ENCOUNTER, &isModernFatefulEncounter);
SetMonData(temp, MON_DATA_POKEBALL, &ball);
*egg = *temp;
}