Page 1 of 1

Refreshing Save Data When Modifying Quest

Posted: Mon Mar 06, 2023 6:07 pm
by cptscrimshaw
Hi Tony,

As I'm getting deeper into development, I'm relying on save files to load further into the story. While working on quests, I'll often need to tweak/add/remove nodes and their various properties to build them out and get things working. I'm finding this difficult because when I tweak something, it's not reflected in the current save file. Is there a way to get the quest to refresh based on my changes while still using the existing save file?

Let me know if this doesn't make sense...

Thanks!

Re: Refreshing Save Data When Modifying Quest

Posted: Mon Mar 06, 2023 9:34 pm
by Tony Li
Hi,

You will be able to do that (to a degree) in version 1.2.34.

This is a complex topic, and there are a few things to consider / features that Quest Machine offers:

You can set a version number on the save system itself. When you save a game, it stores the current save system version number in the saved game. You can use this version number to make decisions about how to load save data.

Quest Machine saves hand-written quests (i.e., made in the Quest Editor window) in a compact format. This keeps saved game data small, but it adds an extra wrinkle when changing existing quests between versions of your game:

Each version of Quest Machine saves a "quest format" version number.

Versions 1.0.0 - 1.2.29 use quest format version 1.

Versions 1.2.30 - 1.2.33 use quest format version 2 to handle "already true" condition flags that were added to quests in 1.2.30.

Version 1.2.34 will use quest format version 3, which will store extra information about quest node lists and counter lists. This will make saved game files slightly bigger, but the tradeoff is definitely worth it.

Quest format versions 1 and 2 assume quest data in saved games have the same number of quest nodes as the current version of the quest. A change in quest format version 3 will allow you to load games in which the quest had a different number of quest nodes when the game was saved.

So the short of it is that you'll be able to do what you want with saved games that were saved in quest format version 3 (i.e., Quest Machine 1.2.34+).

Re: Refreshing Save Data When Modifying Quest

Posted: Mon Apr 08, 2024 7:50 pm
by cptscrimshaw
Hi Tony,

Coming back to this since I finally upgraded QM to 1.2.45.

Whenever I load my game from an older save file, it isn't able to load any of the quests:
https://ibb.co/z2x446J

I assume this is because the save system for QM has changed and the files aren't compatible (which is fine). However, when I started with a brand new save file in the game and got the first quest, it still won't load when I load the new save file:
https://ibb.co/RcFX0bs

Any idea what's going on?

(For reference, and if it matters, I'm on version 2.2.41.1 of DS.)

Re: Refreshing Save Data When Modifying Quest

Posted: Mon Apr 08, 2024 8:37 pm
by Tony Li
Hi,

Saved games should be backward and forward compatible.

Let's first look at the issue with saving and loading in the current version. The issue may be in your quest. Can you save and load in Quest Machine's Demo scene without getting any warnings?

If so, inspect your quest (00-A Particular and Peculiar Patron) in the Quest Editor window. From the gear menu in the upper right, select Debug > Delete Unused Subassets. Also give it a quick visual look-over in the Quest Editor to make sure it looks right at a glance. Then try to play a game, save, and then load.

Re: Refreshing Save Data When Modifying Quest

Posted: Mon Apr 08, 2024 8:55 pm
by cptscrimshaw
Thanks for the quick reply.

Saving and loading works fine in the QM demo scene. I went through the process including Debug > Delete Unused Subassets and the quest itself looks fine. But I'm getting the exact same error as in my 2nd screen shot in my last post.

The only changes or modifications that I've made to QM are a subclass of QuestJournal:

Code: Select all

namespace PixelCrushers.QuestMachine
{

    /// <summary>
    /// This subclass of QuestList provides facilities to show the list in a QuestJournalUI.
    /// </summary>
    [AddComponentMenu("")] // Use wrapper instead.
    public class QuestJournalES : QuestJournal
    {
        public override Quest AddQuest(Quest quest)
        {
            base.AddQuest(quest);
            if (quest.isTrackable)
            {
                var currentTrackedQuest = questList.Find(x => x.showInTrackHUD);
                if (currentTrackedQuest == null)
                {
                    quest.showInTrackHUD = true;
                    RepaintUIs();
                }
            }

            return quest;
        }
    }
}
And I modified some of the code in UnityUIQuestJournalUI:

Code: Select all

protected virtual void AddQuestsToUI(List<Quest> quests, string requiredGroupName, RectTransform container, bool onlyAddActive)
        {
            bool completedQuests = false;

            foreach (var quest in quests)
            {
                if (quest == null) continue;
                var questState = quest.GetState();
                Debug.Log(quest.GetEditorName() + "|" + quest.GetState().ToString());
                if (questState == QuestState.WaitingToStart) continue;
                if (!showCompletedQuests && IsCompletedQuestState(questState)) continue;
                if (onlyAddActive && questState != QuestState.Active) continue;
                if (!onlyAddActive && questState == QuestState.Active) continue;
                var groupName = StringField.GetStringValue(quest.group);
                if (string.Equals(groupName, requiredGroupName))
                {
                    if (questState == QuestState.Active)
                    {
                        AddQuestToUI(quest, container);
                    }
                }
            }

            questSelectionContentContainer.Find("Completed Title").SetAsLastSibling();

            foreach (var quest in quests)
            {
                if (quest == null) continue;
                var questState = quest.GetState();
                if (questState == QuestState.WaitingToStart) continue;
                if (!showCompletedQuests && IsCompletedQuestState(questState)) continue;
                if (onlyAddActive && questState != QuestState.Active) continue;
                if (!onlyAddActive && questState == QuestState.Active) continue;
                var groupName = StringField.GetStringValue(quest.group);
                if (string.Equals(groupName, requiredGroupName))
                {
                    if (questState == QuestState.Successful)
                    {
                        AddQuestToUI(quest, container);
                        completedQuests = true;
                    }
                }
            }

            if (!completedQuests)
            {
                questSelectionContentContainer.Find("Completed Title").gameObject.SetActive(false);
            }
            else
            {
                questSelectionContentContainer.Find("Completed Title").gameObject.SetActive(true);
            }
        }
These changes all worked before I updated to the new version, as well.

Re: Refreshing Save Data When Modifying Quest

Posted: Mon Apr 08, 2024 9:02 pm
by Tony Li
Hi,

Can you send a reproduction project to tony (at) pixelcrushers.com (along with reproduction steps), or at least the "00-A Particular and Peculiar Patron" quest asset?

Re: Refreshing Save Data When Modifying Quest

Posted: Mon Apr 08, 2024 9:30 pm
by cptscrimshaw
Thanks for taking a look Tony. I just sent you a repro project with instructions (and some save files).

Cheers!

Re: Refreshing Save Data When Modifying Quest

Posted: Mon Apr 08, 2024 9:43 pm
by Tony Li
Thanks! I see the email. I'll get to work on it in the morning and let you know what I find.