# Hidden Ability Capsule 1.0

Kirik here. Over in Thundaga, I saw someone ask for a script to create an item similar to the Ability Capsule, except it also allowed the player to cycle through a mon's Hidden Abilities as well. I had created this a few months ago, but never shared it, so today, I decided to share the code with my native server and I'm going to share it here as well.

In PItem_ItemEffects, either scroll to the bottom until you find Ability Capsule, which is Line 1087 for me in Essentials V.18, or simply Ctrl+Shift+F AbilityCapsue. Insert 2 lines at the very bottom of the page and add the following lines of code:

Code:
ItemHandlers::UseOnPokemon.add(:SUPERCAPSULE,proc{|item,pokemon,scene|
abils=pokemon.getAbilityList
abil1=0; abil2=0; abil3=0; abil4=0; abil5=0; abil6=0
for i in abils
abil1=i[0] if i[1]==0
abil2=i[0] if i[1]==1
abil3=i[0] if i[1]==2
abil4=i[0] if i[1]==3
abil5=i[0] if i[1]==4
abil6=i[0] if i[1]==5
end
oldidx = pokemon.abilityIndex
pokemon.setAbility(pokemon.abilityIndex + 1)
if scene.pbConfirm(_INTL("Would you like to change {1}'s ability to {2}?",pokemon.name, PBAbilities.getName(pokemon.ability)))
scene.pbRefresh
scene.pbDisplay(_INTL("{1}'s Ability changed to {2}!", pokemon.name, PBAbilities.getName(pokemon.ability)))
next true
else
pokemon.setAbility(oldidx)
next false
end
})

Once this part is done, go to your items.txt file and add the following at the bottom, using whatever the next number in your sequence is:
Code:
XXX,SUPERCAPSULE,Super Capsule,Super Capsule,2,10000,"A capsule that allows a Pokémon with switch between all abilities they possess.",1,0,0,

Lastly, don't forget to add in an image for your new capsule with the appropriate item number.

I can't seem to figure out how to implement the Zygarde part of the script yet, so I will
Credits
Credit if used:
Kirik - For the edits into making this code.
Marin - For getting parts of the code to function correctly.
Author
AngelusMortis