diff --git a/worlds/ladx/LADXR/generator.py b/worlds/ladx/LADXR/generator.py index 72d631da86a0..0406ad51f890 100644 --- a/worlds/ladx/LADXR/generator.py +++ b/worlds/ladx/LADXR/generator.py @@ -3,6 +3,7 @@ import importlib.machinery import os import pkgutil +from collections import defaultdict from .romTables import ROMWithTables from . import assembler @@ -322,6 +323,22 @@ def gen_hint(): if args.doubletrouble: patches.enemies.doubleTrouble(rom) + if ap_settings["text_shuffle"]: + buckets = defaultdict(list) + # For each ROM bank, shuffle text within the bank + for n, data in enumerate(rom.texts._PointerTable__data): + # Don't muck up which text boxes are questions and which are statements + if type(data) != int and data and data != b'\xFF': + buckets[(rom.texts._PointerTable__banks[n], data[len(data) - 1] == 0xfe)].append((n, data)) + for bucket in buckets.values(): + # For each bucket, make a copy and shuffle + shuffled = bucket.copy() + rnd.shuffle(shuffled) + # Then put new text in + for bucket_idx, (orig_idx, data) in enumerate(bucket): + rom.texts[shuffled[bucket_idx][0]] = data + + if ap_settings["trendy_game"] != TrendyGame.option_normal: # TODO: if 0 or 4, 5, remove inaccurate conveyor tiles diff --git a/worlds/ladx/LADXR/patches/owl.py b/worlds/ladx/LADXR/patches/owl.py index b22386a6cb8f..47e575191a31 100644 --- a/worlds/ladx/LADXR/patches/owl.py +++ b/worlds/ladx/LADXR/patches/owl.py @@ -11,15 +11,17 @@ def removeOwlEvents(rom): re.removeEntities(0x41) re.store(rom) # Clear texts used by the owl. Potentially reused somewhere o else. - rom.texts[0x0D9] = b'\xff' # used by boomerang # 1 Used by empty chest (master stalfos message) # 8 unused (0x0C0-0x0C7) # 1 used by bowwow in chest # 1 used by item for other player message # 2 used by arrow chest messages # 2 used by tunics - for idx in range(0x0BE, 0x0CE): - rom.texts[idx] = b'\xff' + + # Undoing this, we use it for text shuffle now + #rom.texts[0x0D9] = b'\xff' # used by boomerang + # for idx in range(0x0BE, 0x0CE): + # rom.texts[idx] = b'\xff' # Patch the owl entity into a ghost to allow refill of powder/bombs/arrows diff --git a/worlds/ladx/LADXR/patches/phone.py b/worlds/ladx/LADXR/patches/phone.py index f38745606c38..a2f3939a08a1 100644 --- a/worlds/ladx/LADXR/patches/phone.py +++ b/worlds/ladx/LADXR/patches/phone.py @@ -2,34 +2,35 @@ def patchPhone(rom): - rom.texts[0x141] = b"" - rom.texts[0x142] = b"" - rom.texts[0x143] = b"" - rom.texts[0x144] = b"" - rom.texts[0x145] = b"" - rom.texts[0x146] = b"" - rom.texts[0x147] = b"" - rom.texts[0x148] = b"" - rom.texts[0x149] = b"" - rom.texts[0x14A] = b"" - rom.texts[0x14B] = b"" - rom.texts[0x14C] = b"" - rom.texts[0x14D] = b"" - rom.texts[0x14E] = b"" - rom.texts[0x14F] = b"" - rom.texts[0x16E] = b"" - rom.texts[0x1FD] = b"" - rom.texts[0x228] = b"" - rom.texts[0x229] = b"" - rom.texts[0x22A] = b"" - rom.texts[0x240] = b"" - rom.texts[0x241] = b"" - rom.texts[0x242] = b"" - rom.texts[0x243] = b"" - rom.texts[0x244] = b"" - rom.texts[0x245] = b"" - rom.texts[0x247] = b"" - rom.texts[0x248] = b"" + # reenabled for text shuffle +# rom.texts[0x141] = b"" +# rom.texts[0x142] = b"" +# rom.texts[0x143] = b"" +# rom.texts[0x144] = b"" +# rom.texts[0x145] = b"" +# rom.texts[0x146] = b"" +# rom.texts[0x147] = b"" +# rom.texts[0x148] = b"" +# rom.texts[0x149] = b"" +# rom.texts[0x14A] = b"" +# rom.texts[0x14B] = b"" +# rom.texts[0x14C] = b"" +# rom.texts[0x14D] = b"" +# rom.texts[0x14E] = b"" +# rom.texts[0x14F] = b"" +# rom.texts[0x16E] = b"" +# rom.texts[0x1FD] = b"" +# rom.texts[0x228] = b"" +# rom.texts[0x229] = b"" +# rom.texts[0x22A] = b"" +# rom.texts[0x240] = b"" +# rom.texts[0x241] = b"" +# rom.texts[0x242] = b"" +# rom.texts[0x243] = b"" +# rom.texts[0x244] = b"" +# rom.texts[0x245] = b"" +# rom.texts[0x247] = b"" +# rom.texts[0x248] = b"" rom.patch(0x06, 0x2A8F, 0x2BBC, ASM(""" ; We use $DB6D to store which tunics we have. This is normally the Dungeon9 instrument, which does not exist. ld a, [$DC0F] diff --git a/worlds/ladx/LADXR/pointerTable.py b/worlds/ladx/LADXR/pointerTable.py index 9b8d49466c02..a1a92ba1780b 100644 --- a/worlds/ladx/LADXR/pointerTable.py +++ b/worlds/ladx/LADXR/pointerTable.py @@ -116,7 +116,10 @@ def store(self, rom): rom.banks[ptr_bank][ptr_addr] = pointer & 0xFF rom.banks[ptr_bank][ptr_addr + 1] = (pointer >> 8) | 0x40 - for n, s in enumerate(self.__data): + data = list(enumerate(self.__data)) + data.sort(key=lambda t: type(t[1]) == int or -len(t[1])) + + for n, s in data: if isinstance(s, int): pointer = s else: diff --git a/worlds/ladx/Options.py b/worlds/ladx/Options.py index f80ad1552001..f1d5c5130168 100644 --- a/worlds/ladx/Options.py +++ b/worlds/ladx/Options.py @@ -43,6 +43,12 @@ class TradeQuest(DefaultOffToggle, LADXROption): display_name = "Trade Quest" ladxr_name = "tradequest" +class TextShuffle(DefaultOffToggle): + """ + [On] Shuffles all the text in the game + [Off] (default) doesn't shuffle them. + """ + class Rooster(DefaultOnToggle, LADXROption): """ [On] Adds the rooster to the item pool. @@ -431,6 +437,7 @@ class AdditionalWarpPoints(DefaultOffToggle): 'trendy_game': TrendyGame, 'gfxmod': GfxMod, 'palette': Palette, + 'text_shuffle': TextShuffle, 'shuffle_nightmare_keys': ShuffleNightmareKeys, 'shuffle_small_keys': ShuffleSmallKeys, 'shuffle_maps': ShuffleMaps, @@ -439,4 +446,5 @@ class AdditionalWarpPoints(DefaultOffToggle): 'music_change_condition': MusicChangeCondition, 'nag_messages': NagMessages, 'ap_title_screen': APTitleScreen, + }