mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
Subnautica: updates (#759)
* Subnautica: add more goals * Subnautica: fix wrongly positioned Databox * Subnautica: allow techs to remain vanilla * Subnautica: make zipimport compatible * Subnautica: force two Seaglide fragments into local sphere 1
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
import logging
|
||||
from typing import List, Dict, Any
|
||||
|
||||
from BaseClasses import Region, Entrance, Location, Item, Tutorial, ItemClassification, RegionType
|
||||
from worlds.AutoWorld import World, WebWorld
|
||||
from . import Items
|
||||
from . import Locations
|
||||
from . import Options
|
||||
from .Items import item_table
|
||||
from .Rules import set_rules
|
||||
|
||||
logger = logging.getLogger("Subnautica")
|
||||
|
||||
from .Locations import lookup_name_to_id as locations_lookup_name_to_id
|
||||
from .Items import item_table, lookup_name_to_item, advancement_item_names
|
||||
from .Items import lookup_name_to_id as items_lookup_name_to_id
|
||||
|
||||
from .Regions import create_regions
|
||||
from .Rules import set_rules
|
||||
from .Options import options
|
||||
|
||||
from BaseClasses import Region, Entrance, Location, MultiWorld, Item, Tutorial, ItemClassification, RegionType
|
||||
from ..AutoWorld import World, WebWorld
|
||||
|
||||
|
||||
class SubnaticaWeb(WebWorld):
|
||||
tutorials = [Tutorial(
|
||||
@@ -34,34 +32,51 @@ class SubnauticaWorld(World):
|
||||
game: str = "Subnautica"
|
||||
web = SubnaticaWeb()
|
||||
|
||||
item_name_to_id = items_lookup_name_to_id
|
||||
location_name_to_id = locations_lookup_name_to_id
|
||||
options = options
|
||||
item_name_to_id = {data["name"]: item_id for item_id, data in Items.item_table.items()}
|
||||
location_name_to_id = {data["name"]: loc_id for loc_id, data in Locations.location_table.items()}
|
||||
options = Options.options
|
||||
|
||||
data_version = 2
|
||||
required_client_version = (0, 1, 9)
|
||||
required_client_version = (0, 3, 3)
|
||||
|
||||
prefill_items: List[Item]
|
||||
|
||||
def generate_early(self) -> None:
|
||||
self.prefill_items = [
|
||||
self.create_item("Seaglide Fragment"),
|
||||
self.create_item("Seaglide Fragment")
|
||||
]
|
||||
|
||||
def create_regions(self):
|
||||
self.world.regions += [
|
||||
self.create_region("Menu", None, ["Lifepod 5"]),
|
||||
self.create_region("Planet 4546B",
|
||||
Locations.events + [location["name"] for location in Locations.location_table.values()])
|
||||
]
|
||||
|
||||
# refer to Rules.py
|
||||
set_rules = set_rules
|
||||
|
||||
def generate_basic(self):
|
||||
# Link regions
|
||||
self.world.get_entrance('Lifepod 5', self.player).connect(self.world.get_region('Planet 4546B', self.player))
|
||||
self.world.get_entrance("Lifepod 5", self.player).connect(self.world.get_region("Planet 4546B", self.player))
|
||||
|
||||
# Generate item pool
|
||||
pool = []
|
||||
neptune_launch_platform = None
|
||||
extras = 0
|
||||
valuable = self.world.item_pool[self.player] == "valuable"
|
||||
for item in item_table:
|
||||
valuable = self.world.item_pool[self.player] == Options.ItemPool.option_valuable
|
||||
for item in item_table.values():
|
||||
for i in range(item["count"]):
|
||||
subnautica_item = self.create_item(item["name"])
|
||||
if item["name"] == "Neptune Launch Platform":
|
||||
neptune_launch_platform = subnautica_item
|
||||
elif valuable and not item["progression"]:
|
||||
self.world.push_precollected(subnautica_item)
|
||||
elif valuable and ItemClassification.filler == item["classification"]:
|
||||
extras += 1
|
||||
else:
|
||||
pool.append(subnautica_item)
|
||||
|
||||
for item_name in self.world.random.choices(sorted(advancement_item_names - {"Neptune Launch Platform"}),
|
||||
for item_name in self.world.random.choices(sorted(Items.advancement_item_names - {"Neptune Launch Platform"}),
|
||||
k=extras):
|
||||
item = self.create_item(item_name)
|
||||
item.classification = ItemClassification.filler # as it's an extra, just fast-fill it somewhere
|
||||
@@ -72,39 +87,57 @@ class SubnauticaWorld(World):
|
||||
# Victory item
|
||||
self.world.get_location("Aurora - Captain Data Terminal", self.player).place_locked_item(
|
||||
neptune_launch_platform)
|
||||
self.world.get_location("Neptune Launch", self.player).place_locked_item(
|
||||
SubnauticaItem("Victory", ItemClassification.progression, None, player=self.player))
|
||||
for event in Locations.events:
|
||||
self.world.get_location(event, self.player).place_locked_item(
|
||||
SubnauticaItem(event, ItemClassification.progression, None, player=self.player))
|
||||
# make the goal event the victory "item"
|
||||
self.world.get_location(self.world.goal[self.player].get_event_name(), self.player).item.name = "Victory"
|
||||
|
||||
def set_rules(self):
|
||||
set_rules(self.world, self.player)
|
||||
def fill_slot_data(self) -> Dict[str, Any]:
|
||||
goal: Options.Goal = self.world.goal[self.player]
|
||||
item_pool: Options.ItemPool = self.world.item_pool[self.player]
|
||||
vanilla_tech: List[str] = []
|
||||
if item_pool == Options.ItemPool.option_valuable:
|
||||
for item in Items.item_table.values():
|
||||
if item["classification"] == ItemClassification.filler:
|
||||
vanilla_tech.append(item["tech_type"])
|
||||
|
||||
def create_regions(self):
|
||||
create_regions(self.world, self.player)
|
||||
slot_data: Dict[str, Any] = {
|
||||
"goal": goal.current_key,
|
||||
"vanilla_tech": vanilla_tech,
|
||||
}
|
||||
|
||||
def fill_slot_data(self):
|
||||
slot_data = {}
|
||||
return slot_data
|
||||
|
||||
def create_item(self, name: str) -> Item:
|
||||
item = lookup_name_to_item[name]
|
||||
item_id: int = self.item_name_to_id[name]
|
||||
|
||||
return SubnauticaItem(name,
|
||||
ItemClassification.progression if item["progression"] else ItemClassification.filler,
|
||||
item["id"], player=self.player)
|
||||
item_table[item_id]["classification"],
|
||||
item_id, player=self.player)
|
||||
|
||||
def create_region(self, name: str, locations=None, exits=None):
|
||||
ret = Region(name, RegionType.Generic, name, self.player)
|
||||
ret.world = self.world
|
||||
if locations:
|
||||
for location in locations:
|
||||
loc_id = self.location_name_to_id.get(location, None)
|
||||
location = SubnauticaLocation(self.player, location, loc_id, ret)
|
||||
ret.locations.append(location)
|
||||
if exits:
|
||||
for region_exit in exits:
|
||||
ret.exits.append(Entrance(self.player, region_exit, ret))
|
||||
return ret
|
||||
|
||||
def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None):
|
||||
ret = Region(name, RegionType.Generic, name, player)
|
||||
ret.world = world
|
||||
if locations:
|
||||
for location in locations:
|
||||
loc_id = locations_lookup_name_to_id.get(location, 0)
|
||||
location = SubnauticaLocation(player, location, loc_id, ret)
|
||||
ret.locations.append(location)
|
||||
if exits:
|
||||
for exit in exits:
|
||||
ret.exits.append(Entrance(player, exit, ret))
|
||||
def get_pre_fill_items(self) -> List[Item]:
|
||||
return self.prefill_items
|
||||
|
||||
return ret
|
||||
def pre_fill(self) -> None:
|
||||
reachable = self.world.get_reachable_locations(player=self.player)
|
||||
self.world.random.shuffle(reachable)
|
||||
items = self.prefill_items.copy()
|
||||
for item in items:
|
||||
reachable.pop().place_locked_item(item)
|
||||
|
||||
|
||||
class SubnauticaLocation(Location):
|
||||
@@ -112,4 +145,4 @@ class SubnauticaLocation(Location):
|
||||
|
||||
|
||||
class SubnauticaItem(Item):
|
||||
game = "Subnautica"
|
||||
game: str = "Subnautica"
|
||||
|
Reference in New Issue
Block a user