Please try this:
DS_ORK2BadQuestFix_2024-11-03-a.unitypackage
Replace your QuestJournalForORK component with the included QuestJournalForORKWithVerify, which I put in the folder Assets/Test. You can replace it in-place.
Then give it a test. We may need to test this back and forth a few times. The script makes the assumption that in a bad quest the Start node's state is not True. That's the rule it's currently using to identify bad quests. My guess is that when a quest fails to show any content, it's because none of the quest nodes are in states that have content (e.g., quest nodes aren't active, so they're not showing the active state content.) If this doesn't work, we'll need to find a different way to identify bad quests.
Here's the script that's included in the unitypackage above.
Code: Select all
using System.Collections.Generic;
using UnityEngine;
using ORKFramework;
namespace PixelCrushers.QuestMachine.ORKSupport
{
public class QuestJournalForORKWithVerify : QuestJournalForORK
{
public override void LoadGame(DataObject data)
{
// If the saved game doesn't have QuestJournalForORK data,
// then we know that it's saved through ORKQuestMachineSaveData,
// and we don't need to do anything.
if (data == null) return;
// If QuestJournalForORK has saved data, we use it to restore
// the player's quest journal, and then we remove "bad" quests.
// First, restore the quests.
base.LoadGame(data);
// Then make a list of bad quests, which are quests whose Start
// nodes aren't in the True state.
var badQuests = new List<Quest>();
foreach (var quest in questList)
{
if (quest == null) continue;
if (quest.startNode == null ||
quest.startNode.GetState() != QuestNodeState.True)
{
badQuests.Add(quest);
}
}
// Finally, remove the bad quests from the journal.
foreach (var badQuest in badQuests)
{
Debug.Log($"Deleting bad quest {badQuest.id}");
DeleteQuest(badQuest);
}
}
}
}