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.

TrollandToad.com
Reply
 
Thread Tools
  #1    
Old August 25th, 2012 (12:01 PM).
FL's Avatar
FL FL is offline
Pokémon Island Creator
     
    Join Date: Sep 2010
    Gender: Male
    Posts: 1,717
    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

    Relevant Advertising!

      #2    
    Old August 25th, 2012 (12:50 PM).
    Nickalooose Nickalooose is offline
    --------------------
       
      Join Date: Mar 2008
      Gender: Female
      Posts: 1,309
      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 (4:40 AM).
      FL's Avatar
      FL FL is offline
      Pokémon Island Creator
         
        Join Date: Sep 2010
        Gender: Male
        Posts: 1,717
        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 (4:57 AM).
        Nickalooose Nickalooose is offline
        --------------------
           
          Join Date: Mar 2008
          Gender: Female
          Posts: 1,309
          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 (6:40 AM). Edited August 26th, 2012 by FL.
          FL's Avatar
          FL FL is offline
          Pokémon Island Creator
             
            Join Date: Sep 2010
            Gender: Male
            Posts: 1,717
            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.
            __________________
            Reply With Quote
              #6    
            Old August 27th, 2012 (4:15 AM).
            Nickalooose Nickalooose is offline
            --------------------
               
              Join Date: Mar 2008
              Gender: Female
              Posts: 1,309
              Perfect, just trying to make this script have more options and give variety, nice work
              Reply With Quote
                #7    
              Old May 9th, 2015 (10:57 AM). Edited May 9th, 2015 by FL.
              FL's Avatar
              FL FL is offline
              Pokémon Island Creator
                 
                Join Date: Sep 2010
                Gender: Male
                Posts: 1,717
                If you use the code in the last post, you can add this at someplace:

                Code:
                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.
                __________________
                Reply With Quote
                Reply

                Quick Reply

                Join the conversation!

                Create an account to post a reply in this thread, participate in other discussions, and more!

                Create a PokéCommunity Account

                Sponsored Links
                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

                Forum Jump


                All times are GMT -8. The time now is 4:19 AM.