Problem with adding new quests
-
- Posts: 9
- Joined: Sun Jul 28, 2024 5:26 am
Problem with adding new quests
Hello !
I have such a case.
Im working on a project that already passed first iteration. For that i prepared some quests and that was working. Now im working on second iteration where i will have new questline and i have to support old saves.
I thought it will be enough to set "add new quests since saved game" as true on Quest Journal but it's not... On Screenshot attached You can see that quest OnBoarding is added to the list (that quest did non exists in previous version).
However after loading old save, that quest is not added for the player.
What i'm doing wrong ?
I have such a case.
Im working on a project that already passed first iteration. For that i prepared some quests and that was working. Now im working on second iteration where i will have new questline and i have to support old saves.
I thought it will be enough to set "add new quests since saved game" as true on Quest Journal but it's not... On Screenshot attached You can see that quest OnBoarding is added to the list (that quest did non exists in previous version).
However after loading old save, that quest is not added for the player.
What i'm doing wrong ?
- Attachments
-
- Restore Quests Problem.png (56.57 KiB) Viewed 11610 times
Re: Problem with adding new quests
Hi,
Did you add this new quest to your quest database?
Do you intend the player to have this quest from the start, or does the player get the quest from a quest giver? If it's from a quest giver, you should add the quest to the quest giver's Quests list. If it's on the player, you may need to activate it.
Did you add this new quest to your quest database?
Do you intend the player to have this quest from the start, or does the player get the quest from a quest giver? If it's from a quest giver, you should add the quest to the quest giver's Quests list. If it's on the player, you may need to activate it.
-
- Posts: 9
- Joined: Sun Jul 28, 2024 5:26 am
Re: Problem with adding new quests
Hi !
Yes, it is in database
Player should have it from the start.
To activate that after load should i prepare another script to somehow handle ApplyData() function after deserialization, or maybe there is some condition i can set in quest asset/quest journal ?
Autostart conditions are set in the quest asset, that quest starts properly automatically on new game, problem exists only after load old save.
Best
Yes, it is in database

Player should have it from the start.
To activate that after load should i prepare another script to somehow handle ApplyData() function after deserialization, or maybe there is some condition i can set in quest asset/quest journal ?
Autostart conditions are set in the quest asset, that quest starts properly automatically on new game, problem exists only after load old save.
Best
Re: Problem with adding new quests
Hi,
I can confirm that this works in the current Quest Machine version. If you're on an older version, can you back up your project, update to the current version, and check again?
Is that doesn't do it, please feel free to send a reproduction project to tony (at) pixelcrushers.com
I can confirm that this works in the current Quest Machine version. If you're on an older version, can you back up your project, update to the current version, and check again?
Is that doesn't do it, please feel free to send a reproduction project to tony (at) pixelcrushers.com
-
- Posts: 9
- Joined: Sun Jul 28, 2024 5:26 am
Re: Problem with adding new quests
i think im on the latest version, so probably im doing something wrong...
Unfortunate i cannot share project because of the NDA
Unfortunate i cannot share project because of the NDA

- Attachments
-
- Version QM.png (167.09 KiB) Viewed 11390 times
Re: Problem with adding new quests
That's the current version, so you're good there.
Since you can't provide a reproduction project, you'll need to step through the load-game process using a code debugger. Here are the steps:
1. Attach your code debugger the project.
2. Put a breakpoint on the first line of the QuestJournal class's ApplyData() method:
3. Play the game and load a saved game. The debugger will stop on the base.ApplyData(data) line.
4. Step into the method. Step through until you get to line 520 of the QuestListContainer class:
5. Step into this block of code and see if the adds the quest. The "originalQuestList" property should include the newly-added quest that didn't exist in the saved game.
Since you can't provide a reproduction project, you'll need to step through the load-game process using a code debugger. Here are the steps:
1. Attach your code debugger the project.
2. Put a breakpoint on the first line of the QuestJournal class's ApplyData() method:
Code: Select all
base.ApplyData(data);
4. Step into the method. Step through until you get to line 520 of the QuestListContainer class:
Code: Select all
if (addNewQuestsSinceSavedGame)
-
- Posts: 9
- Joined: Sun Jul 28, 2024 5:26 am
Re: Problem with adding new quests
i did already, on player that list is empty.
That also seems at least for me properly, because in init:
which means we are assigning reference i think.
So next in ApplyData we are calling DestroyQuestsInstances() or something like that, which deletes quests from questList so also from... originalQuestList i think
so then orginalQuestLink is empty in my case, maybe that's kinda race condition or something ?
Code: Select all
if (addNewQuestsSinceSavedGame)
{
for (int i = 0; i < originalQuestList.Count; i++)
{
var originalQuest = originalQuestList[i];
if (originalQuest == null) continue;
var quest = FindQuest(originalQuest.id);
if (quest == null)
{
// Quest is not in restored list, so it may be new since the saved game. Add it:
quest = originalQuest.Clone();
AddQuest(quest, true);
}
}
}
Code: Select all
public override void Awake()
{
base.Awake();
originalQuestList = questList;
}
So next in ApplyData we are calling DestroyQuestsInstances() or something like that, which deletes quests from questList so also from... originalQuestList i think

