How to save hundreds of peculiar variables, such as a barrel's contents on the other side of the world (similar to Skyrim/Oblivian save data)

Hey community,

So I ran into a predicament where I will soon need to be able to save all modified variables after playing a session of my game. The problem is there are a whole bunch of these variables. These variables can include everything from a random mob’s position and health, to the contents of each and every one of the containers in the world, along your quest progress on one of the hundreds of available quest. So my question is, how can I successfully save these thousands of variables without the save game file exceeding 36 terabytes, and how exactly to go about it.

Any info is greatly appreciated!

In Blueprints? You’re kind of stuck with SaveGame objects. They’re pretty good and they handle arrays, so you can stuff a lost in there.

If you’re willing to go the extra mile, in C++ you could write your own save system and compress it. It’s more likely to get corrupted though and you would have to properly test it.

I really doubt that your save files could become huge. These variables are not big, if you save locations and states via variables such as booleans and vectors, I doubt it’d become huge.

For custom work, short of writing your own code/plugin, you are stuck with basic save game object. However, there are a couple people who have already written plugins for this very thing. There is one in the UE4 Marketplace called “Easy Save & Load” which can be found here: Easy Save & Load in Blueprints - UE Marketplace and it seems to already be compatible with 4.11 (or so it says on marketplace website link above.)

There’s another one, that seems far more comprehensive called “Savior”. The forum postings of the developer can be found here: [Plugin] Auto-Save Game - Marketplace - Unreal Engine Forums but is not sold in the UE4 Marketplace but rather on Gumroad which the link can be found in the forum post or just click here: https://gumroad.com/l/uxnlQ

It doesn’t state on the gumroad link if it’s 4.11 compatible but I saw in the forum it was at least 4.10 but I see no mention of 4.11. He says that he will keep the project updated with every major release so I would expect it to be compatible soon if it isn’t already. In either case, you could probably just recompile the plugin yourself to make it 4.11 compatible, assuming the devs didn’t change any of the necessary Save Game API stuff (which I did not see in the release notes.)

I know these are paid options but as I mentioned, short of doing all the C++ (or extensive BP) work yourself, these are probably your best options.

Hope this helps! Don’t forget to accept the answer if it does! Thanks

Jesse

i don’t recommend you save any vector locations, just save the number of the last entrance the player walked through. Mobs and NPCs shouldn’t save health or location, just a single boolean representing alive or dead. when the game loads, if they are alive, give them full health. their locations can be generated with random logic and the player wont know the difference.

if you used Zelda like chests, you could just store a boolean representing whether its opened or not, but if each chest has multiple items, and the player can choose to take some of those items, you will need to keep track of alot more data. to optimize things, you could place some limitations on container rules, like only allowing the player to remove items, and not allowing them to put items in, and limiting the containers to a maximum of 8 items. this would allow you to store each removed item as a bit, making each chest a single byte. when the chest spawns into the world, it can check these bits to decide which items to remove from its defaults.

when storing items in your player’s inventory, you should only store the ItemID integer, and for randomized loot, you should store the random seed integer, instead of storing all of its base stats. if you want to store things with stats that can be leveled up, they will take up a lot more data. stacked items can be just an ItemID integer and Amount byte. never store names of things, unless the player can design those names in game, and if they can name their avatar, put a tight limit on character count. for all other names, they can be looked up using the ItemID.

i recommend storing all of this data in a single struct called Data, inside an actor called Inventory, which you can spawn from you player controller on begin play, and load its data from your SaveGame file. this Data struct can contain arrays of other structs, or arrays of simple data types. for example: the chest format i described above, could be an array of bytes. when you enter a new area, your inventory can get all actors of Chest, for each Chest, get the ChestID, and use that as an index to Get a byte from the array, then do some math to break the byte into bits, and starting at the end of the list, remove the items at each index corresponding to the bits that are true. enemy spawns work the same way.

So if I were to purchase “Easy Save & Load” and implement into my game, how would I save the contents of all of the container scattered throughout the world? Would I have to make an array of all of the containers and their data structs and save it to an array variable in the save game object? Or would saving this array of structs be too hefty?

Honestly I’ve never used either of these plugins. I’ve read up on the Savior one, which is pretty robust (one I plan on purchasing when I’m at that stage) and the developer of the Easy Save & Load has a website with instructions/videos on how to use his plugin (Savior has a video as well), which can be found on the marketplace page or just click here: http://www.mamoniem.com/products/easy-save-load/

I would suggest reading up on both of them to see which works best for your needs. I personally like the Savior (from what I read) because it let’s you save every single actor, specific blueprints, specific variables, levels, locations, rotations, scales… Nearly Everything and it will just do what it needs to do to save everything for you without worrying about anything. From what I read on the Savior, simply click the “Save Game” box on each variable you want to save and the plugin will do the rest. The only problem he says he has in the plugin is saving Structs but he offers ways to work around this. Again, I suggest reading the Savior forum posts to learn about that and go to the other website to learn about the Easy Save/Load.

Know this is an old question, buuut- you could probably get away with using xml or some kind of spreadsheet for the starting inventory. Then your save-game would only need to store if said content’s changed since starting the game. That’s pretty much how it’s done in the particular games you’ve mentioned.

I am saving lots of objects transform data in a save file. The save file is huge, like 200 megs. I was bale to save about 1/4 of the file size by taking the item name out of the array and only saving it one time.

Is there any way to clean up the way the transform saves, I find it amazing that it will write the following information over and over and over, thousands of times which makes the save file huge.

It seems like ti would just be saving the actual transform XYZ coordinates and not all the other text which is just bloat.

Any help would be great!

`¸D€‰C úB Scale3D StructProperty a Vector ? ? ? None Rotation StructProperty Quat €? Translation StructProperty a Vector ²D€‰C úB Scale3D StructProperty a Vector ? ? ? None

I know this is an old topic but believe that the best way to organize your data is to divide it into categories and then make structures in order to save it structured. Then for loading the content or for saving it, you might manage to do it quite simple by breaking the structure down into the variables and you can have everything nicely wrap up.
You set up the structure and then assign the type to the variable on the SaveGame BP.

Here’s a good post get into the topic, in case anyone needs some extra information.

https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/28614-how-do-blueprint-structures-actually-work

That is what I ended up doing and it. Worked perfectly in BP with a small save file size.