Hello,
I am currently developing an item system that should work similarly to a game like Diablo.
The last few days I have done some research on how to structure such a system, but I’m still a bit unsure. So to make sure my planned approach is solid I’d like to present it here and get some feedback.
I have not looked much into data assets since for now I would like to avoid using C++, but if they would be the best way to go, I would absolutely look into them.
This is the current plan:
-
a separate object for every item type (weapon, armor, consumable, etc.) that holds the following information:
- a data table row handle to get the (default) item values from a data table
- a struct that holds all the data for this specific item type; this is needed in addition to the row handle, because items don’t always use the static values from the data table, e.g. when a weapon gets created some values (e.g. damage) might be randomized and the actual values then get saved in the struct
-
a single base item struct that holds data that all items have in common (regardless of type), e.g. inventory icon, name, description, static mesh, etc.
-
a separate struct for every item type that holds:
- the base item struct
- all variables that are needed for this specific item type
-
a single item actor for all items so items can be seen/picked up in the actual game world (and not just in the inventory) that holds the following information:
- an item object
- static mesh
-
a single item manager object that handles functionality for all items (e.g. what should happen when the player uses a consumable)
Some things I’m still not sure on how to handle:
-
Let’s say a certain weapon (e.g. shotgun x) should get a damage value in the range of 10 to 15 on creation. Where should that damage range (DamageMin: 10, DamageMax: 15) be stored? In the same weapon item struct that holds the actual values? But that would mean that each actual created weapon item would hold a lot of variables that are ultimately unnecessary, since these values are only ever needed when the item is created. So ideally these value ranges for randomizing should be stored separately, no? How to handle this properly?
-
This system would use nested structs. Like described above each item type struct would hold the base item struct as a member. In my readings on forums/reddit some people mentioned problems with nested structs and that you should therefore try to avoid them. E.g. the second post from user Memetron69000 here: https://www.reddit.com/r/unrealengine/comments/160mjkx/how_reliable_and_scalable_are_the_data_tables/
Any thoughts on that? If you were to avoid nested structs, you would have to store all the variables for the base item struct in each item type struct, which seems kind of annoying and unflexible.
I’m grateful for any inputs.
Thanks!
Best regards,
David