From be971027018616030f4b76243f8b4c9dac6d126b Mon Sep 17 00:00:00 2001 From: KrisDavie Date: Mon, 23 Dec 2024 15:55:44 +0100 Subject: [PATCH] Separate OWG and HMG connection code Split making HMG entrances and connecting them Correctly link IP lobby (not portal) --- Main.py | 22 ++++++++------- OverworldGlitchRules.py | 14 ++------- UnderworldGlitchRules.py | 61 ++++++++++++++++++++++------------------ 3 files changed, 48 insertions(+), 49 deletions(-) diff --git a/Main.py b/Main.py index 695d1559..36235d11 100644 --- a/Main.py +++ b/Main.py @@ -27,7 +27,7 @@ from Fill import dungeon_tracking from Fill import sell_potions, sell_keys, balance_multiworld_progression, balance_money_progression, lock_shop_locations from ItemList import generate_itempool, difficulties, fill_prizes, customize_shops, fill_specific_items -from UnderworldGlitchRules import create_hybridmajor_connections, get_hybridmajor_connection_entrances +from UnderworldGlitchRules import connect_hmg_entrances_regions, create_hmg_entrances_regions from Utils import output_path, parse_player_names from source.item.FillUtil import create_item_pool_config, massage_item_pool, district_item_pool_config, verify_item_pool_config @@ -282,7 +282,8 @@ def main(args, seed=None, fish=None): for player in range(1, world.players + 1): if world.logic[player] in ('nologic', 'hybridglitches'): - create_hybridmajor_connections(world, player) + create_hmg_entrances_regions(world, player) + connect_hmg_entrances_regions(world, player) generate_itempool(world, player) verify_item_pool_config(world) @@ -544,6 +545,10 @@ def copy_world(world): connection = Entrance(player, 'Uncle S&Q', parent) parent.exits.append(connection) connection.connect(target) + # This makes the regions for HMG only + # we'll connect them later after all other connections are made (OW <=> UW, Portals) + if world.logic[player] in ('nologic', 'hybridglitches'): + create_hmg_entrances_regions(ret, player) # copy bosses for dungeon in world.dungeons: @@ -560,7 +565,6 @@ def copy_world(world): # We have to skip these for now. They require both the rest of the entrances _and_ the dungeon portals to be copied first # We will connect them later - hmg_entrances = get_hybridmajor_connection_entrances() for region in world.regions: copied_region = ret.get_region(region.name, region.player) @@ -571,8 +575,6 @@ def copy_world(world): for location in copied_region.locations: location.parent_region = copied_region for entrance in region.entrances: - if entrance.name in hmg_entrances: - continue ret.get_entrance(entrance.name, entrance.player).connect(copied_region) # fill locations @@ -620,15 +622,15 @@ def copy_world(world): for player in range(1, world.players + 1): if world.logic[player] in ('nologic', 'hybridglitches'): - create_hybridmajor_connections(ret, player) + connect_hmg_entrances_regions(ret, player) for region in world.regions: copied_region = ret.get_region(region.name, region.player) for entrance in region.entrances: - if entrance.name not in hmg_entrances: - continue - ret.get_entrance(entrance.name, entrance.player).connect(copied_region) - + ent = ret.get_entrance(entrance.name, entrance.player) + if (ent.connected_region != copied_region): + ent.connect(copied_region) + for player in range(1, world.players + 1): set_rules(ret, player) diff --git a/OverworldGlitchRules.py b/OverworldGlitchRules.py index 55e9d896..b9abef8d 100644 --- a/OverworldGlitchRules.py +++ b/OverworldGlitchRules.py @@ -282,20 +282,12 @@ def add_alternate_rule(entrance, rule): old_rule = entrance.access_rule entrance.access_rule = lambda state: old_rule(state) or rule(state) - -def create_no_logic_connections(player, world, connections, connect_external=False): +def create_no_logic_connections(player, world, connections): for entrance, parent_region, target_region, *rule_override in connections: parent = world.get_region(parent_region, player) - - if isinstance(target_region, Region): - target_region = target_region.name - - if connect_external and target_region.endswith(" Portal"): - target = world.get_portal(target_region[:-7], player).find_portal_entrance().parent_region - else: - target = world.get_region(target_region, player) - + target = world.get_region(target_region, player) connection = Entrance(player, entrance, parent) + connection.spot_type = 'OWG' parent.exits.append(connection) connection.connect(target) diff --git a/UnderworldGlitchRules.py b/UnderworldGlitchRules.py index beb95ed9..623a1dcc 100644 --- a/UnderworldGlitchRules.py +++ b/UnderworldGlitchRules.py @@ -1,9 +1,7 @@ import functools -from BaseClasses import Entrance, DoorType +from BaseClasses import Entrance, DoorType, Door from DoorShuffle import connect_simple_door import Rules -from OverworldGlitchRules import create_no_logic_connections -from Doors import create_door kikiskip_spots = [ ("Kiki Skip", "Spectacle Rock Cave (Bottom)", "Palace of Darkness Portal") @@ -13,7 +11,7 @@ heraswamp_spots = [("Hera to Swamp Clip", "Mire Torches Top", "Swamp Portal")] -icepalace_spots = [("Ice Lobby Clip", "Ice Portal", "Ice Bomb Drop - Top")] +icepalace_spots = [("Ice Lobby Clip", "Ice Lobby", "Ice Bomb Drop - Top")] thievesdesert_spots = [ ("Thieves to Desert West Clip", "Thieves Attic", "Desert West Portal"), @@ -29,10 +27,29 @@ ("Paradox Front Teleport", "Paradox Cave Front", "Paradox Cave Chest Area") ] -# Create connections between dungeons/locations -def create_hybridmajor_connections(world, player): - fix_fake_worlds = world.fix_fake_world[player] +def create_hmg_entrances_regions(world, player): + for spots in [ + kikiskip_spots, + mirehera_spots, + heraswamp_spots, + icepalace_spots, + thievesdesert_spots, + specrock_spots, + paradox_spots, + ]: + for entrance, parent_region, _, *_ in spots: + parent = world.get_region(parent_region, player) + connection = Entrance(player, entrance, parent) + connection.spot_type = 'HMG' + if connection not in parent.exits: + parent.exits.append(connection) + + ip_bomb_top_reg = world.get_region("Ice Bomb Drop - Top", player) + ip_clip_entrance = Entrance(player, "Ice Bomb Drop Clip", ip_bomb_top_reg) + ip_bomb_top_reg.exits.append(ip_clip_entrance) + +def connect_hmg_entrances_regions(world, player): for spots in [ kikiskip_spots, mirehera_spots, @@ -42,34 +59,22 @@ def create_hybridmajor_connections(world, player): specrock_spots, paradox_spots, ]: - create_no_logic_connections(player, world, spots, connect_external=fix_fake_worlds) + for entrance, _, target_region, *_ in spots: + connection = world.get_entrance(entrance, player) + if world.fix_fake_world[player] and target_region.endswith(" Portal"): + target = world.get_portal(target_region[:-7], player).find_portal_entrance().parent_region + else: + target = world.get_region(target_region, player) + connection.connect(target) # Add the new Ice path (back of bomb drop to front) to the world and model it properly - clip_door = create_door(player, "Ice Bomb Drop Clip", DoorType.Logical) + ip_clip_entrance = world.get_entrance('Ice Bomb Drop Clip', 1) + clip_door = Door(player, "Ice Bomb Drop Clip", DoorType.Logical, ip_clip_entrance) world.doors += [clip_door] world.initialize_doors([clip_door]) - ice_bomb_top_reg = world.get_region("Ice Bomb Drop - Top", player) - ice_bomb_top_reg.exits.append( - Entrance(player, "Ice Bomb Drop Clip", ice_bomb_top_reg) - ) connect_simple_door(world, "Ice Bomb Drop Clip", "Ice Bomb Drop", player) -def get_hybridmajor_connection_entrances(): - connections = [] - for connector in ( - kikiskip_spots - + mirehera_spots - + heraswamp_spots - + icepalace_spots - + thievesdesert_spots - + specrock_spots - + paradox_spots - ): - connections.append(connector[0]) - connections.append('Ice Bomb Drop Clip') - return set(connections) - # For some entrances, we need to fake having pearl, because we're in fake DW/LW. # This creates a copy of the input state that has Moon Pearl. def fake_pearl_state(state, player):