- 143
- Posts
- 5
- Years
- Seen Mar 26, 2024
Hey, just a quick piece of code to enable hidden abilities naturally for wild, trainer and obtainable Pokemon.The only drawback of this method is that it doesn't feel elegant, because it overrides every newly created Pokemon's ability. This leads to Pokemon not having natural abilities anymore.This may sound bad, but it actually only affects the debug screen so it won't matter in the actual game.
To implement it you simply have to insert 2 pieces of code.(Keep in mind this was made in EssentialsV.18 and may not work in other versions)
First put this in Pokebattle_Pokemon below "@mail = nil":
Now insert this right above "#=============================================================================
# Nature
#=============================================================================":
That's it, but I got a little extra if you want ability capsules be able to change abilities to hidden abilities.
Just replace the whole function "ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE,proc { |item,pkmn,scene|" with:
If you encounter any problem's while using this script be sure to comment them. :)
To implement it you simply have to insert 2 pieces of code.(Keep in mind this was made in EssentialsV.18 and may not work in other versions)
First put this in Pokebattle_Pokemon below "@mail = nil":
Spoiler:
Code:
# This enables Pokemon to get their hidden abilities in a natural way
list=getAllAbilityList[1]
self.setAbility(list[rand(list.length)])
# Nature
#=============================================================================":
Spoiler:
Code:
# Returns the list of abilities this Pokémon can have treating hidden abilities as normal ones
def getAllAbilityList
abils=[]; ret=[[],[]]
abilities = pbGetSpeciesData(@species,formSimple,SpeciesAbilities)
hiddenAbil = pbGetSpeciesData(@species,formSimple,SpeciesHiddenAbility)
if abilities.is_a?(Array)
abils.push(abilities[0])
abils.push(abilities[1])
else
abils.push(abilities)
end
if hiddenAbil.is_a?(Array)
abils.push(hiddenAbil[0])
abils.push(hiddenAbil[1])
abils.push(hiddenAbil[2])
abils.push(hiddenAbil[3])
else
abils.push(hiddenAbil)
end
for i in 0...abils.length
next if !abils[i] || abils[i]<=0
ret[0].push(abils[i]); ret[1].push(i)
end
return ret
end
Just replace the whole function "ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE,proc { |item,pkmn,scene|" with:
Spoiler:
Code:
ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE,proc { |item,pkmn,scene|
# Get a list of both the abilities' constants and their indexes
abils = pkmn.getAllAbilityList
# Check if the Pokemon only has 1 ability or is Zygarde
if abils[1].length<=1 || isConst?(pkmn.species,PBSpecies,:ZYGARDE)
scene.pbDisplay(_INTL("It won't have any effect."))
next false
end
# Check if this is the Pokemon's last ability(start from the beginning if true)
if pkmn.abilityIndex==abils[1][abils[1].length-1]
newabil = 0
newabilname = PBAbilities.getName(abils[0][0])
else
newabil = pkmn.abilityIndex+1
newabilname = PBAbilities.getName(abils[0][newabil])
end
# Let the player confirm the change
if scene.pbConfirm(_INTL("Would you like to change {1}'s Ability to {2}?",
pkmn.name,newabilname))
# Change the ability
pkmn.setAbility(newabil)
scene.pbRefresh
scene.pbDisplay(_INTL("{1}'s Ability changed to {2}!",pkmn.name,
PBAbilities.getName(pkmn.ability)))
next true
end
next false
})
Last edited: