Thread: [Essentials script] Random Egg Generator
View Single Post
  #5    
Old August 26th, 2012 (06:40 AM). Edited August 26th, 2012 by FL.
FL's Avatar
FL
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
Quote originally posted by Nickalooose:
No you did just answer my question, I don't know if you wanted to add a section where you can keep desired types etc. It would be a good idea, like for example you pick up an egg in a volcano, it would be unlikely a Caterpie should hatch, but adding all Pokémon that aren't fire types would take a while and maybe cause 1 or 2 to be missed and randomly hatch a Pokémon you never meant to.
Use:
Code:
def randomEggGenerator(exceptions=[],enableIncenseEvos=false,type=-1)
  # Phione and Manaphy are always exceptions 
  exceptions+=[PBSpecies::PHIONE,PBSpecies::MANAPHY] 
  if $Trainer.party.length>=6
    Kernel.pbMessage(_INTL(
        "I'm sorry, but it would seem that you can't carry any more Pokemon."))
  else   
    species=0
    dexdata=pbOpenDexData
    while(species==0)
      species=rand(PBSpecies.maxValue)+1
      pbDexDataOffset(dexdata,species,8)
      type1=dexdata.fgetb
      type2=dexdata.fgetb
      # Redo the loop if the species can't be in an egg, is an exceptions or
      # is an evolution (only if enableIncenseEvos=false)
      species=0 if (!pbHasEggEx?(species) || exceptions.include?(species) || 
          (!enableIncenseEvos && pbGetPreviousForm(species)!=species) ||
          (type!=-1 && type!=type1 && type!=type2))
    end
    dexdata.close    
    pbGenerateEgg(species)
    Kernel.pbMessage(
        _INTL("{1} received the Egg!\\se[itemlevel]\1",$Trainer.name))
  end
end
Use the command 'randomEggGenerator([],false,PBTypes::FIRE)'

EDIT: Take note that pokémon like Azurill counts as normal type.
__________________
Reply With Quote