Skip to content

Commit

Permalink
Added a GetSpeciesPreEvolution function and fixed EVO_NONE value (#3696)
Browse files Browse the repository at this point in the history
  • Loading branch information
LOuroboros authored Dec 11, 2023
1 parent 0daf348 commit ed3e944
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
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;
}

0 comments on commit ed3e944

Please sign in to comment.