Skip to content

Commit

Permalink
TUNIC: Fix for nmg logic bug (#2772)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScipioWright authored Jan 28, 2024
1 parent aa72f67 commit b4212d1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 28 deletions.
51 changes: 29 additions & 22 deletions worlds/tunic/er_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def scene_destination(self) -> str: # full, nonchanging name to interpret by th
destination="Furnace_gyro_lower"),
Portal(name="Caustic Light Cave Entrance", region="Overworld",
destination="Overworld Cave_"),
Portal(name="Swamp Upper Entrance", region="Overworld Laurels",
Portal(name="Swamp Upper Entrance", region="Overworld Swamp Upper Entry",
destination="Swamp Redux 2_wall"),
Portal(name="Swamp Lower Entrance", region="Overworld",
destination="Swamp Redux 2_conduit"),
Expand All @@ -49,15 +49,15 @@ def scene_destination(self) -> str: # full, nonchanging name to interpret by th
destination="Atoll Redux_upper"),
Portal(name="Atoll Lower Entrance", region="Overworld",
destination="Atoll Redux_lower"),
Portal(name="Special Shop Entrance", region="Overworld Laurels",
Portal(name="Special Shop Entrance", region="Overworld Special Shop Entry",
destination="ShopSpecial_"),
Portal(name="Maze Cave Entrance", region="Overworld",
destination="Maze Room_"),
Portal(name="West Garden Entrance near Belltower", region="Overworld Belltower",
destination="Archipelagos Redux_upper"),
Portal(name="West Garden Entrance from Furnace", region="Overworld to West Garden from Furnace",
destination="Archipelagos Redux_lower"),
Portal(name="West Garden Laurels Entrance", region="Overworld Laurels",
Portal(name="West Garden Laurels Entrance", region="Overworld West Garden Laurels Entry",
destination="Archipelagos Redux_lowest"),
Portal(name="Temple Door Entrance", region="Overworld Temple Door",
destination="Temple_main"),
Expand Down Expand Up @@ -533,7 +533,9 @@ class Hint(IntEnum):
"Overworld": RegionInfo("Overworld Redux"),
"Overworld Holy Cross": RegionInfo("Fake", dead_end=DeadEnd.all_cats),
"Overworld Belltower": RegionInfo("Overworld Redux"), # the area with the belltower and chest
"Overworld Laurels": RegionInfo("Overworld Redux"), # all spots in Overworld that you need laurels to reach
"Overworld Swamp Upper Entry": RegionInfo("Overworld Redux"), # upper swamp entry spot
"Overworld Special Shop Entry": RegionInfo("Overworld Redux"), # special shop entry spot
"Overworld West Garden Laurels Entry": RegionInfo("Overworld Redux"), # west garden laurels entry
"Overworld to West Garden from Furnace": RegionInfo("Overworld Redux", hint=Hint.region),
"Overworld Well to Furnace Rail": RegionInfo("Overworld Redux"), # the tiny rail passageway
"Overworld Ruined Passage Door": RegionInfo("Overworld Redux"), # the small space betweeen the door and the portal
Expand Down Expand Up @@ -710,7 +712,7 @@ class Hint(IntEnum):
hallway_helper[p2] = p1

# so we can just loop over this instead of doing some complicated thing to deal with hallways in the hints
hallways_nmg: Dict[str, str] = {
hallways_ur: Dict[str, str] = {
"Ruins Passage, Overworld Redux_east": "Ruins Passage, Overworld Redux_west",
"East Forest Redux Interior, East Forest Redux_upper": "East Forest Redux Interior, East Forest Redux_lower",
"Forest Boss Room, East Forest Redux Laddercave_": "Forest Boss Room, Forest Belltower_",
Expand All @@ -720,20 +722,22 @@ class Hint(IntEnum):
"ziggurat2020_0, Quarry Redux_": "ziggurat2020_0, ziggurat2020_1_",
"Purgatory, Purgatory_bottom": "Purgatory, Purgatory_top",
}
hallway_helper_nmg: Dict[str, str] = {}
for p1, p2 in hallways.items():
hallway_helper[p1] = p2
hallway_helper[p2] = p1
hallway_helper_ur: Dict[str, str] = {}
for p1, p2 in hallways_ur.items():
hallway_helper_ur[p1] = p2
hallway_helper_ur[p2] = p1


# the key is the region you have, the value is the regions you get for having that region
# this is mostly so we don't have to do something overly complex to get this information
dependent_regions: Dict[Tuple[str, ...], List[str]] = {
("Overworld", "Overworld Belltower", "Overworld Laurels", "Overworld Southeast Cross Door", "Overworld Temple Door",
("Overworld", "Overworld Belltower", "Overworld Swamp Upper Entry", "Overworld Special Shop Entry",
"Overworld West Garden Laurels Entry", "Overworld Southeast Cross Door", "Overworld Temple Door",
"Overworld Fountain Cross Door", "Overworld Town Portal", "Overworld Spawn Portal"):
["Overworld", "Overworld Belltower", "Overworld Laurels", "Overworld Ruined Passage Door",
"Overworld Southeast Cross Door", "Overworld Old House Door", "Overworld Temple Door",
"Overworld Fountain Cross Door", "Overworld Town Portal", "Overworld Spawn Portal"],
["Overworld", "Overworld Belltower", "Overworld Swamp Upper Entry", "Overworld Special Shop Entry",
"Overworld West Garden Laurels Entry", "Overworld Ruined Passage Door", "Overworld Southeast Cross Door",
"Overworld Old House Door", "Overworld Temple Door", "Overworld Fountain Cross Door", "Overworld Town Portal",
"Overworld Spawn Portal"],
("Old House Front",):
["Old House Front", "Old House Back"],
("Furnace Fuse", "Furnace Ladder Area", "Furnace Walking Path"):
Expand Down Expand Up @@ -818,12 +822,14 @@ class Hint(IntEnum):


dependent_regions_nmg: Dict[Tuple[str, ...], List[str]] = {
("Overworld", "Overworld Belltower", "Overworld Laurels", "Overworld Southeast Cross Door", "Overworld Temple Door",
("Overworld", "Overworld Belltower", "Overworld Swamp Upper Entry", "Overworld Special Shop Entry",
"Overworld West Garden Laurels Entry", "Overworld Southeast Cross Door", "Overworld Temple Door",
"Overworld Fountain Cross Door", "Overworld Town Portal", "Overworld Spawn Portal",
"Overworld Ruined Passage Door"):
["Overworld", "Overworld Belltower", "Overworld Laurels", "Overworld Ruined Passage Door",
"Overworld Southeast Cross Door", "Overworld Old House Door", "Overworld Temple Door",
"Overworld Fountain Cross Door", "Overworld Town Portal", "Overworld Spawn Portal"],
["Overworld", "Overworld Belltower", "Overworld Swamp Upper Entry", "Overworld Special Shop Entry",
"Overworld West Garden Laurels Entry", "Overworld Ruined Passage Door", "Overworld Southeast Cross Door",
"Overworld Old House Door", "Overworld Temple Door", "Overworld Fountain Cross Door", "Overworld Town Portal",
"Overworld Spawn Portal"],
# can laurels through the gate
("Old House Front", "Old House Back"):
["Old House Front", "Old House Back"],
Expand Down Expand Up @@ -908,13 +914,14 @@ class Hint(IntEnum):

dependent_regions_ur: Dict[Tuple[str, ...], List[str]] = {
# can use ladder storage to get to the well rail
("Overworld", "Overworld Belltower", "Overworld Laurels", "Overworld Southeast Cross Door", "Overworld Temple Door",
("Overworld", "Overworld Belltower", "Overworld Swamp Upper Entry", "Overworld Special Shop Entry",
"Overworld West Garden Laurels Entry", "Overworld Southeast Cross Door", "Overworld Temple Door",
"Overworld Fountain Cross Door", "Overworld Town Portal", "Overworld Spawn Portal",
"Overworld Ruined Passage Door"):
["Overworld", "Overworld Belltower", "Overworld Laurels", "Overworld Ruined Passage Door",
"Overworld Southeast Cross Door", "Overworld Old House Door", "Overworld Temple Door",
"Overworld Fountain Cross Door", "Overworld Town Portal", "Overworld Spawn Portal",
"Overworld Well to Furnace Rail"],
["Overworld", "Overworld Belltower", "Overworld Swamp Upper Entry", "Overworld Special Shop Entry",
"Overworld West Garden Laurels Entry", "Overworld Ruined Passage Door", "Overworld Southeast Cross Door",
"Overworld Old House Door", "Overworld Temple Door", "Overworld Fountain Cross Door", "Overworld Town Portal",
"Overworld Spawn Portal", "Overworld Well to Furnace Rail"],
# can laurels through the gate
("Old House Front", "Old House Back"):
["Old House Front", "Old House Back"],
Expand Down
19 changes: 16 additions & 3 deletions worlds/tunic/er_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,23 @@ def set_er_region_rules(world: "TunicWorld", ability_unlocks: Dict[str, int], re
or (state.has(laurels, player) and options.logic_rules))

regions["Overworld"].connect(
connecting_region=regions["Overworld Laurels"],
connecting_region=regions["Overworld Swamp Upper Entry"],
rule=lambda state: state.has(laurels, player))
regions["Overworld Laurels"].connect(
regions["Overworld Swamp Upper Entry"].connect(
connecting_region=regions["Overworld"],
rule=lambda state: state.has(laurels, player))

regions["Overworld"].connect(
connecting_region=regions["Overworld Special Shop Entry"],
rule=lambda state: state.has(laurels, player))
regions["Overworld Special Shop Entry"].connect(
connecting_region=regions["Overworld"],
rule=lambda state: state.has(laurels, player))

regions["Overworld"].connect(
connecting_region=regions["Overworld West Garden Laurels Entry"],
rule=lambda state: state.has(laurels, player))
regions["Overworld West Garden Laurels Entry"].connect(
connecting_region=regions["Overworld"],
rule=lambda state: state.has(laurels, player))

Expand Down Expand Up @@ -230,7 +244,6 @@ def set_er_region_rules(world: "TunicWorld", ability_unlocks: Dict[str, int], re
connecting_region=regions["West Garden Laurels Exit"],
rule=lambda state: state.has(laurels, player))

# todo: can you wake the boss, then grapple to it, then kill it?
regions["West Garden after Boss"].connect(
connecting_region=regions["West Garden"],
rule=lambda state: state.has(laurels, player))
Expand Down
6 changes: 3 additions & 3 deletions worlds/tunic/er_scripts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Dict, List, Set, Tuple, TYPE_CHECKING
from BaseClasses import Region, ItemClassification, Item, Location
from .locations import location_table
from .er_data import Portal, tunic_er_regions, portal_mapping, hallway_helper, hallway_helper_nmg, \
from .er_data import Portal, tunic_er_regions, portal_mapping, hallway_helper, hallway_helper_ur, \
dependent_regions, dependent_regions_nmg, dependent_regions_ur
from .er_rules import set_er_region_rules

Expand All @@ -28,8 +28,8 @@ def hint_helper(portal: Portal, hint_string: str = "") -> str:
if hint_string == "":
hint_string = portal.name

if logic_rules:
hallways = hallway_helper_nmg
if logic_rules == "unrestricted":
hallways = hallway_helper_ur
else:
hallways = hallway_helper

Expand Down

0 comments on commit b4212d1

Please sign in to comment.