Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed non-regional forms breeding incorrectly #4985

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions include/constants/regions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef GUARD_CONSTANTS_REGIONS_H
#define GUARD_CONSTANTS_REGIONS_H

// Core-series regions
#define REGION_KANTO 0
#define REGION_JOHTO 1
#define REGION_HOENN 2
#define REGION_SINNOH 3
#define REGION_UNOVA 4
#define REGION_KALOS 5
#define REGION_ALOLA 6
#define REGION_GALAR 7
#define REGION_HISUI 8
#define REGION_PALDEA 9
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved

// TODO: Since there's no current multi-region support, we have this constant for the purposes of regional form comparisons.
#define REGION_CURRENT REGION_HOENN

#endif // GUARD_CONSTANTS_REGIONS_H
3 changes: 3 additions & 0 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "sprite.h"
#include "constants/items.h"
#include "constants/regions.h"
#include "constants/region_map_sections.h"
#include "constants/map_groups.h"
#include "contest_effect.h"
Expand Down Expand Up @@ -804,5 +805,7 @@ u16 GetSpeciesPreEvolution(u16 species);
void HealPokemon(struct Pokemon *mon);
void HealBoxPokemon(struct BoxPokemon *boxMon);
const u8 *GetMoveName(u16 moveId);
u16 GetRegionalForm(u32 species, u32 region);
bool32 IsSpeciesForeignRegionalForm(u32 species, u32 currentRegion);

#endif // GUARD_POKEMON_H
21 changes: 14 additions & 7 deletions src/daycare.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,8 @@ static u16 DetermineEggSpeciesAndParentSlots(struct DayCare *daycare, u8 *parent
u16 i;
u16 species[DAYCARE_MON_COUNT];
u16 eggSpecies, parentSpecies;
bool8 hasMotherEverstone, hasFatherEverstone;
bool32 hasMotherEverstone, hasFatherEverstone, motherIsForeign, fatherIsForeign;
bool32 motherEggSpecies, fatherEggSpecies;

for (i = 0; i < DAYCARE_MON_COUNT; i++)
{
Expand All @@ -1056,15 +1057,21 @@ static u16 DetermineEggSpeciesAndParentSlots(struct DayCare *daycare, u8 *parent
}
}

motherEggSpecies = GetEggSpecies(species[parentSlots[0]]);
fatherEggSpecies = GetEggSpecies(species[parentSlots[1]]);
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]];
motherIsForeign = IsSpeciesForeignRegionalForm(motherEggSpecies, REGION_CURRENT);
fatherIsForeign = IsSpeciesForeignRegionalForm(fatherEggSpecies, REGION_CURRENT);

if (motherIsForeign && hasMotherEverstone)
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved
parentSpecies = motherEggSpecies;
else if (fatherIsForeign && hasFatherEverstone && GET_BASE_SPECIES_ID(motherEggSpecies) == GET_BASE_SPECIES_ID(fatherEggSpecies))
parentSpecies = fatherEggSpecies;
else if (motherIsForeign)
parentSpecies = GetRegionalForm(motherEggSpecies, REGION_CURRENT);
else
parentSpecies = GET_BASE_SPECIES_ID(GetEggSpecies(species[parentSlots[0]]));
parentSpecies = motherEggSpecies;

eggSpecies = GetEggSpecies(parentSpecies);

Expand Down
31 changes: 31 additions & 0 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "constants/items.h"
#include "constants/layouts.h"
#include "constants/moves.h"
#include "constants/regions.h"
#include "constants/songs.h"
#include "constants/trainers.h"
#include "constants/union_room.h"
Expand Down Expand Up @@ -6573,3 +6574,33 @@ const u8 *GetMoveName(u16 moveId)
{
return gMovesInfo[moveId].name;
}

u16 GetRegionalForm(u32 species, u32 region)
{
u32 formId = 0;
u32 foundSpecies = 0;

if (GetSpeciesFormTable(species) != NULL)
{
for (formId = 0; GetSpeciesFormTable(species)[formId] != FORM_SPECIES_END; formId++)
{
foundSpecies = GetSpeciesFormTable(species)[formId];
if ((gSpeciesInfo[foundSpecies].isAlolanForm && region == REGION_ALOLA)
|| (gSpeciesInfo[foundSpecies].isGalarianForm && region == REGION_GALAR)
|| (gSpeciesInfo[foundSpecies].isHisuianForm && region == REGION_HISUI)
|| (gSpeciesInfo[foundSpecies].isPaldeanForm && region == REGION_PALDEA))
return foundSpecies;
}
}
return species;
}

bool32 IsSpeciesForeignRegionalForm(u32 species, u32 currentRegion)
{
if ((gSpeciesInfo[species].isAlolanForm && currentRegion != REGION_ALOLA)
|| (gSpeciesInfo[species].isGalarianForm && currentRegion != REGION_GALAR)
|| (gSpeciesInfo[species].isHisuianForm && currentRegion != REGION_HISUI)
|| (gSpeciesInfo[species].isPaldeanForm && currentRegion != REGION_PALDEA))
return TRUE;
return FALSE;
}
Loading