2021-08-29 18:02:02 +00:00
|
|
|
|
import string
|
2023-01-03 01:26:34 +00:00
|
|
|
|
|
2023-11-22 15:20:32 +00:00
|
|
|
|
from .items import RiskOfRainItem, item_table, item_pool_weights, offset, filler_table, environment_offset
|
|
|
|
|
from .locations import RiskOfRainLocation, item_pickups, get_locations
|
|
|
|
|
from .rules import set_rules
|
|
|
|
|
from .ror2environments import environment_vanilla_table, environment_vanilla_orderedstages_table, \
|
|
|
|
|
environment_sotv_orderedstages_table, environment_sotv_table, collapse_dict_list_vertical, shift_by_offset
|
|
|
|
|
|
|
|
|
|
from BaseClasses import Item, ItemClassification, Tutorial
|
|
|
|
|
from .options import ItemWeights, ROR2Options
|
2023-02-05 20:51:03 +00:00
|
|
|
|
from worlds.AutoWorld import World, WebWorld
|
2023-11-22 15:20:32 +00:00
|
|
|
|
from .regions import create_explore_regions, create_classic_regions
|
|
|
|
|
from typing import List, Dict, Any
|
2021-08-29 18:02:02 +00:00
|
|
|
|
|
|
|
|
|
|
2022-05-11 18:05:53 +00:00
|
|
|
|
class RiskOfWeb(WebWorld):
|
|
|
|
|
tutorials = [Tutorial(
|
|
|
|
|
"Multiworld Setup Guide",
|
|
|
|
|
"A guide to setting up the Risk of Rain 2 integration for Archipelago multiworld games.",
|
|
|
|
|
"English",
|
|
|
|
|
"setup_en.md",
|
|
|
|
|
"setup/en",
|
2023-11-22 15:20:32 +00:00
|
|
|
|
["Ijwu", "Kindasneaki"]
|
2022-05-11 18:05:53 +00:00
|
|
|
|
)]
|
|
|
|
|
|
|
|
|
|
|
2021-08-29 18:02:02 +00:00
|
|
|
|
class RiskOfRainWorld(World):
|
2021-09-01 00:45:09 +00:00
|
|
|
|
"""
|
|
|
|
|
Escape a chaotic alien planet by fighting through hordes of frenzied monsters – with your friends, or on your own.
|
|
|
|
|
Combine loot in surprising ways and master each character until you become the havoc you feared upon your
|
|
|
|
|
first crash landing.
|
|
|
|
|
"""
|
2023-10-10 20:30:20 +00:00
|
|
|
|
game = "Risk of Rain 2"
|
|
|
|
|
options_dataclass = ROR2Options
|
|
|
|
|
options: ROR2Options
|
2021-08-29 18:02:02 +00:00
|
|
|
|
topology_present = False
|
2023-11-22 15:20:32 +00:00
|
|
|
|
item_name_to_id = {name: data.code for name, data in item_table.items()}
|
|
|
|
|
item_name_groups = {
|
|
|
|
|
"Stages": {name for name, data in item_table.items() if data.category == "Stage"},
|
|
|
|
|
"Environments": {name for name, data in item_table.items() if data.category == "Environment"},
|
|
|
|
|
"Upgrades": {name for name, data in item_table.items() if data.category == "Upgrade"},
|
|
|
|
|
"Fillers": {name for name, data in item_table.items() if data.category == "Filler"},
|
|
|
|
|
"Traps": {name for name, data in item_table.items() if data.category == "Trap"},
|
|
|
|
|
}
|
2022-08-20 23:09:35 +00:00
|
|
|
|
location_name_to_id = item_pickups
|
2021-08-29 18:02:02 +00:00
|
|
|
|
|
2024-04-09 19:14:18 +00:00
|
|
|
|
data_version = 9
|
|
|
|
|
required_client_version = (0, 4, 5)
|
2022-05-11 18:05:53 +00:00
|
|
|
|
web = RiskOfWeb()
|
2022-08-20 23:09:35 +00:00
|
|
|
|
total_revivals: int
|
2021-08-29 18:02:02 +00:00
|
|
|
|
|
2022-08-20 23:09:35 +00:00
|
|
|
|
def generate_early(self) -> None:
|
|
|
|
|
# figure out how many revivals should exist in the pool
|
2023-10-10 20:30:20 +00:00
|
|
|
|
if self.options.goal == "classic":
|
|
|
|
|
total_locations = self.options.total_locations.value
|
2023-02-05 20:51:03 +00:00
|
|
|
|
else:
|
|
|
|
|
total_locations = len(
|
2023-11-22 15:20:32 +00:00
|
|
|
|
get_locations(
|
2023-10-10 20:30:20 +00:00
|
|
|
|
chests=self.options.chests_per_stage.value,
|
|
|
|
|
shrines=self.options.shrines_per_stage.value,
|
|
|
|
|
scavengers=self.options.scavengers_per_stage.value,
|
|
|
|
|
scanners=self.options.scanner_per_stage.value,
|
|
|
|
|
altars=self.options.altars_per_stage.value,
|
2023-11-22 15:20:32 +00:00
|
|
|
|
dlc_sotv=bool(self.options.dlc_sotv.value)
|
2023-02-05 20:51:03 +00:00
|
|
|
|
)
|
|
|
|
|
)
|
2023-10-10 20:30:20 +00:00
|
|
|
|
self.total_revivals = int(self.options.total_revivals.value / 100 *
|
2023-02-05 20:51:03 +00:00
|
|
|
|
total_locations)
|
2023-10-10 20:30:20 +00:00
|
|
|
|
if self.options.start_with_revive:
|
2023-02-05 20:51:03 +00:00
|
|
|
|
self.total_revivals -= 1
|
2023-11-22 15:20:32 +00:00
|
|
|
|
if self.options.victory == "voidling" and not self.options.dlc_sotv:
|
|
|
|
|
self.options.victory.value = self.options.victory.option_any
|
|
|
|
|
|
|
|
|
|
def create_regions(self) -> None:
|
|
|
|
|
|
|
|
|
|
if self.options.goal == "classic":
|
|
|
|
|
# classic mode
|
|
|
|
|
create_classic_regions(self)
|
|
|
|
|
else:
|
|
|
|
|
# explore mode
|
|
|
|
|
create_explore_regions(self)
|
|
|
|
|
|
|
|
|
|
self.create_events()
|
2022-08-20 23:09:35 +00:00
|
|
|
|
|
2023-02-05 20:51:03 +00:00
|
|
|
|
def create_items(self) -> None:
|
2021-08-29 18:02:02 +00:00
|
|
|
|
# shortcut for starting_inventory... The start_with_revive option lets you start with a Dio's Best Friend
|
2023-10-10 20:30:20 +00:00
|
|
|
|
if self.options.start_with_revive:
|
2022-11-01 02:41:21 +00:00
|
|
|
|
self.multiworld.push_precollected(self.multiworld.create_item("Dio's Best Friend", self.player))
|
2021-08-29 18:02:02 +00:00
|
|
|
|
|
2023-02-05 20:51:03 +00:00
|
|
|
|
environments_pool = {}
|
|
|
|
|
# only mess with the environments if they are set as items
|
2023-10-10 20:30:20 +00:00
|
|
|
|
if self.options.goal == "explore":
|
2023-02-05 20:51:03 +00:00
|
|
|
|
|
2024-04-09 19:14:18 +00:00
|
|
|
|
# check to see if the user doesn't want to use stages, and to figure out what type of stages are being used.
|
|
|
|
|
if not self.options.require_stages:
|
|
|
|
|
if not self.options.progressive_stages:
|
|
|
|
|
self.multiworld.push_precollected(self.multiworld.create_item("Stage 1", self.player))
|
|
|
|
|
self.multiworld.push_precollected(self.multiworld.create_item("Stage 2", self.player))
|
|
|
|
|
self.multiworld.push_precollected(self.multiworld.create_item("Stage 3", self.player))
|
|
|
|
|
self.multiworld.push_precollected(self.multiworld.create_item("Stage 4", self.player))
|
|
|
|
|
else:
|
|
|
|
|
for _ in range(4):
|
|
|
|
|
self.multiworld.push_precollected(self.multiworld.create_item("Progressive Stage", self.player))
|
|
|
|
|
|
2023-02-05 20:51:03 +00:00
|
|
|
|
# figure out all available ordered stages for each tier
|
|
|
|
|
environment_available_orderedstages_table = environment_vanilla_orderedstages_table
|
2023-10-10 20:30:20 +00:00
|
|
|
|
if self.options.dlc_sotv:
|
2023-11-22 15:20:32 +00:00
|
|
|
|
environment_available_orderedstages_table = \
|
|
|
|
|
collapse_dict_list_vertical(environment_available_orderedstages_table,
|
|
|
|
|
environment_sotv_orderedstages_table)
|
2023-02-05 20:51:03 +00:00
|
|
|
|
|
2023-11-22 15:20:32 +00:00
|
|
|
|
environments_pool = shift_by_offset(environment_vanilla_table, environment_offset)
|
2023-02-05 20:51:03 +00:00
|
|
|
|
|
2023-10-10 20:30:20 +00:00
|
|
|
|
if self.options.dlc_sotv:
|
2023-11-22 15:20:32 +00:00
|
|
|
|
environment_offset_table = shift_by_offset(environment_sotv_table, environment_offset)
|
2023-02-05 20:51:03 +00:00
|
|
|
|
environments_pool = {**environments_pool, **environment_offset_table}
|
2023-12-10 18:12:46 +00:00
|
|
|
|
# percollect starting environment for stage 1
|
|
|
|
|
unlock = self.random.choices(list(environment_available_orderedstages_table[0].keys()), k=1)
|
|
|
|
|
self.multiworld.push_precollected(self.create_item(unlock[0]))
|
|
|
|
|
environments_pool.pop(unlock[0])
|
2023-02-05 20:51:03 +00:00
|
|
|
|
|
2021-08-29 18:02:02 +00:00
|
|
|
|
# Generate item pool
|
2023-11-22 15:20:32 +00:00
|
|
|
|
itempool: List[str] = ["Beads of Fealty", "Radar Scanner"]
|
2021-08-29 18:02:02 +00:00
|
|
|
|
# Add revive items for the player
|
2022-08-20 23:09:35 +00:00
|
|
|
|
itempool += ["Dio's Best Friend"] * self.total_revivals
|
2021-08-29 18:02:02 +00:00
|
|
|
|
|
2023-02-05 20:51:03 +00:00
|
|
|
|
for env_name, _ in environments_pool.items():
|
|
|
|
|
itempool += [env_name]
|
|
|
|
|
|
2023-10-10 20:30:20 +00:00
|
|
|
|
if self.options.goal == "classic":
|
2023-02-05 20:51:03 +00:00
|
|
|
|
# classic mode
|
2023-10-10 20:30:20 +00:00
|
|
|
|
total_locations = self.options.total_locations.value
|
2023-02-05 20:51:03 +00:00
|
|
|
|
else:
|
|
|
|
|
# explore mode
|
2024-04-09 19:14:18 +00:00
|
|
|
|
|
|
|
|
|
# Add Stage items to the pool
|
|
|
|
|
if self.options.require_stages:
|
|
|
|
|
itempool += ["Stage 1", "Stage 2", "Stage 3", "Stage 4"] if not self.options.progressive_stages else \
|
|
|
|
|
["Progressive Stage"] * 4
|
|
|
|
|
|
2023-02-05 20:51:03 +00:00
|
|
|
|
total_locations = len(
|
2023-11-22 15:20:32 +00:00
|
|
|
|
get_locations(
|
2023-10-10 20:30:20 +00:00
|
|
|
|
chests=self.options.chests_per_stage.value,
|
|
|
|
|
shrines=self.options.shrines_per_stage.value,
|
|
|
|
|
scavengers=self.options.scavengers_per_stage.value,
|
|
|
|
|
scanners=self.options.scanner_per_stage.value,
|
|
|
|
|
altars=self.options.altars_per_stage.value,
|
2023-11-22 15:20:32 +00:00
|
|
|
|
dlc_sotv=bool(self.options.dlc_sotv.value)
|
2023-02-05 20:51:03 +00:00
|
|
|
|
)
|
|
|
|
|
)
|
2023-08-16 14:21:07 +00:00
|
|
|
|
# Create junk items
|
2023-11-22 15:20:32 +00:00
|
|
|
|
junk_pool = self.create_junk_pool()
|
2021-08-29 18:02:02 +00:00
|
|
|
|
# Fill remaining items with randomly generated junk
|
2023-11-22 15:20:32 +00:00
|
|
|
|
filler = self.random.choices(*zip(*junk_pool.items()), k=total_locations - len(itempool))
|
|
|
|
|
itempool.extend(filler)
|
2021-08-29 18:02:02 +00:00
|
|
|
|
|
|
|
|
|
# Convert itempool into real items
|
2023-11-22 15:20:32 +00:00
|
|
|
|
self.multiworld.itempool += map(self.create_item, itempool)
|
2021-08-29 18:02:02 +00:00
|
|
|
|
|
2023-11-22 15:20:32 +00:00
|
|
|
|
def create_junk_pool(self) -> Dict[str, int]:
|
2023-08-16 14:21:07 +00:00
|
|
|
|
# if presets are enabled generate junk_pool from the selected preset
|
2023-10-10 20:30:20 +00:00
|
|
|
|
pool_option = self.options.item_weights.value
|
2023-08-16 14:21:07 +00:00
|
|
|
|
junk_pool: Dict[str, int] = {}
|
2023-10-10 20:30:20 +00:00
|
|
|
|
if self.options.item_pool_presets:
|
2023-08-16 14:21:07 +00:00
|
|
|
|
# generate chaos weights if the preset is chosen
|
|
|
|
|
if pool_option == ItemWeights.option_chaos:
|
|
|
|
|
for name, max_value in item_pool_weights[pool_option].items():
|
2023-11-22 15:20:32 +00:00
|
|
|
|
junk_pool[name] = self.random.randint(0, max_value)
|
2023-08-16 14:21:07 +00:00
|
|
|
|
else:
|
|
|
|
|
junk_pool = item_pool_weights[pool_option].copy()
|
|
|
|
|
else: # generate junk pool from user created presets
|
|
|
|
|
junk_pool = {
|
2023-10-10 20:30:20 +00:00
|
|
|
|
"Item Scrap, Green": self.options.green_scrap.value,
|
|
|
|
|
"Item Scrap, Red": self.options.red_scrap.value,
|
|
|
|
|
"Item Scrap, Yellow": self.options.yellow_scrap.value,
|
|
|
|
|
"Item Scrap, White": self.options.white_scrap.value,
|
|
|
|
|
"Common Item": self.options.common_item.value,
|
|
|
|
|
"Uncommon Item": self.options.uncommon_item.value,
|
|
|
|
|
"Legendary Item": self.options.legendary_item.value,
|
|
|
|
|
"Boss Item": self.options.boss_item.value,
|
|
|
|
|
"Lunar Item": self.options.lunar_item.value,
|
|
|
|
|
"Void Item": self.options.void_item.value,
|
2023-11-22 15:20:32 +00:00
|
|
|
|
"Equipment": self.options.equipment.value,
|
|
|
|
|
"Money": self.options.money.value,
|
|
|
|
|
"Lunar Coin": self.options.lunar_coin.value,
|
|
|
|
|
"1000 Exp": self.options.experience.value,
|
|
|
|
|
"Mountain Trap": self.options.mountain_trap.value,
|
|
|
|
|
"Time Warp Trap": self.options.time_warp_trap.value,
|
|
|
|
|
"Combat Trap": self.options.combat_trap.value,
|
|
|
|
|
"Teleport Trap": self.options.teleport_trap.value,
|
2023-08-16 14:21:07 +00:00
|
|
|
|
}
|
2023-11-22 15:20:32 +00:00
|
|
|
|
# remove trap items from the pool (excluding lunar items)
|
|
|
|
|
if not self.options.enable_trap:
|
|
|
|
|
junk_pool.pop("Mountain Trap")
|
|
|
|
|
junk_pool.pop("Time Warp Trap")
|
|
|
|
|
junk_pool.pop("Combat Trap")
|
|
|
|
|
junk_pool.pop("Teleport Trap")
|
|
|
|
|
# remove lunar items from the pool
|
2023-10-10 20:30:20 +00:00
|
|
|
|
if not (self.options.enable_lunar or pool_option == ItemWeights.option_lunartic):
|
2023-08-16 14:21:07 +00:00
|
|
|
|
junk_pool.pop("Lunar Item")
|
|
|
|
|
# remove void items from the pool
|
2023-10-10 20:30:20 +00:00
|
|
|
|
if not (self.options.dlc_sotv or pool_option == ItemWeights.option_void):
|
2023-08-16 14:21:07 +00:00
|
|
|
|
junk_pool.pop("Void Item")
|
|
|
|
|
|
|
|
|
|
return junk_pool
|
|
|
|
|
|
2023-11-22 15:20:32 +00:00
|
|
|
|
def create_item(self, name: str) -> Item:
|
|
|
|
|
data = item_table[name]
|
|
|
|
|
return RiskOfRainItem(name, data.item_type, data.code, self.player)
|
2022-08-20 23:09:35 +00:00
|
|
|
|
|
2023-11-22 15:20:32 +00:00
|
|
|
|
def set_rules(self) -> None:
|
|
|
|
|
set_rules(self)
|
2022-08-20 23:09:35 +00:00
|
|
|
|
|
2023-11-22 15:20:32 +00:00
|
|
|
|
def get_filler_item_name(self) -> str:
|
|
|
|
|
weights = [data.weight for data in filler_table.values()]
|
|
|
|
|
filler = self.multiworld.random.choices([filler for filler in filler_table.keys()], weights,
|
|
|
|
|
k=1)[0]
|
|
|
|
|
return filler
|
2021-08-29 18:02:02 +00:00
|
|
|
|
|
2023-11-22 15:20:32 +00:00
|
|
|
|
def fill_slot_data(self) -> Dict[str, Any]:
|
|
|
|
|
options_dict = self.options.as_dict("item_pickup_step", "shrine_use_step", "goal", "victory", "total_locations",
|
|
|
|
|
"chests_per_stage", "shrines_per_stage", "scavengers_per_stage",
|
|
|
|
|
"scanner_per_stage", "altars_per_stage", "total_revivals",
|
2024-04-09 19:14:18 +00:00
|
|
|
|
"start_with_revive", "final_stage_death", "death_link", "require_stages",
|
|
|
|
|
"progressive_stages", casing="camel")
|
2021-08-29 18:02:02 +00:00
|
|
|
|
return {
|
2023-10-10 20:30:20 +00:00
|
|
|
|
**options_dict,
|
2023-11-22 15:20:32 +00:00
|
|
|
|
"seed": "".join(self.random.choice(string.digits) for _ in range(16)),
|
|
|
|
|
"offset": offset
|
2021-08-29 18:02:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-22 15:20:32 +00:00
|
|
|
|
def create_events(self) -> None:
|
|
|
|
|
total_locations = self.options.total_locations.value
|
|
|
|
|
num_of_events = total_locations // 25
|
|
|
|
|
if total_locations / 25 == num_of_events:
|
|
|
|
|
num_of_events -= 1
|
|
|
|
|
world_region = self.multiworld.get_region("Petrichor V", self.player)
|
|
|
|
|
if self.options.goal == "classic":
|
|
|
|
|
# classic mode
|
|
|
|
|
# only setup Pickups when using classic_mode
|
|
|
|
|
for i in range(num_of_events):
|
|
|
|
|
event_loc = RiskOfRainLocation(self.player, f"Pickup{(i + 1) * 25}", None, world_region)
|
|
|
|
|
event_loc.place_locked_item(
|
|
|
|
|
RiskOfRainItem(f"Pickup{(i + 1) * 25}", ItemClassification.progression, None,
|
|
|
|
|
self.player))
|
|
|
|
|
event_loc.access_rule = \
|
|
|
|
|
lambda state, i=i: state.can_reach(f"ItemPickup{((i + 1) * 25) - 1}", "Location", self.player)
|
|
|
|
|
world_region.locations.append(event_loc)
|
|
|
|
|
else:
|
|
|
|
|
# explore mode
|
|
|
|
|
event_region = self.multiworld.get_region("OrderedStage_5", self.player)
|
|
|
|
|
event_loc = RiskOfRainLocation(self.player, "Stage 5", None, event_region)
|
|
|
|
|
event_loc.place_locked_item(RiskOfRainItem("Stage 5", ItemClassification.progression, None, self.player))
|
2023-02-05 20:51:03 +00:00
|
|
|
|
event_loc.show_in_spoiler = False
|
|
|
|
|
event_region.locations.append(event_loc)
|
2023-11-22 15:20:32 +00:00
|
|
|
|
event_loc.access_rule = lambda state: state.has("Sky Meadow", self.player)
|
2022-03-23 21:22:31 +00:00
|
|
|
|
|
2023-11-22 15:20:32 +00:00
|
|
|
|
victory_region = self.multiworld.get_region("Victory", self.player)
|
|
|
|
|
victory_event = RiskOfRainLocation(self.player, "Victory", None, victory_region)
|
|
|
|
|
victory_event.place_locked_item(RiskOfRainItem("Victory", ItemClassification.progression, None, self.player))
|
|
|
|
|
victory_region.locations.append(victory_event)
|