FANDOM


Random Egg Generator
This tutorial was written by -FL-. Please give credit.

This tutorial is related to the following pages:

Click here for more tutorials!


#===============================================================================
# * Random Egg Generator - by FL (Credits will be apreciated)
#===============================================================================
#
# This script is for Pokémon Essentials. It random generates an egg with all
# possible pokémon that can hatch from an eggs (excluding some species like
# Ditto, Mewtwo and Unown) with same probability. You can also filter by type.
#
#===============================================================================
#
# To this scripts works, put it above main and use in script command 
# 'randomEggGenerator'. This only gives to player an egg if the player has
# a empty party slot. You can also calls the method with an array with the
# exceptions that cannot be random generated. Example:
# 'randomEggGenerator(PBSpecies::DRATINI,PBSpecies::LARVITAR)' won't generates
# Dratini or Larvitar.
#
# You can also filter by types calling this method with a type array as
# second parameter. Example: 
# 'randomEggGenerator([],[PBTypes::ROCK,PBTypes::GROUND,PBTypes::STEEL])' only
# generates pokémon that have the Rock, Ground or Steel types. Please note 
# that pokémon like Swablu doesn't count as a Dragon type.
#
# This script also doesn't generate eggs for pokémon than can incense breed
# like Wynaut, but generate for pokémon than are incense babies like Wobbuffet. 
# If you wish to enable the both cases in eggs, both counting as different
# pokémon call the script using 'randomEggGenerator([],[],true)'.
# 
#===============================================================================

def randomEggGenerator(exceptions=[],type=[],enableIncenseEvos=false)
  # 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 (!pbHasEgg?(species) || exceptions.include?(species) || 
          (!type.empty? && !type.include?(type1) && !type.include?(type2)) ||
          (!enableIncenseEvos && pbGetPreviousForm(species)!=species))
    end
    dexdata.close    
    pbGenerateEgg(species)
    Kernel.pbMessage(
        _INTL("{1} received the Egg!\\se[itemlevel]\1",$Trainer.name))
  end
end

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.