JulianOzelRose / TRR-SaveMaster

A savegame editor for Tomb Raider I-III Remastered. Edit items, weapons, ammo, health, statistics, and coordinates. Compatible with PC, PS4, and Nintendo Switch savegames.
10 stars 0 forks source link

Unable to find health bytes (Tomb Raider 2) #1

Closed xTheSolutionNOT closed 6 months ago

xTheSolutionNOT commented 7 months ago

I was about to mess around with the editor, and it didn't recognize the health. See

image

savegame.zip

I attached the save, it's a PC save, I only played and saved TR 2 in save slot 1.

PS: It edits PS4 saves too just fine, the only thing that would be nice is a PS4 <-> PC conversion, otherwise really great and fast job with the editor.

JulianOzelRose commented 7 months ago

Ah yes I just need to add the rest of the health offsets for TR2. I should have an update for that within the next day. Once I've added that it should be able to detect health a good percentage of the time, only main exceptions are when Lara is in a vehicle or walking when you save. Standing is the easiest to detect.

I'm writing another tool to extract individual savegames from a file, which should make downloading/using savegames from TR sites much easier, it's a work in progress, only does TR2 so far. It might also work as a PS4/PC savegame converter, but I don't own a PS4. Give it a try and let me know how it works.

TombConvert.zip

xTheSolutionNOT commented 7 months ago

First of all, thanks for this convert tool. I tested it, I chose a PC save as the source file, and my PS4 save as the destination file. It looked like this:

image

I selected the only slot from my PC save and put it into slot 2 of my PS4 save. On PS4 however, when the save is loaded, it shows that slot 1 was overwritten, not 2. While loading slot 1, the game crashed. slot 2 loads fine, but it's my old save.

Here's my PC save, the original PS4 save, and the converted save for you to compare.

convertedtr2.zip

Edit: When importing slot 1 from PC to slot 1 on PS4 the game also crashes.

JulianOzelRose commented 7 months ago

I've just updated the savegame editor, it should detect health much better for TR2 now. Use the binary here for the newest version.

Regarding the PS2/PC converter, that program (in its current state) does not let you specify which slots to write to. It writes to whatever slot the source savegame is in. I will make it more customizable later once I can get it to convert successfully. I've tested it myself extracting PC games, and it works for PC->PC. It basically makes an exact copy of the source savegame, and writes it to the destination file without changing anything. Because it crashes when converting PC->PS4, this means the PS4 savegames are not 100% the same as PC savegames.

However, because they are similar enough to be edited without issue, that means most (if not all) of the game-relevant data structures are the same. Perhaps just the savegame header is different for PS4, and changing that would allow successful conversion. Let's try a test; backup your PS4 savegame file, and create a brand new one with no saves. Then, start a new TR1 game, and then immediately save without moving or changing anything. Send me that savegame file with just the one TR1 save, and I will see if I can get it to convert to PC.

TR1 savegames have the least amount of dynamic data, so that makes them ideal to test this converter with.

xTheSolutionNOT commented 7 months ago

Ok here's an only TR 1 save, saved one time without moving or anything else.

tr1save.zip

JulianOzelRose commented 7 months ago

I got it to successfully convert to PC with that particular savegame. Try this version with some more TR1 saves (PS4->PC only right now) and let me know how it works.

TombConvert.zip

xTheSolutionNOT commented 7 months ago

I tried different save slots , different positions (while in a jump, side jump etc.), used level skip to advance in the story. all slots transfered fine from PS4 to PC. awesome work once again.

JulianOzelRose commented 7 months ago

Fantastic. This version should be able to do both PC<->PS4 conversion for TR1. Try it out:

TombConvert.zip

You can find plenty of TR1 Remastered PC savegames on this page.

Basically, one section of the PS4 TR1 savegame is identical to PC, one section of the savegame has its bytes shifted by 4 relative to PC, and another section has its bytes shifted by 1. This also explains why the editor was unable to find the health for your PS4 savegames; because the health bytes fall within the shifted offset range. I can patch the editor to detect PS4 health offsets better based on that information.

What doesn't make sense to me is that for TR1, the secondary ammo offsets fall within the shifted offset range. So the editor shouldn't be able to properly edit ammo for an equipped weapon. I can patch that as well, but I'm curious if you've been able to edit ammo of equipped weapons in TR1.

xTheSolutionNOT commented 7 months ago

About weapon ammo editing,

it did work but not as expected. For example, i had max ammo on all weapons, so i shot some bullets on ps4, saved the game. loaded the editor and it showed me full ammo on all weapons ( for example 83 for shotgun, while it should had only 79, ) i edited the ammo for all weapons to something lower, but it didn't recognized the edited ammo once back at the ps4. it only showed full ammo for all weapons.

For the save converting part, it worked flawless. I chosed different saves and different slots. all worked once transfered to PS4. Legendary.

