ATOM RPG

ATOM RPG

Not enough ratings
Editing saved games (1.06)
By Tam
This guide describes how to edit saved games, such as for redistributing skill points, without having to start a new game. Some technical knowledge, namely hexadecimal and how numbers are stored in memory, is assumed.

If you have trouble understanding anything written here, leave a comment. If I have time, I will try to address specific questions and improve the guide.
   
Award
Favorite
Favorited
Unfavorite
Introduction
In ATOM RPG, the saved game folder is normally

%SystemDrive%\users\<username>\AppData\LocalLow\atomteam\atom\

Save games are basically a set of "subfiles" that are concatenated together into one big file. That one big file is then gzip'ed and given a .as file extension.

The basic structure of an unzipped save game file is

1st subfile name (counted Unicode string)
1st subfile length (4 bytes, little-endian)
1st subfile contents (may be JSON data, or something else)
2nd subfile name (counted Unicode string)
2nd subfile length (4 bytes, little-endian)
2nd subfile contents (may be JSON data, or something else)
3rd subfile name (counted Unicode string)
... etc.

Google JSON if you want to know what it is.

Strings for subfile names appear to be stored as counted Windows unicode (UTF-16LE) strings. In other words, there are two bytes which are the number of Unicode characters that follow. So the string "player.dat" would be stored as

0A (length low byte = 10 decimal)
00 (length high byte)
70 p
00
6C l
00
61 a
00
79 y
00
65 e
00
72 r
00
2E .
00
64 d
00
61 a
00
74 t
00

The subfile length is stored as 4 bytes, little-endian. So if the subfile length is 99999, the 4 bytes are

9F
86
01
00

When editing a save game file, it is important to preserve the length of each subfile. In other words, you should not change the overall number of characters in a subfile. If you break this rule, you MUST update the subfile length accordingly, and in order to do that you'll need the Hex Editor plugin for Notepad++.

So, for example, if you want to change a JSON value from "0" to "20", you need to delete a nearby space character to leave the size of that subfile unchanged. Likewise, if you want to change a value from "20" to "0", change it to "00" or change a nearby single space character to two space characters.

NOTE: Deleting the spaces that separate JSON fields and writing 0 as "00" does no harm. The next save you make in-game will re-write all data cleanly anyway.
Step by step
In brief, these are the steps for editing a save game using only 7Zip and Notepad++ (if needed, install the Hex Editor plugin via Plugins -> Plugin Manager menu item):

1. MAKE A BACKUP OF ALL ATOM RPG SAVED GAMES, in case you break your saved game. Copy the numbered saved game of interest to your desktop.

2. Unzip the copy of the saved game using 7Zip, which gives you an uncompressed file with no file extension.

3. Open the uncompressed file in Notepad++ and find the subfile you want. The player is stored in JSON format in the subfile "p_l_a_y_e_r_._d_a_t_", where _ represents a byte with value 0.

To find the player.dat subfile, you can use the regular expression search function in Notepad++ with p.l.a.y.e.r.\..d.a.t. as the expression. In Notepad++ the search dialog should look like this:



4. Change JSON fields as desired, bearing in mind that you should avoid changing the overall length (in bytes) of the JSON data, as explained above. If you delete a character somewhere, add a space elsewhere. If you add a character somewhere, delete a space elsewhere.

5. Re-zip the file (using gzip compression) that you have just been editing into a file with .as file extension (not .gz) using 7Zip. Copy it back to the ATOM RPG saved game folder, overwriting what is there.

6. Run the game, attempt to load your saved game, and verify that your edits have taken effect.

NOTE: If you mess up a saved game, it can cause ATOM RPG to hang when you try to load a game. If that happens, you'll want to restore from the backup you made in step 1.
Alternative methods
It has been brought to my attention that there is a tool available which extracts the subfiles from an uncompressed saved game into individual files, including player.dat. Presumably the tool can also assemble an uncompressed save game from individual files.

I have not used this tool myself and cannot vouch for its safety or reliability, but it is apparently available here:

http://ru.atom-rpg.wikia.com/wiki/AtomSL

DISCLAIMER

The page hosting this tool is a Wiki page which may be editable by anybody, and there are reports that this tool is flagged as malicious or potentially malicious by certain antivirus software. It is poor Internet hygiene to download and run files that have not been confirmed to be safe.

Use at your own risk.

Obviously, if using this tool, the procedure for editing a saved game is somewhat different to what is given in the previous section, so you'll have to figure it out yourself.
7 Comments
Nirfse 5 Mar, 2020 @ 1:53pm 
Brief CLI routine on Linux. It was fun to play around with variables after finishing the game.

Open saved game directory, where "Save_1_v*" is a saved game and "Save_0_v*" is autosave file. You only need the former. Replace your actual slot number instead of "v9" below.

Make a backup:
$ cp Save_1_v9{.as,.as.bk}

Rename file to gzip extension:
$ mv Save_1_v9{.as,.gz}

Unpack gzip archive:
$ gzip -c -d Save_1_v9.gz > Save_1_v9

Use vim to edit extracted binary file. Vim correctly writes data without corrupting unicode strings. Scroll down to the most bottom where you'll find JSON strings (make sure you're familiar with basic vim usage):
$ vim ~/Save_1_v9

Archive edited file:
$ gzip -c ~/Save_1_v9 --keep --no-name -6 > Save_1_v9.as

Your save should show up on "Load game" screen. If it didn't, just remove new file and fallback to your backup:
$ rm Save_1_v9.as && mv Save_1_v9{.as.bk,.as}
JDub 17 Oct, 2019 @ 6:59pm 
Getting Hexeditor for NPP was a bit of a pain. This helped https://superuser.com/a/1410429/5200
=MAG=JBBlack 10 Jun, 2019 @ 7:59am 
Does anyone have a player.dat file with the Entomologist perk in it? If so could you upload it to DropBox?? I would truly appreciate it.
Comguitoz 21 Jan, 2019 @ 5:51am 
Dont use it. It gives me a virus warning.
Tam  [author] 18 Jan, 2019 @ 1:15pm 
@Tenzano - Ta, have added a section mentioning this.
Rain Spell 17 Jan, 2019 @ 3:02pm 
http://ru.atom-rpg.wikia.com/wiki/AtomSL - The utility of packing and unpacking save
kooto 17 Jan, 2019 @ 9:37am 
Thanks, rerolling is easy now :)