Skip to content

Commit

Permalink
Merge pull request ArchipelagoMW#6 from heinermann/noita
Browse files Browse the repository at this point in the history
Limit the generation of chest locations
  • Loading branch information
DaftBrit authored Dec 14, 2022
2 parents 497cce1 + e04d5e6 commit 57fb29c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion worlds/noita/Events.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def create_victory_events(world: MultiWorld, player: int) -> None:


def create_chest_events(world: MultiWorld, player: int) -> None:
total_locations = world.total_locations[player].value
total_locations = world.total_locations[player].value - Locations.num_static_locations

# Iterates all our generated chests and makes sure that they are accessible in a specific
# logical order (?) TODO: Revisit and confirm this
Expand Down
2 changes: 2 additions & 0 deletions worlds/noita/Locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ class NoitaLocation(Location):
},
}

num_static_locations = sum([len(locs) for locs in location_region_mapping.values()]) - TotalLocations.range_end

location_name_to_id: Dict[str, int] = {}
for location_group in location_region_mapping.values():
location_name_to_id.update(location_group)
26 changes: 16 additions & 10 deletions worlds/noita/Regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@
import itertools
from typing import Dict, List, Set
from BaseClasses import Region, Entrance, LocationProgressType, RegionType, MultiWorld
from . import Locations
from . import Locations, Items


# Creates a new Region with the locations found in `location_region_mapping`
# and adds them to the world.
def create_region(world: MultiWorld, player: int, region_name: str) -> Region:
new_region = Region(region_name, RegionType.Generic, region_name, player, world)

# Here we create and assign locations to the region
for location_name, location_id in Locations.location_region_mapping.get(region_name, {}).items():
location = Locations.NoitaLocation(player, location_name, location_id, new_region)
# Chests hack, don't add more locations than we requested
if region_name == "Forest":
total_locations = world.total_locations[player].value - Locations.num_static_locations

# TODO this is a hack.
# If it's not the region with all the shitty chests, increases the priority of important items.
# This way people know they can find their items by checking fixed locations instead of leaving it up to chance.
if region_name != "Forest":
location.progress_type = LocationProgressType.PRIORITY
for i in range(total_locations):
location_name = f"Chest{i+1}"
location_id = 110000+i

new_region.locations.append(location)
location = Locations.NoitaLocation(player, location_name, location_id, new_region)
location.progress_type = LocationProgressType.EXCLUDED

new_region.locations.append(location)
else:
# Here we create and assign locations to the region
for location_name, location_id in Locations.location_region_mapping.get(region_name, {}).items():
location = Locations.NoitaLocation(player, location_name, location_id, new_region)
new_region.locations.append(location)

return new_region

Expand Down

0 comments on commit 57fb29c

Please sign in to comment.