Notices
For all updates, view the main page.

 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.

#1
November 8th, 2012 (5:13 AM).
 thor348 That's Oak to You Join Date: Nov 2012 Location: Albion Gender: Male Nature: Calm Posts: 135
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?

#2
November 8th, 2012 (9:26 AM).
 Umbra Platinum Tier Join Date: Aug 2009 Location: Nearby my feet. Age: 19 Gender: Female Nature: Calm Posts: 1,742
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.
#3
November 8th, 2012 (10:01 AM). Edited November 8th, 2012 by DaSpirit.
 DaSpirit Mad Programmer Join Date: Jul 2007 Location: New York City Gender: Male Nature: Quiet Posts: 240
Quote:
 Originally Posted by hansiec 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.