mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-03-19 03:58:33 +01:00
Merge pull request #1508 from Scott-Bonner/get_ability
Handle GetAbilityBySpecies edge cases
This commit is contained in:
commit
b86694876c
@ -381,6 +381,8 @@
|
|||||||
|
|
||||||
#define SKIP_FRONT_ANIM (1 << 7)
|
#define SKIP_FRONT_ANIM (1 << 7)
|
||||||
|
|
||||||
#define NUM_ABILITY_SLOTS 3
|
#define NUM_ABILITY_SLOTS (NUM_NORMAL_ABILITY_SLOTS + NUM_HIDDEN_ABILITY_SLOTS)
|
||||||
|
#define NUM_NORMAL_ABILITY_SLOTS 2
|
||||||
|
#define NUM_HIDDEN_ABILITY_SLOTS 1
|
||||||
|
|
||||||
#endif // GUARD_CONSTANTS_POKEMON_H
|
#endif // GUARD_CONSTANTS_POKEMON_H
|
||||||
|
@ -5441,14 +5441,26 @@ u8 GetMonsStateToDoubles_2(void)
|
|||||||
|
|
||||||
u8 GetAbilityBySpecies(u16 species, u8 abilityNum)
|
u8 GetAbilityBySpecies(u16 species, u8 abilityNum)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if (abilityNum < NUM_ABILITY_SLOTS)
|
if (abilityNum < NUM_ABILITY_SLOTS)
|
||||||
gLastUsedAbility = gBaseStats[species].abilities[abilityNum];
|
gLastUsedAbility = gBaseStats[species].abilities[abilityNum];
|
||||||
else
|
else
|
||||||
gLastUsedAbility = gBaseStats[species].abilities[0];
|
gLastUsedAbility = ABILITY_NONE;
|
||||||
|
|
||||||
if (gLastUsedAbility == ABILITY_NONE)
|
if (abilityNum >= NUM_NORMAL_ABILITY_SLOTS) // if abilityNum is empty hidden ability, look for other hidden abilities
|
||||||
gLastUsedAbility = gBaseStats[species].abilities[0];
|
{
|
||||||
|
for (i = NUM_NORMAL_ABILITY_SLOTS; i < NUM_ABILITY_SLOTS && gLastUsedAbility == ABILITY_NONE; i++)
|
||||||
|
{
|
||||||
|
gLastUsedAbility = gBaseStats[species].abilities[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_ABILITY_SLOTS && gLastUsedAbility == ABILITY_NONE; i++) // look for any non-empty ability
|
||||||
|
{
|
||||||
|
gLastUsedAbility = gBaseStats[species].abilities[i];
|
||||||
|
}
|
||||||
|
|
||||||
return gLastUsedAbility;
|
return gLastUsedAbility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user