The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Game Development
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Game Development Your number one stop for anything related to creating games (except ROM hacks). You can even make your own!


Reply
Click here to go to the first staff post in this thread.  
Thread Tools
  #1    
Old September 6th, 2013, 05:38 PM
Darkroman
 
Join Date: Oct 2011
Gender: Male
Nature: Adamant
I asked a question regarding tips on a pokemon engine about a year ago, and I've taken a pretty long vacation from learning c++ programming. I've since reread the topic and can now understand every suggestion given to me, but... Since I'm just getting back into it, and consider myself a n00b programmer, I was hoping you guys could help me clear up a few concepts. I've barely started coding, rather just practicing each object oriented method I can think of that will go into the application before I actually start the programming for the real thing.

1. Is there a way where one class can just read another class's object without invoking the outside class's constructor?

Here's some of the code so far to show what I've done.

Spoiler:
Code:
typedef shared_ptr<Pokemon> Pokemon_ptr; // Define type of smart pointer to class

class Player
{
public:
    vector<Pokemon_ptr> Party; // Make a vector of smart pointers that point to class objects
    Player();
    Player(const Player& p);
    void AddPokemon();
};

// ............

Player::Player()
{
    Party.reserve(6);
    cout << "Welcome!" << endl << endl;
} // I'm pretty sure this isn't exactly the right use of a constructor, but this is just for testing purposes.

void Player::AddPokemon()
{
    Party.push_back(Pokemon_ptr (new Pokemon("Bulbasaur", 45, 49, 49, 45, 65, 65))); // vector.push_back(smart_pointer_type (new object(constructor init args)))
    cout << Party[0]->m_name << " was added!" << endl << endl;
}

// .............

class Battle
{
public:
    int battle_hp;
    int battle_atk;
    int battle_def;
    int battle_specatk;
    int battle_specdef;
    int battle_speed;

    Player p;

    Battle(const Player &p);

};

Battle::Battle(const Player &p)
{
    cout << "Calling for base HP of pokemon in the Player class - " << p.Party[0]->m_base_hp << endl;
    p.Party[0]->m_base_hp = 51;

    cout << "Calling for base HP of pokemon in the Player class - " << p.Party[0]->m_base_hp << endl;
}

//main
int main()
{
    Player aPlayer;
    aPlayer.AddPokemon();

    Battle Startbattle(aPlayer);

    cout << "Base HP of pokemon in the Player class in main after battle constructor - " << aPlayer.Party[0]->m_base_hp;

    return 0;
}

// I know it isn't great, and this won't be part of the final code. I plan on separating classes into separate files. Like I said, it's practice. If there's anything you can point out of what a better method would be, please say so.


I'm pretty sure there's some ugliness in that code, but yeah.

2. I remember a while ago that someone said making a subclass for each pokemon is not a great idea. So instead, each pokemon will be an instance of the pokemon class (and makes more sense now that I think about it). The pokemon class constructor will initialize the base stats and name of the pokemon. ( Pokemon Bulbasaur("Bulbasaur", 45, 49, 49, 45, 65, 65) ). Is this the correct way of going about it?
Reply With Quote
  #2    
Old September 7th, 2013, 05:38 AM
th3shark's Avatar
th3shark
Develops in AS3/C++
 
Join Date: Jul 2013
Location: Connecticut
Gender: Male
Nature: Calm
Semi-experienced C++ coder here! Nice to see another person up to the task of creating a battle engine from scratch.

Quote:
1. Is there a way where one class can just read another class's object without invoking the outside class's constructor?
Not quite sure what you're asking here. Do you want code in the constructor to be skipped when the object is created? A constructor has to be called for a class instance to be created. I guess you can have two different constructors with different code in each.

