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

Added a GetSpeciesPreEvolution function and updated the value of EVO_… #3696

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@
#define F_SUMMARY_SCREEN_FLIP_SPRITE 0x80

// Evolution types
#define EVO_NONE 0xffff // Not an actual evolution, used to generate offspring that can't evolve into the specified species, like regional forms.
#define EVOLUTIONS_END 0xFFFF // Not an actual evolution, used to mark the end of an evolution array.
#define EVO_NONE 0xFFFE // Not an actual evolution, used to generate offspring that can't evolve into the specified species, like regional forms.
#define EVO_FRIENDSHIP 1 // Pokémon levels up with friendship ≥ 220
#define EVO_FRIENDSHIP_DAY 2 // Pokémon levels up during the day with friendship ≥ 220
#define EVO_FRIENDSHIP_NIGHT 3 // Pokémon levels up at night with friendship ≥ 220
Expand Down Expand Up @@ -301,8 +302,6 @@
#define EVO_LEVEL_FAMILY_OF_THREE 45 // Pokémon reaches the specified level with a personality value with a modulus of 0
#define EVO_LEVEL_FAMILY_OF_FOUR 46 // Pokémon reaches the specified level with a personality value with a modulus of 1-99

#define EVOLUTIONS_END 0xFFFF

// Evolution 'modes,' for GetEvolutionTargetSpecies
#define EVO_MODE_NORMAL 0
#define EVO_MODE_TRADE 1
Expand Down
1 change: 1 addition & 0 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,5 +709,6 @@ u8 CalculatePartyCount(struct Pokemon *party);
u16 SanitizeSpeciesId(u16 species);
bool32 IsSpeciesEnabled(u16 species);
u16 GetCryIdBySpecies(u16 species);
u16 GetSpeciesPreEvolution(u16 species);

#endif // GUARD_POKEMON_H
19 changes: 19 additions & 0 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -6092,3 +6092,22 @@ u16 GetCryIdBySpecies(u16 species)
return 0;
return gSpeciesInfo[species].cryId;
}

u16 GetSpeciesPreEvolution(u16 species)
{
int i, j;

for (i = SPECIES_BULBASAUR; i < NUM_SPECIES; i++)
{
const struct Evolution *evolutions = GetSpeciesEvolutions(i);
if (evolutions == NULL)
continue;
for (j = 0; evolutions[j].method != EVOLUTIONS_END; j++)
{
if (SanitizeSpeciesId(evolutions[j].targetSpecies) == species)
return i;
}
}

return SPECIES_NONE;
}
Loading