ORK integration

Announcements, support questions, and discussion for Quest Machine.
User avatar
Tony Li
Posts: 22189
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK integration

Post by Tony Li »

Hi,

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);
            }
        }
    }

}
dlevel
Posts: 183
Joined: Wed Nov 16, 2016 6:17 pm

Re: ORK integration

Post by dlevel »

Ok this worked, I can see the previous quests of the player with the new journal with verify. Let me know how we proceed, lets do it step by step to identify the issues and tackle them :)
User avatar
Tony Li
Posts: 22189
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK integration

Post by Tony Li »

Let's test three cases:

1. Start program. Create a new game. Pick up quests. Save game. Exit program. Start program. Load game.
--> Do the quests look correct?

2. [If applicable:] Start program. Load a saved game with working quests.
--> Do the quests look correct?

3. Start program. Load a saved game in which we know some quests don't show any text.
--> Do those bad quests no longer appear in the journal UI?
----> If so, then if you want to add fresh instances of those quests to the player's journal, replace the "// Finally, remove the bad quests from the journal." section of the script with this:

Code: Select all

// Finally, replace the bad quests in the journal.
foreach (var badQuest in badQuests)
{
    Debug.Log($"Adding fresh copy of bad quest {badQuest.id}");
    var questAsset = badQuest.originalAsset;
    DeleteQuest(badQuest);
    var questInstance = questAsset.Clone();
    var questerTextInfo = new QuestParticipantTextInfo(id, displayName, image, null);
    questInstance.AssignQuester(questerTextInfo);
    questInstance.timesAccepted = 1;
    deletedStaticQuests.Remove(StringField.GetStringValue(questInstance.id));
    AddQuest(questInstance);
    questInstance.SetState(QuestState.Active);
}
QuestMachineMessages.RefreshUIs(this);
dlevel
Posts: 183
Joined: Wed Nov 16, 2016 6:17 pm

Re: ORK integration

Post by dlevel »

1) Works fine

2) Everything seems fine here as well

3) No, it doesn't remove any bad quests (no debug log as well)

To verify, I only have changes on the quest journals you sent me (last asset import), and nothing on the ORKQuestMachineSaveData class, as I understand we verified that the journal does the load/save so we try to fix it there right?

Also since we fix the bad quests, there are some finished quests that are bugged as well and remain as finished in the journal, even though the remember quests is disabled. These are auto generated quests on some players, and prevent the player to acquire them again since they are daily, so if we can remove them as well would be great.

Thanks again


edit:

here is a bugged handwritten quest:
https://ibb.co/mNsXndk

Its active but all states inactive, activating the 2nd state manually makes it fine, hope that helps
User avatar
Tony Li
Posts: 22189
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK integration

Post by Tony Li »

Does that quest have no Start node?
dlevel
Posts: 183
Joined: Wed Nov 16, 2016 6:17 pm

Re: ORK integration

Post by dlevel »

the first one is the start one just with changed Id, and it starts fine, but then it bugged due to the issues mentioned in my other posts (game tried to give the quest again being the main reason)

https://ibb.co/QppcQtg
dlevel
Posts: 183
Joined: Wed Nov 16, 2016 6:17 pm

Re: ORK integration

Post by dlevel »

the first one is the start one just with changed Id, and it starts fine, but then it bugged due to the issues mentioned in my other posts (game tried to give the quest again being the main reason)

https://ibb.co/QppcQtg
User avatar
Tony Li
Posts: 22189
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK integration

Post by Tony Li »

dlevel wrote: Tue Nov 05, 2024 3:33 am3) No, it doesn't remove any bad quests (no debug log as well)
Does it log the bad quests to the Console window / Player.log file?

If so, then:
dlevel wrote: Tue Nov 05, 2024 3:33 amhere is a bugged handwritten quest:
https://ibb.co/mNsXndk

Its active but all states inactive, activating the 2nd state manually makes it fine, hope that helps
If you manually activate the first node (the start node), does it make it fine?
dlevel
Posts: 183
Joined: Wed Nov 16, 2016 6:17 pm

Re: ORK integration

Post by dlevel »

No it doesnt log the quests to the console

activating the bad quests first node fixes the issue yes.

Also need to remove the finished quests (grayed in Journal) so ppl can re-take them since they are repeatable auto-generated quests.
User avatar
Tony Li
Posts: 22189
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK integration

Post by Tony Li »

Here's an updated QuestJournalForORKWithVerify.cs script. Please replace the contents of your existing QuestJournalForORKWithVerify.cs with the text below:

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)
            {
                Debug.Log("QuestJournalForORKWithVerify has no saved data. Exiting.");
                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.
            Debug.Log("QuestJournalForORKWithVerify is restoring the quest journal.");
            base.LoadGame(data);

            // Then make a list of bad quests, which are quests whose Start
            // nodes aren't in the True state.
            Debug.Log("QuestJournalForORKWithVerify is making a list of bad quests and completed quests.");
            var badQuests = new List<Quest>();
            var completedQuests = new List<Quest>();
            foreach (var quest in questList)
            { 
                if (quest == null) continue;
                if (quest.GetState() == QuestState.Successful)
                {
                    Debug.Log($"QuestJournalForORKWithVerify: quest is completed: {quest.id}");
                    completedQuests.Add(quest);
                }
                else  if (quest.startNode == null ||
                    quest.startNode.GetState() != QuestNodeState.True)
                {
                    Debug.Log($"QuestJournalForORKWithVerify: quest is bad: {quest.id}");
                    badQuests.Add(quest);
                }
            }

            // Remove completed quests:
            foreach (var completedQuest in completedQuests)
            {
                Debug.Log($"QuestJournalForORKWithVerify removing completed quest {completedQuest.id}");
                DeleteQuest(completedQuest);
            }

            // Finally, replace the bad quests in the journal.
            foreach (var badQuest in badQuests)
            {
                Debug.Log($"QuestJournalForORKWithVerify adding fresh copy of bad quest {badQuest.id}");
                var questAsset = badQuest.originalAsset;
                DeleteQuest(badQuest);
                var questInstance = questAsset.Clone();
                var questerTextInfo = new QuestParticipantTextInfo(id, displayName, image, null);
                questInstance.AssignQuester(questerTextInfo);
                questInstance.timesAccepted = 1;
                deletedStaticQuests.Remove(StringField.GetStringValue(questInstance.id));
                AddQuest(questInstance);
                questInstance.SetState(QuestState.Active);
            }
            QuestMachineMessages.RefreshUIs(this);
        }
    }

}
It will log more info to the Console. When you try to load a bad saved game, please let me know all of the lines that it logs.
Post Reply