PDA

View Full Version : [Essentials script] Random Egg Generator


FL
August 25th, 2012, 12:01 PM
#===============================================================================
# * 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.
#
#===============================================================================
#
# 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.
#
# This script also doesn't generate eggs for pokémon than can incense breed
# like Marill, but generate for pokémon than are incense babies like Azurill.
# 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=[],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
while(species==0)
species=rand(PBSpecies.maxValue)+1
# 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) ||
(!enableIncenseEvos && pbGetPreviousForm(species)!=species))
end
pbGenerateEgg(species)
Kernel.pbMessage(
_INTL("{1} received the Egg!\\se[itemlevel]\1",$Trainer.name))
end
end

Nickalooose
August 25th, 2012, 12:50 PM
Just to say, good script, nice and simple, but for example:

If I were to just want a choice from fire types, would I have to specify all Pokémon except fire types to the exceptions=[] variable?

Or does this script literally choose any of the million Pokémon created except the 2, you say not to?

FL
August 26th, 2012, 04:40 AM
You need to specify all Pokémon except fire types to the exceptions=[] variable. You only need to put the first forms, this script always ignores the evolved species

The exceptions=[] variable only removes pokémon possibilities, if them can't be in an egg (like the Mewtwo and the evo Salamance), then them are ignored.

I didn't understand you second question.

If you wish to made a choice between pokémon types, you need some customizations, tell me than I can do for you, is easy for me.

Nickalooose
August 26th, 2012, 04:57 AM
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.

FL
August 26th, 2012, 06:40 AM
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: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
endUse the command 'randomEggGenerator([],false,PBTypes::FIRE)'

EDIT: Take note that pokémon like Azurill counts as normal type.

Nickalooose
August 27th, 2012, 04:15 AM
Perfect, just trying to make this script have more options and give variety, nice work

FL
May 9th, 2015, 10:57 AM
If you use the code in the last post, you can add this at someplace:

def randomEggBasedOnTypeEntered(helptext)
typeName = pbEnterText(helptext,0,8)
typeValidNumber = nil
typeAvailable = [:NORMAL,:FIGHTING,:FLYING,:POISON,:GROUND,
:ROCK,:BUG,:GHOST,:STEEL,:FIRE,:WATER,:GRASS,:ELECTRIC,:PSYCHIC,
:ICE,:DRAGON,:DARK]
for typeSymbol in typeAvailable
type = getID(PBTypes,typeSymbol)
if PBTypes.getName(type).downcase == typeName.strip.downcase
typeValidNumber = type
break
end
end
if typeValidNumber
randomEggGenerator([],false,typeValidNumber)
return true
end
return false
end

This code allows the player to type a type. If a valid type is typed, give the player a random egg of that type and return true. Otherside returns false. Call as 'randomEggBasedOnTypeEntered("Type name?")' on a conditional branch.