When grabbing such an item, it would be very interesting to have the game give you the next tier for that category instead of giving potentially giving you the best tier right away.
Three cases need to be handled:
Items in chest
Items given by NPC
Items on ground
For each one of those cases, there are two aspects that need to be handled:
the graphical aspect (displaying a proper item, or a sprite of the T1 item that can be interpreted as an upgrade)
the technical aspect (giving the proper next tier item instead of giving the raw item)
The technical side
The function FUN_IncreaseItemQuantityInInventory is used to increment the inventory quantity, and is called by all three cases.
A procedure needs to be injected at the beginning of this function to check if item ID is one of the items eligible for upgrade, and change the item ID on-the-fly if it needs to be done.
The graphical side
The graphical side would be complex to handle properly, because depending on the case, item object entities would have to change of type dynamically on map load, and handling cases such as double entities on maps would be extremely hard to fully cover.
The best option would be to have dedicated item IDs, with a dedicated name in-game (e.g. "Sword Upgrade", "Fire Magic Upgrade") that would have a branching behavior when calling FUN_IncreaseItemQuantityInInventory
To change an item name, a global string must be set up in memory containing the item name.
It must be placed between 0x12DFD2 and 0x12E200, and the string offset must be placed in the global strings offsets table starting at 0x12B9E0 (item name offsets starting at 0x12BDE0)
As for the sprites, it's a tough one. We could use the fact that some unused items re-use the same item sprites as other items to detect sprite ID / address more easily.
Some equipements in the game have several tiers:
When grabbing such an item, it would be very interesting to have the game give you the next tier for that category instead of giving potentially giving you the best tier right away.
Three cases need to be handled:
For each one of those cases, there are two aspects that need to be handled:
The technical side
The function
FUN_IncreaseItemQuantityInInventory
is used to increment the inventory quantity, and is called by all three cases. A procedure needs to be injected at the beginning of this function to check if item ID is one of the items eligible for upgrade, and change the item ID on-the-fly if it needs to be done.The graphical side
The graphical side would be complex to handle properly, because depending on the case, item object entities would have to change of type dynamically on map load, and handling cases such as double entities on maps would be extremely hard to fully cover.
The best option would be to have dedicated item IDs, with a dedicated name in-game (e.g. "Sword Upgrade", "Fire Magic Upgrade") that would have a branching behavior when calling
FUN_IncreaseItemQuantityInInventory
To change an item name, a global string must be set up in memory containing the item name. It must be placed between
0x12DFD2
and0x12E200
, and the string offset must be placed in the global strings offsets table starting at0x12B9E0
(item name offsets starting at0x12BDE0
)As for the sprites, it's a tough one. We could use the fact that some unused items re-use the same item sprites as other items to detect sprite ID / address more easily.