Wednesday, June 6, 2012

Items and Inventory

If you're wondering why I haven't posted about Lands of Adventure in a few weeks, it's because I've been too busy to really do any work on it.  But, even in my time away from it, I have been giving a lot of thought to the way the inventory system would handle items and how shops in the game would be set up.

Before I stopped working on the program a month ago, I had the skeleton of the system worked out.  Earlier today, I jumped back into the thick of things and quickly threw the whole thing together.

One of the shop screens, this one showing weapons.

Originally, I wanted to be lazy in my approach and create the game so that each character could only possess three things:  a weapon, armor and possibly a shield.  What I came to realize after a while was that doing the game that way would make me really unhappy.  I didn't want to cheat the player out of a better inventory system that allowed them to equip and carry multiple items (like rings, magical wands and potions).

So, looking at some older CRPGs, I figured out how to create an inventory system that tracks a certain number of items in a character's inventory and allows them to interact with those items.  A character can equip items that can be worn, trade items that they don't want, drop things they think are unnecessary, and sell items back to the shop at less than their selling cost.

An example character inventory.

What you might be thinking to yourself is that this is fairly obvious.  But, if you aren't a programmer, you may not realize how difficult putting something like this together can be.  Actually, a great many things in a CRPG can be quite challenging to get working exactly the way that you want.

Part of the fun of building one of these games on your own is that there are a lot of technical challenges to overcome that make me appreciate how much hard work went into those old games I loved.  Each time I achieve a goal, I feel it makes me a better programmer...because programming is all about knowing what your problem is and then teaching your computer, via scripted language, how to conquer the problem and do the work you want in just the way that you want.

Equipping armor.

There's still work to be done with the inventory system.  It took a while to figure out how to implement everything in a way that works.  Simple things like: knowing if a player is trying to equip something like armor, or if they're trying to equip a scroll by putting it on their head.  Or, knowing whether the thing the player wants to use in combat is a Rod of Fire, which allows them to damage enemies, or a bandage that will give him the opportunity to heal one of his damaged party characters.

Easy in concept, but harder in execution.  Still, it's rewarding when it works.

No comments:

Post a Comment