mirror of https://github.com/pret/pokeemerald.git
Updated Ability Switcher via special (markdown)
parent
20f5cc4c62
commit
d9edc2380c
|
@ -1,4 +1,4 @@
|
|||
This scripting special lets you switch between a Pokémon's two ability slots. For instance, a Steelix with **Sturdy** will have **Rock Head** after using this special - and vice versa. If the second slot is `ABILITY_NONE`, meaning the Pokémon has no alternative ability, the special will do nothing. Keep in mind that forcefully replacing a Pokémon's ability with this method will cause a PID mismatch, which is relevant if you care about having ''legal'' Pokémon and/or compatibility with other games.
|
||||
This scripting special lets you switch between a Pokémon's two ability slots. For instance, a Steelix with **Sturdy** will have **Rock Head** after using this special - and vice versa. If the second slot is `ABILITY_NONE`, meaning the Pokémon has no alternative ability, the special will do nothing. This also holds true for the handful of Pokémon who have two identical abilities (this happens when their pre-evolved form _does_ have two different abilities). Keep in mind that forcefully replacing a Pokémon's ability with this method will cause a PID mismatch, which is relevant if you care about having ''legal'' Pokémon and/or compatibility with other games.
|
||||
|
||||
The Pokémon is meant to be selected in a script with `special ChoosePartyMon`. The resulting species is then stored in `gSpecialVar_0x8004`, at which point you'd use `special SwitchMonAbility` to change its ability.
|
||||
|
||||
|
@ -40,7 +40,7 @@ void SwitchMonAbility(void)
|
|||
u16 species = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES, NULL);
|
||||
u8 currentAbilityNum = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_ABILITY_NUM, NULL);
|
||||
|
||||
if (gSpeciesInfo[species].abilities[1] != ABILITY_NONE)
|
||||
if (gSpeciesInfo[species].abilities[1] != 0 && gSpeciesInfo[species].abilities[0] != gSpeciesInfo[species].abilities[1])
|
||||
{
|
||||
u8 newAbilityNum = !currentAbilityNum;
|
||||
SetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_ABILITY_NUM, &newAbilityNum);
|
||||
|
@ -48,6 +48,6 @@ void SwitchMonAbility(void)
|
|||
}
|
||||
```
|
||||
|
||||
In short: we first retrieve the selected Pokémon's species and ability number using `GetMonData`. We then check if its second ability is `ABILITY_NONE`. If it's not, we switch abilities by setting `newAbilityNum` to the opposite of `currentAbilityNum` and update the Pokémon's ability using `SetMonData`.
|
||||
In short: we first retrieve the selected Pokémon's species and current ability using GetMonData. We then check if the second ability is **not** ABILITY_NONE and if it differs from the first ability. If both conditions are true, we switch the ability by setting newAbilityNum to the opposite of currentAbilityNum and update the Pokémon's ability using SetMonData.
|
||||
|
||||
And that's it!
|
Loading…
Reference in New Issue