Suppose you have 3 Hand Ax in your inventory.
How would you distinguish one ax from another
EDIT:
For clarification, this question is geared towards how the engine would manage items.
I assume you're talking about "distinguishing" them from one another in the player's eyes, rather than in a back-end sense?
I feel like the best approach would be to change the name, text color, and/or icon for the item whenever it's modified in a way that makes it different from the base "template" for the item. So if you enhance your Hand Axe with a Sapphire to increase its DEF bonus by 3, you could call it "Sapphire Hand Axe" or "Azure Hand Axe" or "Hand Axe D+3" or change its icon or write "Hand Axe" in blue.
As far as how to give a game designer control over what would show up if you're making a general script that people could use, that's one I haven't really thought about. Wherever the "changes" or "enhancements" to the items are set up, that would probably be the best place to let the player either type in a tag to add to the name, or set other rules about how the item's name and icon display.
Alternatively, or in addition to the above, you can include a feature that will allow players to explicitly name their items (by clicking a certain key when the item is highlighted in their inventory). Not only does this allow the player to use whatever mental heuristic works best for them, but you should never ever underestimate the joy of naming your hand axes Steve, Alec, and Crushinator!
Since Wavelength mentioned the players view I will mention it from a developers view. 🙂
If they were hand axes that had exactly the same stats I don't see an issue with tracking their id's (i.e no randomization). The real problem shows it's self though when you have a random item generation script. Each time an item with the same name has a different stat it is counted as a new item and as such it's id will be different between new games. Basically it would be like trying to figure out where a droplet of water from a sprinkler will land (Numb3rs reference). So this leaves checking the name of the item vs checking the id of that item. (I have had problems with doing this).
It would be better if the ID generated in code using certain format. Like
001 - for weapons
002 - for armors
003 - for items
Then followed by ID from database
001-0022 - weapons ID number 22
And each time the weapon is created, add more number
001-0022-1 - Weapon ID number 22 (first)
001-0022-2 - Weapon ID number 22 (second)
Sadly, RPG Maker uses integer as ID. Most of case I know, people use string to handle object ID
For The Vendor, I'm going with extending the RPG::BaseItem class and modifying the gain_item method. Basically, to make sure things are consistent, both when you (the player) and the Heroes (a party separate from the player) gain items, you gain an instance of the item. However, I have a boolean to check if the item is customized; if it is not, the item will return the values for the item ID it belongs to in the database. However, when it is customized, it returns values based on database values modified by the customized modifier stats (these act as increases or decrease modifiers for the item's base stats).
This means that even if I were to change item stats at a later time, all non-customized items will return the updated values; all customized items will also do this, but still apply the modifiers you've applied through crafting/melding, also taking heed of maximum values.
Thus items are all unique in your inventory, because they're all instances of subclasses of the RPG::BaseItem class, but they are in sync with the database at all times.
$data_weapons contains an array of RPG::Weapon instances right?
Each are identical for all games played.
I suggest treating those objects as the base template and then create a Game_Weapon class that captures the dynamic contents. Be sure to save the Game_Weapon objects in the save files.
*hugs*
Ah, sorry, I assumed you meant the player-perspective since you're already one of the farthest along with managing them on the engine side with your Instanced Items script.
I'm certainly no pro at this kind of thing, but the way I'd envision doing it would be to keep an array of arrays (or array of hashes, I guess) that represents the player's "inventory" - that is, each instanced item that the party is holding. A entry (array or hash) inside the larger array would represent all the properties of an item - its unique ID (given to it when the item is created - I'll explain below), its type (item/weapon/armor), its database ID (matching it to a template from your database), and an array or hash of modifications that have been made to that item.
When an instanced item is created (given to the party), a new entry is pushed into the main "inventory" array. One of the properties of the instanced item is its unique ID, which is generated at the time the instanced item is created with something like "def next_id; $game_party.last_id += 1; return $game_party.last_id; end". This way each item can be guaranteed a unique integer ID that will never be repeated.
For scenes that require accessing the player's Inventory (using an item, selecting a Key Item for an event, visiting the "Sell" part of the shop, changing equipment, etc.), I would then rewrite the logic to iterate through the "inventory" array and list each result. When the item is selected, you can return the whole object, or just its ID (and create a "find_where" method that takes an ID and returns the place in the inventory array where the Unique ID is equal to the input ID), and use that information to apply whatever effects need to be applied to the player. So if a Potion object with a "healing +50%" modification is applied, your rewritten use_item method will be able to see that the object is a Potion, pull the base values for Potion from the database, and then apply the +50% modification right before healing the player. Similarly, if the item needs to be consumed when used, or is sold, you can use that find_where method as input for Ruby's "delete_at" array function. Something like "$game_party.inventory.delete_at(find_where(chosen_object[0]))" assuming that the first element in the "object properties" array is its Unique ID.
Equipment gets a little tougher since you can't simply "lose" one of the type of equipment that you put on. I'd probably add an "equipped" property for each instance of equipment to make it unavailable (and to not show up to the player as an item you possess), while still remaining in your inventory array.
So this approach would require an extensive amount of rewriting (which might make it inferior to approaches others have suggested, I'm not sure), but it would be extremely flexible as far as scripting the modifications that designers would be allowed to place on items, and would also have the advantage of allowing any scene in the game to easily access any given object that is selected by the player, assuming it can return its Unique ID.