Dinopony / alundra-randomizer

A randomizer for the PS1 game Alundra
MIT License
12 stars 1 forks source link

Add progressive items #24

Closed Dinopony closed 2 years ago

Dinopony commented 2 years ago

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 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.

Dinopony commented 2 years ago

The technical side is covered in 2e41ae1

The graphical side has been done in 01829c8 the following way: