1. Hey Guest, from June 30th to August 10th 2017, participants have a little over a month to create a game. Check out the forum for more details!
    Dismiss Notice
  1. Totokyl

    Totokyl Thread Author TotoJesus member

    Joined:
    Jul 15, 2017
    Posts:
    6

    Solved Starter Pokemon Randomizer

    Discussion in 'Pokémon Essentials' started by Totokyl, Aug 12, 2017.

    I'm looking for a way to have the normal 3 options at the beginning of the game, Fire,Water,Grass. But I want to randomize all the fire choices into 1, water and grass etc. Is there a way to do this?
     
  2. Sparta

    Sparta Someone who does something. member

    Joined:
    Mar 28, 2017
    Posts:
    142
    Assuming that you mean randomizing the regional starters based on type chosen, this is how I would do it:

    After the player chooses a type, insert this code for each choice and change the Pokemon given.

    Code:
    random=rand(5)
       if random==0
    pbAddPokemon(PBSpecies::BULBASAUR,5)
       elsif random==1
    pbAddPokemon(PBSpecies::CHIKORITA,5)
       elsif random==2
    pbAddPokemon(PBSpecies::TREECKO,5)
       elsif random==3
    pbAddPokemon(PBSpecies::TURTWIG,5)
       elsif random==4
    pbAddPokemon(PBSpecies::SNIVY,5)
    end
    A bit clunky, but it does work.

    Basically, if I understand it correctly, the first line (random=rand(5)) says that it's going to randomly take five numbers (0 to 4) and randomly pick one of those numbers. Then the other lines show what the outcome is for each number chosen. If the number 0 is selected, then the player gets Bulbasaur whereas if 3 is selected, the player gets Turtwig. You can simply copy and paste it and change the Pokemon to whatever you need them to be.

    You can add more options than that, but since that code takes up every line the Script option has, even with Extendtext, someone else more knowledgable than I would have to explain how to do that as I am no professional coder and don't know the best way to do it.
     
    Totokyl likes this.
  3. Totokyl

    Totokyl Thread Author TotoJesus member

    Joined:
    Jul 15, 2017
    Posts:
    6
    Thank You. I will try this out and see if it works.------------------------
    It gave me an error. I tried to insert it into a script edit. Where am I suppose to put it?
     
  4. leilou

    leilou game jam player member

    Joined:
    May 17, 2017
    Posts:
    75
    into an event .. into the script command ... if you could state which error that would help.
     
  5. Totokyl

    Totokyl Thread Author TotoJesus member

    Joined:
    Jul 15, 2017
    Posts:
    6
    Ok, it works when I just put the 4 in there, but when I entered the 5 it gave me an error. I think it may be because I run out of lines to put the 'end' in there.
     
  6. leilou

    leilou game jam player member

    Joined:
    May 17, 2017
    Posts:
    75
    yap that should be the error ... the end is important

    I'm working on a random pokémon script right now ... gonna post it as public ressource during the day I think. Maybe that will help you.
     
    Totokyl likes this.
  7. Marin

    Marin ( ͡° ͜ʖ ͡°) member

    Joined:
    Apr 13, 2017
    Posts:
    89
    If you want to make it shorter, give this a try:
    Code:
    choices = [:BULBASAUR,:CHIKORITA,:TREECKO,:TURTWIG,:SNIVY]
    pbAddPokemon(choices[rand(choices.size)],5)
    
    Does the same as Sparta's piece, but it's just a bit smaller. To add a Pokémon, just add it in the list above and it'll pick one of them.
     
    Sparta and Hematite like this.
  8. Totokyl

    Totokyl Thread Author TotoJesus member

    Joined:
    Jul 15, 2017
    Posts:
    6
    I got this error when trying to open the event...
    Exception: RuntimeError
    Message: Script error within event 10, map 2 (Lappet Town):
    Exception: SyntaxError
    Message: (eval):3:in `pbExecuteScript'compile error
    (eval):3: syntax error
    WIG,:SNIVY,:CHESPIN]
    ^
    (eval):3: syntax error
    WIG,:SNIVY,:CHESPIN]
    ^
    ***Line '(choices.size)],5)' shouldn't begin with '('. Try
    putting the '(' at the end of the previous line instead,
    or using 'extendtext.exe'.
    ***Full script:
    choices =
    [:BULBASAUR,:CHIKORITA,:TREECKO,:TURT
    WIG,:SNIVY,:CHESPIN]
    pbAddPokemon(choices[rand
    (choices.size)],5)

    Interpreter:276:in `pbExecuteScript'
    Interpreter:1606:in `command_355'
    Interpreter:494:in `execute_command'
    Interpreter:193:in `update'
    Interpreter:106:in `loop'
    Interpreter:198:in `update'
    Scene_Map:103:in `follow_update'
    Scene_Map:101:in `loop'
    Scene_Map:114:in `follow_update'
    Follow Pokemon:1551:in `update'
     
  9. Sparta

    Sparta Someone who does something. member

    Joined:
    Mar 28, 2017
    Posts:
    142
    That's... a whole lot better than what I had. You is really smartz.

    I think you didn't run Extendtext before adding those lines of code. When it comes to code, that does make a difference.

    This is what it looks like when you just put it in without Extendtext.

    [​IMG]

    See how it screws up the lines of code across five rows? That's what the issue is. However, when you run Extendtext and add the lines of code, this is what it should look like:

    [​IMG]

    It keeps it in the nice two rows as it should be. And that does work correctly. So what you need to do is run Extendtext and then paste the code in. Make sure it looks like the lower image.
     
    Marin likes this.
  10. leilou

    leilou game jam player member

    Joined:
    May 17, 2017
    Posts:
    75
    the problem is that you mustn't have a Bracket at the start of the line ... so just put it back to the line above with a newline ... having the array in multiple lines shouldn't be a problem
     
    Marin likes this.
  11. Totokyl

    Totokyl Thread Author TotoJesus member

    Joined:
    Jul 15, 2017
    Posts:
    6
    How do you extendtext?
     
  12. Sparta

    Sparta Someone who does something. member

    Joined:
    Mar 28, 2017
    Posts:
    142
    The Extendtext program is found in the game's main folder - the same place as the Audio, Data, Graphics, and PBS folders. Just double click it when your project is open in RMXP. It'll look like nothing has happened for a little bit, but when you go back to your project to add text the entry boxes should be bigger.
     
    Totokyl and Tomix9tomix like this.
  13. Totokyl

    Totokyl Thread Author TotoJesus member

    Joined:
    Jul 15, 2017
    Posts:
    6
    Thanks to everyone for all the help on this, it works like a charm.