Sign in to follow this  
rogerdv

RPG item system: storing definitions

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this