
Quest System Plugin - Available on Fab.
The quest system comes with out of the box support for serializing and saving quests. Quests are managed by the quest subsystem and notebooks are managed by the notebook subsystem. Both subsystems provide functions to save and load data from an archive.
Quests are saved to and loaded from a FQuestSaveArchive struct. To save all quests managed by the quest subsystem, call Save Quests to Archive function on the quest subsystem and pass it a FQuestSaveArchive struct as parameter. All quests managed by the quest subsystem will be saved in the struct. To load quests saved in the archive, call Load Quests From Archive on the quest subsystem and pass it the archive struct that holds the saved data.
Notebooks are saved to and loaded from a FNotebookSaveArchive struct. To save all notebooks managed by the notebook subsystem, call Save Notebooks to Archive function on the notebook subsystem and pass it a FNotebookSaveArchive struct as parameter. All notebooks managed by the notebook subsystem will be saved in the struct. To load notebooks saved in the archive, call Load Notebooks From Archive on the notebooks subsystem and pass it the archive struct that holds the saved data.
These archive structs can be conveniently stored inside a Save Game object. Continuing the first person shooter example from Your First Quest example, Create a blueprint derived from USaveGame and call it BP_SaveGame. Create two variables in the save game blueprint of type FQuestSaveArchive and FNotebookSaveArchive and call them QuestsArchive and NotebooksArchive respectively. These will be saved when the save object is saved to a file.
To save the game to disk and load from it, follow the following steps.
Open the BP_FirstPersonGameMode blueprint. Create variables SaveObject of type BP_SaveGame and SlotName of type String. We will create the save object when the game starts. For now, set the SlotName variable's value to a non-empty value. This will be the name of the save file.
Create a custom event and call it Load. Script the function as shown below. The first part of the function checks if we have a save object file. If we have one we load it and load quests and notebooks from it. If we don't have a saved file, we just create a save game object to use later. We then load quest assets. If you followed the Your First Quest example, remember to remove the call to Load Quest Assets from the level blueprint.
Create a custom event and call it Save. Script the function as shown below. The function checks if we have a save object, and if we do, save quests and notebooks to it and then save it to a save game file.
Override the Event Begin Play and Event End Play functions in the game mode blueprint. Call Load from the Event Begin Play Function and Save from the Event End Play function.
The project will now save and load quests and notebooks. If you want to start the quests fresh and not from a saved state, delete the SaveGame file which is located in the Project/Saved/SaveGames folder.
This only saves and loads quests and notebooks. Other data that needs to be saved, such as actors or player data are not handled. Do note that actors spawned from a quest are not saved and loaded with the quest.
This method will save and load quests when changing worlds. The first person example does not need to change worlds but if your game nees to change worlds, the game instance is a better place to manage saving and loading.