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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5ac19e4
Fixed non-regional forms breeding incorrectly-
AsparagusEduardo Jul 16, 2024
5c3ef5a
Fixed Paldean form check
AsparagusEduardo Jul 16, 2024
9f2e702
Region argument for IsSpeciesForeignRegionalForm
AsparagusEduardo Jul 16, 2024
ace0a9d
Merge branch '_RHH/master' into _RHH/pr/master/fixFormBreeding
AsparagusEduardo Dec 31, 2024
982bcd5
Daycare tests
AsparagusEduardo Dec 31, 2024
1814960
Regional form tests
AsparagusEduardo Dec 31, 2024
54cddb1
Finally fixed it
AsparagusEduardo Dec 31, 2024
74fea0d
Regions to enum
AsparagusEduardo Dec 31, 2024
96b58c0
oops
AsparagusEduardo Dec 31, 2024
bcccbaf
REGION_CURRENT to inline function
AsparagusEduardo Dec 31, 2024
040cf99
Consolidated function and adjusted names
AsparagusEduardo Jan 1, 2025
4950a34
Added Shellos test to make sure that other forms don't get broken
AsparagusEduardo Jan 1, 2025
a37c959
Fixed mix of logic of regular vs regional forms. Added Alola/Galar tests
AsparagusEduardo Jan 1, 2025
00c4c69
Adjusted test
AsparagusEduardo Jan 3, 2025
5d85c19
Merge branch '_RHH/master' into _RHH/pr/master/fixFormBreeding
AsparagusEduardo Jan 12, 2025
55e6360
Made tests occupy less horizontal space + Added Hisui and Paldea checks
AsparagusEduardo Feb 2, 2025
c512a2e
Removed duplicity in test
AsparagusEduardo Feb 2, 2025
cad01da
Fix assumes
AsparagusEduardo Feb 2, 2025
3e2f6f0
Future-proofing: Set Hoenn as default region for maps
AsparagusEduardo Feb 2, 2025
7452920
Revert "Future-proofing: Set Hoenn as default region for maps"
AsparagusEduardo Feb 3, 2025
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);

#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);
fatherIsForeign = IsSpeciesForeignRegionalForm(fatherEggSpecies);

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].isGalarianForm && region == REGION_GALAR))
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved
return foundSpecies;
}
}
return species;
}

bool32 IsSpeciesForeignRegionalForm(u32 species)
{
if ((gSpeciesInfo[species].isAlolanForm && REGION_CURRENT != REGION_ALOLA)
|| (gSpeciesInfo[species].isGalarianForm && REGION_CURRENT != REGION_GALAR)
|| (gSpeciesInfo[species].isHisuianForm && REGION_CURRENT != REGION_HISUI)
|| (gSpeciesInfo[species].isGalarianForm && REGION_CURRENT != REGION_GALAR))
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved
return TRUE;
return FALSE;
}
Loading