Update RoR2 logic to use event locations
This commit is contained in:
parent
aabc86fc01
commit
23d245d43c
|
@ -7,11 +7,7 @@ class RiskOfRainLocation(Location):
|
|||
# 37000 - 38000
|
||||
base_location_table = {
|
||||
"Victory": None,
|
||||
"Level One": None,
|
||||
"Level Two": None,
|
||||
"Level Three": None,
|
||||
"Level Four": None,
|
||||
"Level Five": None
|
||||
|
||||
}
|
||||
# 37006 - 37506
|
||||
item_pickups = {
|
||||
|
|
|
@ -1,45 +1,29 @@
|
|||
from BaseClasses import MultiWorld
|
||||
from ..AutoWorld import LogicMixin
|
||||
from ..generic.Rules import set_rule
|
||||
|
||||
|
||||
class RiskOfRainLogic(LogicMixin):
|
||||
def _ror_has_items(self, player: int, amount: int) -> bool:
|
||||
count: int = self.item_count("Common Item", player) + self.item_count("Uncommon Item", player) + \
|
||||
self.item_count("Legendary Item", player) + self.item_count("Boss Item", player) + \
|
||||
self.item_count("Lunar Item", player) + self.item_count("Equipment", player) + \
|
||||
self.item_count("Dio's Best Friend", player) + self.item_count("Item Scrap, White", player) + \
|
||||
self.item_count("Item Scrap, Green", player) + self.item_count("Item Scrap, Red", player) + \
|
||||
self.item_count("Item Scrap, Yellow", player)
|
||||
return count >= amount
|
||||
from ..generic.Rules import set_rule, add_rule
|
||||
|
||||
|
||||
def set_rules(world: MultiWorld, player: int):
|
||||
# divide by 5 since 5 levels (then commencement)
|
||||
items_per_level = max(int(world.total_locations[player] / 5 / (world.item_pickup_step[player]+1)), 1)
|
||||
total_locations = world.total_locations[player] # total locations for current player
|
||||
event_location_step = 25 # set an event location at these locations for "spheres"
|
||||
divisions = total_locations // event_location_step
|
||||
|
||||
# lock item pickup access based on level completion
|
||||
for i in range(1, items_per_level):
|
||||
set_rule(world.get_location(f"ItemPickup{i}", player), lambda state: True)
|
||||
for i in range(items_per_level, 2*items_per_level):
|
||||
set_rule(world.get_location(f"ItemPickup{i}", player), lambda state: state.has("Beat Level One", player))
|
||||
for i in range(2*items_per_level, 3*items_per_level):
|
||||
set_rule(world.get_location(f"ItemPickup{i}", player), lambda state: state.has("Beat Level Two", player))
|
||||
for i in range(3*items_per_level, 4*items_per_level):
|
||||
set_rule(world.get_location(f"ItemPickup{i}", player), lambda state: state.has("Beat Level Three", player))
|
||||
for i in range(4*items_per_level, world.total_locations[player] + 1):
|
||||
set_rule(world.get_location(f"ItemPickup{i}", player), lambda state: state.has("Beat Level Four", player))
|
||||
if divisions:
|
||||
for i in range(1, divisions): # since divisions is the floor of total_locations / 25
|
||||
event_loc = world.get_location(f"Pickup{i * event_location_step}", player)
|
||||
for n in range(i * event_location_step, (i + 1) * event_location_step): # we want to create a rule for each of the 25 locations per division
|
||||
if n == i * event_location_step:
|
||||
set_rule(world.get_location(f"ItemPickup{n}", player), lambda state, event_item=event_loc.item.name: state.has(event_item, player))
|
||||
else:
|
||||
set_rule(world.get_location(f"ItemPickup{n}", player),
|
||||
lambda state, n = n: state.can_reach(f"ItemPickup{n - 1}", 'Location', player))
|
||||
for i in range(divisions * event_location_step, total_locations+1):
|
||||
set_rule(world.get_location(f"ItemPickup{i}", player), lambda state, i=i: state.can_reach(f"ItemPickup{i - 1}", "Location", player))
|
||||
|
||||
# require items to beat each stage
|
||||
set_rule(world.get_location("Level Two", player),
|
||||
lambda state: state.has("Beat Level One", player) and state._ror_has_items(player, items_per_level))
|
||||
set_rule(world.get_location("Level Three", player),
|
||||
lambda state: state._ror_has_items(player, 2 * items_per_level) and state.has("Beat Level Two", player))
|
||||
set_rule(world.get_location("Level Four", player),
|
||||
lambda state: state._ror_has_items(player, 3 * items_per_level) and state.has("Beat Level Three", player))
|
||||
set_rule(world.get_location("Level Five", player),
|
||||
lambda state: state._ror_has_items(player, 4 * items_per_level) and state.has("Beat Level Four", player))
|
||||
set_rule(world.get_location("Victory", player),
|
||||
lambda state: state._ror_has_items(player, 5 * items_per_level) and state.has("Beat Level Five", player))
|
||||
lambda state: state.can_reach(f"ItemPickup{total_locations}", "Location", player))
|
||||
if world.total_revivals[player] or world.start_with_revive[player]:
|
||||
total_revivals = world.total_revivals[player] // 100 * world.total_locations[player]
|
||||
add_rule(world.get_location("Victory", player),
|
||||
lambda state: state.has("Dio's Best Friend", player, total_revivals + int(world.start_with_revive[player])))
|
||||
|
||||
world.completion_condition[player] = lambda state: state.has("Victory", player)
|
||||
|
|
|
@ -90,6 +90,7 @@ class RiskOfRainWorld(World):
|
|||
|
||||
def create_regions(self):
|
||||
create_regions(self.world, self.player)
|
||||
create_events(self.world, self.player, int(self.world.total_locations[self.player]))
|
||||
|
||||
def fill_slot_data(self):
|
||||
return {
|
||||
|
@ -102,9 +103,25 @@ class RiskOfRainWorld(World):
|
|||
|
||||
def create_item(self, name: str) -> Item:
|
||||
item_id = item_table[name]
|
||||
item = RiskOfRainItem(name, True, item_id, self.player)
|
||||
if name == "Dio's Best Friend":
|
||||
prog = True
|
||||
else:
|
||||
prog = False
|
||||
item = RiskOfRainItem(name, prog, item_id, self.player)
|
||||
return item
|
||||
|
||||
|
||||
def create_events(world: MultiWorld, player: int, total_locations: int):
|
||||
num_of_events = total_locations // 25
|
||||
if total_locations / 25 == num_of_events:
|
||||
num_of_events -= 1
|
||||
for i in range(num_of_events):
|
||||
event_loc = RiskOfRainLocation(player, f"Pickup{(i + 1) * 25}", None, world.get_region('Petrichor V', player))
|
||||
event_loc.place_locked_item(RiskOfRainItem(f"Pickup{(i + 1) * 25}", True, None, player))
|
||||
event_loc.access_rule(lambda state, i=i: state.can_reach(f"ItemPickup{((i + 1) * 25) - 1}", player))
|
||||
world.get_region('Petrichor V', player).locations.append(event_loc)
|
||||
|
||||
|
||||
# generate locations based on player setting
|
||||
def create_regions(world, player: int):
|
||||
world.regions += [
|
||||
|
@ -115,11 +132,6 @@ def create_regions(world, player: int):
|
|||
]
|
||||
|
||||
world.get_entrance("Lobby", player).connect(world.get_region("Petrichor V", player))
|
||||
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))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue