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 April 27th, 2013 (3:50 PM).
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
     
    Join Date: Sep 2012
    Age: 24
    Gender: Male
    Posts: 59
    Alright first thing first.... I did not create this script, I just altered it slightly for some different performances.

    Credits to FL.

    1. I changed the script to accept minimum/maximum values. This is so you can choose to limit the range of pokemon it can generate, EX: 1,151 will generate only Gen 1 pokemon.
    152,251 will generate Gen 2 pokemon.

    2. Made it easier to add exceptions/type limits. No longer have to type PBSpecies::POKENAME
    Just type :POKENAME. Same for PBTypes::TYPE, just :TYPE.

    The main reason I did this was because I needed fewer amount of pokemon to be generated, and needed more space in the event script.

    Once again, no need to credit me for the script.
    Just replace the old script with this new one, and call it like this:
    randomEggGenerator(min,max,[exceptions],[types],incense)

    Example for Generation 1 only, Fire type, and no incense:
    randomEggGenerator(1,151,[],[:FIRE])

    Example for Generation 2 only, No starter pokemon, incense set to true:
    randomEggGenerator(152,251,[:CHIKORITA,:CYNDAQUIL,:TOTODILE],[],true)

    To use it like the original script:
    randomEggGenerator(1,649,[exceptions],[types],false/true)

    Final time.... This is just a modified version of FL.'s script.

    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. You can also filter by type.
    #
    #===============================================================================
    #
    # 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(1,649,[:DRATINI,:LARVITAR],[])' won't generates
    # Dratini or Larvitar.
    #
    # You can also filter by types calling this method with a type array as
    # second parameter. Example: 
    # 'randomEggGenerator(1,649[],[:ROCK,:GROUND,:STEEL])' only
    # generates pokémon that have the Rock, Ground or Steel types. Please note 
    # that pokémon like Swablu doesn't count as a Dragon type.
    #
    # This script also doesn't generate eggs for pokémon than can incense breed
    # like Wynaut, but generate for pokémon than are incense babies like Wobbuffet. 
    # If you wish to enable the both cases in eggs, both counting as different
    # pokémon call the script using 'randomEggGenerator(1,649,[],[],true)'.
    # 
    #===============================================================================
    
    def randomEggGenerator(min,max,exceptions=[],type=[],enableIncenseEvos=false)
      for i in 0...type.length
        type[i]=getID(PBTypes,type[i]) if !type[i].is_a?(Integer)
      end
      for i in 0...exceptions.length
        exceptions[i]=getID(PBSpecies,exceptions[i]) if !exceptions[i].is_a?(Integer)
      end
      # 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=min+rand(max-min)
          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 (!pbHasEgg?(species) || exceptions.include?(species) || 
              (!type.empty? && !type.include?(type1) && !type.include?(type2)) ||
              (!enableIncenseEvos && pbGetPreviousForm(species)!=species))
        end
        dexdata.close    
        pbGenerateEgg(species)
        Kernel.pbMessage(
            _INTL("{1} received the Egg!\\se[itemlevel]\1",$Trainer.name))
      end
    end
    Reply With Quote

    Relevant Advertising!

      #2    
    Old April 30th, 2013 (4:04 PM).
    FL's Avatar
    FL FL is offline
    Pokémon Island Creator
       
      Join Date: Sep 2010
      Gender: Male
      Posts: 1,711
      Well done!

      I prefer to use a Range object (or its array conversion) rather than a min/max values. Thus, the Exception can be handled directly in this array, making three parameters as one!

      Ah! I also prefer to put default values for these parameters.
      __________________
      Reply With Quote
        #3    
      Old February 20th, 2014 (3:50 PM).
      joeyhugg's Avatar
      joeyhugg joeyhugg is offline
         
        Join Date: Apr 2013
        Gender: Male
        Posts: 384
        This will be most useful. Thanks!
        __________________
        This signature has been disabled.
        Signature exceeds height limit.
        Please review and fix the issues by reading the signature rules.

        You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

        Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
        Reply With Quote
          #4    
        Old May 5th, 2014 (5:04 PM). Edited May 7th, 2014 by mej71.
        mej71's Avatar
        mej71 mej71 is offline
        • Moderator
         
        Join Date: Mar 2014
        Location: Omnipresence
        Gender: Male
        Posts: 1,210
        I know this was written for v12, but I'm having a problem with it. I call it, and it runs, but then when i go to check my party I get this error

        Code:
        Exception: RuntimeError
        Message: filename is nil
        SpriteWindow:218:in `initialize'
        PokemonSprite:113:in `new'
        PokemonSprite:113:in `pokemon='
        PokemonSprite:99:in `initialize'
        PokemonParty:341:in `new'
        PokemonParty:341:in `initialize'
        PokemonParty:614:in `new'
        PokemonParty:614:in `pbStartScene'
        PokemonParty:612:in `each'
        PokemonParty:612:in `pbStartScene'
        Using this to call it: randomEggGenerator(1,721,[],[],false)
        Reply With Quote
          #5    
        Old May 12th, 2014 (12:41 PM).
        FL's Avatar
        FL FL is offline
        Pokémon Island Creator
           
          Join Date: Sep 2010
          Gender: Male
          Posts: 1,711
          Quote:
          Originally Posted by mej71 View Post
          I know this was written for v12, but I'm having a problem with it. I call it, and it runs, but then when i go to check my party I get this error

          Code:
          Exception: RuntimeError
          Message: filename is nil
          SpriteWindow:218:in `initialize'
          PokemonSprite:113:in `new'
          PokemonSprite:113:in `pokemon='
          PokemonSprite:99:in `initialize'
          PokemonParty:341:in `new'
          PokemonParty:341:in `initialize'
          PokemonParty:614:in `new'
          PokemonParty:614:in `pbStartScene'
          PokemonParty:612:in `each'
          PokemonParty:612:in `pbStartScene'
          Using this to call it: randomEggGenerator(1,721,[],[],false)
          'pbGenerateEgg(1)' gives you Bulbasaur? If no, then there is something wrong with your Essentials.
          __________________
          Reply With Quote
            #6    
          Old May 12th, 2014 (1:22 PM).
          mej71's Avatar
          mej71 mej71 is offline
          • Moderator
           
          Join Date: Mar 2014
          Location: Omnipresence
          Gender: Male
          Posts: 1,210
          Quote:
          Originally Posted by FL View Post
          'pbGenerateEgg(1)' gives you Bulbasaur? If no, then there is something wrong with your Essentials.
          It wound up being me, thanks so much!

          For some reason, this line in def pbCheckPokemonIconFiles

          Code:
          bitmapFileName=sprintf("Graphics/Icons/iconEgg") if !pbResolveBitmap(bitmapFileName)
          got changed to

          Code:
          bitmapFileName=sprintf("Graphics/Pictures/iconEgg") if !pbResolveBitmap(bitmapFileName)
          though I have no idea why I would have changed that nor do I remember doing so lol.
          Reply With Quote
            #7    
          Old July 13th, 2014 (11:29 AM).
          StevenStoner StevenStoner is offline
             
            Join Date: Jul 2014
            Gender: Male
            Posts: 2
            Where do I put it? Like, what section?
            Reply With Quote
              #8    
            Old July 13th, 2014 (11:36 AM).
            Glaceon's Avatar
            Glaceon Glaceon is offline
            Craziest Glaceon you will meet
               
              Join Date: Jan 2013
              Location: Ljubljana
              Age: 18
              Gender: Other
              Nature: Lonely
              Posts: 1,390
              Quote:
              Originally Posted by StevenStoner View Post
              Where do I put it? Like, what section?
              find the Main script in the script editor(the very last one), right click and chose insert, name the new section whatever you want and put the script there
              Reply With Quote
                #9    
              Old July 13th, 2014 (3:36 PM).
              StevenStoner StevenStoner is offline
                 
                Join Date: Jul 2014
                Gender: Male
                Posts: 2
                Quote:
                Originally Posted by Roaming Murkrow View Post
                find the Main script in the script editor(the very last one), right click and chose insert, name the new section whatever you want and put the script there
                Oh... lol thanks, hahahahaha
                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 7:00 PM.