• 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.

Problem random rival generator script

  • 13
    Posts
    13
    Years
    After seeing the tutorial Weighted Egg Generator made ​​by GReusch on Essentials Wiki, I decided to put in my game a system of random starter. This far everything is ok. The problem started after I put that even the rival receives his starter randomly according to the type supereffective on your. What can be the problem in the script put below (the numbers represent the number of the type in the file types.txt)

    def Random_Rival_Supereffective

    if $Trainer.pokemonParty[0].type1==PBTypes::NORMAL
      Rival=[1]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::FIGHTING
      Rival=[2, 14, 18]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::FLYING
      Rival=[5, 13, 15]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::POISON
      Rival=[4, 14]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::GROUND
      Rival=[11, 12, 15]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::ROCK
      Rival=[1, 4, 8, 11, 12]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::BUG
      Rival=[2, 5, 10]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::GHOST
      Rival=[7, 17]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::STEEL
      Rival=[1, 4, 10]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::FIRE
      Rival=[4, 5, 11]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::WATER
      Rival=[12, 13]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::GRASS
      Rival=[2, 3, 6, 10, 15]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::ELECTRIC
      Rival=[4]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::PSYCHIC
      Rival=[6, 7, 17]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::ICE
      Rival=[1, 5, 7, 10]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::DRAGON
      Rival=[15, 16, 18]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::DARK
      Rival=[1, 6, 18]
    elsif $Trainer.pokemonParty[0].type1==PBTypes::FAIRY
      Rival=[3, 8]
    end
      
    $game_variables[26]=Rival[rand(Rival.length)]
      
    end
     
    Question, is the egg hatched by the time the rival is getting his starter? If not, the egg wouldn't have a type and that would cause problems.
     
    Lexor, you haven't explained what your problem is. You've barely explained half of what you were trying to do.

    Do bear in mind that $Trainer.pokemonParty only looks for Pokémon. It will ignore eggs. The name's a bit of a give-away. You may want to just use $Trainer.party.
     
    Sorry I forgot to explain it. I wanted to call the function when the egg was hatched but perhaps it's better change it as you say Maruno. The real problem I have is a syntax error in the lines of the declaration of the array, but I can't find it
     
    Last edited:
    You don't need to do anything when the egg hatches. You can choose the rival's starter immediately after the player receives their egg. Eggs are identical to Pokémon, except a single value is different. This means they have a type already, so you can look at the egg's type immediately and come up with a starter for the rival based on it.

    Like I said, use $Trainer.party instead of $Trainer.pokemonParty.
     
    Thanks to you FL now it works, but when I call the function I get this error. What could be the error?

    ---------------------------
    Pokemon Essentials
    ---------------------------
    Exception: RuntimeError

    Message: Script error within event 20, map 3 (Alex's house):

    Exception: NameError

    Message: (eval):1:in `pbExecuteScript'uninitialized constant Interpreter::Random_Rival_Supereffective

    ***Full script:

    Random_Rival_Supereffective


    Interpreter:243:in `pbExecuteScript'

    Interpreter:1600:in `eval'

    Interpreter:243:in `pbExecuteScript'

    Interpreter:1600:in `command_355'

    Interpreter:494:in `execute_command'

    Interpreter:193:in `update'

    Interpreter:106:in `loop'

    Interpreter:198:in `update'

    Scene_Map:103:in `update'

    Scene_Map:101:in `loop'



    Interpreter:276:in `pbExecuteScript'

    Interpreter:1600:in `command_355'

    Interpreter:494:in `execute_command'

    Interpreter:193:in `update'

    Interpreter:106:in `loop'

    Interpreter:198:in `update'

    Scene_Map:103:in `update'

    Scene_Map:101:in `loop'

    Scene_Map:114:in `update'

    Scene_Map:68:in `main'



    This exception was logged in

    C:\Users\User\Saved Games/Pokemon Essentials/errorlog.txt.

    Press Ctrl+C to copy this message to the clipboard.
    ---------------------------
    OK
    ---------------------------
     
    Back
    Top