Underrail Forum

Underrail => General => Topic started by: MichaelBurge on December 29, 2015, 01:03:40 am

Title: How to reset Abram's quest state if you've messed it up
Post by: MichaelBurge 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/
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: Orobis 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: MichaelBurge 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: TΛPETRVE 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: MichaelBurge 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: TΛPETRVE 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: Orobis 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.

Title: Re: How to reset Abram's quest state if you've messed it up
Post by: minsc 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: MichaelBurge 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: MisterBurkes 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: MichaelBurge 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: MisterBurkes 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: player1 on March 01, 2016, 07:53:46 am
Does this still work with recent save format file changes?
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: MichaelBurge 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: blakjak 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.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: max silver on March 07, 2016, 07:52:45 pm
I can also confirm that this procedure works under the latest game version. It took me awhile to fully sink my head around the necessary hex edits, but I finally got it right and worked my way through the Abram quests. It's too bad that so many quest are locked up if you unwittingly give an incorrect answer, many thanks to the OP for the workaround.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: player1 on March 13, 2016, 04:13:47 pm
@MichaelBurge
Your packer will crash if proper arguments are not passed.

If in future you want to make new version of tool, I would suggest adding validation for arguments as well as help output with list or arguments, if no argument is passed. This is de facto standard for command line tools.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: Jessen on April 03, 2016, 05:31:32 am
Its interesting to see that this isn't the only thing you can do with the save editing, I've gone so far as to change items into other items, and all that  in between. It would be nice if we had a tool that could do this all automatically for us.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: player1 on April 03, 2016, 07:33:55 am
Has anyone had luck with modding faction hostility?

I'm trying to resolve this issue:
http://underrail.com/forums/index.php?topic=2164.0
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: Jessen on April 05, 2016, 12:25:17 am
@epeli
Have you had any progress in your tool? I've been hoping that we might end up making a save editor for UnderRail that can save us time when we're toying with the save. I've edited a whole bunch of items into my inventory and looked at the other parts of the save, but I'm trying to find more ways to make it even easier and quicker.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: Jessen on April 05, 2016, 02:54:34 am
The dialog stuff certainly, though I wonder who I could talk to about making a tool for the inventory, feats and Psi powers aspects of the saves
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: andz on August 12, 2019, 12:15:07 am
So what flags do I need to change?

I have:

npc_abram_saidHeWantsEmbassyInfo 01
npc_abram_agreedToAnswerEmbassyQuestions 01
npc_abram_toldHimYouHaveEmbassyAccess 01 (was 00, changed to 01)
npc_abram_toldHimEmbassyHasDogs 00
npc_abram_interviewCompleted 01
npc_abram_interviewScore 02

But Abram still doesn't want to talk to me.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: cmdrfunk on August 18, 2019, 10:42:58 pm
So what flags do I need to change?

I have:

npc_abram_saidHeWantsEmbassyInfo 01
npc_abram_agreedToAnswerEmbassyQuestions 01
npc_abram_toldHimYouHaveEmbassyAccess 01 (was 00, changed to 01)
npc_abram_toldHimEmbassyHasDogs 00
npc_abram_interviewCompleted 01
npc_abram_interviewScore 02

But Abram still doesn't want to talk to me.

Yep I modified the same stuff and he won't talk to me in 2019
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: Albino on September 18, 2019, 09:33:59 pm
EDIT
This topic seems to be still getting plenty of traffic, so...
The CLI unpacker linked in the post above doesn't work correctly for recent files because it uses a hardcoded number from 2015 as Underrail data model version. Fixing files packed with this program is just a matter of changing the version bytes in file header back to what they were in your original file, but there's also an easier way:

For (un)packing Underrail files from any current and future versions, try https://underrail.info.tm/unpacker/ (Remember to choose correct version from dropdown menu before repacking! Versions from files you unpack are temporarily added to the list.)

ORIGINAL POST
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.

That's good to know! Many other Underrail files appear to have the same structure. I had tried to unpack other gzipped files earlier, but I couldn't identify the headers (yeah, this stuff is way over my head) :)

I tried using this but I'm currently on version 1.1.0.12 with the expansion, is it still doable? All I get after opening it in notepad or a hex editor is just a bunch of gibberish.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: Slimu on October 21, 2019, 07:55:39 am
I also tried with the latest version of the game and it doesn't work.

In my case, I declined planting the bug in the embassy. I found the flag for it, but editing it didn't work. What I found strange was that there were also two other flags about the rescue mission appearing before the flag I mentioned. I also updated them and it didn't work. Since I was experimenting, I tried two other things, setting the flags to a different name (changing Abram to Bbram) and setting the flags to the same name as ones previously set. Neither of them worked and the save couldn't be loaded.

I also tried removing them and leaving only the flags relating to the first task, but it didn't work. I saw that after a flag's name & value, the 4th byte was holding some counter, with values like m, n, o, etc. (in my file). I guess that removing the lines should be done with updating the counter for the following values. Because the counter values were pretty small, I guess it starts from 0 based on some trigger.

 A solution may be to check a save file for a character which accepted the task and compare the flag values. But I'm afraid there may be another field set beyond this named ones which holds the actual state if Abram should talk to you again.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: Calcium on October 30, 2020, 12:58:01 am
Just got this working today, can confirm it still works in the current version. You need to find the image at the beginning of this thread where he shows you exactly which strings to alter the values of. Cheers!
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: WendigoBob on May 04, 2021, 09:24:34 pm
Does anybody know how to unpack for the latest versions of the game? I keep getting a "Failed to load saved game" error. I'm assuming the problem is tied with the packing/unpacking, as even an unmodified global.dat that has just been unpacked/packed causes the error. The original main.exe is of course nonfunctional, but even the website (https://underrail.info/unpacker/) seems to be limited to 1.0 patches.
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: Vizendel on September 27, 2021, 09:16:04 am
Is there any way to edit these files to respawn Everard if I happened to murderhobo him like 40 hours before I even touched the Oculus quests?
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: redgoesfastfastfastfast on October 03, 2021, 08:19:23 am
I'm 99% sure there is no way to respawn a dead NPC
Title: Re: How to reset Abram's quest state if you've messed it up
Post by: Liquor_Snake on December 01, 2021, 12:23:16 am
Has anyone figured out a way to add a new flags to global.dat ? Or maybe is it possible to completely restart the state of given location?