• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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.

Is there a code to give the player a random pokemon

  • 35
    Posts
    11
    Years
    • Seen Sep 17, 2015
    I wanted to add in a fourth option for starters that gives the player a random pokemon, preferably first stage. Is there a code that does that
     
    I don't think there's a script that does that, but you could set a Variable to a random number (e.g. range 1-10), and then create 10 Conditional Branches, the condition being "If variable equals X", X being a different number from the range. Each Conditional Branch will contain the regular Pokemon adding script, and each will give the player a different Pokemon.
     
    It's even simpler than that
    Code:
    pbAddToParty((rand(PBSpecies.maxValue)+1),20)

    20 is the level. Note that this can give any pokemon, including legendaries. If you want to blacklist certain pokemon, you will have to make a slight change.

    Edit, just reread what you asked

    Code:
    randpoke=pbGetBabySpecies((rand(PBSpecies.maxValue)+1))
    pbAddToParty(randpoke,20)

    This still can include legendaries though.
     
    It's even simpler than that
    Code:
    pbAddToParty((rand(PBSpecies.maxValue)+1),20)

    20 is the level. Note that this can give any pokemon, including legendaries. If you want to blacklist certain pokemon, you will have to make a slight change.

    Edit, just reread what you asked

    Code:
    randpoke=pbGetBabySpecies((rand(PBSpecies.maxValue)+1))
    pbAddToParty(randpoke,20)

    This still can include legendaries though.
    This way a pokémon like Caterpie (numbers 10, 11 and 12) have three times more chance than a pokémon without evolution like Carnivine (number 455) because its numbers are 1. Eevee just have eight times the chance.

    I suggest you to use a Random Egg generator and remove the "Egg" part.
     
    Back
    Top