Development Pt.2
Back from nightsift, with stamina replenished after some sleep, I can continue with development. 3 days off ahead of me, so wohooo.
I’ve been thinking during my shift about last post, and realized it would be good idea to talk a bit about naming convention. It is not an issue at this stage, while having very few object types, but it will help to avoid a lot of headaches at later stages. Looking for specific object in 100 objects named “TestObject001” to “TestObject100” is not best way to go. I like to use simple naming conventions, like t_ for textures, dt_ for data tables, sk_ for skeleton, skm_ for skeletal meshes, sm_ for static meshes…etc. For an instance, “t_sword_steel” and “sm_sword_steel”, so I’ll know this texture belongs to this object, and it is also makes refering to objects much easier as well. Ok, let’s jump back to UE4 engine.
So now, when picking objects and simple inventory is implemented, it will be good idea to make use of them. From previous post we know that object is simple collection of variables that is being moved between world and character’s inventory (for now). So, I’m going to approach using items same way as I did for picking items. Now, when all information about picked object is stored in inventory slot, I can use it to use or equip item. By clicking on item, it will extract required information and use item (or move it to equipment slot in case of armour or weapon).

Nah, just realized we want to swap equipment items as well, so I need to modify this function a bit. But core idea stays the same.

So that’s the basic function logic for equipping and using items. Same function logic is used to unequip items, with one exception only. If unequipping items, we need to check if there’s space in inventory first. If inventory is full, character simply can’t unequip item. It seems that there shouldn’t be any issues with switching items, since we are moving one item from, and on item to inventory. Hovewer, there are som exceptions, like 2 handed weapons. Let’s say my character has sword in primary hand, and shield in secondary hand, and I wan’t to equip new super-awesome 2 handed sword I just found. In that case we are moving 2 objects to inventory (from both hands), but only 1 object from inventory. So if inventory is full, equipping 2 handed weapon in this case should not be possible. Ok, I’m just talking about nothing now, let’s jump back at prototyping.
Well, now I need new UI widget for equipment window, something simple for testing purpose. In this case I’ve inspired myself by modern video games, where instance of player character is being rendered inside inventory/equipment window in real time.

Took an inspiration for equipment window from Conan Exiles video game. I’ve actually learned a lot thanks to the Conan Exiles DevKit provided by Funcom, as well as from watching many tutorials provided for free by other professionals (Jackson from TitanicGames is my favourite). But remember, copying and pasting chunks of code is strictly no-no, tutorials should serve learning purpose, for one to understand principles so one will be later able to use knowledge to create own art or code.
There are 2 more things I want to do before testing. Character render inside equipment window should represent player character in the game world, while character in the game world should change appearance based on equipped armour.

Well, there’s actually one more thing I want to do before finishing this post, to close this “inventory episode”. So while messing with inventory system, I’m going to add one more thing, which is storage items like chest, cabinet…etc. It is basically same system, but with one difference. Each storage object having its own inventory and with multiple storage objects in the game world, I need to make sure game will display inventory only of storage item player is interacting with. For this purpose I’m going to use simple collider, which defines interactable area of storage object, one more variable which defines which specific storage object player is interacting with, and also array “storageInventory” which holds all items in the storage.


So let’s test it now, everything should work (hopefully) and this episode can be closed.
So everything works (for now). Items can be picked, equipped/unequipped, player changes appearance based on equipped items, each storage chest has it’s own inventory and capacity…etc. That’s hopefully basic inventory/storage system done. But I will probably get back to it later (I’m sure I’ve forgot something that will come up later). Now just add some footnotes and that’s me done for now.
Footnotes
- enemy inventory system – not going to implement inventory system for enemies. I will probably use simple array of objects that enemies can drop once killed. So I will need to add one more variable to item variables collection that defines chance of item being dropped by killed enemy (for each item in enemy inventory array, get “dropChance” variable, perform roll, if “dropChance” => random integer in range 0-100, spawn item)
- Crafting system – have a look at crafting system. Thinking about few types of crafting tables (can possibly use itemType enum from item variables collection). Have look at recipes system also (could be learned? Unlocked by skill? Dropped by enemies? Need a specific NPC character to craft items, i.e. armorsmith, weaponsmith, alchemist…etc.?).
Leave a Reply