From 63d471514f05ccd4ccacc20807068400020f8bcc Mon Sep 17 00:00:00 2001 From: Bryce Wilson Date: Wed, 16 Oct 2024 18:37:41 -0700 Subject: [PATCH] Pokemon Emerald: Add flag for shoal cave to bounces (#4021) * Pokemon Emerald: Add shoal cave state to map updates * Pokemon Emerald: Fix shoal cave flag wrong byte, delay bounce to end of map transition --- worlds/pokemon_emerald/client.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/worlds/pokemon_emerald/client.py b/worlds/pokemon_emerald/client.py index 4405b34074..5add7b3fca 100644 --- a/worlds/pokemon_emerald/client.py +++ b/worlds/pokemon_emerald/client.py @@ -117,6 +117,11 @@ LEGENDARY_NAMES = {k.lower(): v for k, v in { DEFEATED_LEGENDARY_FLAG_MAP = {data.constants[f"FLAG_DEFEATED_{name}"]: name for name in LEGENDARY_NAMES.values()} CAUGHT_LEGENDARY_FLAG_MAP = {data.constants[f"FLAG_CAUGHT_{name}"]: name for name in LEGENDARY_NAMES.values()} +SHOAL_CAVE_MAPS = tuple(data.constants[map_name] for map_name in [ + "MAP_SHOAL_CAVE_LOW_TIDE_ENTRANCE_ROOM", + "MAP_SHOAL_CAVE_LOW_TIDE_INNER_ROOM", +]) + class PokemonEmeraldClient(BizHawkClient): game = "Pokemon Emerald" @@ -414,13 +419,17 @@ class PokemonEmeraldClient(BizHawkClient): read_result = await bizhawk.guarded_read( ctx.bizhawk_ctx, - [(sb1_address + 0x4, 2, "System Bus")], - [guards["SAVE BLOCK 1"]] + [ + (sb1_address + 0x4, 2, "System Bus"), # Current map + (sb1_address + 0x1450 + (data.constants["FLAG_SYS_SHOAL_TIDE"] // 8), 1, "System Bus"), + ], + [guards["IN OVERWORLD"], guards["SAVE BLOCK 1"]] ) if read_result is None: # Save block moved return current_map = int.from_bytes(read_result[0], "big") + shoal_cave = int(read_result[1][0] & (1 << (data.constants["FLAG_SYS_SHOAL_TIDE"] % 8)) > 0) if current_map != self.current_map: self.current_map = current_map await ctx.send_msgs([{ @@ -429,6 +438,7 @@ class PokemonEmeraldClient(BizHawkClient): "data": { "type": "MapUpdate", "mapId": current_map, + **({"tide": shoal_cave} if current_map in SHOAL_CAVE_MAPS else {}), }, }])