Quote:
2. I remember a while ago that someone said making a subclass for each pokemon is not a great idea. So instead, each pokemon will be an instance of the pokemon class (and makes more sense now that I think about it). The pokemon class constructor will initialize the base stats and name of the pokemon. ( Pokemon Bulbasaur("Bulbasaur", 45, 49, 49, 45, 65, 65) ). Is this the correct way of going about it?
No. A pokemon is much more than just its name and base stats. Here's data I have stored which is constant for a species of pokemon (written in AS3, but same concept):
Spoiler:
Code:
		//constant for a species of pokemon
		protected var _sprite:PokemonSprite;
		protected var _profile:BitmapData;
		protected var _name:String = "";
		protected var _id:int = 0;
		protected var _type1:int = Types.NORMAL;
		protected var _type2:int = Types.NONE;
		protected var _percentMale:Number = .5;
		protected var _hasGender:Boolean = true;
		protected var _innateAbility:int = Ability.NONE;
		protected var _levitates:Boolean = false; //if doesn't touch the ground (but grounded attacks will still hit)
		/* multiplier for how fast experience is earned.  Dependent on the type of pokemon
		 * (3 main values are 5/4 (fast), 1 (medium), and 4/5 (slow)) */
		protected var _levelUpSpeed:Number = 1;
		protected var _baseHP:int = 75;
		protected var _baseAtk:int = 75;
		protected var _baseDef:int = 75;
		protected var _baseSpAtk:int = 75;
		protected var _baseSpDef:int = 75;
		protected var _baseSpeed:int = 75;
		/* _naturalMoves[i] is the moveID or Vector of moveIDs of the move(s) the pokemon can learn upon reaching level i 
		 * _naturalMoves[0] are all the moves the pokemon starts out with */
		protected var _naturalMoves:Object = {};
		/* List of moves the pokemon can learn by means other than leveling up */
		protected var _learnableMoves:Vector.<int> = new Vector.<int>();
		/* List of abilities a pokemon can learn */
		protected var _learnableAbilities:Vector.<int> = new Vector.<int>();
		/* A function returning the id of the pokemon this should evolve into.
		 * Returns NONE unless the pokemon is above a certain level, for instance */
		public function shouldEvolveInto(moveSituation:MoveSituation=null):int {
			return Pokes.NONE;
		}

You are not going to want to initialize all that in the pokemon's constructor. If you don't want each pokemon to be a separate class, then each pokemon should be a separate file with data on it that is parsed during the game.

And some advantages of each pokemon being a separate class:
  • No need to write a file parser, and no need to have separate files for each pokemon.
  • You can take advantage of constants and enumerations when using classes.
  • Classes can have functions that can be overridden. For example, I found it easier to represent how a pokemon evolves with a function instead of a variable.

Classes may not be the most conventional way to handle pokemon, but that's how I do it, and it has caused me no problems so far. Feel free to ask me any questions!
__________________
Reply With Quote
  #3    
Old September 7th, 2013, 06:20 AM
zingzags's Avatar
zingzags
Creator or Pokemon Serenity
 
Join Date: Jan 2009
Location: Boston
Age: 20
Nature: Adamant
You are able to pass through an object in c++. For example the same way you would use a regular variable, but what do you mean was the object already pre-made (with the constructors being used, or not). There is something called method/function overloading, which lets you create the same method/function/constructor with the same name, but different parameters.
__________________
Pokemon Serenity is my fangame name.
name decided 12/15/09
Currently helping:
Pokemon ebony
and
Xenotime:
Reply With Quote
  #4    
Old September 9th, 2013, 08:01 AM
Darkroman
 
Join Date: Oct 2011
Gender: Male
Nature: Adamant
Thanks for the replies, guys. Well, like I said before my code that I posted in the spoiler is just practice stuff.

Zingzags: I didn't know you could overload a class' constructor.

th3shark: I know that Pokemon have a LOT more data members than just name and base stats. This is what I can think of off the time of my head.

Name
Nickname
Level
Base Stats: HP / Attack / Defense / Speed / Special Attack / Special Defense
Calculated Stats: Current HP / Max HP / Attack / Defense / Speed / Special Attack / Special Defense
Nature
EVs and IVs
Abilities
Item slot
Attack List
Status inflictions: 1st being the main ones.. poison, paralysis, freeze, burn, sleep... confusion also, but since confusion can coincide with other inflictions I feel it should have its own dedicated member (right word?)
Sprite pointer, but I'm not doing graphics so I don't plan on including that.
Pokedex entry: Species, number (national), height, weight, and description.

My battle class will be the one to keep track of everything in a battle (well duh). It's gonna have its own members for pokemon stats that will be modified based on whatever stat modifying moves there are. I'm thinking the flow for it will be...

