Inventory ideas (babble)
So this game project will have survival mechanics, and sandbox style building aspects as a supporting feature to the main focus of the RPG. Because of this, I need a simple but flexible inventory system. One that can allow players to easily store, organize and access items, as well as allow for crafting.
I’ve decided to use a slot system rather than something like a material catalog, on account of the fact that the same inventory space will be used for carrying a large diversity of procedurally generated and player created items, such as unique weapons and armor parts. A material catalog would be more efficient for crafting, but due to the diversity of unique items, this isn’t feasible.
The way a slot system works is simple. The inventory is an array that holds item stack structs. These structs track what type of item they represent via an integer ID system, and track how many items are in the stack with another integer variable. The ID tells the stack where to look in a table of items, telling it what graphics to display and how large the item stack can be before it won’t accept any more. Constructed or procedurally generated items, however, all count as distinct types and can’t stack. Even of you happen to find 2 identical weapons or armor parts, their stack size is limited to 1. Those items then use a simple string as their “seed”, wherein each character in the string represents a point of data for the item, such as what blade, hilt, handle, pommel, materials, element and ability the weapon has. Every item stack will have the capacity to hold a string like this, but it’s only used for these constructed items.
Crafting recipes are simply a list of items as components, and a list of items as results. When attempting to craft, a copy of the inventory is made to perform a check on. Then, for every item in the recipe, the inventory is checked slot by slot to find the matching type. If it finds it, it either takes what it needs from that stack by reducing the quantity variable by the required number, or reduces the required number by the number in the stack, and destroys the stack, based on whether there’s more in the stack than it needs. Once the required number is met for each material, it moves onto the next material immediately, not bothering to check the rest of the inventory. If it ever reaches the end of the inventory without meeting the required number of items, then the inventory simply doesn’t contain the required items, and the crafting fails. The copied inventory is erased, leaving the original unaffected, and the player is informed that they are missing components. If all the item requirements are met, and the crafting never reaches a fail-state, then the inventory has all the required items, and the crafting succeeds. The copy of the inventory that’s had the needed components removed is then used to overwrite the original inventory, and the result items are placed into the inventory. In the case that the inventory is full, the items will check if they can instead be immediately equipped to a functional slot instead, and if not, they’ll simply be dropped.
Normally, the player will have access to a limited range of recipes that they can use anywhere, assuming they have the materials. However, if the player uses a crafting station of some sort, they can then access other recipes, such as using a loom to make cloth, or a foundry to refine ore into metal. This creates the ability for a complete system of progression in game, allowing for as simple or complex of a crafting tree as desired. For instance, I’ve decided that certain recipes will only be available of a crafting station is manned by an NPC worker, with more recipes being unlocked as the NPC levels up their skill in that job. NPC based recipes will have a work-time, both meaning that players can’t just instantly craft and use things like potions and weapons, but also that players can do a lot of crafting with different NPCs in parallel. This is partly due to the tycoon side of this game’s mechanics, which allow players to build, populate and logistically organize their own village using simple homes, workshops and containers.
With a system of simple inventory management and item crafting, even this early in development, this game can become “playable” as a sandbox. And due to the nature of this game, the sandbox elements take priority in development, even though the final focus will be on the RPG side. This is simply because the players means of progressing with the world will primarily be through resource gathering and crafting, and because the world it’s self is made to accommodate the mining and building aspects.











