Inventory and how to create/destroy the items

This seems to be extremely problematic. At first I used structures that also holds an actor to whatever item that structure is, but since every item is a structure and I couldnt make an array of said struct inside it. This was a no go since I need bags :smiley:

Storing them as actors allows me to easily setup their own inventories (bags, chests etc), problem here is that I cant destroy them since they all reference to the same object.
I discovered the AssetID array, havent tried it yet but every variable is a reference.

Another problem is the random stats on items.

So I am thinking if the inventory should be two arrays, one that holds the actor class (with variable to its own inventory if it has one). And another array wich keeps structures to store that specific items stats.
So that when you spawn the actor from class, it has the specific inventory size for that class. But also has all the random stats for that specific item?
Does this sound reasonable? I mean its an extra array for every inventory object, I just cant handle the thought that there would be 100s or thousands of items in the world hidden at the same time.

Edit: Did some maps, and no matter how I try I always end up with the bag needing an inventory of stats, wich is the same structure as the stats structure the bag has.


Iā€™m not exactly sure what kind of inventory you want to have. It sounds a bit like you want to do some kind of Diablo-like-inventory?

Hello, there are some key features it need to have :slight_smile: Probably similiar to Diablo yes!

It needs to store random generated values for items that require it.
Able to hold items with inventories (Bags etc).
Able to drop these items so players can open their inventories.
Able to split and modify stacks of items.

Still no luck, I have to do some more thinking for sure. Making each slot in the inventory hold structures just does not work for me, because at some point a bag inventory will point to the structure that it was made up of.
The problem is the bags, I will try something else.

As an example a 10 slot bag:

While bag is inventory it cannot be opened and it cannot have items in it so the bags inventory is always the same for said bag while in inventory. 10 empty slots check!
Upon equipping that bag it adds slots to your own inventory.
When dropped it creates the item first, then populates all the empty slots with the appropriate items form your own inventory.
Next person who loots the bag will see the items and can either loot it, or pick it up where if picking it up the bags slots are added to your inventory IF you have a slot available to equip the bag in
Else you have to empty it first and then loot the bag

JC Inventory from the market place is built with destroying items on pickup/equip.

Got this working now, items are structures holding their class for when created. And their individual stats are transfered when moved between containers :slight_smile: