Consolidated function and adjusted names

This commit is contained in:
Eduardo Quezada 2025-01-01 13:14:06 -03:00
parent bcccbaf073
commit 040cf998bb
5 changed files with 27 additions and 20 deletions

View file

@ -14,7 +14,7 @@ enum Region
REGION_GALAR,
REGION_HISUI,
REGION_PALDEA,
REGION_COUNT,
REGIONS_COUNT,
};
#endif // GUARD_CONSTANTS_REGIONS_H

View file

@ -911,7 +911,7 @@ const u8 *GetMoveAnimationScript(u16 moveId);
void UpdateDaysPassedSinceFormChange(u16 days);
void TrySetDayLimitToFormChange(struct Pokemon *mon);
u32 CheckDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler);
u32 GetRegionalForm(u32 species, u32 region);
u32 GetRegionalFormByRegion(u32 species, u32 region);
bool32 IsSpeciesForeignRegionalForm(u32 species, u32 currentRegion);
#endif // GUARD_POKEMON_H

View file

@ -1014,7 +1014,7 @@ static u16 DetermineEggSpeciesAndParentSlots(struct DayCare *daycare, u8 *parent
else if (fatherIsForeign && hasFatherEverstone)
parentSpecies = fatherEggSpecies;
else if (motherIsForeign)
parentSpecies = GetRegionalForm(motherEggSpecies, currentRegion);
parentSpecies = GetRegionalFormByRegion(motherEggSpecies, currentRegion);
else
parentSpecies = motherEggSpecies;

View file

@ -6979,7 +6979,19 @@ u32 CheckDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler)
return gMovesInfo[move].type;
}
u32 GetRegionalForm(u32 species, u32 region)
bool32 IsSpeciesRegionalFormFromRegion(u32 species, u32 region)
{
switch (region)
{
case REGION_ALOLA: return gSpeciesInfo[species].isAlolanForm;
case REGION_GALAR: return gSpeciesInfo[species].isGalarianForm;
case REGION_HISUI: return gSpeciesInfo[species].isHisuianForm;
case REGION_PALDEA: return gSpeciesInfo[species].isPaldeanForm;
default: return FALSE;
}
}
u32 GetRegionalFormByRegion(u32 species, u32 region)
{
u32 formId = 0;
u32 firstFoundSpecies = 0;
@ -6992,13 +7004,8 @@ u32 GetRegionalForm(u32 species, u32 region)
if (firstFoundSpecies == 0)
firstFoundSpecies = formTable[formId];
if ((gSpeciesInfo[formTable[formId]].isAlolanForm && region == REGION_ALOLA)
|| (gSpeciesInfo[formTable[formId]].isGalarianForm && region == REGION_GALAR)
|| (gSpeciesInfo[formTable[formId]].isHisuianForm && region == REGION_HISUI)
|| (gSpeciesInfo[formTable[formId]].isPaldeanForm && region == REGION_PALDEA))
{
if (IsSpeciesRegionalFormFromRegion(formTable[formId], region))
return formTable[formId];
}
}
if (firstFoundSpecies != 0)
return firstFoundSpecies;
@ -7008,10 +7015,11 @@ u32 GetRegionalForm(u32 species, u32 region)
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;
u32 i;
for (i = 0; i < REGIONS_COUNT; i++)
{
if (IsSpeciesRegionalFormFromRegion(species, i) && currentRegion != i)
return TRUE;
}
return FALSE;
}

View file

@ -14,7 +14,7 @@
StorePokemonInDaycare(&gPlayerParty[0], &gSaveBlock1Ptr->daycare.mons[1]); \
RUN_OVERWORLD_SCRIPT( special GiveEggFromDaycare; );
TEST("Daycare Pokémon generate Eggs of the lowest member of the evolutionary family")
TEST("(Daycare) Pokémon generate Eggs of the lowest member of the evolutionary family")
{
ASSUME(P_FAMILY_PIKACHU == TRUE);
ASSUME(P_GEN_2_CROSS_EVOS == TRUE);
@ -29,7 +29,7 @@ TEST("Daycare Pokémon generate Eggs of the lowest member of the evolutionary fa
EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_SPECIES), SPECIES_PICHU);
}
TEST("Daycare Pokémon offspring species is based off the mother's species")
TEST("(Daycare) Pokémon offspring species is based off the mother's species")
{
u32 offspring = 0;
ASSUME(P_FAMILY_PIKACHU == TRUE);
@ -44,7 +44,7 @@ TEST("Daycare Pokémon offspring species is based off the mother's species")
EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_SPECIES), offspring);
}
TEST("Daycare Pokémon can breed with Ditto if they don't belong to the Ditto or No Eggs Discovered group")
TEST("(Daycare) Pokémon can breed with Ditto if they don't belong to the Ditto or No Eggs Discovered group")
{
u32 j = 0;
u32 parentSpecies = 0;
@ -63,10 +63,9 @@ TEST("Daycare Pokémon can breed with Ditto if they don't belong to the Ditto or
EXPECT_NE(GetMonData(&gPlayerParty[0], MON_DATA_SPECIES), SPECIES_NONE);
else
EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_SPECIES), SPECIES_NONE);
}
TEST("Daycare Pokémon with regional forms give the correct offspring")
TEST("(Daycare) Pokémon with regional forms give the correct offspring")
{
u32 offspring = 0;
ASSUME(P_FAMILY_MEOWTH == TRUE);