Jump to content
  • Advertisement
Sign in to follow this  
jblevins1991

Storing Pokemon in an array?

This topic is 2508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im working on a pokemon game and so far the only thing that has stumped me is storing pokemon and storing attacks.

class pokemon
{
public:

} Bulbasaur;

above is my pokemon template class. i have more done than this but i wont post any more that what i have above for various reasons.

class player
{
public:
int playersparty[6];

};

above is the player class. i can't wrap my mind around how to store objects such as pokemon in an array. the array will represent the players pokemon party through out the game. any help would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
You mean something like

class player
{
public:
Pokemon playersparty[6];
};

?

Or do you mean something much more generic, so you can store both Pokemon and players in this array?

FYI, creating a Pokemon-style game is fine, but using trademarked and copyrighted characters and IP is not.

Share this post


Link to post
Share on other sites

You mean something like

class player
{
public:
Pokemon playersparty[6];
};

?

Or do you mean something much more generic, so you can store both Pokemon and players in this array?

FYI, creating a Pokemon-style game is fine, but using trademarked and copyrighted characters and IP is not.


Thank you for the help. I know that using trademarked IP is illegal sir. I appreciate your concern and vigilance. I am creating my own character etc.

Any clue on how to create attacks?

Share this post


Link to post
Share on other sites

Any clue on how to create attacks?


That's a pretty vague question. You can make it so a Pokemon has a takeDamage() function that tells it how much damage and what kind (i.e. fire, water, etc.), and a Pokemon can invoke takeDamage() on another Pokemon. There's a million ways to implement this though and it really depends on how you design your program.

Share this post


Link to post
Share on other sites
There are three obvious layers:

  • A fixed set of hardwired basic mechanisms: for example hit points, special states (e.g. stunning), creature experience and change (e.g. adding moves or evolving to another species). They are the foundation of everything that can happen in the game.
  • Arbitrary but fixed numbers of definitions including the not-at-all-Pokémon species, their attacks and their types. Loaded from data files, immutable (and therefore omitted from saved games), and referencing sprites and other equally read-only game assets. Every creature should have some means (a pointer?) to access the objects that represent its species and its attacks.
  • An unlimited amount of not-at-all-Pokémon individuals (wild, in the player's team, in someone else's team, etc.) These objects are created at the beginning of the game and according to other events (scheduled battles, random encounters etc.), are destroyed when the player loses track of them, are normally persisted in saved games, and have a lot of mutable fields (e.g. current and maximum hit points and skills).

    A variable named Bulbasaur is just about the most inappropriate way to make a creature species object. Do it a few hundred times, and you'll bloat your source code and increase compilation times, mix up your engine and game content without hope, and forfeit proper editing tools and game data customization.

Share this post


Link to post
Share on other sites
I cloned the Gen 4 pokemon mechanics a while ago, and they're fairly difficult to abstract and construct. There rules to the mechanics often have special cases. For instance ordering attacks and quick claw's effect. There is a wide variety of attack mechanics so designing around it proved fairly challenging.

Pokemon have individual stats, and base stats. So I had an object "PokemonSpecies" which represented for instance Bulbasaur, it contained things like Bulbasaurs base stats (45 hp, 49 atk, 49 def, 65 sp.atk, 65 sp.def, 45 speed), pokedex information, EV yeild, and sprites and such. PokemonSpecies were loaded from files much like LorenzoGatti said. So I had like "Bulbasaur.pkmn" and "Pikachu.pkmn" etc etc.

The actual "Pokemon" object held things like Level, CurrentHP, stats, EVs, etc etc. So there is a clear distinction between species and an actual Pokemon.

Handling attacks is pretty convoluted, some moves last more than one turn, moves have only one type but it is not always the same (metronome), and have a category of damage (which effects which type of def and atk effect its damage) Some moves require special effects on hit, on activation, on miss, and other various conditions. Moves make "contact". You're going to have a bunch of virtual functions which you override to accomplish special effects.

So, not to be condescending, if you're having trouble gasping how to do things I'd recommend sticking to Gen I mechanics. Which has far fewer things to worry about. Or invent your own simpler mechanics. I developed the whole thing with info mostly from bulbapedia. It has detailed explanations of the mechanics.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!