Create battle object
Copy pokemon objects into battle class from player, and NPC (or player 2...) party slots into battle pokemon party vector.
Send pokemon in first party slot of players out to battle, check abilities
Wait for move
Check move priority first, if same priority, pokemon with higher speed goes first
Do battle move stuff... (attack, or set weather condition if Pokemon changes weather, or if player switches out pokemon, move chosen pokemon to first party slot)
Check held item ability
If Pokemon's HP <= 0, it has fainted. If HP is below 0, set HP to 0.
Wait for player to choose another Pokemon to send out, once pokemon is chosen, move chosen to first party slot.

...Something like that. I'm gonna need to research a lot more on move priorities, abilities and secondary effects (such as absorb and the likes), but I think I pretty much got the gist of it.
Reply With Quote
  #5    
Old September 9th, 2013, 08:16 AM
th3shark's Avatar
th3shark
Develops in AS3/C++
 
Join Date: Jul 2013
Location: Connecticut
Gender: Male
Nature: Calm
Yes, but keep in mind some of these members (such as name, base stats) are unique to a specific pokemon species.

Also, level and calculated stats are not stored. These are calculated from exp, base stats, EVs, IVs, nature, etc.

Quote:
Sprite pointer, but I'm not doing graphics so I don't plan on including that.
You probably should lol

Your plan for the battle flow looks fine to me. Good luck!
__________________
Reply With Quote
  #6    
Old September 9th, 2013, 09:00 AM
Darkroman
 
Join Date: Oct 2011
Gender: Male
Nature: Adamant
Quote:
Originally Posted by th3shark View Post
Yes, but keep in mind some of these members (such as name, base stats) are unique to a specific pokemon species.

Also, level and calculated stats are not stored. These are calculated from exp, base stats, EVs, IVs, nature, etc.
Well, since my program will just be mainly a battle engine, I don't know if I'll even include methods for leveling. I figure I'll just let the user choose a Pokemon, and choose its level, nickname, and EVs. From there, the class will choose IVs at random, and calculate the final stats. Why can't I store calculated stats within the class object and have a method to change them later?

Quote:
Originally Posted by th3shark View Post
You probably should lol
Honestly this battle engine wll sort of be my own final project for basic c++ programming. If I'm successful in it, and it all works out.. then I'll move to GUI programming, and programming stuff like graphics and sound (with SDL). If it all works out, I could release it to the public, make it open sourced, and people could modify it for graphics on their own. I do plan on making my battle engine somewhat modular, easily readable, and well documented in any case.

Quote:
Originally Posted by th3shark View Post
Your plan for the battle flow looks fine to me. Good luck!
Cool, thanks!

Edit: BTW, I know almost nothing when it comes to programming for graphics. I've taken a look at it before, (mainly Direct3D) and quite frankly, it's a little intimidating to me, lol.

Last edited by Darkroman; September 9th, 2013 at 09:06 AM.
Reply With Quote
  #7    
Old September 9th, 2013, 12:02 PM
th3shark's Avatar
th3shark
Develops in AS3/C++
 
Join Date: Jul 2013
Location: Connecticut
Gender: Male
Nature: Calm
Quote:
Why can't I store calculated stats within the class object and have a method to change them later?
You can, but it would be a lot easier to have one getter function calculate stats from EVs etc. than to change the the calculated stats every time a variable changes.

Quote:
this battle engine wll sort of be my own final project for basic c++ programming
Out of curiosity, are you learning C++ on your own or taking a class?

Quote:
BTW, I know almost nothing when it comes to programming for graphics. I've taken a look at it before, (mainly Direct3D) and quite frankly, it's a little intimidating to me, lol.
I've used SFML with C++ for 2d games before. It's a relatively simple library to use. I'd recommend trying it out if you haven't started learning something else already.
__________________
Reply With Quote
  #8    
Old September 9th, 2013, 01:04 PM
Darkroman
 
Join Date: Oct 2011
Gender: Male
Nature: Adamant
Quote:
Originally Posted by th3shark View Post
You can, but it would be a lot easier to have one getter function calculate stats from EVs etc. than to change the the calculated stats every time a variable changes.
That's what I was trying to say . A getter function being called based on a condition of some sort: if (level up = true) { CalculateStats(); }<-- something along those lines

