• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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
    9
    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
     
  • 585
    Posts
    11
    Years
    • Seen Feb 7, 2017
    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.
     
  • 1,224
    Posts
    10
    Years
    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.
     

    FL

    Pokémon Island Creator
  • 2,454
    Posts
    13
    Years
    • Seen May 16, 2024
    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