2021-08-29 14:02:02 -04:00
|
|
|
|
import string
|
2021-09-07 17:14:20 -05:00
|
|
|
|
from .Items import RiskOfRainItem, item_table, item_pool_weights
|
2021-08-29 14:02:02 -04:00
|
|
|
|
from .Locations import location_table, RiskOfRainLocation, base_location_table
|
|
|
|
|
from .Rules import set_rules
|
|
|
|
|
|
|
|
|
|
from BaseClasses import Region, Entrance, Item, MultiWorld
|
2021-09-07 17:14:20 -05:00
|
|
|
|
from .Options import ror2_options
|
2021-08-29 14:02:02 -04:00
|
|
|
|
from ..AutoWorld import World
|
|
|
|
|
|
|
|
|
|
client_version = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
"""
|
2021-08-29 14:02:02 -04:00
|
|
|
|
game: str = "Risk of Rain 2"
|
|
|
|
|
options = ror2_options
|
|
|
|
|
topology_present = False
|
|
|
|
|
|
2021-09-01 16:46:44 +02:00
|
|
|
|
item_name_to_id = item_table
|
|
|
|
|
location_name_to_id = location_table
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
2021-09-27 12:15:15 -05:00
|
|
|
|
data_version = 2
|
2021-08-31 10:08:19 -04:00
|
|
|
|
forced_auto_forfeit = True
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
|
|
|
|
def generate_basic(self):
|
|
|
|
|
# shortcut for starting_inventory... The start_with_revive option lets you start with a Dio's Best Friend
|
|
|
|
|
if self.world.start_with_revive[self.player].value:
|
|
|
|
|
self.world.push_precollected(self.world.create_item("Dio's Best Friend", self.player))
|
|
|
|
|
|
2021-09-08 13:53:06 -05:00
|
|
|
|
# if presets are enabled generate junk_pool from the selected preset
|
2021-10-08 13:27:23 -05:00
|
|
|
|
pool_option = self.world.item_weights[self.player].value
|
2021-09-08 13:53:06 -05:00
|
|
|
|
if self.world.item_pool_presets[self.player].value:
|
|
|
|
|
# generate chaos weights if the preset is chosen
|
|
|
|
|
if pool_option == 5:
|
|
|
|
|
junk_pool = {
|
2021-09-26 20:56:04 -05:00
|
|
|
|
"Item Scrap, Green": self.world.random.randint(0, 80),
|
2021-10-04 22:28:40 -05:00
|
|
|
|
"Item Scrap, Red": self.world.random.randint(0, 45),
|
|
|
|
|
"Item Scrap, Yellow": self.world.random.randint(0, 30),
|
2021-09-08 13:53:06 -05:00
|
|
|
|
"Item Scrap, White": self.world.random.randint(0, 100),
|
|
|
|
|
"Common Item": self.world.random.randint(0, 100),
|
|
|
|
|
"Uncommon Item": self.world.random.randint(0, 70),
|
2021-10-08 13:27:23 -05:00
|
|
|
|
"Legendary Item": self.world.random.randint(0, 30),
|
2021-10-04 22:28:40 -05:00
|
|
|
|
"Boss Item": self.world.random.randint(0, 20),
|
2021-09-08 13:53:06 -05:00
|
|
|
|
"Lunar Item": self.world.random.randint(0, 60),
|
2021-09-26 20:56:04 -05:00
|
|
|
|
"Equipment": self.world.random.randint(0, 40)
|
2021-09-08 13:53:06 -05:00
|
|
|
|
}
|
|
|
|
|
else:
|
2021-09-10 04:11:01 +02:00
|
|
|
|
junk_pool = item_pool_weights[pool_option].copy()
|
2021-09-11 22:14:39 +02:00
|
|
|
|
else: # generate junk pool from user created presets
|
2021-09-08 13:53:06 -05:00
|
|
|
|
junk_pool = {
|
2021-09-06 23:40:39 -05:00
|
|
|
|
"Item Scrap, Green": self.world.green_scrap[self.player].value,
|
|
|
|
|
"Item Scrap, Red": self.world.red_scrap[self.player].value,
|
|
|
|
|
"Item Scrap, Yellow": self.world.yellow_scrap[self.player].value,
|
|
|
|
|
"Item Scrap, White": self.world.white_scrap[self.player].value,
|
|
|
|
|
"Common Item": self.world.common_item[self.player].value,
|
|
|
|
|
"Uncommon Item": self.world.uncommon_item[self.player].value,
|
|
|
|
|
"Legendary Item": self.world.legendary_item[self.player].value,
|
|
|
|
|
"Boss Item": self.world.boss_item[self.player].value,
|
|
|
|
|
"Lunar Item": self.world.lunar_item[self.player].value,
|
|
|
|
|
"Equipment": self.world.equipment[self.player].value
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-26 20:56:04 -05:00
|
|
|
|
if not self.world.enable_lunar[self.player]:
|
2021-10-04 22:28:40 -05:00
|
|
|
|
if not pool_option == 4:
|
|
|
|
|
junk_pool.pop("Lunar Item")
|
2021-09-26 20:56:04 -05:00
|
|
|
|
|
2021-08-29 14:02:02 -04:00
|
|
|
|
# Generate item pool
|
|
|
|
|
itempool = []
|
|
|
|
|
|
|
|
|
|
# Add revive items for the player
|
|
|
|
|
itempool += ["Dio's Best Friend"] * self.world.total_revivals[self.player]
|
|
|
|
|
|
|
|
|
|
# Fill remaining items with randomly generated junk
|
|
|
|
|
itempool += self.world.random.choices(list(junk_pool.keys()), weights=list(junk_pool.values()),
|
2021-09-01 17:35:16 -04:00
|
|
|
|
k=self.world.total_locations[self.player] -
|
2021-09-11 22:14:39 +02:00
|
|
|
|
self.world.total_revivals[self.player])
|
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))
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
|
|
|
|
self.world.itempool += itempool
|
|
|
|
|
|
|
|
|
|
def set_rules(self):
|
|
|
|
|
set_rules(self.world, self.player)
|
|
|
|
|
|
|
|
|
|
def create_regions(self):
|
|
|
|
|
create_regions(self.world, self.player)
|
|
|
|
|
|
|
|
|
|
def fill_slot_data(self):
|
|
|
|
|
return {
|
|
|
|
|
"itemPickupStep": self.world.item_pickup_step[self.player].value,
|
|
|
|
|
"seed": "".join(self.world.slot_seeds[self.player].choice(string.digits) for i in range(16)),
|
2021-09-01 17:35:16 -04:00
|
|
|
|
"totalLocations": self.world.total_locations[self.player].value,
|
2021-09-06 13:15:07 -04:00
|
|
|
|
"totalRevivals": self.world.total_revivals[self.player].value,
|
|
|
|
|
"startWithDio": self.world.start_with_revive[self.player].value
|
2021-08-29 14:02:02 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def create_item(self, name: str) -> Item:
|
|
|
|
|
item_id = item_table[name]
|
2021-09-07 17:14:20 -05:00
|
|
|
|
item = RiskOfRainItem(name, True, item_id, self.player)
|
2021-08-29 14:02:02 -04:00
|
|
|
|
return item
|
|
|
|
|
|
2021-10-09 05:55:50 -05:00
|
|
|
|
# generate locations based on player setting
|
2021-08-29 14:02:02 -04:00
|
|
|
|
def create_regions(world, player: int):
|
|
|
|
|
world.regions += [
|
|
|
|
|
create_region(world, player, 'Menu', None, ['Lobby']),
|
|
|
|
|
create_region(world, player, 'Petrichor V',
|
|
|
|
|
[location for location in base_location_table] +
|
2021-10-09 05:55:50 -05:00
|
|
|
|
[f"Item Pickup {i}" for i in range(1, 1 + world.total_locations[player])])
|
2021-08-29 14:02:02 -04:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
world.get_entrance("Lobby", player).connect(world.get_region("Petrichor V", player))
|
2021-09-07 09:22:12 -05:00
|
|
|
|
world.get_location("Level One", player).place_locked_item(RiskOfRainItem("Beat Level One", True, None, player))
|
|
|
|
|
world.get_location("Level Two", player).place_locked_item(RiskOfRainItem("Beat Level Two", True, None, player))
|
|
|
|
|
world.get_location("Level Three", player).place_locked_item(RiskOfRainItem("Beat Level Three", True, None, player))
|
|
|
|
|
world.get_location("Level Four", player).place_locked_item(RiskOfRainItem("Beat Level Four", True, None, player))
|
|
|
|
|
world.get_location("Level Five", player).place_locked_item(RiskOfRainItem("Beat Level Five", True, None, player))
|
|
|
|
|
world.get_location("Victory", player).place_locked_item(RiskOfRainItem("Victory", True, None, player))
|
2021-08-29 14:02:02 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None):
|
|
|
|
|
ret = Region(name, None, name, player)
|
|
|
|
|
ret.world = world
|
|
|
|
|
if locations:
|
|
|
|
|
for location in locations:
|
2021-09-11 22:14:39 +02:00
|
|
|
|
loc_id = location_table[location]
|
2021-08-29 14:02:02 -04:00
|
|
|
|
location = RiskOfRainLocation(player, location, loc_id, ret)
|
|
|
|
|
ret.locations.append(location)
|
|
|
|
|
if exits:
|
|
|
|
|
for exit in exits:
|
|
|
|
|
ret.exits.append(Entrance(player, exit, ret))
|
|
|
|
|
|
|
|
|
|
return ret
|