Subnautica: filler items distribution (#3104)

This commit is contained in:
Fabian Dill
2024-04-14 20:36:25 +02:00
committed by GitHub
parent 7b3727e945
commit 1c14d1107f
3 changed files with 54 additions and 18 deletions

View File

@@ -4,7 +4,7 @@ import logging
import itertools
from typing import List, Dict, Any, cast
from BaseClasses import Region, Entrance, Location, Item, Tutorial, ItemClassification
from BaseClasses import Region, Location, Item, Tutorial, ItemClassification
from worlds.AutoWorld import World, WebWorld
from . import items
from . import locations
@@ -42,14 +42,16 @@ class SubnauticaWorld(World):
item_name_to_id = {data.name: item_id for item_id, data in items.item_table.items()}
location_name_to_id = all_locations
option_definitions = options.option_definitions
options_dataclass = options.SubnauticaOptions
options: options.SubnauticaOptions
data_version = 10
required_client_version = (0, 4, 1)
creatures_to_scan: List[str]
def generate_early(self) -> None:
if not self.options.filler_items_distribution.weights_pair[1][-1]:
raise Exception("Filler Items Distribution needs at least one positive weight.")
if self.options.early_seaglide:
self.multiworld.local_early_items[self.player]["Seaglide Fragment"] = 2
@@ -98,7 +100,7 @@ class SubnauticaWorld(World):
planet_region
]
# refer to Rules.py
# refer to rules.py
set_rules = set_rules
def create_items(self):
@@ -129,7 +131,7 @@ class SubnauticaWorld(World):
extras -= group_amount
for item_name in self.random.sample(
# list of high-count important fragments as priority filler
# list of high-count important fragments as priority filler
[
"Cyclops Engine Fragment",
"Cyclops Hull Fragment",
@@ -140,7 +142,7 @@ class SubnauticaWorld(World):
"Modification Station Fragment",
"Moonpool Fragment",
"Laser Cutter Fragment",
],
],
k=min(extras, 9)):
item = self.create_item(item_name)
pool.append(item)
@@ -176,7 +178,10 @@ class SubnauticaWorld(World):
item_id, player=self.player)
def get_filler_item_name(self) -> str:
return item_table[self.multiworld.random.choice(items_by_type[ItemType.resource])].name
item_names, cum_item_weights = self.options.filler_items_distribution.weights_pair
return self.random.choices(item_names,
cum_weights=cum_item_weights,
k=1)[0]
class SubnauticaLocation(Location):