2021-08-29 14:02:02 -04:00
|
|
|
|
import string
|
2023-01-02 19:26:34 -06:00
|
|
|
|
|
2023-02-05 13:51:03 -07:00
|
|
|
|
from .Items import RiskOfRainItem, item_table, item_pool_weights, environment_offest
|
|
|
|
|
from .Locations import RiskOfRainLocation, get_classic_item_pickups, item_pickups, orderedstage_location
|
2021-08-29 14:02:02 -04:00
|
|
|
|
from .Rules import set_rules
|
2023-02-05 13:51:03 -07:00
|
|
|
|
from .RoR2Environments import *
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
2023-02-13 18:06:43 -06:00
|
|
|
|
from BaseClasses import Region, Entrance, Item, ItemClassification, MultiWorld, Tutorial
|
2023-10-10 15:30:20 -05:00
|
|
|
|
from .Options import ItemWeights, ROR2Options
|
2023-02-05 13:51:03 -07:00
|
|
|
|
from worlds.AutoWorld import World, WebWorld
|
|
|
|
|
from .Regions import create_regions
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
|
|
|
|
|
2022-05-11 13:05:53 -05: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",
|
|
|
|
|
["Ijwu"]
|
|
|
|
|
)]
|
|
|
|
|
|
|
|
|
|
|
2021-08-29 14:02:02 -04:00
|
|
|
|
class RiskOfRainWorld(World):
|
2021-08-31 20:45:09 -04: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 15:30:20 -05:00
|
|
|
|
game = "Risk of Rain 2"
|
|
|
|
|
options_dataclass = ROR2Options
|
|
|
|
|
options: ROR2Options
|
2021-08-29 14:02:02 -04:00
|
|
|
|
topology_present = False
|
|
|
|
|
|
2021-09-01 16:46:44 +02:00
|
|
|
|
item_name_to_id = item_table
|
2022-08-20 18:09:35 -05:00
|
|
|
|
location_name_to_id = item_pickups
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
2023-06-26 22:47:52 -06:00
|
|
|
|
data_version = 7
|
|
|
|
|
required_client_version = (0, 4, 2)
|
2022-05-11 13:05:53 -05:00
|
|
|
|
web = RiskOfWeb()
|
2022-08-20 18:09:35 -05:00
|
|
|
|
total_revivals: int
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
2023-08-16 08:21:07 -06:00
|
|
|
|
def __init__(self, multiworld: "MultiWorld", player: int):
|
|
|
|
|
super().__init__(multiworld, player)
|
|
|
|
|
self.junk_pool: Dict[str, int] = {}
|
|
|
|
|
|
2022-08-20 18:09:35 -05:00
|
|
|
|
def generate_early(self) -> None:
|
|
|
|
|
# figure out how many revivals should exist in the pool
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if self.options.goal == "classic":
|
|
|
|
|
total_locations = self.options.total_locations.value
|
2023-02-05 13:51:03 -07:00
|
|
|
|
else:
|
|
|
|
|
total_locations = len(
|
|
|
|
|
orderedstage_location.get_locations(
|
2023-10-10 15:30:20 -05: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,
|
|
|
|
|
dlc_sotv=self.options.dlc_sotv.value
|
2023-02-05 13:51:03 -07:00
|
|
|
|
)
|
|
|
|
|
)
|
2023-10-10 15:30:20 -05:00
|
|
|
|
self.total_revivals = int(self.options.total_revivals.value / 100 *
|
2023-02-05 13:51:03 -07:00
|
|
|
|
total_locations)
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if self.options.start_with_revive:
|
2023-02-05 13:51:03 -07:00
|
|
|
|
self.total_revivals -= 1
|
2022-08-20 18:09:35 -05:00
|
|
|
|
|
2023-02-05 13:51:03 -07:00
|
|
|
|
def create_items(self) -> None:
|
2021-08-29 14:02:02 -04:00
|
|
|
|
# shortcut for starting_inventory... The start_with_revive option lets you start with a Dio's Best Friend
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if self.options.start_with_revive:
|
2022-10-31 21:41:21 -05:00
|
|
|
|
self.multiworld.push_precollected(self.multiworld.create_item("Dio's Best Friend", self.player))
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
2023-02-05 13:51:03 -07:00
|
|
|
|
environments_pool = {}
|
|
|
|
|
# only mess with the environments if they are set as items
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if self.options.goal == "explore":
|
2023-02-05 13:51:03 -07:00
|
|
|
|
|
|
|
|
|
# figure out all available ordered stages for each tier
|
|
|
|
|
environment_available_orderedstages_table = environment_vanilla_orderedstages_table
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if self.options.dlc_sotv:
|
2023-02-05 13:51:03 -07:00
|
|
|
|
environment_available_orderedstages_table = collapse_dict_list_vertical(environment_available_orderedstages_table, environment_sotv_orderedstages_table)
|
|
|
|
|
|
|
|
|
|
environments_pool = shift_by_offset(environment_vanilla_table, environment_offest)
|
|
|
|
|
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if self.options.dlc_sotv:
|
2023-02-05 13:51:03 -07:00
|
|
|
|
environment_offset_table = shift_by_offset(environment_sotv_table, environment_offest)
|
|
|
|
|
environments_pool = {**environments_pool, **environment_offset_table}
|
2023-10-10 15:30:20 -05:00
|
|
|
|
environments_to_precollect = 5 if self.options.begin_with_loop else 1
|
2023-02-05 13:51:03 -07:00
|
|
|
|
# percollect environments for each stage (or just stage 1)
|
|
|
|
|
for i in range(environments_to_precollect):
|
|
|
|
|
unlock = self.multiworld.random.choices(list(environment_available_orderedstages_table[i].keys()), k=1)
|
|
|
|
|
self.multiworld.push_precollected(self.create_item(unlock[0]))
|
|
|
|
|
environments_pool.pop(unlock[0])
|
|
|
|
|
|
2021-08-29 14:02:02 -04:00
|
|
|
|
# Generate item pool
|
2022-08-20 18:09:35 -05:00
|
|
|
|
itempool: List = []
|
2021-08-29 14:02:02 -04:00
|
|
|
|
# Add revive items for the player
|
2022-08-20 18:09:35 -05:00
|
|
|
|
itempool += ["Dio's Best Friend"] * self.total_revivals
|
2023-06-26 22:47:52 -06:00
|
|
|
|
itempool += ["Beads of Fealty"]
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
2023-02-05 13:51:03 -07:00
|
|
|
|
for env_name, _ in environments_pool.items():
|
|
|
|
|
itempool += [env_name]
|
|
|
|
|
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if self.options.goal == "classic":
|
2023-02-05 13:51:03 -07:00
|
|
|
|
# classic mode
|
2023-10-10 15:30:20 -05:00
|
|
|
|
total_locations = self.options.total_locations.value
|
2023-02-05 13:51:03 -07:00
|
|
|
|
else:
|
|
|
|
|
# explore mode
|
|
|
|
|
total_locations = len(
|
|
|
|
|
orderedstage_location.get_locations(
|
2023-10-10 15:30:20 -05: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,
|
|
|
|
|
dlc_sotv=self.options.dlc_sotv.value
|
2023-02-05 13:51:03 -07:00
|
|
|
|
)
|
|
|
|
|
)
|
2023-08-16 08:21:07 -06:00
|
|
|
|
# Create junk items
|
|
|
|
|
self.junk_pool = self.create_junk_pool()
|
2021-08-29 14:02:02 -04:00
|
|
|
|
# Fill remaining items with randomly generated junk
|
2023-08-16 08:21:07 -06:00
|
|
|
|
while len(itempool) < total_locations:
|
|
|
|
|
itempool.append(self.get_filler_item_name())
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
|
|
|
|
# Convert itempool into real items
|
2021-09-11 22:14:39 +02:00
|
|
|
|
itempool = list(map(lambda name: self.create_item(name), itempool))
|
2022-10-31 21:41:21 -05:00
|
|
|
|
self.multiworld.itempool += itempool
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
2022-08-20 18:09:35 -05:00
|
|
|
|
def set_rules(self) -> None:
|
2022-10-31 21:41:21 -05:00
|
|
|
|
set_rules(self.multiworld, self.player)
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
2023-08-16 08:21:07 -06:00
|
|
|
|
def get_filler_item_name(self) -> str:
|
|
|
|
|
if not self.junk_pool:
|
|
|
|
|
self.junk_pool = self.create_junk_pool()
|
|
|
|
|
weights = [data for data in self.junk_pool.values()]
|
|
|
|
|
filler = self.multiworld.random.choices([filler for filler in self.junk_pool.keys()], weights,
|
|
|
|
|
k=1)[0]
|
|
|
|
|
return filler
|
|
|
|
|
|
|
|
|
|
def create_junk_pool(self) -> Dict:
|
|
|
|
|
# if presets are enabled generate junk_pool from the selected preset
|
2023-10-10 15:30:20 -05:00
|
|
|
|
pool_option = self.options.item_weights.value
|
2023-08-16 08:21:07 -06:00
|
|
|
|
junk_pool: Dict[str, int] = {}
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if self.options.item_pool_presets:
|
2023-08-16 08:21:07 -06: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():
|
|
|
|
|
junk_pool[name] = self.multiworld.random.randint(0, max_value)
|
|
|
|
|
else:
|
|
|
|
|
junk_pool = item_pool_weights[pool_option].copy()
|
|
|
|
|
else: # generate junk pool from user created presets
|
|
|
|
|
junk_pool = {
|
2023-10-10 15:30:20 -05: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,
|
|
|
|
|
"Equipment": self.options.equipment.value
|
2023-08-16 08:21:07 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# remove lunar items from the pool if they're disabled in the yaml unless lunartic is rolled
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if not (self.options.enable_lunar or pool_option == ItemWeights.option_lunartic):
|
2023-08-16 08:21:07 -06:00
|
|
|
|
junk_pool.pop("Lunar Item")
|
|
|
|
|
# remove void items from the pool
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if not (self.options.dlc_sotv or pool_option == ItemWeights.option_void):
|
2023-08-16 08:21:07 -06:00
|
|
|
|
junk_pool.pop("Void Item")
|
|
|
|
|
|
|
|
|
|
return junk_pool
|
|
|
|
|
|
2022-08-20 18:09:35 -05:00
|
|
|
|
def create_regions(self) -> None:
|
|
|
|
|
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if self.options.goal == "classic":
|
2023-02-05 13:51:03 -07:00
|
|
|
|
# classic mode
|
|
|
|
|
menu = create_region(self.multiworld, self.player, "Menu")
|
|
|
|
|
self.multiworld.regions.append(menu)
|
|
|
|
|
# By using a victory region, we can define it as being connected to by several regions
|
|
|
|
|
# which can then determine the availability of the victory.
|
|
|
|
|
victory_region = create_region(self.multiworld, self.player, "Victory")
|
|
|
|
|
self.multiworld.regions.append(victory_region)
|
|
|
|
|
petrichor = create_region(self.multiworld, self.player, "Petrichor V",
|
2023-10-10 15:30:20 -05:00
|
|
|
|
get_classic_item_pickups(self.options.total_locations.value))
|
2023-02-05 13:51:03 -07:00
|
|
|
|
self.multiworld.regions.append(petrichor)
|
|
|
|
|
|
|
|
|
|
# classic mode can get to victory from the beginning of the game
|
|
|
|
|
to_victory = Entrance(self.player, "beating game", petrichor)
|
|
|
|
|
petrichor.exits.append(to_victory)
|
|
|
|
|
to_victory.connect(victory_region)
|
2022-08-20 18:09:35 -05:00
|
|
|
|
|
2023-02-05 13:51:03 -07:00
|
|
|
|
connection = Entrance(self.player, "Lobby", menu)
|
|
|
|
|
menu.exits.append(connection)
|
|
|
|
|
connection.connect(petrichor)
|
|
|
|
|
else:
|
|
|
|
|
# explore mode
|
|
|
|
|
create_regions(self.multiworld, self.player)
|
2022-08-20 18:09:35 -05:00
|
|
|
|
|
2022-10-31 21:41:21 -05:00
|
|
|
|
create_events(self.multiworld, self.player)
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
|
|
|
|
def fill_slot_data(self):
|
2023-10-10 15:30:20 -05:00
|
|
|
|
options_dict = self.options.as_dict("item_pickup_step", "shrine_use_step", "goal", "total_locations",
|
|
|
|
|
"chests_per_stage", "shrines_per_stage", "scavengers_per_stage",
|
|
|
|
|
"scanner_per_stage", "altars_per_stage", "total_revivals", "start_with_revive",
|
|
|
|
|
"final_stage_death", "death_link", casing="camel")
|
2021-08-29 14:02:02 -04:00
|
|
|
|
return {
|
2023-10-10 15:30:20 -05:00
|
|
|
|
**options_dict,
|
2023-02-02 01:14:23 +01:00
|
|
|
|
"seed": "".join(self.multiworld.per_slot_randoms[self.player].choice(string.digits) for _ in range(16)),
|
2021-08-29 14:02:02 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def create_item(self, name: str) -> Item:
|
|
|
|
|
item_id = item_table[name]
|
2023-02-05 13:51:03 -07:00
|
|
|
|
classification = ItemClassification.filler
|
2023-06-26 22:47:52 -06:00
|
|
|
|
if name in {"Dio's Best Friend", "Beads of Fealty"}:
|
2022-08-20 18:09:35 -05:00
|
|
|
|
classification = ItemClassification.progression
|
2023-02-05 13:51:03 -07:00
|
|
|
|
elif name in {"Legendary Item", "Boss Item"}:
|
2022-08-20 18:09:35 -05:00
|
|
|
|
classification = ItemClassification.useful
|
2023-02-05 13:51:03 -07:00
|
|
|
|
elif name == "Lunar Item":
|
|
|
|
|
classification = ItemClassification.trap
|
|
|
|
|
|
|
|
|
|
# Only check for an item to be a environment unlock if those are known to be in the pool.
|
2023-08-16 08:21:07 -06:00
|
|
|
|
# This should shave down comparisons.
|
2023-02-05 13:51:03 -07:00
|
|
|
|
|
|
|
|
|
elif name in environment_ALL_table.keys():
|
2023-02-17 14:08:18 -07:00
|
|
|
|
if name in {"Hidden Realm: Bulwark's Ambry", "Hidden Realm: Gilded Coast,"}:
|
2023-02-05 13:51:03 -07:00
|
|
|
|
classification = ItemClassification.useful
|
|
|
|
|
else:
|
|
|
|
|
classification = ItemClassification.progression
|
|
|
|
|
|
2022-08-20 18:09:35 -05:00
|
|
|
|
item = RiskOfRainItem(name, classification, item_id, self.player)
|
2021-08-29 14:02:02 -04:00
|
|
|
|
return item
|
|
|
|
|
|
2022-03-23 16:22:31 -05:00
|
|
|
|
|
2022-08-20 18:09:35 -05:00
|
|
|
|
def create_events(world: MultiWorld, player: int) -> None:
|
2023-10-10 15:30:20 -05:00
|
|
|
|
total_locations = world.worlds[player].options.total_locations.value
|
2022-03-23 16:22:31 -05:00
|
|
|
|
num_of_events = total_locations // 25
|
|
|
|
|
if total_locations / 25 == num_of_events:
|
|
|
|
|
num_of_events -= 1
|
2022-08-20 18:09:35 -05:00
|
|
|
|
world_region = world.get_region("Petrichor V", player)
|
2023-10-10 15:30:20 -05:00
|
|
|
|
if world.worlds[player].options.goal == "classic":
|
2023-02-05 13:51:03 -07:00
|
|
|
|
# only setup Pickups when using classic_mode
|
|
|
|
|
for i in range(num_of_events):
|
|
|
|
|
event_loc = RiskOfRainLocation(player, f"Pickup{(i + 1) * 25}", None, world_region)
|
|
|
|
|
event_loc.place_locked_item(RiskOfRainItem(f"Pickup{(i + 1) * 25}", ItemClassification.progression, None, player))
|
|
|
|
|
event_loc.access_rule = \
|
|
|
|
|
lambda state, i=i: state.can_reach(f"ItemPickup{((i + 1) * 25) - 1}", "Location", player)
|
|
|
|
|
world_region.locations.append(event_loc)
|
2023-10-10 15:30:20 -05:00
|
|
|
|
elif world.worlds[player].options.goal == "explore":
|
2023-02-05 13:51:03 -07:00
|
|
|
|
for n in range(1, 6):
|
2022-08-20 18:09:35 -05:00
|
|
|
|
|
2023-02-05 13:51:03 -07:00
|
|
|
|
event_region = world.get_region(f"OrderedStage_{n}", player)
|
|
|
|
|
event_loc = RiskOfRainLocation(player, f"Stage_{n}", None, event_region)
|
|
|
|
|
event_loc.place_locked_item(RiskOfRainItem(f"Stage_{n}", ItemClassification.progression, None, player))
|
|
|
|
|
event_loc.show_in_spoiler = False
|
|
|
|
|
event_region.locations.append(event_loc)
|
2022-03-23 16:22:31 -05:00
|
|
|
|
|
2023-02-05 13:51:03 -07:00
|
|
|
|
victory_region = world.get_region("Victory", player)
|
|
|
|
|
victory_event = RiskOfRainLocation(player, "Victory", None, victory_region)
|
2022-08-20 18:09:35 -05:00
|
|
|
|
victory_event.place_locked_item(RiskOfRainItem("Victory", ItemClassification.progression, None, player))
|
|
|
|
|
world_region.locations.append(victory_event)
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
|
|
|
|
|
2023-02-05 13:51:03 -07:00
|
|
|
|
def create_region(world: MultiWorld, player: int, name: str, locations: Dict[str, int] = {}) -> Region:
|
2023-02-13 18:06:43 -06:00
|
|
|
|
ret = Region(name, player, world)
|
2023-02-05 13:51:03 -07:00
|
|
|
|
for location_name, location_id in locations.items():
|
|
|
|
|
ret.locations.append(RiskOfRainLocation(player, location_name, location_id, ret))
|
2021-08-29 14:02:02 -04:00
|
|
|
|
return ret
|