How to approach storing a big list of stats for weapons?

Posted By: jumpman

How to approach storing a big list of stats for weapons? - 10/13/17 19:09

Hello,

How would you approach making a big data file that would store a big group of weapons, and stats relating to each weapon?

For example, like in an excel sheet, you would have each column be a single weapon, and the first row would be the model file, the second row would be the durability, the 3rd row would be the piercing damage, swing speed, etc etc.

How would you make that for your game, as well as be able to read it? I supposed I could use multiple arrays, but that isnt very intuitive to look at while coding.
Posted By: Superku

Re: How to approach storing a big list of stats for weapons? - 10/13/17 19:12

Create your own struct!
http://www.conitec.net/beta/structs.htm

Then save it either via game_save or with your own save function.
Posted By: Reconnoiter

Re: How to approach storing a big list of stats for weapons? - 10/13/17 21:05

Hi,

What you can do is create a struct with all the data of the item type (including the item name as string, bmap, sounds etc).
Now for every item type (e.g. Club, Bow) you can create a struct which holds the data for the item type.

MY_ITEM_STRUCT data_club;

And than set all the values for it in some startup function.

Code:
void struct_startup() {
 data_club.name = str_create("Club");
data_club.attack = 6;
...
}



Now you just have to store somewhere what type of item(s) each player/entity has and add that to player/entity the stats. E.g. in an other struct or in the entity skills or such.
There is alot of possibilities with structs and I recommend also read the pieces about struct array which are also very usefull (e.g. to store data for each seperate item or e.g. for each player).
© 2024 lite-C Forums