Originally posted by KneeGrow
But with that previous post, what woudl the struct look like for a potion for example? What would you do about the maxdamage and mindamage then?
The original code posted was by me, and at the time I was basing the struct off of a weapon crafting rpg test. IN the middle of making the example struct to offer as help I added a feature to maek it more robust(I added the ITEMTYPE to the struct) but I forgot change the variable names to be move vague. THis would be a better example:
Code:
typedef enum ITEM_TYPE { IT_WEAPON, IT_POTION, IT_ARMOR, IT_WHATEVER };
struct ITEM {
int min; // minimum value - use is determined by item type. Weapons would equate this to damge
// potions would equate this to healing power
// armor might equate these to armorclass, weight or damge deflecting values
int max;// maximum value - same as above
int costbase;// cost to purchase and sell to be used in formula
int craftxp; // xp you gain from crafting object - potions would call this alchemey
char [25] name; // readable name of the object
int id; // numerical value of item for quick comparisons
ITEM_TYPE type; // enumerated type of item
}
ITEM gameItems[230];
// gameItems would be the games list of all the items in the game.
// else where in your player/character object
ITEM inventory[230][100];
// this is an array of an array. This limits the player to having 100 of every item.
Of course this is a pretty simple item object. A real games item struct would probably be much bigger with a ton more variables that would or wouldnt be used in special item cases. Its up to you to come up with a suitable item object.
Good luck.