Author Topic: How to reset Abram's quest state if you've messed it up  (Read 26105 times)

MichaelBurge

  • Probably not a Spambot
  • *
  • Posts: 29
  • Karma: +11/-0
    • View Profile
How to reset Abram's quest state if you've messed it up
« on: December 29, 2015, 01:03:40 am »
I accidentally told Abram that there were dogs in the Junkyard Embassy compound, but realized too late that this would cut me off from the questline. I didn't want to redo all of my progress because of that one mistake, so I cheated by editing one of my saves. It appears to work, so I thought I'd document what I did here in case anyone else finds it useful. Be sure to save a copy of your game before attempting anything like this.

I'm not sure I actually recommend doing this, but it's here if you're desperate. I'll note that I'm writing this immediately after noticing Abram pick up the change, but I haven't gone through the entire questline yet to see if there are any issues.

1. Quests often have  a simple 'yes/no' trigger  that tracks your dialogue options, whether you've killed people, where you've been, who you've talked to, etc. These are stored in your 'global.dat' file. This files consists of a 16-byte GUID that identifies the file as being Underrail-related, an 8-byte version marker, and then the gzip'ed output of serializing some internal game data structures. So you should remove the first 24 bytes and unzip the remainder(let's call this remainder the 'Unpacked File'). You can use the 'unpack' option on my program below[1] to do this step.

2. Notice some interesting strings in the resulting file with names like "npc_abram_saidHeWantsEmbassyInfo" or "npc_abram_toldHimEmbassyHasDogs" that all look relevant, next to some binary gibberish. I believe that these are set when the dialog files("Data/Dialogs/Characters/abram.udlg") are interpreted by the Underrail engine. You should only have flags in your save that the game has actually set, since it lazily creates them as needed. Your action here should be to review the Unpacked File for Abram-related flags using any text editor.

3. Underrail treats a missing flag as equivalent to being false. Observe that the byte immediately following all quest flag names has a value of 1. It will be significantly easier to change this value to a 0 than to attempt to remove the flag entirely. Using your hex editor of choice[2], locate and change all of these bytes to 0.

4. The Unpacked File needs to be packed again in order for Underrail to read it. Gzip it, and then prepend the 24 bytes that you removed in step 1. You can use the 'pack' option on my program below[1] to do this step. Then name it 'global.dat' and replace your original 'global.dat' with it.

[1]
Binary: https://github.com/MichaelBurge/underrail-unpacker/releases

Usage:
Main.exe unpack < original_global.dat > unpacked.dat
Main.exe pack < unpacked.dat > new_global.dat

Here's an example of me building this, unpacking one of my example saves, repacking it, and then confirming that the files match. You'll want to have 'make', 'csc'(the C# compiler), and 'md5sum' in your PATH to follow along.
Code: [Select]
C:\Users\mike2_000\Desktop\repos\underrail-unpacker>make
csc.exe Main.cs
Microsoft (R) Visual C# Compiler version 12.0.21005.1
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.


>Main.exe unpack < "C:\Users\mike2_000\Documents\My Games\Underrail\Saves\a\global.dat" > unpacked.dat
>Main.exe pack < unpacked.dat > packed.dat

>md5sum "C:\Users\mike2_000\Documents\My Games\Underrail\Saves\a\global.dat" packed.dat
\e12ab7cfcdde5281b93ab502bb197dc0 *C:\\Users\\mike2_000\\Documents\\My Games\\Underrail\\Saves\\a\\global.dat
e12ab7cfcdde5281b93ab502bb197dc0 *packed.dat

[2] If you're on Windows, I used HxD to edit my Unpacked File:
http://mh-nexus.de/en/hxd/

Orobis

  • Probably not a Spambot
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #1 on: December 29, 2015, 05:33:22 am »
Thanks for this, i made a thread asking if anyone was able to do this, hopefully it works, but if not no big deal.

MichaelBurge

  • Probably not a Spambot
  • *
  • Posts: 29
  • Karma: +11/-0
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #2 on: December 29, 2015, 06:50:59 pm »
Quote
Thanks for this, i made a thread asking if anyone was able to do this, hopefully it works, but if not no big deal.

It seems to be working: I made it to the Oculus without any trouble.

TΛPETRVE

  • Scavenger
  • ***
  • Posts: 159
  • Karma: +16/-5
  • Obey the Schnibble!
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #3 on: December 29, 2015, 07:19:32 pm »
Did you have to correct anything on Jack Quicksilver's quests? The Foundry and/or Lenox Pierce quests are still bugged.
But the problem is, indeed, it zlots at Vlurxtrznbnaxl.

MichaelBurge

  • Probably not a Spambot
  • *
  • Posts: 29
  • Karma: +11/-0
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #4 on: December 29, 2015, 09:23:55 pm »
I didn't have to make any further corrections, and was able to complete all of Jack's quests optimally. If you've made a mistake further along in the questline, I imagine that there are a different set of flags. They seem to listed in the game file in the same order that the game set them, so that may help you find them.

I never met Jack in SGS, so if you've done that quest that could also be something to look at.

TΛPETRVE

  • Scavenger
  • ***
  • Posts: 159
  • Karma: +16/-5
  • Obey the Schnibble!
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #5 on: December 29, 2015, 09:30:00 pm »
Now that you mention it, the one time I actually made it to Oculus was when I skipped Jack Quicksilver's delivery mission. Might try that again; maybe there is a connection.
But the problem is, indeed, it zlots at Vlurxtrznbnaxl.

Orobis

  • Probably not a Spambot
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #6 on: December 30, 2015, 12:56:08 am »
On second thought i'm not going to do this, just going to wait for my next play through to do this quest line, don't have to do everything in a single play through.


minsc

  • Probably not a Spambot
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #7 on: January 01, 2016, 07:03:54 am »
Could someone better explain how to get this save editor to work for a noob like me? I've got mainfile, main.cs and the exe in the same folder as my save but the exe crashes when I try to run it.

I should mention I'm trying to undo my choice to report Abram to the Protectorate guard so I can do that side questline.
« Last Edit: January 01, 2016, 04:14:22 pm by minsc »

MichaelBurge

  • Probably not a Spambot
  • *
  • Posts: 29
  • Karma: +11/-0
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #8 on: January 01, 2016, 11:40:45 pm »
Could someone better explain how to get this save editor to work for a noob like me? I've got mainfile, main.cs and the exe in the same folder as my save but the exe crashes when I try to run it.

The instructions and program are a little thin - I stopped working on it as soon as I got the questline to continue, so that post is something of a quick braindump before I forgot everything. Thanks for giving it a try.

It's a command line program, so you'll need to use a command prompt to run it. It does currently crash if you leave off its command line argument. Try these instructions:

1. Open your Windows command prompt
2. Navigate to the directory holding your Underrail save using the 'cd' command. Use 'dir' to confirm that you're in the right place: You should see a file called 'global.dat' is there.
3. Copy the Main.exe into this directory with the 'global.dat' file
4. Run this on your command prompt:
Code: [Select]
Main.exe unpack < global.dat > unpacked.dat
5. Search for Abram-related strings like 'npc_abram_saidHeWantsEmbassyInfo' in the 'unpacked.dat' file. They should be grouped somewhat close together.
6. Using the hex editor on the 'unpacked.dat' file, change the 01 byte immediately to the right of each Abram-related string to a 00. Save the file.
7. Repack the file by running the following on your command prompt:
Code: [Select]
Main.exe pack < unpacked.dat > global.dat
8. Reload your save, and then talk to Abram.

If you still have trouble getting it to work, let me know which step is giving you problems. I could try moving some of these steps into the program.

MisterBurkes

  • Probably not a Spambot
  • *
  • Posts: 10
  • Karma: +2/-0
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #9 on: January 04, 2016, 10:25:45 pm »
Could someone better explain how to get this save editor to work for a noob like me? I've got mainfile, main.cs and the exe in the same folder as my save but the exe crashes when I try to run it.

The instructions and program are a little thin - I stopped working on it as soon as I got the questline to continue, so that post is something of a quick braindump before I forgot everything. Thanks for giving it a try.

It's a command line program, so you'll need to use a command prompt to run it. It does currently crash if you leave off its command line argument. Try these instructions:

1. Open your Windows command prompt
2. Navigate to the directory holding your Underrail save using the 'cd' command. Use 'dir' to confirm that you're in the right place: You should see a file called 'global.dat' is there.
3. Copy the Main.exe into this directory with the 'global.dat' file
4. Run this on your command prompt:
Code: [Select]
Main.exe unpack < global.dat > unpacked.dat
5. Search for Abram-related strings like 'npc_abram_saidHeWantsEmbassyInfo' in the 'unpacked.dat' file. They should be grouped somewhat close together.
6. Using the hex editor on the 'unpacked.dat' file, change the 01 byte immediately to the right of each Abram-related string to a 00. Save the file.
7. Repack the file by running the following on your command prompt:
Code: [Select]
Main.exe pack < unpacked.dat > global.dat
8. Reload your save, and then talk to Abram.

If you still have trouble getting it to work, let me know which step is giving you problems. I could try moving some of these steps into the program.

Could you elaborate on the hex editing part? I'm changing several 01s to 00s but not sure if I've done it correctly. I'm successfully unpacking - repacking, but my edits are corrupting the save file.

MichaelBurge

  • Probably not a Spambot
  • *
  • Posts: 29
  • Karma: +11/-0
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #10 on: January 05, 2016, 02:41:42 am »
Could someone better explain how to get this save editor to work for a noob like me? I've got mainfile, main.cs and the exe in the same folder as my save but the exe crashes when I try to run it.

The instructions and program are a little thin - I stopped working on it as soon as I got the questline to continue, so that post is something of a quick braindump before I forgot everything. Thanks for giving it a try.

It's a command line program, so you'll need to use a command prompt to run it. It does currently crash if you leave off its command line argument. Try these instructions:

1. Open your Windows command prompt
2. Navigate to the directory holding your Underrail save using the 'cd' command. Use 'dir' to confirm that you're in the right place: You should see a file called 'global.dat' is there.
3. Copy the Main.exe into this directory with the 'global.dat' file
4. Run this on your command prompt:
Code: [Select]
Main.exe unpack < global.dat > unpacked.dat
5. Search for Abram-related strings like 'npc_abram_saidHeWantsEmbassyInfo' in the 'unpacked.dat' file. They should be grouped somewhat close together.
6. Using the hex editor on the 'unpacked.dat' file, change the 01 byte immediately to the right of each Abram-related string to a 00. Save the file.
7. Repack the file by running the following on your command prompt:
Code: [Select]
Main.exe pack < unpacked.dat > global.dat
8. Reload your save, and then talk to Abram.

If you still have trouble getting it to work, let me know which step is giving you problems. I could try moving some of these steps into the program.

Could you elaborate on the hex editing part? I'm changing several 01s to 00s but not sure if I've done it correctly. I'm successfully unpacking - repacking, but my edits are corrupting the save file.

I opened up one of my saves and took a screenshot of the bytes that I would change if I were doing this again. The changes should be highlighted in red in the attachment. All of the red 00s were previously 01s. I don't have a save near this area so I'm unable to test it, but I've used a similar trick elsewhere. You'll notice the byte next to 'npc_abram_toldHimEmbassyHasDogs' didn't need to be changed, because this time around I told him there were no dogs(so the byte remained 00).

If you edit outside of these, it does tend to corrupt the save file. Or if you try to change the name of a flag, or remove a flag's section. It's possible to do these, but they take more work.

MisterBurkes

  • Probably not a Spambot
  • *
  • Posts: 10
  • Karma: +2/-0
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #11 on: January 06, 2016, 01:11:17 am »
Thanks, it worked! Looks like I had to change all of the 01s to 00s preceding a 05 offset.

player1

  • Tchortist
  • ****
  • Posts: 321
  • Karma: +13/-0
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #12 on: March 01, 2016, 07:53:46 am »
Does this still work with recent save format file changes?

MichaelBurge

  • Probably not a Spambot
  • *
  • Posts: 29
  • Karma: +11/-0
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #13 on: March 01, 2016, 04:36:47 pm »
Does this still work with recent save format file changes?

Let me check.

I think so, at least for the purposes of changing quest flags. The global.dat file appears superficially to be the same format as before, and the bytes that I'd change are in the same position.

For the rest of the changes, the new files look substantially similar to the old ones. It looks like the focus was on packing the hundreds of different files into 3-4 16MB chunks, rather than changing the format itself.

blakjak

  • Probably not a Spambot
  • *
  • Posts: 19
  • Karma: +2/-0
  • sic itur ad astra
    • View Profile
Re: How to reset Abram's quest state if you've messed it up
« Reply #14 on: March 01, 2016, 10:28:26 pm »
Does this still work with recent save format file changes?
Let me check.

I can confirm that it seems to work with the new saves. I used it earlier today and Underrail hasn't crashed at all.