Skip to content

Commit

Permalink
Separate OWG and HMG connection code
Browse files Browse the repository at this point in the history
Split making HMG entrances and connecting them
Correctly link IP lobby (not portal)
  • Loading branch information
KrisDavie committed Dec 23, 2024
1 parent fe2a01b commit be97102
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 49 deletions.
22 changes: 12 additions & 10 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down
14 changes: 3 additions & 11 deletions OverworldGlitchRules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
61 changes: 33 additions & 28 deletions UnderworldGlitchRules.py
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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"),
Expand All @@ -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,
Expand All @@ -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):
Expand Down

0 comments on commit be97102

Please sign in to comment.