The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Pokémon Essentials
Register New Account FAQ/Rules Chat Blogs Mark Forums Read

Notices

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  
Unread November 8th, 2012, 01:13 PM
thor348's Avatar
thor348
That's Oak to You
 
Join Date: Nov 2012
Location: Arizona
Gender: Male
Nature: Calm
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
  #2  
Unread November 8th, 2012, 05:26 PM
hansiec's Avatar
hansiec
Scripting Genius
 
Join Date: Aug 2009
Location: Somewhere on earth where else?
Age: 16
Gender: Male
Nature: Adamant
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.
__________________
My Game:


Reply With Quote
  #3  
Unread November 8th, 2012, 06:01 PM
DaSpirit's Avatar
DaSpirit
Mad Programmer
 
Join Date: Jul 2007
Location: New York City
Gender: Male
Nature: Quiet
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.
__________________
My Links:

Last edited by DaSpirit; November 8th, 2012 at 06:08 PM.
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 UTC. The time now is 06:57 PM.


Style by Perdition Haze, artwork by Sa-Dui.
Like our Facebook Page Follow us on TwitterMessage Board Statistics | © 2002 - 2013 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to Pokémon USA, Inc. and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company, Pokémon USA, Inc., The Pokémon Company International, or Wizards of the Coast. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2013 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User posts belong to the user.