FANDOM


Weighted Egg Generator
This tutorial was written by GReusch. Please give credit.

This tutorial is related to the following pages:

Click here for more tutorials!


In this tutorial you will learn how to make an egg generator that can give the player a egg. There are two major differences between this generator and FL's Random Egg Generator:

  1. In FL's generator, a random egg is selected from all possible Pokémon species and the user defines exceptions. In this generator, the user just picks what species they want available, so it works better when there are only a few choices for what can hatch from the egg.
  2. This generator uses a tier system, meaning that the user can make certain Pokémon have a lesser chance of generating.

The Script

As usual, put this script somewhere above "Main." To call it, use "weightedEggGenerator"

​#===============================================================================
# Weighted Egg Generator - By GReusch
#===============================================================================
#This is a script that can be used to generate a Pokémon egg based off 
#of a list of species. It also has support for multiple tiers of rarity. It
#uses weighted random generation to allow the user to define how rare each tier
#is.
#
#As usual, insert a blank script above "Main" and add all of this to it.
#
#You call this script with "weightedEggGenerator"
#===============================================================================
#Define Pokémon below
TIER1=[PBSpecies::BULBASAUR,PBSpecies::CHARMANDER,PBSpecies::SQUIRTLE]
TIER2=[PBSpecies::CHIKORITA,PBSpecies::CYNDAQUIL,PBSpecies::TOTODILE]
TIER3=[PBSpecies::PHIONE]

#This is where you pick the percentages for an egg to be picked from a certain 
#tier. MAKE SURE YOUR PERCENTAGES ADD TO 100!!!!!
CHANCES=[90,9,1]

def weightedEggGenerator
  if $Trainer.party.length>=6
    Kernel.pbMessage(_INTL(
        "I'm sorry, but it would seem that you can't carry any more Pokémon."))
  else
    #Adds all of the tier lists to a larger list
    tierlist=[]
    tierlist.push(TIER1)
    tierlist.push(TIER2)
    tierlist.push(TIER3)
    #Selects either Tier 1, 2, or 3 based on the user-defined percentages
    random = rand(100)
    index=0
    for chance in CHANCES
        if(random < chance)
          selectedtier = tierlist[index]
          break
        end
        random -= chance
        index+=1
      end
    #Randomly selects one of the indexes in the selected tier
    species=selectedtier[rand(selectedtier.length)]
    pbGenerateEgg(species)
    Kernel.pbMessage(
        _INTL("{1} received the Egg!\\se[itemlevel]\1",$Trainer.name))
  end
end

How to use it

After you have pasted the above code into a blank script, the first thing you will want to do is change what species can hatch from the egg, and how likely it is for the player to get a specific species.

At the top of the script, you'll see:

TIER1=[PBSpecies::BULBASAUR,PBSpecies::CHARMANDER,PBSpecies::SQUIRTLE]
TIER2=[PBSpecies::CHIKORITA,PBSpecies::CYNDAQUIL,PBSpecies::TOTODILE]
TIER3=[PBSpecies::PHIONE]

These are the three tiers of Pokémon, with Tier 1 being the most common and Tier 3 being the rarest. Just add/remove any Pokémon you want keeping the format "PBSpecies::XXX" with XXX being the Pokémon's name in all caps. Separate each Pokémon entry with a comma.

The next thing you will want to do is customize how rare each tier is. This is what you want to edit:

CHANCES=[90,9,1]

These are the probabilities that a certain tier of Pokémon will be selected. The first number (90) implies that there is a 90% chance that Tier 1 will be chosen. The second number (9) implies that there is a 9% chance that Tier 2 is chosen. Tier 3 has only a 1% chance. You can change these three numbers to whatever you want, but make sure they add up to 100!

That's all you need to do! The script will randomly choose one of the three tiers and then randomly select one of the Pokémon in that tier to put in the egg. I will eventually be improving this tutorial by explaining how you can add more tiers!

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.