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:
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.
#==========================================================================
#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
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:
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:
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 (and fix the indents in the code for readability).
- 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.
- This generator uses a tier system, meaning that the user can make certain Pokémon have a lesser chance of generating.
As usual, put this script somewhere above "Main." To call it, use "weightedEggGenerator"
Spoiler:
#==========================================================================
# 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.
#==========================================================================
#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
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 (and fix the indents in the code for readability).