/=================================================================\ | blackle & minerobber's guide to hacking/corrupting undertale[1] | \=================================================================/ [1] ...on linux with wine = Intro = This guide assumes you've downloaded the DRM free version of undertale from humble bundle or other, which will give you the executible called "UNDERTALE_WINDOWS.exe". Additionally, it assumes the version is 1.00, but you can probably find all the file offsets I've found using the same techniques if you have a different version (has toby even released another version yet?) Basically how this guide will go is I will discuss the basics of modifying this executable, from shuffling music around, to changing the text the characters say (WE GOT TORIEL TO SAY FUCK!), to extracting and modifying the game spritesheets. I'm assuming knowledge of the command line. you need to have/know how to use the following things to follow this guide: - linux computer - terminal emulator - dd/strings/sed/grep/etc... - wine - python(?) - the corruptor utility I'm currently writing and will post sometime is in python, - and I might add another section on how to goof with it?? - cab extractors/compressors - I'll go over this so don't worry - binwalk (https://github.com/devttys0/binwalk) - really only if you have a different version and have to find offsets from scratch - a hex editor (for text editing) - pretty much any hex editor should work if you don't know one or two of these things that's fine bc I'll be writing out the commands to use. = Preliminaries = Basically the undertale exe is a launcher with the actual code nested inside. it looks like this - undertale_windows.exe - embedded cabinet file - undertale.exe - data.win - credits.txt - music/sound oggs - other junk the file archive extractor I had installed on my computer (file-roller) found the cab file right away, but if you want to extract it manually you can use binwalk to find the offset and size: ~$ binwalk UNDERTALE_WINDOWS.exe DECIMAL HEXADECIMAL DESCRIPTION -------------------------------------------------------------------------------- 0 0x0 Microsoft portable executable 55652 0xD964 Microsoft Cabinet archive data, 124547897 bytes, 220 files ^C (quit bc that's all we need to see) use dd to pull it out: ~$ dd if=UNDERTALE_WINDOWS.exe of=UNDERTALE.cab skip=55652 count=124547897 bs=1 and then extract it. To extract the cab you can either use cabextract, which might already be installed? It was on my machine but I couldn't remember where I got it from. You can also use cabarc.exe, which is a utility program in windows that extracts or makes cabinet files with different compression rates. we're going to need this later anway, a copy is in my public_html root: '/cabarc.exe' make sure you run these in a directory you don't mind getting filled up with cruft ~$ cabextract UNDERTALE.cab or ~$ wine cabarc.exe x UNDERTALE.cab and now you have tons of files! = Testing apparatus == now that you have everything extracted, you can actually play the game by running the newly created UNDERTALE.exe directly. Doing this will cause the exe to read the assets (ogg files, data.win, etc) from the directory it's run in, and not the cabinet file. This way you can do edits to all the assets, and test those edits without needing to wrap them back into the origional UNDERTALE_WINDOWS.exe file. the one problem is you can't save or load your game when running from the bare EXE, so you best get used to playing in the ruins over and over and over again. oddly enough it does keep track of how many times you've met flowey, so they'll start saying "don't you have anything better to do?" basically every time you encounter him = Music swapping = the most obvious first thing to do is change the music files around, eg. setting the intro theme to megalovania: ~$ mv mus_story.ogg mus_story.ogg.bak ~$ mv mus_zz_megalovania.ogg mus_story.ogg ~$ mv mus_story.ogg.bak mus_zz_megalovania.ogg then run UNDERTALE.exe for some giggles :3 you could also use your own music files, but I'm guessing they have to be ogg. I haven't fully experimented with using custom music files yet. I don't think there would be a problem but it might assume certian bitrates or something *shrug* = Text editing/swapping = (written by ~minerobber) Text editing in Undertale is quite easy once you get the hang of it. Open the data.win file in your favorite hex editor. (Most text can be edited this way) - Strategy 1: Word Find - Search for a word in the sentence you want to edit. (i.e; "FLOWEY") It must be one or two words at the most, as control characters (stuff like yellow text and the like) are stored within the sentence, making it harder to find the line you wish to change. After you find the string you are looking for, you can edit it. See footnote 1 of this section for a link to a description of what control characters do what. - Strategy 2: Control Character Search - See footnote 1 of this section for control characters. Find the control character that matches what you want, and search for it as a string literal in your hex editor. (i.e; "\Ts" for Sans dialogue) All lines starting with the control character you chose are for what you searched. (in the earlier example, this would bring up all of Sans's dialogue. (as an aside: Sans's? Sans'?)) - Once you've found your string - Now that you've found your string, look for the panel of the hex editor where you see ASCII characters. This is where you can type whatever you're replacing your string with. If the replacement string is shorter, end all text how the original ends. (If it ends in "%%", end your modified string with "%%", etc.) [Footnote 1: https://www.reddit.com/r/Underminers/comments/3teemm/wip_documenting_stringstxt/] = Extracting and modifying spritesheets = (under construction... by that I mean blackle should write this section unless they want me to -minerobber)