so then orginalQuestLink is empty in my case, maybe that's kinda race condition or something ?
Re: Problem with adding new quests
Hi,
Yes, there was a latent bug if the Save System's Frames To Wait Before Apply Data was set to zero. In this case, the Quest Journal's Start() method won't have fixed up questList yet. Please try this patch:
QM_QuestListPatch_2025-02-04.unitypackage
Yes, there was a latent bug if the Save System's Frames To Wait Before Apply Data was set to zero. In this case, the Quest Journal's Start() method won't have fixed up questList yet. Please try this patch:
QM_QuestListPatch_2025-02-04.unitypackage
-
- Posts: 9
- Joined: Sun Jul 28, 2024 5:26 am
Re: Problem with adding new quests
tested that, but i think what you did in that patch is:
which from other hand is breaking 2 other things:
a) If you have quest giver with such a method:
Then the quest will not appear in the journal. I didn't discovered yet why.
b) with that approach progression of the quests is not loaded properly. So i have a save where i already made some progression with that new quest line, after that patch, whole progress is reset to the very beggining so seems like problem with deserialization.
Maybe for now i will back to older version and set Frames To Wait Before Apply Data to something like 1 or 2
Code: Select all
public override void Awake()
{
base.Awake();
originalQuestList = new List<Quest>(questList);
}
a) If you have quest giver with such a method:
Code: Select all
public override void Start()
{
base.Start();
GiveAllQuestsToQuester(GameManager.Instance.Player.gameObject);
}
b) with that approach progression of the quests is not loaded properly. So i have a save where i already made some progression with that new quest line, after that patch, whole progress is reset to the very beggining so seems like problem with deserialization.
Maybe for now i will back to older version and set Frames To Wait Before Apply Data to something like 1 or 2

-
- Posts: 9
- Joined: Sun Jul 28, 2024 5:26 am
Re: Problem with adding new quests
Update:
I set Frames To Wait Before Apply Data as 2, but it didn't solve the issue
I was somehow able to manage fix that by making new class:
public class OnboardingController : QuestGiver { }
and i added that new quest to that giver's quest list instead.
Then i coded something like that:
and well... it helped, i could play that new quest on old saves, but then if i saved and loaded again from, that state, the game was completely broken. Like i had some quests added then to QuestJournal in multiple states for example 2 quests were both WaitingToStart and Sucessfull at the same time (so the same quest was added 2 times to questJournal just with different state) in the questJournal's questList.
I set Frames To Wait Before Apply Data as 2, but it didn't solve the issue

I was somehow able to manage fix that by making new class:
public class OnboardingController : QuestGiver { }
and i added that new quest to that giver's quest list instead.
Then i coded something like that:
Code: Select all
public override void Start()
{
base.Start();
GiveAllQuestsToQuester(GameManager.GameManager.Instance.Player.gameObject);
}
public override void ApplyData(string data)
{
base.ApplyData(data);
StartCoroutine(CheckActiveQuest());
}
private IEnumerator CheckActiveQuest()
{
for (int i = 0; i < 2; i++)
{
yield return new WaitForEndOfFrame();
}
var questJournal = GameManager.GameManager.Instance.Player.GetComponent<QuestJournal>();
for (int i = 0; i < questList.Count; i++)
{
if(!questJournal.ContainsQuest(questList[i].id))
{
questJournal.AddQuest(questList[i]);
//GiveQuestToQuester(questList[i], GameManager.GameManager.Instance.Player.GetComponent<QuestListContainer>());
}
}
// var journal = GameManager.GameManager.Instance.Player.GetComponent<QuestListContainer>();
questJournal.RepaintUIs();
}