The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Scripts & Tutorials
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.


Advertise here

Reply
 
Thread Tools
  #1    
Old August 25th, 2012, 12:01 PM
FL's Avatar
FL
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male

Advertise here
Code:
#===============================================================================
# * 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
__________________
Reply With Quote
  #2    
Old August 25th, 2012, 12:50 PM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
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?
Reply With Quote
  #3    
Old August 26th, 2012, 04:40 AM
FL's Avatar
FL
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
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.
__________________
Reply With Quote
  #4    
Old August 26th, 2012, 04:57 AM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
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.
Reply With Quote
  #5    
Old August 26th, 2012, 06:40 AM
FL's Avatar
FL
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
Quote:
Originally Posted by Nickalooose View Post
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.
__________________

Last edited by FL; August 26th, 2012 at 08:44 AM.
Reply With Quote
  #6    
Old August 27th, 2012, 04:15 AM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
Perfect, just trying to make this script have more options and give variety, nice work
Reply With Quote
Reply
Quick Reply

Sponsored Links


Advertise here
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 12:04 AM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.