Save game editing

General discussion about the game.
arhimmel
Posts: 9
Joined: Mon Sep 17, 2012 11:25 pm

Re: Save game editing

Postby arhimmel » Tue Sep 18, 2012 12:27 am

swixel wrote:
arhimmel wrote:32 bit integers are longs. they are "long" bc integers used to be 16 bit. of course things have changed.


Oh, right. I was calibrating around words (32bits), assuming you meant a 64bit (too much modern C++ work where 'long' indicates 64bit for me now).. I haven't/don't tend to use 16bit-based syntax and just work around words, so my bad. I'm also working on this in C# to get some practice in it (adding to my confusion, an 'int' is 32 bits here too :P). Haven't looked into your code yet, but will release my C# stuff once I'm done getting the structure variant flags out of the way so we can at least pull data in a sane way.

I think I've identified types if nothing else ...



And I'm using Sublime Text 2, but it's commercial.



yeah the python struct is based on good old C.

i just updated my code and its a bit better but messy.

im using komodo edit along with hex fiend and zsh.

at some time or other i do plan to make a GUI for this
ChickenBandit
Posts: 15
Joined: Mon Sep 17, 2012 4:40 pm

Re: Save game editing

Postby ChickenBandit » Tue Sep 18, 2012 12:29 am

I haven't done any programming since high school, I'll just keep helping with decoding this crap I guess :)
swixel
Posts: 80
Joined: Mon Sep 17, 2012 6:08 am

Re: Save game editing

Postby swixel » Tue Sep 18, 2012 12:36 am

arhimmel wrote:yeah the python struct is based on good old C.

i just updated my code and its a bit better but messy.

im using komodo edit along with hex fiend and zsh.

at some time or other i do plan to make a GUI for this


Oh, I haven't looked at that. I'm just mucking about with raw bytes and C#. It's much easier in cpp... but yeah, idk. I could use Python too, but I felt like a new language last Thursday so I picked it up.

I'll have a look once I'm done. I tend to get my head in a funk and then can't recalibrate, so I don't want to pick up any errors (not saying there are any) and then try to force my parser into playing nice when there's an artefact.

ChickenBandit wrote:I haven't done any programming since high school, I'll just keep helping with decoding this crap I guess :)


This is just a hobby for me; no formal training, it's just amusing :P
Frodyne
Posts: 4
Joined: Mon Sep 17, 2012 11:11 pm

Re: Save game editing

Postby Frodyne » Tue Sep 18, 2012 12:38 am

I think I can help shed some light on the crew section of the save file.
And just to illustrate, I went and started a new game. Say hello to my crew (or at least Phillips, since it is him we will be playing with):
Image
After this I saved and quit, and this is how the save file looks in a hex editor (do not try editing it in any kind of plain text editor!)
The interesting part is highlighted in red.
Image
Now, you may notice that the crew is listed above my highlight, but as far as I can tell this is just a list of how the ship was equipped at the start of the game, and does not actually do anything - but I could of course be wrong. :D

In any case, the data for our dear crewmember Phillips (or Chris Phillips as is his full name) starts at the "0E" at the top of my red box - or rather at the "0E 00 00 00". This is a 32 bit integer in little-endian format, it basically means "14", and it is the length of his name - which, as you can see is the next field.
If you want to change his name, you MUST (!!!) change the length to match, or the game cannot read the save and it will freeze on load. Same thing applies to the race pair for that matter.

But first let me dump a small table here:

Code: Select all

Int32   Length of name
String   Name
Int32   Length of race
String   Race
Int32   0000 0000 ? - No idea what this does
Int32   Health
Int32   X coordinate
Int32   Y coordinate
Int32   Room
Int32   Room tile (0-3)
Int32   0100 0000 ? - No idea what this does
Int32   Piloting (0-30)
Int32   Engines (0-30)
Int32   Shields (0-110)
Int32   Weapons (0-130)
Int32   Repair (0-36)
Int32   Combat (0-16)
Int32   Gender (0 = female, 1 = male)
Int32   Stat repairs
Int32   Stat combat kills
Int32   Stat piloted evasions
Int32   Stat jumps survived
Int32   Stat skill masteries

This basically describes the entire chunk.

I think the easiest way to explain it is to show an edit, so here is what I did to our man Phillips:
Image
So, what has happened? Well, to take it from the top; first I changed the length of his race from "05 00 00 00" to "06 00 00 00" to compensate for me changing his race from "human" (5 characters) to "mantis" (6 characters) - note that I made sure to insert an extra character in the file instead of overwriting one of the "00"s. This also means that everything after has been shifted one spot if you compare with the before image.

