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)
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!
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: https://www.unrealengine.com/marketplace/easy-save-load 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: https://forums.unrealengine.com/showthread.php?88541-Plugin-Auto-Save-Game&highlight=savior 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
answered Apr 06 '16 at 02:15 AM
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.
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.
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.
answered Dec 02 '18 at 06:27 AM
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.
answered Oct 13 '16 at 07:37 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here