OoT-Randomizer icon indicating copy to clipboard operation
OoT-Randomizer copied to clipboard

Fix effective starting trade items

Open fenhl opened this issue 1 year ago • 2 comments

This PR fixes a bug where in full trade shuffle, if you start with a trade quest item from Impa and then find another one, the one you started with is lost. To reproduce, start this plando and open one of the chests:

{
    "settings": {
        "open_forest": "open",
        "spawn_positions": ["child"],
        "adult_trade_shuffle": true,
        "shuffle_song_items": "any",
        "starting_items": {
            "Zeldas Letter": 1
        }
    },
    "entrances": {
        "Child Spawn -> KF Links House": "KF Midos House"
    },
    "locations": {
        "Song from Impa": "Poachers Saw",
        "KF Midos Top Left Chest": "Pocket Egg",
        "KF Midos Top Right Chest": "Cojiro",
        "KF Midos Bottom Left Chest": "Odd Mushroom",
        "KF Midos Bottom Right Chest": "Odd Potion"
    }
}

On Dev, you will see that the poacher's saw has been replaced with the item you got from the chest, and using the D-pad to go back to the saw doesn't work. After opening a second chest, you can toggle between the two items you got from chests, but still can't select the saw. With this PR, the D-pad toggle works as soon as the first chest is opened, and the saw is included.

Details:

  • The code from Patches.py that would set the “owned” flags for starting trade items is removed and instead these flags are handled by the SaveContext.py system, which also handles effective starting items such as the song from Impa in Skip Child Zelda.
  • The logic in configure_effective_starting_items for selecting the last trade item in the sequence is removed. This logic was redundant since SaveContext.py already handles an address being written to multiple times by keeping the larger value.
  • Minor code cleanup in Patches.py removing a redundant check (world.skip_child_zelda implies 'Zeldas Letter' in world.distribution.starting_items).
  • Minor code cleanup in SaveContext.py for the ocarina buttons.

fenhl avatar May 12 '24 20:05 fenhl

Good work. So the bug was caused by Patches.py not setting the "owned" flag correctly?

cjohnson57 avatar May 13 '24 05:05 cjohnson57

Yes. The code in Patches.py to set “owned” flags was only running for explicit starting items, not for effective starting items like the song from Impa. I could have simply changed the iterator in that code, but I think this fix is cleaner.

fenhl avatar May 13 '24 05:05 fenhl

Oops.. guess this one slipped my mind

cjohnson57 avatar Dec 12 '24 23:12 cjohnson57