Skip to content

Commit

Permalink
ALTTP: Fix ArchipelagoMW#2290's crashes (ArchipelagoMW#2973)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alchav authored Mar 22, 2024
1 parent 355223b commit bdd498d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
38 changes: 19 additions & 19 deletions worlds/alttp/ItemPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def cut_item(items, item_to_cut, minimum_items):
multiworld.itempool += items

if multiworld.retro_caves[player]:
set_up_take_anys(multiworld, player) # depends on world.itempool to be set
set_up_take_anys(multiworld, world, player) # depends on world.itempool to be set


take_any_locations = {
Expand All @@ -528,30 +528,30 @@ def cut_item(items, item_to_cut, minimum_items):
take_any_locations.sort()


def set_up_take_anys(world, player):
def set_up_take_anys(multiworld, world, player):
# these are references, do not modify these lists in-place
if world.mode[player] == 'inverted':
if multiworld.mode[player] == 'inverted':
take_any_locs = take_any_locations_inverted
else:
take_any_locs = take_any_locations

regions = world.random.sample(take_any_locs, 5)
regions = multiworld.random.sample(take_any_locs, 5)

old_man_take_any = LTTPRegion("Old Man Sword Cave", LTTPRegionType.Cave, 'the sword cave', player, world)
world.regions.append(old_man_take_any)
old_man_take_any = LTTPRegion("Old Man Sword Cave", LTTPRegionType.Cave, 'the sword cave', player, multiworld)
multiworld.regions.append(old_man_take_any)

reg = regions.pop()
entrance = world.get_region(reg, player).entrances[0]
connect_entrance(world, entrance.name, old_man_take_any.name, player)
entrance = multiworld.get_region(reg, player).entrances[0]
connect_entrance(multiworld, entrance.name, old_man_take_any.name, player)
entrance.target = 0x58
old_man_take_any.shop = TakeAny(old_man_take_any, 0x0112, 0xE2, True, True, total_shop_slots)
world.shops.append(old_man_take_any.shop)
multiworld.shops.append(old_man_take_any.shop)

swords = [item for item in world.itempool if item.player == player and item.type == 'Sword']
swords = [item for item in multiworld.itempool if item.player == player and item.type == 'Sword']
if swords:
sword = world.random.choice(swords)
world.itempool.remove(sword)
world.itempool.append(item_factory('Rupees (20)', world))
sword = multiworld.random.choice(swords)
multiworld.itempool.remove(sword)
multiworld.itempool.append(item_factory('Rupees (20)', world))
old_man_take_any.shop.add_inventory(0, sword.name, 0, 0)
loc_name = "Old Man Sword Cave"
location = ALttPLocation(player, loc_name, shop_table_by_location[loc_name], parent=old_man_take_any)
Expand All @@ -562,16 +562,16 @@ def set_up_take_anys(world, player):
old_man_take_any.shop.add_inventory(0, 'Rupees (300)', 0, 0)

for num in range(4):
take_any = LTTPRegion("Take-Any #{}".format(num+1), LTTPRegionType.Cave, 'a cave of choice', player, world)
world.regions.append(take_any)
take_any = LTTPRegion("Take-Any #{}".format(num+1), LTTPRegionType.Cave, 'a cave of choice', player, multiworld)
multiworld.regions.append(take_any)

target, room_id = world.random.choice([(0x58, 0x0112), (0x60, 0x010F), (0x46, 0x011F)])
target, room_id = multiworld.random.choice([(0x58, 0x0112), (0x60, 0x010F), (0x46, 0x011F)])
reg = regions.pop()
entrance = world.get_region(reg, player).entrances[0]
connect_entrance(world, entrance.name, take_any.name, player)
entrance = multiworld.get_region(reg, player).entrances[0]
connect_entrance(multiworld, entrance.name, take_any.name, player)
entrance.target = target
take_any.shop = TakeAny(take_any, room_id, 0xE3, True, True, total_shop_slots + num + 1)
world.shops.append(take_any.shop)
multiworld.shops.append(take_any.shop)
take_any.shop.add_inventory(0, 'Blue Potion', 0, 0)
take_any.shop.add_inventory(1, 'Boss Heart Container', 0, 0)
location = ALttPLocation(player, take_any.name, shop_table_by_location[take_any.name], parent=take_any)
Expand Down
2 changes: 1 addition & 1 deletion worlds/alttp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def stage_fill_hook(cls, multiworld, progitempool, usefulitempool, filleritempoo
if not multiworld.ganonstower_vanilla[player] or \
world.options.glitches_required.current_key in {'overworld_glitches', 'hybrid_major_glitches', "no_logic"}:
pass
elif 'triforce_hunt' in world.options.goal.current_key and ('local' in world.options.goal.current_key or world.players == 1):
elif 'triforce_hunt' in world.options.goal.current_key and ('local' in world.options.goal.current_key or multiworld.players == 1):
trash_counts[player] = multiworld.random.randint(world.options.crystals_needed_for_gt * 2,
world.options.crystals_needed_for_gt * 4)
else:
Expand Down

0 comments on commit bdd498d

Please sign in to comment.