Inventory System For RPG

Sep 19, 2011 at 4:19pm
Hello,

Can someone please give me a code that acts like an inventory system for a text-based RPG. I need it to store weapons in my game. Any help would be greatly appreciated. Thanks.

- Code Assassin
Sep 19, 2011 at 5:14pm
That's as if I told you "draw me a picture please". I'd have to ask what the inventory system would behave like, how items are stored, overall how you're going to use it.

And writing an inventory system really isn't the hardest part when writing a text rpg, what are you going to do with the other parts? Are you going to ask others to write them for you too?
Sep 19, 2011 at 5:26pm
try this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
class inventory {

public:
   unsigned int m_count;
   std::vector m_items[CONST_MAX_SIZE];

private:
   bool AddItem( Item* pItem );
   bool RemoveItem( Item* pItem);
   bool ReplaceItem( Item* pItem);
   bool GetItem( unsigned int index);
   unsigned int GetNumberOfItem( );
}
Last edited on Sep 19, 2011 at 5:27pm
Sep 19, 2011 at 5:35pm
You're right my question does sound a bit suspicious.

I've actually written a bunch of code by myself for my RPG. I'm a beginner anyway (12 yrs old). I just needed someone to provide me with an example is all. Not write the whole thing for me... Thanks for your comment anyway.
Sep 19, 2011 at 5:52pm
Thanks, Ceruleus

Topic archived. No new replies allowed.