Events.onWildPokemonCreate+=proc {|sender,e|
pokemon=e[0]
dexdata=pbOpenDexData
pbDexDataOffset(dexdata,pokemon.species,31)
compat10=dexdata.fgetb
compat11=dexdata.fgetb
dexdata.close
if compat10==15 || compat11==15 || # Undiscovered Egg Group
isConst?(pokemon.species,PBSpecies,:MANAPHY)
# Manaphy is not in the Undiscovered egg group, so needs a special case
bob=[0,1,2,3,4,5]
for i in 0...3
billy=rand(bob.length) # random spot in the bob array
pokemon.iv[bob[billy]]=31 # set the IV (determined by the billy'th number in bob) to 31
bob[billy]=nil # erasing the billy'th number from bob so no repeat selections happen
bob.compact!
end
end
}