From 6d28978480a1327fccbd1899f9f7b08e0bbe5ffa Mon Sep 17 00:00:00 2001 From: pepperpow Date: Sun, 10 Jan 2021 03:33:28 -0600 Subject: [PATCH 1/2] Prevent shop slots rebalancing each other + dungeon item criteria --- Main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Main.py b/Main.py index 3d877568..a4604151 100644 --- a/Main.py +++ b/Main.py @@ -210,8 +210,15 @@ def main(args, seed=None): if world.players > 1: balance_multiworld_progression(world) - candidates = [l for l in world.get_locations() if l.item.name in ['Bee Trap', 'Shovel', 'Bug Catching Net', 'Cane of Byrna', 'Triforce Piece'] or - any([x in l.item.name for x in ['Key', 'Map', 'Compass', 'Clock', 'Heart', 'Sword', 'Shield', 'Bomb', 'Arrow', 'Mail']])] + + candidates = [] + for location in [l for l in world.get_locations() if l.item.name in ['Bee Trap', 'Shovel', 'Bug Catching Net', 'Cane of Byrna', 'Triforce Piece'] or + any([x in l.item.name for x in ['Key', 'Map', 'Compass', 'Clock', 'Heart', 'Sword', 'Shield', 'Bomb', 'Arrow', 'Mail']])]: + if ( world.keyshuffle[location.item.player] or not location.item.smallkey) and \ + (world.bigkeyshuffle[location.item.player] or not location.item.bigkey) and \ + (world.mapshuffle[location.item.player] or not location.item.map) and \ + (world.compassshuffle[location.item.player] or not location.item.compass): + candidates.append(location) world.random.shuffle(candidates) shop_slots = [item for sublist in [shop.region.locations for shop in world.shops] for item in sublist if item.name != 'Potion Shop'] shop_slots_adjusted = [] @@ -224,6 +231,7 @@ def main(args, seed=None): # if item is a rupee or single bee, or identical, swap it out if (shop_item is not None and shop_item['item'] == item.name) or 'Rupee' in item.name or (item.name in ['Bee']): for c in candidates: # chosen item locations + if c.parent_region.shop or c is location: continue if 'Rupee' in c.item.name or c.item.name in 'Bee': continue if (shop_item is not None and shop_item['item'] == c.item.name): continue if c.item_rule(location.item): # if rule is good... From 4250004f11196ee4e2fff351bdc820ce1e10d010 Mon Sep 17 00:00:00 2001 From: pepperpow Date: Sun, 10 Jan 2021 05:11:45 -0600 Subject: [PATCH 2/2] Added Shop ID constant and forfeit values --- Main.py | 4 ++-- MultiClient.py | 2 +- MultiServer.py | 1 + Regions.py | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Main.py b/Main.py index a4604151..e067fb5a 100644 --- a/Main.py +++ b/Main.py @@ -11,7 +11,7 @@ import concurrent.futures from BaseClasses import World, CollectionState, Item, Region, Location, PlandoItem from Items import ItemFactory, item_table, item_name_groups -from Regions import create_regions, create_shops, mark_light_world_regions, lookup_vanilla_location_to_entrance +from Regions import create_regions, create_shops, mark_light_world_regions, lookup_vanilla_location_to_entrance, SHOP_ID_START from InvertedRegions import create_inverted_regions, mark_dark_world_regions from EntranceShuffle import link_entrances, link_inverted_entrances, plando_connect from Rom import patch_rom, patch_race_rom, patch_enemizer, apply_rom_settings, LocalRom, get_hash_string @@ -409,7 +409,7 @@ def main(args, seed=None): main_entrance = get_entrance_to_region(region) for location in region.locations: if type(location.address) == int: # skips events and crystals - if location.address >= 0x400000: continue + if location.address >= SHOP_ID_START: continue if lookup_vanilla_location_to_entrance[location.address] != main_entrance.name: er_hint_data[region.player][location.address] = main_entrance.name diff --git a/MultiClient.py b/MultiClient.py index 90ba6893..0eee6eef 100644 --- a/MultiClient.py +++ b/MultiClient.py @@ -1154,7 +1154,7 @@ async def track_locations(ctx : Context, roomid, roomdata): if roomid in location_shop_ids: misc_data = await snes_read(ctx, SHOP_ADDR, len(location_shop_order)*3) for cnt, b in enumerate(misc_data): - my_check = Regions.shop_table_by_location_id[0x400000 + cnt] + my_check = Regions.shop_table_by_location_id[Regions.SHOP_ID_START + cnt] if int(b) > 0 and my_check not in ctx.locations_checked: new_check(my_check) except Exception as e: diff --git a/MultiServer.py b/MultiServer.py index ccdd6c24..dd844414 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -475,6 +475,7 @@ def send_new_items(ctx: Context): def forfeit_player(ctx: Context, team: int, slot: int): all_locations = {values[0] for values in Regions.location_table.values() if type(values[0]) is int} all_locations.update({values[1] for values in Regions.key_drop_data.values()}) + all_locations.update({values for values in range(Regions.SHOP_ID_START, Regions.SHOP_ID_START + 256)}) ctx.notify_all("%s (Team #%d) has forfeited" % (ctx.player_names[(team, slot)], team + 1)) register_location_checks(ctx, team, slot, all_locations) diff --git a/Regions.py b/Regions.py index 247bd841..90111abb 100644 --- a/Regions.py +++ b/Regions.py @@ -442,7 +442,8 @@ shop_table = { 'Capacity Upgrade': (0x0115, ShopType.UpgradeShop, 0x04, True, True, [('Bomb Upgrade (+5)', 100, 7), ('Arrow Upgrade (+5)', 100, 7)]) } -shop_table_by_location_id = {0x400000 + cnt: s for cnt, s in enumerate( +SHOP_ID_START = 0x400000 +shop_table_by_location_id = {SHOP_ID_START + cnt: s for cnt, s in enumerate( [item for sublist in [["{} Slot {}".format(name, num + 1) for num in range(3)] for name in shop_table] for item in sublist])} shop_table_by_location = {y: x for x, y in shop_table_by_location_id.items()}