• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Random Pokemon Selection

  • 10
    Posts
    8
    Years
    I'm looking to create an event where you receive a random Pokemon from a list of pre selected choices. How would you do this?
     
    I'm no expert coder or anything - in fact, I'm pretty sure this isn't the best way to do it - but I got this to work.

    You'll want to add a script section in the event that looks like this:

    [PokeCommunity.com] Random Pokemon Selection


    You'd probably want to run ExtendText from the main project folder, as that you give you more room to add the code.

    Now, how it works.

    You'd want to set that first line 'random3=rand(5)' is set to the same number of Pokemon that you want. You'd be changing the number in parenthesis. So if you have ten Pokemon on the list, then set it to 'random3=rand(10)' and such.

    Then the next line 'if random3==0' tells it what to do if the random number selected is 0 (these numbers start a 0 instead of 1, so you'd only go up to 4). In this case, it would be to give the player a Bulbasaur. The next line, 'if random3==1' tells it that if the number selected is 1, then the player gets a Charmander. You'd want to do that for each Pokemon that they player can get, going up by one each time.

    Then make sure that you have that nice 'end' at the very bottom, which tells the code to end.

    I hope that helps - I'm not a coder by a long shot, but it's something I was able to piece together that functions. Someone more experienced might be able to give you a much better method of doing it.
     
    That will work, nice Sparta! ;)

    I would personally make it easier, something like this (untested):
    Code:
    species = [:BULBASAUR,:CHARMANDER,:SQUIRTLE,
               :MEWTWO,:MEW]
    pbAddPokemon(species[rand(species.size)],5)

    This is setting an array of symbols (preceded with a ':'). In the adding Pok?mon part, we're randomly picking one of those with a range of 0 to the size of the array (last number is excluded so we don't have to say - 1, as you often do need to). This means you can just add one to the list and it'll dynamically so the rest for you.
     
    Last edited:
    Hello.
    Is it possible generate shiny Pokemon?
    pkmn.makeShiny, p.makeShiny and etc. doen't work me.
    Thank you!

    You should write the script like this:
    Code:
    species = [:BULBASAUR,:CHARMANDER,:SQUIRTLE,:MEWTWO,:MEW]
    poke=PokeBattle_Pokemon.new(species[rand(species.size)],5,$Trainer)
    poke.makeShiny
    pbAddPokemon(poke)
     
    Back
    Top