Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions worlds/witness/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,17 @@ class WitnessWorld(World):
def _get_slot_data(self) -> Dict[str, Any]:
return {
"seed": self.options.puzzle_randomization_seed.value,
"victory_location": int(self.player_logic.VICTORY_LOCATION, 16),
"panelhex_to_id": self.player_locations.CHECK_PANELHEX_TO_ID,
"item_id_to_door_hexes": static_witness_items.get_item_to_door_mappings(),
"victory_location": self.player_logic.VICTORY_LOCATION,
"item_id_to_door_ids": static_witness_items.get_item_to_door_mappings(),
"door_items_in_the_pool": self.player_items.get_door_item_ids_in_pool(),
"doors_that_shouldnt_be_locked": [int(h, 16) for h in self.player_logic.FORBIDDEN_DOORS],
"disabled_entities": [int(h, 16) for h in self.player_logic.COMPLETELY_DISABLED_ENTITIES],
"hunt_entities": [int(h, 16) for h in self.player_logic.HUNT_ENTITIES],
"doors_that_shouldnt_be_locked": list(self.player_logic.FORBIDDEN_DOORS),
"disabled_entities": list(self.player_logic.COMPLETELY_DISABLED_ENTITIES),
"hunt_entities": list(self.player_logic.HUNT_ENTITIES),
"log_ids_to_hints": self.log_ids_to_hints,
"laser_ids_to_hints": self.laser_ids_to_hints,
"progressive_item_lists": self.player_items.get_progressive_item_ids_in_pool(),
"obelisk_side_id_to_EPs": static_witness_logic.OBELISK_SIDE_ID_TO_EP_HEXES,
"precompleted_puzzles": [int(h, 16) for h in self.player_logic.EXCLUDED_ENTITIES],
"obelisk_side_id_to_EPs": static_witness_logic.OBELISK_SIDE_ID_TO_EP_IDS,
"precompleted_puzzles": list(self.player_logic.EXCLUDED_ENTITIES),
"panel_hunt_required_absolute": self.panel_hunt_required_count
}

Expand Down Expand Up @@ -157,9 +156,7 @@ def determine_sufficient_progression(self) -> None:
def generate_early(self) -> None:
disabled_locations = self.options.exclude_locations.value

self.player_logic = WitnessPlayerLogic(
self, disabled_locations, self.options.start_inventory.value
)
self.player_logic = WitnessPlayerLogic(self, disabled_locations, self.options.start_inventory.value)

