From d9edc2380c41a0adc0a1a8aecba09a727570969e Mon Sep 17 00:00:00 2001 From: Scyrous <74797764+Scyrous@users.noreply.github.com> Date: Mon, 19 Aug 2024 07:01:57 +0200 Subject: [PATCH] Updated Ability Switcher via special (markdown) --- Ability-Switcher-via-special.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ability-Switcher-via-special.md b/Ability-Switcher-via-special.md index d0ea0ab..eab79dc 100644 --- a/Ability-Switcher-via-special.md +++ b/Ability-Switcher-via-special.md @@ -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! \ No newline at end of file