🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

RPG item system: storing definitions

Started by
0 comments, last by Ravyne 8 years, 2 months ago

In my first project, I designed an xml based system to keep my item definitions. It sort of works, but it takes some work to create new items, because the process is manual. Also requires to load all item prefabs from Resources folder, on runtime. Advantages: it is kinda flexible, not all register must have the same attributes.

For my second project, I decided to take a more "proffesional" aproach, and choose to use ScriptableObject to store the information. Soon I realized that having several different kind of items (weapons, armor, implants), the definition would be a hughe data structure with lots of info, some of them irrelevant for some items (an armor doesnt does damage, or has range, or requires ammunition). The other choice was to have separate definition classes for each item type, and one database for each type: a list of weapons, a list of armor, etc.

My solution for this was to use a property system, which I already tested in my previous project: each item can have a list of properties, like damage, protection, bonus, a subtype like damage type, protection type, affected skill, and a value. I would like to hear some suggestions about how to improve this idea, or if there is any better solution.

Advertisement
It somewhat depends on how homogenous the set of properties is among objects of a certain category (where category means, say, shields/chestplates/blades) -- if the properties are homogenous then each category maps well to a database table or, more simply, a spreadsheet page.

If individual objects are non-homogenous but the range of options is well-defined, then something like XML can be a good fit because it allows variance within a well-structured and verifiable format.

If individual objects are non-homogenous and the range of options is more ad-hoc (in the sense that objects might have properties that are unique to itself), then something like JSON or YAML can be a good fit; these formats are semi-structured -- that is, the grammer and parsing rules are well-defined, but there's no formal data schema like XML. For good and for bad, there's nothing stopping you from putting any data you want anywhere, so long as your program's parsing logic can cope.

throw table_exception("(? ???)? ? ???");

This topic is closed to new replies.

Advertisement