• 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!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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.

[Scripting Question] How to make the starter Pokemon random?

  • 1
    Posts
    3
    Years
    • Seen Feb 21, 2022
    This is my first foray into scripting. I did some research prior and have tried a couple different inputs. So far this is the only one I've tried that doesn't crash the game with a scripting error but it doesn't actually give the player any pokemon:

    random3=rand(4)
    if random3==0
    pbAddPokemon(PBSpecies::CHARMANDER,5)
    elseif random3==1
    pbAddPokemon(PBSpecies::TORCHIC,5)
    elseif random3==2
    pbAddPokemon(PBSpecies::FENNEKIN,5)
    elseif random3==3
    pbAddPokemon(PBSpecies::LITTEN,5)
    end

    What is the appropriate way to make an event tile give a random reward?
     
    I would advise you to use a RMXP variable and assign your random value to it. I would advise you to use a RMXP variable and assign your random value to it. By default, it is variable 7 for Essentials.

    Afterwards, you can use the conditions "If variable = 0, 1, 2 or 3" to give the appropriate consequences to the continuation of your adventure (for example: quote the good name of your starter or modify the team of the rival).

    Code:
    $game_variables[7] = rand(4)
    if $game_variables[7] == 0
      pbAddPokemon(PBSpecies::CHARMANDER,5)
    elsif $game_variables[7] == 1
      pbAddPokemon(PBSpecies::TORCHIC,5)
    elsif $game_variables[7] == 2
      pbAddPokemon(PBSpecies::FENNEKIN,5)
    else #Ensure that at least one starter is given
      pbAddPokemon(PBSpecies::LITTEN,5)
    end
    $game_switches[3] = false #Switch used *in Essentials to determine whether the player is in the middle of choosing a starter.

    Also, Beware of the ruby syntax : it's "elsif" and not "elseif".
    If the script is entered in an event-making command, it must be in one block. Otherwise, your instance variable "random3" is lost and returns "nil", which will generate an inequality on all your comparisons, so only false conditions.
     
    Back
    Top