From 21b8c731793975de71d35fc671e1b642a8971da0 Mon Sep 17 00:00:00 2001 From: cassidy <43386495+cassidoxa@users.noreply.github.com> Date: Sun, 2 Feb 2020 20:10:56 -0500 Subject: [PATCH] Add "timer" as individual setting (#23) --- BaseClasses.py | 6 +++--- EntranceRandomizer.py | 2 +- ItemList.py | 10 +++++----- Main.py | 2 ++ Mystery.py | 7 +++++++ Rom.py | 14 +++++++------- easy.yaml | 9 ++++++++- 7 files changed, 33 insertions(+), 17 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index f7ddb98a..5d2a4ce9 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -18,7 +18,7 @@ class World(object): self.swords = swords.copy() self.difficulty = difficulty.copy() self.difficulty_adjustments = difficulty_adjustments.copy() - self.timer = timer + self.timer = timer.copy() self.progressive = progressive self.goal = goal.copy() self.algorithm = algorithm @@ -37,7 +37,6 @@ class World(object): self.shuffle_bonk_prizes = False self.light_world_light_cone = False self.dark_world_light_cone = False - self.clock_mode = 'off' self.rupoor_cost = 10 self.aga_randomness = True self.lock_aga_door_in_escape = False @@ -48,7 +47,6 @@ class World(object): self.retro = retro.copy() self.custom = custom self.customitemarray = customitemarray - self.can_take_damage = True self.hints = hints.copy() self.dynamic_regions = [] self.dynamic_locations = [] @@ -93,6 +91,8 @@ class World(object): set_player_attr('open_pyramid', False) set_player_attr('treasure_hunt_icon', 'Triforce Piece') set_player_attr('treasure_hunt_count', 0) + set_player_attr('clock_mode', 'off') + set_player_attr('can_take_damage', False) def get_name_string_for_object(self, obj): return obj.name if self.players == 1 else f'{obj.name} ({self.get_player_names(obj.player)})' diff --git a/EntranceRandomizer.py b/EntranceRandomizer.py index 724d0d4b..725e6c1a 100755 --- a/EntranceRandomizer.py +++ b/EntranceRandomizer.py @@ -289,7 +289,7 @@ def parse_arguments(argv, no_defaults=False): playerargs = parse_arguments(shlex.split(getattr(ret,f"p{player}")), True) for name in ['logic', 'mode', 'swords', 'goal', 'difficulty', 'item_functionality', - 'shuffle', 'crystals_ganon', 'crystals_gt', 'openpyramid', + 'shuffle', 'crystals_ganon', 'crystals_gt', 'openpyramid', 'timer', 'mapshuffle', 'compassshuffle', 'keyshuffle', 'bigkeyshuffle', 'startinventory', 'retro', 'accessibility', 'hints', 'beemizer', 'shufflebosses', 'shuffleenemies', 'enemy_health', 'enemy_damage', 'shufflepots', diff --git a/ItemList.py b/ItemList.py index b1b3bf88..7d92e8a0 100644 --- a/ItemList.py +++ b/ItemList.py @@ -129,12 +129,12 @@ def generate_itempool(world, player): 'dungeons', 'triforcehunt', 'crystals'] - or world.mode[player] not in ['open', 'standard', 'inverted'] or world.timer not in ['none', 'display', + or world.mode[player] not in ['open', 'standard', 'inverted'] or world.timer[player] not in ['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown']): raise NotImplementedError('Not supported yet') - if world.timer in ['ohko', 'timed-ohko']: + if world.timer[player] in ['ohko', 'timed-ohko']: world.can_take_damage = False if world.goal[player] in ['pedestal', 'triforcehunt']: @@ -181,14 +181,14 @@ def generate_itempool(world, player): if world.custom: (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, lamps_needed_for_dark_rooms) = make_custom_item_pool(world.progressive[player], world.shuffle[player], - world.difficulty[player], world.timer, world.goal[player], + world.difficulty[player], world.timer[player], world.goal[player], world.mode[player], world.swords[player], world.retro[player], world.customitemarray) world.rupoor_cost = min(world.customitemarray[69], 9999) else: (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, lamps_needed_for_dark_rooms) = get_pool_core(world.progressive[player], world.shuffle[player], - world.difficulty[player], world.timer, world.goal[player], + world.difficulty[player], world.timer[player], world.goal[player], world.mode[player], world.swords[player], world.retro[player]) for item in precollected_items: @@ -226,7 +226,7 @@ def generate_itempool(world, player): world.lamps_needed_for_dark_rooms = lamps_needed_for_dark_rooms if clock_mode is not None: - world.clock_mode = clock_mode + world.clock_mode[player] = clock_mode if treasure_hunt_count is not None: world.treasure_hunt_count[player] = treasure_hunt_count diff --git a/Main.py b/Main.py index 37bb4e4e..d2e2ec7b 100644 --- a/Main.py +++ b/Main.py @@ -54,6 +54,7 @@ def main(args, seed=None): world.enemy_health = args.enemy_health.copy() world.enemy_damage = args.enemy_damage.copy() world.beemizer = args.beemizer.copy() + world.timer = args.timer.copy() world.shufflepots = args.shufflepots.copy() world.progressive = args.progressive.copy() world.extendedmsu = args.extendedmsu.copy() @@ -273,6 +274,7 @@ def copy_world(world): ret.enemy_health = world.enemy_health.copy() ret.enemy_damage = world.enemy_damage.copy() ret.beemizer = world.beemizer.copy() + ret.timer = world.timer.copy() ret.shufflepots = world.shufflepots.copy() ret.extendedmsu = world.extendedmsu.copy() diff --git a/Mystery.py b/Mystery.py index b4e151a4..5da15a85 100644 --- a/Mystery.py +++ b/Mystery.py @@ -217,6 +217,13 @@ def roll_settings(weights): ret.beemizer = int(get_choice('beemizer')) if 'beemizer' in weights else 0 + ret.timer = {'none': 'none', + 'timed': 'timed', + 'timed_ohko': 'timed-ohko', + 'ohko': 'ohko', + 'timed_countdown': 'timed-countdown', + 'display': 'display'}[get_choice('timer')] if 'timer' in weights.keys() else 'none' + ret.progressive = convert_to_on_off(get_choice('progressive')) if "progressive" in weights else 'on' inventoryweights = weights.get('startinventory', {}) startitems = [] diff --git a/Rom.py b/Rom.py index 9bb65dfb..05debbb2 100644 --- a/Rom.py +++ b/Rom.py @@ -707,7 +707,7 @@ def patch_rom(world, rom, player, team, enemized): # Set stun items rom.write_byte(0x180180, 0x03) # All standard items #Set overflow items for progressive equipment - if world.timer in ['timed', 'timed-countdown', 'timed-ohko']: + if world.timer[player] in ['timed', 'timed-countdown', 'timed-ohko']: overflow_replacement = GREEN_CLOCK else: overflow_replacement = GREEN_TWENTY_RUPEES @@ -861,19 +861,19 @@ def patch_rom(world, rom, player, team, enemized): ERtimeincrease = 20 if world.keyshuffle[player] or world.bigkeyshuffle[player] or world.mapshuffle[player]: ERtimeincrease = ERtimeincrease + 15 - if world.clock_mode == 'off': + if world.clock_mode[player] == 'off': rom.write_bytes(0x180190, [0x00, 0x00, 0x00]) # turn off clock mode write_int32(rom, 0x180200, 0) # red clock adjustment time (in frames, sint32) write_int32(rom, 0x180204, 0) # blue clock adjustment time (in frames, sint32) write_int32(rom, 0x180208, 0) # green clock adjustment time (in frames, sint32) write_int32(rom, 0x18020C, 0) # starting time (in frames, sint32) - elif world.clock_mode == 'ohko': + elif world.clock_mode[player] == 'ohko': rom.write_bytes(0x180190, [0x01, 0x02, 0x01]) # ohko timer with resetable timer functionality write_int32(rom, 0x180200, 0) # red clock adjustment time (in frames, sint32) write_int32(rom, 0x180204, 0) # blue clock adjustment time (in frames, sint32) write_int32(rom, 0x180208, 0) # green clock adjustment time (in frames, sint32) write_int32(rom, 0x18020C, 0) # starting time (in frames, sint32) - elif world.clock_mode == 'countdown-ohko': + elif world.clock_mode[player] == 'countdown-ohko': rom.write_bytes(0x180190, [0x01, 0x02, 0x01]) # ohko timer with resetable timer functionality write_int32(rom, 0x180200, -100 * 60 * 60 * 60) # red clock adjustment time (in frames, sint32) write_int32(rom, 0x180204, 2 * 60 * 60) # blue clock adjustment time (in frames, sint32) @@ -882,13 +882,13 @@ def patch_rom(world, rom, player, team, enemized): write_int32(rom, 0x18020C, (10 + ERtimeincrease) * 60 * 60) # starting time (in frames, sint32) else: write_int32(rom, 0x18020C, int((5 + ERtimeincrease / 2) * 60 * 60)) # starting time (in frames, sint32) - if world.clock_mode == 'stopwatch': + if world.clock_mode[player] == 'stopwatch': rom.write_bytes(0x180190, [0x02, 0x01, 0x00]) # set stopwatch mode write_int32(rom, 0x180200, -2 * 60 * 60) # red clock adjustment time (in frames, sint32) write_int32(rom, 0x180204, 2 * 60 * 60) # blue clock adjustment time (in frames, sint32) write_int32(rom, 0x180208, 4 * 60 * 60) # green clock adjustment time (in frames, sint32) write_int32(rom, 0x18020C, 0) # starting time (in frames, sint32) - if world.clock_mode == 'countdown': + if world.clock_mode[player] == 'countdown': rom.write_bytes(0x180190, [0x01, 0x01, 0x00]) # set countdown, with no reset available write_int32(rom, 0x180200, -2 * 60 * 60) # red clock adjustment time (in frames, sint32) write_int32(rom, 0x180204, 2 * 60 * 60) # blue clock adjustment time (in frames, sint32) @@ -1119,7 +1119,7 @@ def patch_rom(world, rom, player, team, enemized): rom.write_byte(0x18003B, 0x01 if world.mapshuffle[player] else 0x00) # maps showing crystals on overworld # compasses showing dungeon count - if world.clock_mode != 'off': + if world.clock_mode[player] != 'off': rom.write_byte(0x18003C, 0x00) # Currently must be off if timer is on, because they use same HUD location elif world.compassshuffle[player]: rom.write_byte(0x18003C, 0x01) # show on pickup diff --git a/easy.yaml b/easy.yaml index d7dd6c50..3979712b 100644 --- a/easy.yaml +++ b/easy.yaml @@ -105,6 +105,13 @@ beemizer: 2: 0 3: 0 4: 0 +timer: + none: 1 + timed: 0 + timed_ohko: 0 + ohko: 0 + timed_countdown: 0 + display: 0 rom: sprite: random: 1 @@ -141,4 +148,4 @@ rom: uw_palettes: default: 1 random: 1 - blackout: 0 \ No newline at end of file + blackout: 0