self.player_locations: WitnessPlayerLocations = WitnessPlayerLocations(self, self.player_logic)
self.player_items: WitnessPlayerItems = WitnessPlayerItems(
Expand Down Expand Up @@ -351,7 +348,7 @@ def fill_slot_data(self) -> Dict[str, Any]:

for item_name, hint in laser_hints.items():
item_def = cast(DoorItemDefinition, static_witness_logic.ALL_ITEMS[item_name])
self.laser_ids_to_hints[int(item_def.panel_id_hexes[0], 16)] = make_compact_hint_data(hint, self.player)
self.laser_ids_to_hints[item_def.panel_entity_ids[0]] = make_compact_hint_data(hint, self.player)
already_hinted_locations.add(cast_not_none(hint.location))

# Audio Log Hints
Expand Down Expand Up @@ -448,9 +445,9 @@ def create_region(world: WitnessWorld, name: str, player_locations: WitnessPlaye
location_obj = WitnessLocation(world.player, location, loc_id, ret)

if location in static_witness_logic.ENTITIES_BY_NAME:
entity_hex = static_witness_logic.ENTITIES_BY_NAME[location]["entity_hex"]
entity_id = static_witness_logic.ENTITIES_BY_NAME[location].entity_id

if entity_hex in world.player_logic.EXCLUDED_ENTITIES:
if entity_id in world.player_logic.EXCLUDED_ENTITIES:
location_obj.progress_type = LocationProgressType.EXCLUDED

ret.locations.append(location_obj)
Expand Down
1,530 changes: 765 additions & 765 deletions worlds/witness/data/WitnessLogic.txt

Large diffs are not rendered by default.

1,530 changes: 765 additions & 765 deletions worlds/witness/data/WitnessLogicExpert.txt

Large diffs are not rendered by default.

1,530 changes: 765 additions & 765 deletions worlds/witness/data/WitnessLogicVanilla.txt

Large diffs are not rendered by default.

1,530 changes: 765 additions & 765 deletions worlds/witness/data/WitnessLogicVariety.txt

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions worlds/witness/data/definition_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@ class RegionDefinition:
name: str
short_name: str
area: AreaDefinition
logical_entities: List[str] = field(default_factory=list)
physical_entities: List[str] = field(default_factory=list)
logical_entities: List[int] = field(default_factory=list)
physical_entities: List[int] = field(default_factory=list)


@dataclass
class EntityDefinition:
entity_name: str
entity_id: int
region: RegionDefinition | None
entity_type: str
location_type: str | None
area: AreaDefinition
order: int = 0


class ConnectionDefinition(NamedTuple):
Expand Down
2 changes: 1 addition & 1 deletion worlds/witness/data/item_definition_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ProgressiveItemDefinition(ItemDefinition):

@dataclass(frozen=True)
class DoorItemDefinition(ItemDefinition):
panel_id_hexes: List[str]
panel_entity_ids: List[int]


@dataclass(frozen=True)
Expand Down
9 changes: 5 additions & 4 deletions worlds/witness/data/static_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from . import static_logic as static_witness_logic
from .item_definition_classes import DoorItemDefinition, ItemCategory, ItemData
from .static_locations import ID_START

ID_START = 158000
Comment on lines -7 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to keep ID_START if cross-game ID conflicts are no longer an issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since items are not changing, I see no reason to disturb their IDs atm

Copy link
Member Author

@NewSoupVi NewSoupVi Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like yes I could also change the ID of the Dots item from 158010 to 10 or whatever, but I guess like... I don't really see a need, since the item IDs are already completely arbitrary. It just means I have to make another breaking / backwards compatible client change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair


ITEM_DATA: Dict[str, ItemData] = {}
ITEM_GROUPS: Dict[str, Set[str]] = {}
Expand Down Expand Up @@ -42,8 +43,8 @@ def populate_items() -> None:
elif definition.category is ItemCategory.DOOR:
classification = ItemClassification.progression

first_entity_hex = cast(DoorItemDefinition, definition).panel_id_hexes[0]
entity_type = static_witness_logic.ENTITIES_BY_HEX[first_entity_hex]["entityType"]
first_entity_id = cast(DoorItemDefinition, definition).panel_entity_ids[0]
entity_type = static_witness_logic.ENTITIES_BY_ID[first_entity_id].entity_type

if entity_type == "Door":
ITEM_GROUPS.setdefault("Doors", set()).add(item_name)
Expand Down Expand Up @@ -77,7 +78,7 @@ def get_item_to_door_mappings() -> Dict[int, List[int]]:
for item_name, item_data in ITEM_DATA.items():
if not isinstance(item_data.definition, DoorItemDefinition) or item_data.ap_code is None:
continue
output[item_data.ap_code] = [int(hex_string, 16) for hex_string in item_data.definition.panel_id_hexes]
output[item_data.ap_code] = item_data.definition.panel_entity_ids
return output


Expand Down
43 changes: 11 additions & 32 deletions worlds/witness/data/static_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from . import static_logic as static_witness_logic

ID_START = 158000

GENERAL_LOCATIONS = {
"Tutorial Front Left",
"Tutorial Back Left",
Expand Down Expand Up @@ -409,10 +407,6 @@
"Mountain Bottom Floor Discard",
}

GENERAL_LOCATION_HEXES = {
static_witness_logic.ENTITIES_BY_NAME[entity_name]["entity_hex"] for entity_name in GENERAL_LOCATIONS
}

OBELISK_SIDES = {
"Desert Obelisk Side 1",
"Desert Obelisk Side 2",
Expand Down Expand Up @@ -450,42 +444,27 @@
"Town Obelisk Side 6",
}

ALL_LOCATIONS_TO_ID: Dict[str, int] = {}

AREA_LOCATION_GROUPS: Dict[str, Set[str]] = {}


def get_id(entity_hex: str) -> int:
"""
Calculates the location ID for any given location
"""

return cast(int, static_witness_logic.ENTITIES_BY_HEX[entity_hex]["id"])


def get_event_name(entity_hex: str) -> str:
def get_event_name(entity_id: int) -> str:
"""
Returns the event name of any given panel.
"""

action = " Opened" if static_witness_logic.ENTITIES_BY_HEX[entity_hex]["entityType"] == "Door" else " Solved"
action = " Opened" if static_witness_logic.ENTITIES_BY_ID[entity_id].entity_type == "Door" else " Solved"

return cast(str, static_witness_logic.ENTITIES_BY_HEX[entity_hex]["checkName"]) + action
return cast(str, static_witness_logic.ENTITIES_BY_ID[entity_id].entity_name) + action


ALL_LOCATIONS_TO_IDS = {
panel_obj["checkName"]: get_id(chex)
for chex, panel_obj in static_witness_logic.ENTITIES_BY_HEX.items()
if panel_obj["id"]
ALL_LOCATIONS_TO_ID = {
panel_obj.entity_name: entity_id
for entity_id, panel_obj in static_witness_logic.ENTITIES_BY_ID.items()
if panel_obj.location_type is not None
}

ALL_LOCATIONS_TO_IDS = dict(
sorted(ALL_LOCATIONS_TO_IDS.items(), key=lambda loc: loc[1])
)

for key, item in ALL_LOCATIONS_TO_IDS.items():
ALL_LOCATIONS_TO_ID[key] = item
ALL_LOCATIONS_TO_ID = dict(sorted(ALL_LOCATIONS_TO_ID.items(), key=lambda item: item[1]))

for loc in ALL_LOCATIONS_TO_IDS:
area = static_witness_logic.ENTITIES_BY_NAME[loc]["area"].name
AREA_LOCATION_GROUPS.setdefault(area, set()).add(loc)
for location_name in ALL_LOCATIONS_TO_ID:
area = static_witness_logic.ENTITIES_BY_NAME[location_name].area.name
AREA_LOCATION_GROUPS.setdefault(area, set()).add(location_name)
Loading
Loading