To business then. Probably a few of you guys know what a "roguelike" dungeon crawler is. Well, I'm trying to recreate the inventory system from one of those games. I think I've got a handle on the theory of it, I'm just having some issues with the execution.
Here's my method:
I have three types of arrays. First, I have the 'item' array. It's a global 2D array, and it sets the definitions, attributes, etc., of every item in the game. It's used when an item is first created, and it's also used to check whether or not the item's function is known by the player character.
Secondly, there's the 'instance' array, which is a local, 1D array that each physical instance of an item has, specifying how it differs from the stock 'item'. As an example;
The 'item' table specifies that item ID "1" 'looks' like a Pinewood Staff, is actually a Staff of Menace, is not known by the player and has a maximum of ten uses.
The 'instance' table specifies that this particular Pinewood Staff is cursed, has six uses remaining and has been tentatively labelled "Useless?" by the player. However, the player does not know that the staff is cursed, nor that it has six uses remaining.
Then there's the inventory array. It's a local, 2D array that details everything the character or an NPC/Enemy owns.
Now, what I need to happen (but am having a little trouble with executing) is this: no matter what, the 'instance' array needs to transition in and out of the 'inventory' arrays seamlessly, because item manipulation is going to be happening a lot... and making sure the individual aspects of each item don't change in this process is very necessary. Let's say I drop the item. I need it to create an instance of obj_item whose 'instance' array is identical to the inventory slot it came out of. Then let's say I pick it back up again. Considering the 1D instance array as a 'column', Is there a fast way of transcribing the 'instance' column onto a free 'inventory' column (without, of course, individually setting each slot) and vice versa?
Any advice would be appreciated. ^.^