From 5b64c5f9341f31c4243d009c13a79cc1392b97d7 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 7 Mar 2023 09:09:24 +0100 Subject: [PATCH] Subnautica: fix exported radiation logic (#1507) --- worlds/subnautica/Locations.py | 9 +++++++-- worlds/subnautica/Rules.py | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/worlds/subnautica/Locations.py b/worlds/subnautica/Locations.py index da92f8d4..e0a33966 100644 --- a/worlds/subnautica/Locations.py +++ b/worlds/subnautica/Locations.py @@ -580,9 +580,14 @@ if False: # turn to True to export for Subnautica mod with open("locations.json", "w") as f: json.dump(payload, f) - def radiated(pos: Vector): - aurora_dist = math.sqrt((pos["x"] - 1038.0) ** 2 + (pos["y"] - -3.4) ** 2 + (pos["y"] - -163.1) ** 2) + # copy-paste from Rules + def is_radiated(x: float, y: float, z: float) -> bool: + aurora_dist = math.sqrt((x - 1038.0) ** 2 + y ** 2 + (z - -163.1) ** 2) return aurora_dist < 950 + # end of copy-paste + + def radiated(pos: Vector): + return is_radiated(pos["x"], pos["y"], pos["z"]) def far_away(pos: Vector): return (pos["x"] ** 2 + pos["z"] ** 2) > (800 ** 2) diff --git a/worlds/subnautica/Rules.py b/worlds/subnautica/Rules.py index 48db25a8..793c85be 100644 --- a/worlds/subnautica/Rules.py +++ b/worlds/subnautica/Rules.py @@ -221,6 +221,11 @@ def get_max_depth(state: "CollectionState", player: int): ) +def is_radiated(x: float, y: float, z: float) -> bool: + aurora_dist = math.sqrt((x - 1038.0) ** 2 + y ** 2 + (z - -163.1) ** 2) + return aurora_dist < 950 + + def can_access_location(state: "CollectionState", player: int, loc: LocationDict) -> bool: need_laser_cutter = loc.get("need_laser_cutter", False) if need_laser_cutter and not has_laser_cutter(state, player): @@ -235,8 +240,7 @@ def can_access_location(state: "CollectionState", player: int, loc: LocationDict pos_y = pos["y"] pos_z = pos["z"] - aurora_dist = math.sqrt((pos_x - 1038.0) ** 2 + (pos_y - -3.4) ** 2 + (pos_z - -163.1) ** 2) - need_radiation_suit = aurora_dist < 950 + need_radiation_suit = is_radiated(pos_x, pos_y, pos_z) if need_radiation_suit and not state.has("Radiation Suit", player): return False