Forum Mod Bakery Docs

Custom map files and saving data? How are Vending Machines and Crates "saved"?

Please login to contribute to the conversation.
In my current project, I have the following issue:

I'm using multiple .p3d files that contain the map for different levels. The mod I'm making makes use of the Fully Connected Map, this uses the original names for the files from the original game, such as l1z3.p3d, l3r2.p3d and so on. As I wanted to make my mod use independent files for different levels, so that crates and vending machines are independent for level 2 and 3 from level 1. For example, if I break all the crates/vending machines in Level 1, I want a new instance of the map for Level 2, so those "respawn" technically when in fact the mod is loading another p3d file instead. So for example, Level 1 uses l1z2.p3d, in level 2, I have set up the mission scripts and Terra file to use my custom named version, l1az2.p3d. This works perfectly as you would expect, however it is not saving the data of vending machines and crates, If I destroy them, then come back they respawn or reload and are no longer broken, effectively creating an unlimited coin exploit.

Initially I thought this was because the game wasn't being told to save that data as I imagine somewhere its told to "save data for l1z1.p3d". Obviously with my files, they go by another name that was never intended. I’m also wondering how the game would actually go about that, as even in the vanilla game, after driving around/restarting the level or reloading certain parts of the map, they load the same file which still has those breakable objects in, but somewhere it knows wether or not the player has broken them before, so the issue wouldn’t be with the p3d but how the game reads it and determines those particular assets, as lampposts and other breakables will re spawn as we want them to, but crates/vending machines won’t.

For some reason, don't ask me why, I decided to see what would happen when I made the game load one of my custom files in the level.mfk file, it expectedly loaded the file twice, as it is being told to load it both by the Terra file and the level.mfk file. So I broke the crates that were duplicated on top of each other and restarted the level, for some reason now only one crate appeared, instead of 2, which means somewhere that data was saved somehow, although I expect this is because the level.mfk never "despawned" so it never "respawned" the crate. As I only restarted through mission select and not by changing levels, which I probably should have tested before typing this up.

I saw this "we're not really sure how Radical figures out what props to save to the save file as destroyed" - Loren, in a post made asking how to make vending machines respawn, the only reason I ask now is because I also read threads where people were saying that the idea of a fully connected map was impossible due to the restraints. However as we all know now, it was made possible. Also, given the fact that when that specific quote was posted 6 years ago, that could have potentially been enough time for people to work out and understand how it works now?

At this point I'm guessing I'm not actually looking for a solution, hence why I’ve listed this as a “question” instead of “help needed” as I don't even think what I'm trying to do is even possible at this point in time, but I guess I just want confirmation of that, until I'm told, "No, it's not possible" I'm going to be overloading my brain trying to work this one out.
As far as I know, no, there's no way to have user-defined/custom save data such as destroyed props.
I am so happy somebody has finally said those words. I was not far away from my brain giving me the 0x000000EF error.
I'm not sure on the specifies, I recall hearing at one point that the game has hardcode that defines how many Buzz Cola Crates/Vending Machines in a region can be tracked in the save data, which probably ties in to the P3D data chunk names. I guess any additional props of that nature just don't count. Certain non-Buzz Cola props have flags in the save data too (such as the Lemonade Stand), and that's probably a similar thing but hardcoded a bit differently.
I have decided to cut the feature from the mod. There are so many things I need to accomplish first, that spending time trying to understand and edit how the original developers coded that specific part of the game just isn't practical. I suppose at the end of the day, for a completionist like me, anyone who plays the mod won't have to go through the mind-numbing task of destroying and collecting all those things in every level, every cloud and all that. ^^