Advertisement Jump to content
Sign in to follow this  

Item modificators

This topic is 4886 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I need help to come up with a good way to handle item-properties in my VC++ rpg. An item (an armour for example) can have a list of several mods. Like it gives +10 to Hp, +1 strength, 30% faster running speed and so on. These should be red in from a text file, maybe in chunks of WHAT it mods, HOW it mods it(add/mul) and the AMOUNT it mods. These should be applied on the GameObject equipping the item. Im not sure how to map these item-properties to my game-object hierarchy, toghether with file-loading, and enums. How i ever concieve it it seems like i will have to hardcode alot of enums against switch-cases and so on. Can anyone point me in a direction of a smart way of doing this? Dont know if I make any sense at all. Thanks, /T!

Share this post

Link to post
Share on other sites
You could store the increase/decrease value of the mod along with the mod name in the file, then parse the file and reading in the value, then apply the value.


Share this post

Link to post
Share on other sites
You could store the data in XML format and use or create a XML loader to parse the file and then apply the mod. I was looking over this recently and I know the Boost library has an archive class that can parse XML data -> here.

Alternatively, just create your own format and use a dedicated load function to read and apply the mod.
A custom format like the follwing might be suitable:

#item descriptor - this is a comment line
>item "Heavy Armour"
>img_src "images/shiny_shield.jpg"
>desc "Made from a tryoaxylete alloy, protects against standard bullet rounds, arrows and strong blows.
Warning: Will hinder the wearers agility, not recomended for extended use.
Shipment id: #066537.6"

#item attributes - this is a comment line
>health add 10
>agility mul 0.75
>strength add 2
>stamina add -3

Share this post

Link to post
Share on other sites
a quick and easy way do do it could be done by creating simple arrays of values for example:

4; //4 items in the list
0x0001, -10; //attribute number 1 (could be hp) -10 means -10hp
0x0002, 15; //attribute number 2 (could be str) 10 means +10str
0x0003, 3; //attribute #3 (could mean dmg %) 3 could mean +3% more dmg
0x0004, 7; //attribute #4 (could mean defence%) 7 means 7% more defence

something simple like this can also be aligned to fit a 32bit word, use bitshifts to get the data out of the 32bit words and takes a small amount of space.

to load it just do something like this:

struct sData
uint AttrAbility;
int AttrAmount;


//pseudo code

sData *loadNext = new sData [4]; //4 comes from example up there

for( int i=0; i<4; i++ )
loadNext.AttrAbility = AbilityLoadedFromFile;
loadNext.AttrAmount = AmountLoadedFromFile


Share this post

Link to post
Share on other sites
Thanks all of you!
I will have a look at that boost library.

I guess my question was a bit unclear though. My problem wasn't the actual file-handling, but rather than how to best connect my in-code variables to those in the textfile, without getting a whole mess out of it.
Especially when i have a deep gameobject hierarchy. Maybe boost provides this for me.

T :)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!