pokemon.setAbility(2) will change the Pokemon's ability to its Hidden Ability.
You can use this in many ways. Using your examples:
1.)
Having a small percentage of wild Pokemon have their Hidden Ability when encountered in the wild
In PField_EncounterModifiers, near the top, you should find the following code. Insert the red stuff.
Code:
# Make all wild Pokémon shiny while a certain Switch is ON (see Settings).
Events.onWildPokemonCreate+=proc {|sender,e|
pokemon=e[0]
if $game_switches[SHINY_WILD_POKEMON_SWITCH]
pokemon.makeShiny
end[COLOR=Red]
abil=pokemon.getAbilityList
bob=10 # set this number to the chance you want wild Pokemon to be shiny
if abil.length>2 && rand(100)<bob
pokemon.setAbility(2)
end[/COLOR]
}
2.)
Having a special tutor to change a Pokemon's ability to it's hidden ability.
Create the event so that it allows you to choose a party member (examples of this in the example maps can be found in the Name Rater and the Day Care lady), then include the following script:
Code:
$Trainer.party[pbGet(1)].setAbility(2)
3.)
Having a item similar to the ability capsule to give a Pokémon it's hidden ability.
Add the following code somewhere in PItem_ItemEffects:
Code:
ItemHandlers::UseOnPokemon.add(:DREAMCAPSULE,proc{|item,pokemon,scene|
abil=pokemon.getAbilityList
dream_abil=[]
for i in 0...abil[0].length
dream_abil.push(abil[0][i]) if abil[1][i]>1
end
if dream_abil.length >0
if Kernel.pbConfirmMessage(_INTL("Do you want to change {1}'s ability to {2}?",
pokemon.name,PBAbilities.getName(dream_abil[0])))
pokemon.setAbility(2)
scene.pbDisplay(_INTL("{1}'s ability was changed to {2}!",pokemon.name,PBAbilities.getName(pokemon.ability)))
pokemon.calcStats
next true
else
next false
end
else
scene.pbDisplay(_INTL("It won't have any effect."))
next false
end
})
In order for this to work, you will need to go into your game's PBS files and add this line to items.txt:
Code:
597,DREAMCAPSULE,Dream Capsule,1,2000,"A capsule that allows a Pokémon with a Dream World Ability to switch to it when used.",1,0,0