Quote:
Originally Posted by th3shark View Post
Out of curiosity, are you learning C++ on your own or taking a class?
Self-taught.

Quote:
Originally Posted by th3shark View Post
I've used SFML with C++ for 2d games before. It's a relatively simple library to use. I'd recommend trying it out if you haven't started learning something else already.
I'll be sure to check it out, thanks.
Reply With Quote
  #9    
Old September 9th, 2013, 01:15 PM
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
Quote:
Originally Posted by Darkroman View Post
That's what I was trying to say . A getter function being called based on a condition of some sort: if (level up = true) { CalculateStats(); }<-- something along those lines
That's sort of how Essentials works. The stats are stored as separate variables, and upon changing something that would affect them (e.g. levelling up, changing form, using certain items on the Pokémon) the stats are recalculated and resaved.

I believe the latest games have the stats recalculated immediately, rather than waiting until level-up to dump any new EVs into them (as the older games did it).
__________________
Reply With Quote
  #10    
Old September 9th, 2013, 01:59 PM
Darkroman
 
Join Date: Oct 2011
Gender: Male
Nature: Adamant
Quote:
Originally Posted by Maruno View Post
That's sort of how Essentials works. The stats are stored as separate variables, and upon changing something that would affect them (e.g. levelling up, changing form, using certain items on the Pokémon) the stats are recalculated and resaved.

I believe the latest games have the stats recalculated immediately, rather than waiting until level-up to dump any new EVs into them (as the older games did it).
I was hoping you'd reply some time, lol. You were a big help in my previous c++ question thread.

So, instead of on some condition, it just recalculates the stats after an EV is given in new games? This is a bit off topic I know, but does it recalculate during battle after every time one Pokemon KOs the other, or after the battle is over with no level up?

Back on-topic: Is it correct form if I included a getter function be called in a class constructor?
Reply With Quote
  #11    
Old September 9th, 2013, 02:05 PM
th3shark's Avatar
th3shark
Develops in AS3/C++
 
Join Date: Jul 2013
Location: Connecticut
Gender: Male
Nature: Calm
Well to each there own for calculated stats, I suppose.

Quote:
Is it correct form if I included a getter function be called in a class constructor?
Is it okay to call a getter function from a class constructor? I don't see why not. Constructors are usually for setting and initializing data though, so why would you need to do this?
__________________
Reply With Quote
  #12    
Old September 9th, 2013, 02:13 PM
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
Quote:
Originally Posted by Darkroman View Post
I was hoping you'd reply some time, lol. You were a big help in my previous c++ question thread.

So, instead of on some condition, it just recalculates the stats after an EV is given in new games? This is a bit off topic I know, but does it recalculate during battle after every time one Pokemon KOs the other, or after the battle is over with no level up?
Essentials is a little haphazard about when it recalculates stats, because I haven't specifically looked at that. Stats are recalculated upon level-up (obviously), and if a Pokémon's form changes, or an EV-altering item is used on it, or it Transforms, or if it evolves. Currently a Pokémon will not recalculate its stats due to gaining EVs from battle, and those EVs will go unused until one of the aforementioned events.

That's just how Essentials works at the moment. It sounds nearly correct, so far as I know, except it should also recalculate upon gaining EVs from battle.

Thinking about it, if stats are now supposed to always take all EVs into account all the time, it's redundant to save the stat values separately. They can indeed be calculated when required (from the base stat/EVs/IVs/nature).
__________________
Reply With Quote
  #13    
Old September 9th, 2013, 02:36 PM
th3shark's Avatar
th3shark
Develops in AS3/C++
 
Join Date: Jul 2013
Location: Connecticut
Gender: Male
Nature: Calm
Quote:
Thinking about it, if stats are now supposed to always take all EVs into account all the time, it's redundant to save the stat values separately. They can indeed be calculated when required (from the base stat/EVs/IVs/nature).
Yeah, there's that too.

Here's a C++ equivalent to how it works in Evoas:
Code:
#include <math.h>

int getLevel(){
    double l = pow(_exp*_levelUpSpeed,1.0/3);
    if (ceil(l) - l < .0000001){ //rounding errors
        l = ceil(l);
    }
    return int(l);
}
int getAtk(){
    //original formula, replace with the official formula using EVs, IVs, etc.
    return statAtkCalculate(_baseAtk, getLevel(), _gender, _trainAtk);
}
__________________
Reply With Quote
  #14    