Then after changing his race, I went and moved him away from his former human buddies. This meant skipping past the mystery "00 00 00 00" (every crew member I have ever seen has had a 0 here, so ??), and the "64 00 00 00" which is hex for "100 health on this guy". This leaves us at the "FB 01 00 00" (507 in decimal) which is his X coordinate on the ship, followed by the "C0 00 00 00" (192) which is the Y coordinate.
Now, I want to move him to the top left corner of the med bay, which is 6 squares left and 2 up from the current position, which means that we have to move him 210 pixels left and 70 up (somebody found out here: http://www.ftlgame.com/forum/viewtopic.php?f=4&t=2190 that each square is 35x35 pixels). So I need to move him to 297x122 (507 - 210 = 297, 192 - 70 = 122), which in hex is "29 01 00 00" and "74 00 00 00".
But that is not enough (at least I don't think so, haven't tried it yet). The next two ints are the room number and the room tile number. For the first I unpacked the "data.dat" and looked in "kestral.txt" which gives the room layout for the Kestral ship I'm using - long story short; the helm is room 0 and the med bay is 4, so that int was changed from "00 00 00 00" to "04 00 00 00".
The next one is easier: Top left square is 0, top right is 1, bottom left is 2 and bottom right is 3 - basically the order they naturally fill up a room, ignoring any computer terminals. Here Phillips is going from position 1 in the helm to position 0 in the med bay.
...
Ok, once that we are done mutating and moving the guy it is time to be nice to him. We skip another mystery int - this one is "01 00 00 00" for all the crew I have seen, so no idea what it does. But then we get to the skills, this is basically a row of 6 ints detailing your skills in order. They were all 0, but I decided to just max them all just for fun. As my table shows, the max values are 30, 30, 110, 130, 36, and 16 - which in hex turn into; 1E, 1E, 6E, 82, 24, and 10 (they still take four pairs each in the save file, so "1E 00 00 00" etc.).
So after all that, how does it look like when I load my mutilated save? Why, like this (wave for the camera Phillips :) ).
Image
Anyway, that was all for now. Feel free to ask questions, but no guarantees that I can answer them. ;)
ChickenBandit
Posts: 15
Joined: Mon Sep 17, 2012 4:40 pm

Re: Save game editing

Postby ChickenBandit » Tue Sep 18, 2012 12:46 am

Ok, so here's my work on doors so far:

Image

Starting 4 blocks after the FF FF FF FF stuff are the doors, after which there is a door every 8 blocks. Haven't figured out which are all which so far, but the 1st (going left to right then down) is the bridge door, 2nd is the right sensor room door, 3rd is the right door control room door, 4th is the left door control room door, and 5th is the left sensor room door. Not sure about any after that, I'll be working on it.

EDIT: The last 6 before you get to the weapons loadout are the airlocks, confirmed that by killing my crew :)
Last edited by ChickenBandit on Tue Sep 18, 2012 12:52 am, edited 1 time in total.
arhimmel
Posts: 9
Joined: Mon Sep 17, 2012 11:25 pm

Re: Save game editing

Postby arhimmel » Tue Sep 18, 2012 12:49 am

i messed up look below
Last edited by arhimmel on Tue Sep 18, 2012 12:50 am, edited 1 time in total.
arhimmel
Posts: 9
Joined: Mon Sep 17, 2012 11:25 pm

Re: Save game editing

Postby arhimmel » Tue Sep 18, 2012 12:49 am

Frodyne wrote:But first let me dump a small table here:

Code: Select all

Int32   Length of name
String   Name
Int32   Length of race
String   Race
Int32   0000 0000 ? - No idea what this does
Int32   Health
Int32   X coordinate
Int32   Y coordinate
Int32   Room
Int32   Room tile (0-3)
Int32   0100 0000 ? - No idea what this does
Int32   Piloting (0-30)
Int32   Engines (0-30)
Int32   Shields (0-110)
Int32   Weapons (0-130)
Int32   Repair (0-36)
Int32   Combat (0-16)
Int32   Gender (0 = female, 1 = male)
Int32   Stat repairs
Int32   Stat combat kills
Int32   Stat piloted evasions
Int32   Stat jumps survived
Int32   Stat skill masteries

This basically describes the entire chunk.



this is great. i was just getting to this part. you definitely just saved me a lot of time
Scratch
Posts: 5
Joined: Sat Sep 15, 2012 10:59 am

Re: Save game editing

Postby Scratch » Tue Sep 18, 2012 12:50 am

Very nice work.

Anyone found the data for resources?
ChickenBandit
Posts: 15
Joined: Mon Sep 17, 2012 4:40 pm

Re: Save game editing

Postby ChickenBandit » Tue Sep 18, 2012 12:56 am

Scratch wrote:Very nice work.

Anyone found the data for resources?


As in fuel, missiles, scrap, etc.? Nope, going to get to that one eventually though.
arhimmel
Posts: 9
Joined: Mon Sep 17, 2012 11:25 pm

Re: Save game editing

Postby arhimmel » Tue Sep 18, 2012 1:01 am

ChickenBandit wrote:
Scratch wrote:Very nice work.

Anyone found the data for resources?


As in fuel, missiles, scrap, etc.? Nope, going to get to that one eventually though.


yeah i found them. they are right before the listing of all the crew members and theirs skills.


thye appear in the following order

Code: Select all

Int32 HP
Int32 Fuel
Int32 Drone Parts
Int32 Missiles
Int32 Spare Parts

Who is online

Users browsing this forum: No registered users and 33 guests