From 990141df476117debd8f7822fa5f2330a6e0a9c7 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Mon, 4 Oct 2021 22:28:40 -0500 Subject: [PATCH 1/4] Risk of Rain 2: logic updates --- worlds/ror2/Items.py | 31 ++++++++++++++++++++++--------- worlds/ror2/Options.py | 4 +++- worlds/ror2/Rules.py | 4 +++- worlds/ror2/__init__.py | 11 ++++++----- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/worlds/ror2/Items.py b/worlds/ror2/Items.py index fa6f4d27..c4ece1dc 100644 --- a/worlds/ror2/Items.py +++ b/worlds/ror2/Items.py @@ -1,6 +1,5 @@ from BaseClasses import Item import typing -from random import randint class RiskOfRainItem(Item): game: str = "Risk of Rain 2" @@ -48,12 +47,12 @@ new_weights = { "Uncommon Item": 40, "Legendary Item": 10, "Boss Item": 5, - "Lunar Item": 15, - "Equipment": 25 + "Lunar Item": 10, + "Equipment": 20 } uncommon_weights = { - "Item Scrap, Green": 15, + "Item Scrap, Green": 45, "Item Scrap, Red": 5, "Item Scrap, Yellow": 1, "Item Scrap, White": 30, @@ -62,7 +61,7 @@ uncommon_weights = { "Legendary Item": 10, "Boss Item": 5, "Lunar Item": 15, - "Equipment": 25 + "Equipment": 20 } legendary_weights = { @@ -75,7 +74,7 @@ legendary_weights = { "Legendary Item": 100, "Boss Item": 5, "Lunar Item": 15, - "Equipment": 25 + "Equipment": 20 } lunartic_weights = { @@ -96,8 +95,8 @@ no_scraps_weights = { "Item Scrap, Red": 0, "Item Scrap, Yellow": 0, "Item Scrap, White": 0, - "Common Item": 80, - "Uncommon Item": 30, + "Common Item": 100, + "Uncommon Item": 40, "Legendary Item": 15, "Boss Item": 5, "Lunar Item": 10, @@ -117,6 +116,19 @@ even_weights = { "Equipment": 1 } +scraps_only = { + "Item Scrap, Green": 70, + "Item Scrap, White": 100, + "Item Scrap, Red": 30, + "Item Scrap, Yellow": 5, + "Common Item": 0, + "Uncommon Item": 0, + "Legendary Item": 0, + "Boss Item": 0, + "Lunar Item": 0, + "Equipment": 0 +} + item_pool_weights: typing.Dict[int, typing.Dict[str, int]] = { 0: default_weights, 1: new_weights, @@ -124,7 +136,8 @@ item_pool_weights: typing.Dict[int, typing.Dict[str, int]] = { 3: legendary_weights, 4: lunartic_weights, 6: no_scraps_weights, - 7: even_weights + 7: even_weights, + 8: scraps_only } lookup_id_to_name: typing.Dict[int, str] = {id: name for name, id in item_table.items() if id} diff --git a/worlds/ror2/Options.py b/worlds/ror2/Options.py index b2cc89a1..233d97f8 100644 --- a/worlds/ror2/Options.py +++ b/worlds/ror2/Options.py @@ -130,7 +130,8 @@ class ItemWeights(Choice): Lunartic makes everything a lunar item.
Chaos generates the pool completely at random with rarer items having a slight cap to prevent this option being too easy.
No Scraps removes all scrap items from the item pool.
- Even generates the item pool with every item having an even weight.""" + Even generates the item pool with every item having an even weight.
+ Scraps Only will be only scrap items in the item pool.""" displayname = "Item Weights" option_default = 0 option_new = 1 @@ -140,6 +141,7 @@ class ItemWeights(Choice): option_chaos = 5 option_no_scraps = 6 option_even = 7 + option_scraps_only = 8 #define a dictionary for the weights of the generated item pool. ror2_weights: typing.Dict[str, type(Option)] = { diff --git a/worlds/ror2/Rules.py b/worlds/ror2/Rules.py index 4f374832..9b33328f 100644 --- a/worlds/ror2/Rules.py +++ b/worlds/ror2/Rules.py @@ -8,7 +8,9 @@ class RiskOfRainLogic(LogicMixin): 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("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 diff --git a/worlds/ror2/__init__.py b/worlds/ror2/__init__.py index 166e58b7..4aa6f278 100644 --- a/worlds/ror2/__init__.py +++ b/worlds/ror2/__init__.py @@ -38,13 +38,13 @@ class RiskOfRainWorld(World): if pool_option == 5: junk_pool = { "Item Scrap, Green": self.world.random.randint(0, 80), - "Item Scrap, Red": self.world.random.randint(0, 40), - "Item Scrap, Yellow": self.world.random.randint(0, 50), + "Item Scrap, Red": self.world.random.randint(0, 45), + "Item Scrap, Yellow": self.world.random.randint(0, 30), "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), - "Legendary Item": self.world.random.randint(0, 45), - "Boss Item": self.world.random.randint(0, 30), + "Legendary Item": self.world.random.randint(0, 300), + "Boss Item": self.world.random.randint(0, 20), "Lunar Item": self.world.random.randint(0, 60), "Equipment": self.world.random.randint(0, 40) } @@ -65,7 +65,8 @@ class RiskOfRainWorld(World): } if not self.world.enable_lunar[self.player]: - junk_pool.pop("Lunar Item") + if not pool_option == 4: + junk_pool.pop("Lunar Item") # Generate item pool itempool = [] From a93d633d2586ece1bd7c8a3f1effb2c17c8c1818 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Fri, 8 Oct 2021 13:27:23 -0500 Subject: [PATCH 2/4] Risk of Rain 2: move a variable definition so it can be reused. Reverted a change that broke stuff for some reason. --- worlds/ror2/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/worlds/ror2/__init__.py b/worlds/ror2/__init__.py index 4aa6f278..f8e59e2f 100644 --- a/worlds/ror2/__init__.py +++ b/worlds/ror2/__init__.py @@ -32,8 +32,8 @@ class RiskOfRainWorld(World): self.world.push_precollected(self.world.create_item("Dio's Best Friend", self.player)) # if presets are enabled generate junk_pool from the selected preset + pool_option = self.world.item_weights[self.player].value if self.world.item_pool_presets[self.player].value: - pool_option = self.world.item_weights[self.player].value # generate chaos weights if the preset is chosen if pool_option == 5: junk_pool = { @@ -43,7 +43,7 @@ class RiskOfRainWorld(World): "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), - "Legendary Item": self.world.random.randint(0, 300), + "Legendary Item": self.world.random.randint(0, 30), "Boss Item": self.world.random.randint(0, 20), "Lunar Item": self.world.random.randint(0, 60), "Equipment": self.world.random.randint(0, 40) @@ -110,7 +110,7 @@ def create_regions(world, player: int): create_region(world, player, 'Menu', None, ['Lobby']), create_region(world, player, 'Petrichor V', [location for location in base_location_table] + - [f"Item Pickup {i}" for i in range(1, world.start_with_revive[player].value+world.total_locations[player])]) + [f"Item Pickup {i}" for i in range(1, 1 + world.total_locations[player])]) # i don't understand this line but it works ] world.get_entrance("Lobby", player).connect(world.get_region("Petrichor V", player)) From d3780cd9d540e7dfe9bea2463b2ba87811379254 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Sat, 9 Oct 2021 05:55:50 -0500 Subject: [PATCH 3/4] Documentation update --- worlds/ror2/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worlds/ror2/__init__.py b/worlds/ror2/__init__.py index f8e59e2f..3a4611d7 100644 --- a/worlds/ror2/__init__.py +++ b/worlds/ror2/__init__.py @@ -104,13 +104,13 @@ class RiskOfRainWorld(World): item = RiskOfRainItem(name, True, item_id, self.player) return item - +# generate locations based on player setting 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] + - [f"Item Pickup {i}" for i in range(1, 1 + world.total_locations[player])]) # i don't understand this line but it works + [f"Item Pickup {i}" for i in range(1, 1 + world.total_locations[player])]) ] world.get_entrance("Lobby", player).connect(world.get_region("Petrichor V", player)) From d8de84e4177714799d2f977a046b3b4750095ef5 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Sat, 9 Oct 2021 22:11:05 -0500 Subject: [PATCH 4/4] Revert Item Pickup to ItemPickup because it broke stuff --- worlds/ror2/Locations.py | 2 +- worlds/ror2/Rules.py | 12 ++++++------ worlds/ror2/__init__.py | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/worlds/ror2/Locations.py b/worlds/ror2/Locations.py index fcb48a83..b3de5cff 100644 --- a/worlds/ror2/Locations.py +++ b/worlds/ror2/Locations.py @@ -15,7 +15,7 @@ base_location_table = { } # 37006 - 37106 item_pickups = { - f"Item Pickup {i}": 37005+i for i in range(1, 101) + f"ItemPickup{i}": 37005+i for i in range(1, 101) } location_table = {**base_location_table, **item_pickups} diff --git a/worlds/ror2/Rules.py b/worlds/ror2/Rules.py index 9b33328f..df207b5e 100644 --- a/worlds/ror2/Rules.py +++ b/worlds/ror2/Rules.py @@ -20,15 +20,15 @@ def set_rules(world: MultiWorld, player: int): # lock item pickup access based on level completion for i in range(1, items_per_level): - set_rule(world.get_location(f"Item Pickup {i}", player), lambda state: True) + 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"Item Pickup {i}", player), lambda state: state.has("Beat Level One", player)) + 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"Item Pickup {i}", player), lambda state: state.has("Beat Level Two", player)) + 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"Item Pickup {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"Item Pickup {i}", player), lambda state: state.has("Beat Level Four", player)) + 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)) # require items to beat each stage set_rule(world.get_location("Level Two", player), diff --git a/worlds/ror2/__init__.py b/worlds/ror2/__init__.py index 3a4611d7..410c40dd 100644 --- a/worlds/ror2/__init__.py +++ b/worlds/ror2/__init__.py @@ -64,6 +64,7 @@ class RiskOfRainWorld(World): "Equipment": self.world.equipment[self.player].value } + # remove lunar items from the pool if they're disabled in the yaml unless lunartic is rolled if not self.world.enable_lunar[self.player]: if not pool_option == 4: junk_pool.pop("Lunar Item") @@ -110,7 +111,7 @@ def create_regions(world, player: int): create_region(world, player, 'Menu', None, ['Lobby']), create_region(world, player, 'Petrichor V', [location for location in base_location_table] + - [f"Item Pickup {i}" for i in range(1, 1 + world.total_locations[player])]) + [f"ItemPickup{i}" for i in range(1, 1 + world.total_locations[player])]) ] world.get_entrance("Lobby", player).connect(world.get_region("Petrichor V", player))