Old September 9th, 2013, 03:33 PM
Darkroman
 
Join Date: Oct 2011
Gender: Male
Nature: Adamant
I actually look at it a slightly different way I think. Just call the function method that calculates stats for pokemon after certain stat altering events: EV-altering items, on level up, on Pokemon KO, evolution, form changing, etc. For EV specific events, all you really need to do is call the same calculate stats method after EV altering items, and after your Pokemon KOs another one.


Code:
Player 1 and NPC sends out pokemon.

// ... battley stuff

Player 1 Pokemon KOs NPC's pokemon
If ( !Max_EV(); )
{
     Get info of opponent's pokemon EV reward
     Add opponent's pokemon EV reward to player 1's first pokemon EV values
     If other player's pokemon were brought in during battle
          Add opponent's KO'd pokemon EV reward to player's other Pokemon
}
Where Max_EV() would return a bool value '1' if your pokemon's max EVs of 510 have been reached, and 0 otherwise. Of course I didn't take into account if the other pokemon brought out during battle has max EVs, nor did I take into account individual max EV values of 255. Too much pseudocode to write here. You get my idea. I'm still a n00b programmer like I said, and I'm pretty sure there's a cleaner, more efficient way to implement this, but yeah.

I do have an STL question. Is there an STL container where you can switch element spots? Like, say switch around what [0] and [4] point to without destroying anything? the 1st element now is set to the 5th element, and 5th now set to 1st. Something like that?

Last edited by Darkroman; September 9th, 2013 at 03:52 PM.
Reply With Quote
  #15    
Old September 9th, 2013, 04:10 PM
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
Quote:
Originally Posted by Darkroman View Post
I actually look at it a slightly different way I think. Just call the function method that calculates stats for pokemon after certain stat altering events: EV-altering items, on level up, on Pokemon KO, evolution, form changing, etc. For EV specific events, all you really need to do is call the same calculate stats method after EV altering items, and after your Pokemon KOs another one.
You could do that, and that's what Essentials currently does (with one missing call). However, if there is no situation where the latest EVs are not counted, then functionally there's no difference between this and calculating the stats on the fly when needed. And at least with the on-the-fly calculations, you don't have to throw calls to the calcStats method all over the place, nor do you use an additional 6 variables to store the stat values which are redundant.
__________________
Reply With Quote
  #16    
Old September 9th, 2013, 04:14 PM
Darkroman
 
Join Date: Oct 2011
Gender: Male
Nature: Adamant
I'm not too familiar with on-the-fly calculations done in programming. My thinking whenever there was a change, you'd have to be specific on that change. What am I not understanding here?
Reply With Quote
  #17    
Old September 9th, 2013, 04:23 PM
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
What I mean is that, when asking a Pokémon object what its Attack stat is (for example), instead of returning a saved variable which is updated each time an EV changes, a value for the Attack stat is calculated there and then and returned (but isn't saved anywhere).

Even if the Attack stat doesn't change between two instances of asking the Pokémon object what it is, it'll still be calculated both times.

I don't know if the correct term is getter or accessor or whatever. I just mean that you do the calculation on the spot when you need the stat, rather than preparing the stat value in advance (i.e. each time an EV changes) and keeping it around until you need it.
__________________
Reply With Quote
  #18    
Old September 9th, 2013, 04:42 PM
th3shark's Avatar
th3shark
Develops in AS3/C++
 
Join Date: Jul 2013
Location: Connecticut
Gender: Male
Nature: Calm
Quote:
I do have an STL question. Is there an STL container where you can switch element spots? Like, say switch around what [0] and [4] point to without destroying anything? the 1st element now is set to the 5th element, and 5th now set to 1st. Something like that?
I dunno. Just do this:
Code:
Pokemon* temp = team[0];
team[0] = team[5];
team[5] = temp;
@Mods we need an Audino smiley
__________________
Reply With Quote
  #19    
Old September 9th, 2013, 05:08 PM
Darkroman
 
Join Date: Oct 2011
Gender: Male
Nature: Adamant
Quote:
Originally Posted by Maruno View Post
What I mean is that, when asking a Pokémon object what its Attack stat is (for example), instead of returning a saved variable which is updated each time an EV changes, a value for the Attack stat is calculated there and then and returned (but isn't saved anywhere).

Even if the Attack stat doesn't change between two instances of asking the Pokémon object what it is, it'll still be calculated both times.

I don't know if the correct term is getter or accessor or whatever. I just mean that you do the calculation on the spot when you need the stat, rather than preparing the stat value in advance (i.e. each time an EV changes) and keeping it around until you need it.
Ahh, well I wasn't thinking along the lines of returning the variable. I was thinking more along the lines of assignment. CalculateStats(); just reads information of your pokemon object's EVs, IVs, nature, and base stats and assigns the final value based on the stat formulas.

So, I could make all my stat variables private within the class and can only be changed by CalculateStats() since it's code within the class, and when dealing with adding or subtracting EVs, I could send a pokemon's reward EVs by const_reference through a function method defined in the class that takes the reference variables' values and adds the numbers to the object's current EVs; checking if max EVs first, of course. Since EVs are only given, and not taken in battle, you only need to add.

Now that I'm thinking about it, why not a method that does what I said above in addition to having that method call the CalculateStats() function after giving the reward EVs?
Edit: An item class can also have its own reward EV method doing what I said above, with the addition of subtracting EVs for certain berries. Warn me if I'm way off track here....... seriously. I'm just thinking up stuff of what I could do. I'm kind of just mind vomiting if you will... Seriously, stop me!! Lmao

As far as getters or setters. I found this page to be informative. http://www.zeuscmd.com/tutorials/cpl...andsetters.php So, for example, my CalculateStats() function would be a setter. Some kind of function method to read the stats, like outputting a pokemon stats, would be a getter -> GetStats()

Last edited by Darkroman; September 9th, 2013 at 05:46 PM.
Reply With Quote
  #20    
Old September 10th, 2013, 05:58 AM
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
It looks like you're still fixed on having a pokemon.attack variable, using CalculateStats() to give it a particular value, and then looking at that value when you want to know the Pokémon's attack stat. I'm saying that you don't need to do this.

pokemon.attack() is a public getter which solely contains the code: return CalculateStat(Stats::Attack). The actual value of the attack stat isn't saved anywhere in the Pokémon class, because it doesn't need to be. That's all you need. The CalculateStat(stat) method will take into account the current EVs, and returns the calculated value for the stat given as the argument. All you need to worry about is changing the Pokémon's EVs.

The main benefit is that you don't use as many variables, and you don't need to make sure you put a call to pokemon.CalculateStats() everywhere. It's all automatic.
__________________
Reply With Quote
  #21    
Old September 10th, 2013, 08:54 AM
Darkroman
 
Join Date: Oct 2011
Gender: Male
Nature: Adamant
Now I understand... I can't believe I didn't see it before. *derp*

@Mods: I think there should be a smiley that portrays how dumb one feels at a given moment.
Reply With Quote
  #22    
Old September 22nd, 2013, 01:35 PM
codemonkey85's Avatar
codemonkey85
Software Developer
 
Join Date: Jun 2008
Location: New Milford, CT
Age: 28
Gender: Male
Nature: Mild
Hey - couldn't help but notice some of the things you need to do for your project overlap with some of the things I needed to do for mine, and since they're both in C++, I thought you might want to take a look at what I have up on GitHub:

PKMDS-G5: An open source C++ library for hacking Pokémon save files

You can probably pretty easily use a portion of the pkmds-g5 class, if not also the stuff dealing with SQLite (along with Veekun's SQLite database).

Quote:
Originally Posted by th3shark View Post
I dunno. Just do this:
Code:
Pokemon* temp = team[0];
team[0] = team[5];
team[5] = temp;
What about std::swap?

Code:
void swap_pkm(pokemon_obj &a, pokemon_obj &b)
{
    std::swap(a,b);
}

...

swap_pkm(party[0],party[4]);
This is basically what I do as well.
__________________
Creator of PKMDS Code Library
Find the source on GitHub! Contributions welcome!
codemonkey85 on (also Twitter)

Last edited by codemonkey85; September 22nd, 2013 at 01:49 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
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 02:30 AM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 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 generated content remains the property of its creator.