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 November 8th, 2012 (5:13 AM).
thor348's Avatar
thor348 thor348 is offline
That's Oak to You
     
    Join Date: Nov 2012
    Location: Arizona
    Gender: Male
    Nature: Calm
    Posts: 136
    I've been coding with C++ for years but can't seem to figure this out cause Ruby is different. My question is, how would I make professor Oaks Assistant check how many pokemon you've caught so he can give you an egg? or HM?
    Reply With Quote

    Relevant Advertising!

      #2    
    Old November 8th, 2012 (9:26 AM).
    Umbra's Avatar
    Umbra Umbra is offline
    • Platinum Tier
     
    Join Date: Aug 2009
    Location: Nearby my feet.
    Age: 20
    Gender: Female
    Nature: Calm
    Posts: 1,745
    Not really teh best then, usually in c++ when I handle arrays I do something like this:

    Code:
    bool seen[649];
    int seen_amt=-1; // This could be 0 depending on how you build up you program.
    now you can do the same for caught, and every time the play catches a pokemon just add 1 to caught_amt. OR you could use the longer (in terms of processing) way:

    Code:
    int pokemon_caught()
      int i, amt=0;
      for (i=0; i<649; i++){
        if (caught[i] == true){
          amt++;
        }
      }
      return amt;
    }
    Well anyways, depending on what your situation is, the one is better than the other.

    NOTE: the 649 is just what I used because of regions 1-5 have 649 in total, you may obviously change this if you want to.
    Reply With Quote
      #3    
    Old November 8th, 2012 (10:01 AM). Edited November 8th, 2012 by DaSpirit.
    DaSpirit's Avatar
    DaSpirit DaSpirit is offline
    Mad Programmer
       
      Join Date: Jul 2007
      Location: New York City
      Gender: Male
      Nature: Quiet
      Posts: 240
      Quote:
      Originally Posted by hansiec View Post
      Not really the best then, usually in c++ when I handle arrays I do something like this:

      Code:
      bool seen[649];
      int seen_amt=-1; // This could be 0 depending on how you build up you program.
      Not the best C++.

      Using booleans are a bad choice for something like this. Because you're using many booleans at once, it is better to use a bitset. You can just use 64bit variables, and use bitwise operations to set whether a Pokemon has been caught or not. Then, instead of looping through your variables, you can simply test whether they have reached the maximum amount (all bits are equal to 1) with a simple equal sign. Because you're using 64bits and you want to test for 649 Pokemon, you need 11 64bit variables.

      It's a lot faster and uses less memory. 11 64 bit variables is equal to 88 bytes, compared to 649 bytes if you use a bool. I wouldn't know the implementation in Ruby, but that was sort of a pseudo-code for you.

      Check out the Wikia, it shows how you can mark a Pokemon as seen in Essentials: http://pokemonessentials.wikia.com/wiki/Pok%C3%A9dex
      Check the Pokedex script, as it lists how many Pokemon have been seen. Just copy that script.
      __________________
      Yes.
      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 6:23 AM.