Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualVladR

Posted 22 April 2013 - 12:08 PM

Basically I just need a way to describe an item. Give it a name, what type of clothing it is(head piece, gloves, etc.), and what stat changes it provides. Then in the game be able to grab the information and use it to alter the player's stats. 

 

Just use regular structures and enums.

Have one enum for type of the item : enum EObjectType {None=0, Weapon, Armour, Potion }

And have one struct that will keep all the relevant info about the item (whether it is a weapon, armour or potion):

struct SObject

{

  int ID; // global unique ID for the object - autoincrementing it, when filling up the internal DB is enough

  EObjectType ObjectType;

  .....

  int AddToStrength;

  int AddToDexterity;

  int AddToAccuracy;

  ...

  int RequiredStrength;

  int RequiredDexterity;

  int RequiredAccuracy;

}

 

Then, when using the item from the inventory, you just add those AddToStrength/Dexterity/Accuracy values to your stats values and you are done.

 

 

Personally, I am using text files for the database of the game objects. I wrote a very simple parser in an afternoon and never had to touch it since, so I guess it was a reasonable effort. This way, I can keep all my weapons, armours, potions in separate *.TXT files that are very easy to edit in Notepad.

 

When loading all items from the file, I just put them to a std::vector <SObject> Weapons, std::vector<SObject>Armour, std::vector<SObject> Potions. This way they are easy to work with (iterate, search, add/remove).

 

 

There is one more important advantage for having the "database" of items in TXT files - when you are testing, you will want to have multiple sets of these files so that you can test the different gameplay due to different objects/stats.

 

It will prove invaluable, when all the testers need to do, is just to replace the TXT files with a different set of TXT files. Even if that tester is just you.


#1VladR

Posted 22 April 2013 - 11:54 AM

Basically I just need a way to describe an item. Give it a name, what type of clothing it is(head piece, gloves, etc.), and what stat changes it provides. Then in the game be able to grab the information and use it to alter the player's stats. 

 

Just use regular structures and enums.

Have one enum for type of the item : enum EObjectType {None=0, Weapon, Armour, Potion }

And have one struct that will keep all the relevant info about the item (whether it is a weapon, armour or potion):

struct SObject

{

  int ID; // global unique ID for the object - autoincrementing it, when filling up the internal DB is enough

  EObjectType ObjectType;

  .....

  int AddToStrength;

  int AddToDexterity;

  int AddToAccuracy;

  ...

}

 

Then, when using the item from the inventory, you just add those AddToStrength/Dexterity/Accuracy values to your stats values and you are done.

 

 

Personally, I am using text files for the database of the game objects. I wrote a very simple parser in an afternoon and never had to touch it since, so I guess it was a reasonable effort. This way, I can keep all my weapons, armours, potions in separate *.TXT files that are very easy to edit in Notepad.

 

 

There is one more important advantage for having the "database" of items in TXT files - when you are testing, you will want to have multiple sets of these files so that you can test the different gameplay due to different objects/stats.

 

It will prove invaluable, when all the testers need to do, is just to replace the TXT files with a different set of TXT files. Even if that tester is just you.


PARTNERS