Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.

Reply
 
Thread Tools
  #1    
Old December 14th, 2013 (12:27 PM).
Lexor's Avatar
Lexor Lexor is offline
     
    Join Date: Jun 2012
    Location: Italy
    Gender: Male
    Posts: 8
    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
    Reply With Quote

    Relevant Advertising!

      #2    
    Old December 14th, 2013 (2:06 PM).
    G-Master's Avatar
    G-Master G-Master is offline
    Lead of Pokémon Roll
       
      Join Date: Dec 2013
      Location: AZ
      Gender: Male
      Nature: Docile
      Posts: 56
      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.
      Reply With Quote
        #3    
      Old December 14th, 2013 (3:12 PM).
      Maruno's Avatar
      Maruno Maruno is offline
      Lead Dev of Pokémon Essentials
         
        Join Date: Jan 2008
        Location: England
        Posts: 5,171
        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.
        __________________
        Go to the Pokémon Essentials Wiki

        | Downloads | Tutorials | Fangames |
        | All Animations Project |

        Follow me on Twitter: @maruno42


        Reply With Quote
          #4    
        Old December 15th, 2013 (1:07 AM). Edited December 15th, 2013 by Lexor.
        Lexor's Avatar
        Lexor Lexor is offline
           
          Join Date: Jun 2012
          Location: Italy
          Gender: Male
          Posts: 8
          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
          Reply With Quote
            #5    
          Old December 22nd, 2013 (3:31 AM).
          FL's Avatar
          FL FL is offline
          Pokémon Island Creator
             
            Join Date: Sep 2010
            Gender: Male
            Posts: 1,693
            In the ruby, the standard are to declare variables with lowercase (except constants). so declarate 'Rival' as 'rival'. If you initialize a variable in a if/elsif/else this variable only remains until the conditional is finished. So put 'rival=nil' before the 'if'.
            __________________
            Reply With Quote
              #6    
            Old December 22nd, 2013 (4:35 AM).
            Maruno's Avatar
            Maruno Maruno is offline
            Lead Dev of Pokémon Essentials
               
              Join Date: Jan 2008
              Location: England
              Posts: 5,171
              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.
              __________________
              Go to the Pokémon Essentials Wiki

              | Downloads | Tutorials | Fangames |
              | All Animations Project |

              Follow me on Twitter: @maruno42


              Reply With Quote
                #7    
              Old December 22nd, 2013 (3:23 PM).
              Lexor's Avatar
              Lexor Lexor is offline
                 
                Join Date: Jun 2012
                Location: Italy
                Gender: Male
                Posts: 8
                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)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
                ---------------------------
                Reply With Quote
                  #8    
                Old December 29th, 2013 (3:30 AM).
                FL's Avatar
                FL FL is offline
                Pokémon Island Creator
                   
                  Join Date: Sep 2010
                  Gender: Male
                  Posts: 1,693
                  In the ruby, the standard are to declare methods with lowercase. Try to change all 'Random_Rival_Supereffective' to 'random_Rival_Supereffective'.
                  __________________
                  Reply With Quote
                    #9    
                  Old December 29th, 2013 (2:29 PM).
                  Lexor's Avatar
                  Lexor Lexor is offline
                     
                    Join Date: Jun 2012
                    Location: Italy
                    Gender: Male
                    Posts: 8
                    Finally works. Thank you FL. To think that was a mistake so trivial ...
                    Reply With Quote
                    Reply
                    Quick Reply

                    Sponsored Links
                    Thread Tools

                    Posting Rules
                    You may not post new threads
                    You may not post replies
                    You may not post attachments
                    You may not edit your posts

                    BB code is On
                    Smilies are On
                    [IMG] code is On
                    HTML code is Off

                    Forum Jump


                    All times are GMT -8. The time now is 11:50 AM.