JulianOzelRose commented 7 months ago

Awesome, looks like PC<->PS4 conversion is possible indeed. Let's get it working for TR2 and TR3. Do the same thing as before with TR1. Backup your savegame file, do a new savegame file, and then do TR2 -> new game, and immediately save without changing anything. Then do a new savegame file again, then TR3 -> new game, then save immediately without changing anything. Send me both files and I will try to get PS4 <-> PC conversion working for TR2 and TR3. I'll create a separate repo for this program once it's working for all 3 games.

xTheSolutionNOT commented 7 months ago

There you go, a save from TR 2 and TR 3 right at the start of each game, without moving. If that matters, for TR2 i saved right after she slides down at the beginning of TR2. So technically she moved. But as you may know you always slides for a second at the beginning of TR 2, i saved right after she stops.

TR2.3.test.saves.zip

JulianOzelRose commented 7 months ago

Okay, this one should be able to convert PC<->PS4 for all 3 games, give it a try.

TombConvert.zip

xTheSolutionNOT commented 7 months ago

This also works flawless so far. I filled all saveslots for TR 2 and 3 in different level, and positions (thanks to level skips), and all of them transfered fine to PS4. You sir are a legend.

JulianOzelRose commented 7 months ago

Thanks haha, glad it works. I patched the editor so that the latest version should be able to read health for all 3 games better for PS4, as well as write ammo properly for TR1.

I've attached a build that should be able to write to ammo properly for PS4 saves for TR2 and TR3, but it's hard for me to test it. Give it a try and let me know how it works. If everything is good, I'll patch the editor to have these changes.

TRR-SaveMaster-PS4.zip

xTheSolutionNOT commented 7 months ago

I didn't had much time to test but so far I tested the first, fifteenth, and last slot for TR 2 and 3 and it edited ammo just fine. It also recognized health for all slots in both games for PS4

xTheSolutionNOT commented 6 months ago

A friend of mine reported that for TR 2 there are still some issues to find health when it's saved during running or rolling.

He gave me this for you, it's for better health recognition

private bool IsKnownByteFlagPattern(byte byteFlag1, byte byteFlag2, byte byteFlag3) { if (byteFlag1 == 0x02 && byteFlag2 == 0x00 && byteFlag3 == 0x02) return true; // Standing if (byteFlag1 == 0x13 && byteFlag2 == 0x00 && byteFlag3 == 0x13) return true; // Climbing if (byteFlag1 == 0x21 && byteFlag2 == 0x00 && byteFlag3 == 0x21) return true; // On water if (byteFlag1 == 0x0D && byteFlag2 == 0x00 && byteFlag3 == 0x0D) return true; // Underwater if (byteFlag1 == 0x17 && byteFlag2 == 0x00 && byteFlag3 == 0x02) return true; // Rolling if (byteFlag1 == 0x01 && byteFlag2 == 0x00 && byteFlag3 == 0x01) return true; // Running if (byteFlag1 == 0x2F && byteFlag2 == 0x00 && byteFlag3 == 0x2F) return true; // Moving on Top of Water

Flag 1 is Current Flag 3 is Next so in a roll it be 17 - Current Stand 02 = final position

not sure what flag 2 is.

Edit: Another might be useful offsets could be

0x610 = Time Taken 0x620 = Distance Travelled 0x627 = Medi Packs Used

chances are all the games will have them in this same section just after the Main Ammo section

JulianOzelRose commented 6 months ago

Updated. The latest version should now detect health when rolling or walking on top of water. It also includes the changes for improved ammo writing and health detection for PS4 savegames. The savegame extractor/converter also has its own repo now, you can find it here. It has an improved UI and is a bit more efficient. If you have issues with it, you can report them there.

About the health byte flags, I will try to add as many as I can for maximum accuracy. But there some that have to be omitted. For example, when Lara is walking, the byte flags are 0x00, 0x00, 0x02 -- which would lead to false positives. Same thing with vehicles. In this implementation file for TR classic editor, I have around 30 byte flags. I think that's the most you can reasonably add without getting false positives for health. I'm also planning to switch to the same kind of algorithm for health detection used in that file and iterate through offset ranges instead of hard-coded offsets. But I haven't been able to get to Nightmare in Vegas or All Hallows, so if you have a savegame with those levels, it would be much appreciated to send them.

Thanks for the other offsets provided, I'll try and figure out a way to read and cleanly integrate them into the UI. I also found the offset for collectible crystals for TR3, so I'll probably add that too, as it allows you to instantly get the achievement if you don't already have it, so it's useful.

EDIT: Marking this issue as closed, as TR2 health should now be detected for PC and PS4 now. If you encounter any other problems, feel free to open up another issue here, or here in the case of the converter. Thanks for testing the PS4 saves!