Resource icon

How to Allow Hidden Abilities to Naturally Occur

This script provides an edit originally created by the Reborn team which allows for Hidden Abilities to occur in the wild as well as can be obtained through event scripts without the use of defining a random variable. Although, please note that this gives the HA the same chance to occur as the regular abilities. (I'll make amends to the code if I can figure out a method to make it occur less.)

But to begin, search for this line in the script editor:
Ruby:
  def abilityIndex
You should find the section you're looking for in Pokebattle_Pokemon. Anyways, the next step is to replace the entire #Ability section with:
Ruby:
################################################################################
# Ability
################################################################################
# Returns the index of this Pokémon's ability.
  def abilityIndex
    abil=@abilityflag!=nil ? @abilityflag: (@personalID%3)
    return abil
  end

# Returns the ID of this Pokemon's ability.
  def ability
    abil=abilityIndex
    dexdata=pbOpenDexData
      pbDexDataOffset(dexdata,@species,40)
      h1=dexdata.fgetb
      h2=dexdata.fgetb
      h3=dexdata.fgetb
      h4=dexdata.fgetb
      pbDexDataOffset(dexdata,@species,2)
      ret1=dexdata.fgetb
      ret2=dexdata.fgetb
    dexdata.close
    ret=ret1
    if abil==2
      return h1 if h1>0
      abil=(@personalID&1)
    elsif abil==3
      return h2 if h2>0
      abil=(@personalID&1)
    elsif abil==4
      return h3 if h3>0
      abil=(@personalID&1)
    elsif abil==5
      return h4 if h4>0
      abil=(@personalID&1)
    end
    if abil==1
      ret=ret2
      ret=ret1 if ret2==0
    end
    return ret
  end

# Sets this Pokémon's ability to a particular ability (if possible).
  def setAbility(value)
    @abilityflag=value
  end

  def hasHiddenAbility?
    abil=abilityIndex
    return abil!=nil && abil>=2
  end

# Returns the list of abilities this Pokémon can have.
  def getAbilityList
    abils=[]; ret=[[],[]]
    dexdata=pbOpenDexData
    pbDexDataOffset(dexdata,@species,2)
    abils.push(dexdata.fgetb)
    abils.push(dexdata.fgetb)
    pbDexDataOffset(dexdata,@species,40)
    abils.push(dexdata.fgetb)
    abils.push(dexdata.fgetb)
    abils.push(dexdata.fgetb)
    abils.push(dexdata.fgetb)
    dexdata.close
    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
To account for this change in the debug menu, search for:
Ruby:
when "setability"
You should find this section in debug_pokemon. All you have to do is replace the entire ability section with:
Ruby:
    when "setability"
       ### Ability ###
          cmd=0
          loop do
            abils=pkmn.getAbilityList
            oldabil=PBAbilities.getName(pkmn.ability)
            commands=[]
            for i in 0...abils[0].length
              commands.push((abils[1][i]<2 ? "" : "(H) ")+PBAbilities.getName(abils[0][i]))
            end
            commands.push(_INTL("Remove override"))
            msg=[_INTL("Ability {1} is natural.",oldabil),
                 _INTL("Ability {1} is being forced.",oldabil)][pkmn.abilityflag ? 1 : 0]
            cmd=@scene.pbShowCommands(msg,commands,cmd)
            # Break
            if cmd==-1
              break
            # Set ability override
            elsif cmd>=0 && cmd<abils[0].length
              pkmn.setAbility(abils[1][cmd])
            # Remove override
            elsif cmd==abils[0].length
              pkmn.abilityflag=nil
            end
            pbRefreshSingle(pkmnid)
          end
And that's it! You should now be able to regularly encounter pokemon with hidden abilities in the wild! Enjoy!
Credits
Myself, Marcello (Reborn team)
Likes: AngelusMortis
Author
Michael
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Michael

Top