Page 28 of 29

Re: ORK integration

Posted: Fri Jan 03, 2025 7:32 am
by dlevel
So, I m still struggling with the offer conditions, using variables, with Min selected, and want to have minimum 3/4, it still doesn't work sometimes. I haven't found when it's not, but it just doesn't trigger for some players. I even had one player's save to have the indicator on Offer, but speaking with the NPC triggers the not meet criteria dialogue and player can't get the quest, even though they meet the 3/4 variables criteria. Any chance you have any idea what might happening?

Re: ORK integration

Posted: Fri Jan 03, 2025 7:52 am
by Tony Li
Hi,

What QM version are you using?

In the upcoming 1.2.51, there's this fix related to backtracking steps in a quest (such as when the player drops items necessary for an item quest):

- Fixed: Quest node whose True actions set itself inactive and parent sets its active again now properly restarts node's condition checking.

Version 1.2.48.1 [October 10, 2024] has this fix that might be relevant:

- Fixed: Quest offer conditions recheck prior to showing offer dialogue text now observes condition count mode (any, min, or all).

Re: ORK integration

Posted: Sat Jan 04, 2025 3:05 am
by dlevel
upgraded to .50 just few days ago, still having the issue.

Edit: weird thing is that after updating I got a couple of more bug reports about NPCs having the offer icon indicator but not giving the players quests. Might be a coincidence but just mentioning it.

In short my main issue right now is handwritten one time quests not being consistent when they are being offered regarding the offer conditions, while the indicators show they should be available

Re: ORK integration

Posted: Sat Jan 04, 2025 9:57 am
by Tony Li
Hi,

Can you try this patch?

QM_ConditionRecheckPatch_2025-01-03-a.unitypackage

Just yesterday, I fixed a bug in how Quest Machine rechecks offer conditions at the moment they start dialogue. I don't think it will address any indicator issues, but it should fix some cases where a quest becomes offerable but then conditions change and it becomes unofferable.

Re: ORK integration

Posted: Sun Jan 05, 2025 1:42 am
by dlevel
YES! It works now as intended! Thank you

Re: ORK integration

Posted: Sun Jan 05, 2025 10:33 am
by Tony Li
Glad to help! BTW, if this was working before (in an earlier QM version) and then broke in a later version, it's because I added rechecks. In early QM versions, once a quest's offer conditions became true, they stayed true even if the conditions changed (e.g., player had enough of an item for the offer conditions to be true, but then lost some of the items before talking to the NPC). I added rechecking in 1.2.48 last September but it had that bug that I fixed a couple of days ago.

Re: ORK integration

Posted: Sun Jan 05, 2025 12:16 pm
by dlevel
That explains a lot, will keep you posted, rolled out the new update to players

Re: ORK integration

Posted: Thu Jan 23, 2025 2:17 am
by dlevel
I have 2 players reporting that their quests completely disappeared right after finishing the quest attached (over 10 quests disappeared, restarting didnt help), I dont see anything in the logs other than the clean up run (script below). I m trying to debug myself, but any idea what might be happening? Also any idea how can I give them back their lost quests other than a save rollback?

quest: https://we.tl/t-9yp3YC6XpX

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using ORKFramework;
using PixelCrushers.QuestMachine;

namespace PixelCrushers.QuestMachine.ORKSupport
{
    public class QuestJournalForORKWithVerify : QuestJournalForORK
    {
        private DataObject pendingData;

        public override void LoadGame(DataObject data)
        {
            if (data == null)
            {
                Debug.Log("No saved data. Exiting.");
                return;
            }
            if (questList == null)
            {
                Debug.LogError("questList is null.");
                return;
            }

            // Store the data and start the coroutine.
            pendingData = data;
            StartCoroutine(DeferredLoadGame());
        }

        private IEnumerator DeferredLoadGame()
        {
            // First frame: Just wait.
            yield return null;

            // Second frame: call the base method.
            // This will run Quest Machine's ApplyData(), which triggers VerifyTrueNodeChildrenAreActive().
            base.LoadGame(pendingData);

            // Wait a couple more frames to ensure Quest Machine finishes any enumerations,
            // auto-verifications, or UI updates it might still be doing.
            yield return null;
            yield return null;

            // Now, in the third frame after calling base.LoadGame, 
            // do your custom quest modifications:
            DoQuestCleanupAndFixes();

            // Done! You shouldn't get the enumeration error now.
        }

        private void DoQuestCleanupAndFixes()
        {
            // 1) Remove duplicates
            var firstQuestInstances = new List<Quest>();
            var duplicateQuestInstances = new List<Quest>();
            var allQuests = new List<Quest>(questList);

            foreach (var quest in allQuests)
            {
                if (quest == null) continue;

                bool alreadyHasQuest = firstQuestInstances.Find(x => StringField.Equals(x.id, quest.id)) != null;
                if (!alreadyHasQuest)
                {
                    firstQuestInstances.Add(quest);
                }
                else
                {
                    duplicateQuestInstances.Add(quest);
                }
            }
            foreach (var duplicate in duplicateQuestInstances)
            {
                Debug.Log($"Removing duplicate quest: {duplicate.id}");
                DeleteQuest(duplicate);
            }

            // 2) Identify completed/bad quests
            var badQuests = new List<Quest>();
            var completedQuests = new List<Quest>();
            allQuests = new List<Quest>(questList);

            foreach (var quest in allQuests)
            {
                if (quest == null) continue;
                if (quest.GetState() == QuestState.Successful)
                {
                    completedQuests.Add(quest);
                }
                else if (quest.startNode == null || quest.startNode.GetState() != QuestNodeState.True)
                {
                    badQuests.Add(quest);
                }
            }

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

            // 4) Replace bad quests with fresh copies
            foreach (var badQuest in badQuests)
            {
                if (badQuest.originalAsset == null)
                {
                    Debug.LogWarning($"Quest {badQuest.id} has a null original asset.");
                    continue;
                }
                Debug.Log($"Replacing bad quest {badQuest.id} with a fresh copy.");
                var questAsset = badQuest.originalAsset;
                DeleteQuest(badQuest);

                var questInstance = questAsset.Clone();
                if (questInstance == null)
                {
                    Debug.LogWarning($"Failed to clone quest asset for quest {badQuest.id}.");
                    continue;
                }

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

            // 5) Refresh UI
            QuestMachineMessages.RefreshUIs(this);
        }
    }
}

Re: ORK integration

Posted: Thu Jan 23, 2025 5:22 pm
by Tony Li
Hi,

I'll take a look at that quest by end of day tomorrow. (Hopefully today but I'm showing a game at an event [darkwebSTREAMER at MAGFest] and my responses are a little delayed today. Did the quests disappear when the quest finished or when loading a saved game?

Re: ORK integration

Posted: Fri Jan 24, 2025 3:46 am
by dlevel
As per the reports the dissapeared when quest finished to 1 player, and the other noticed it a day later or so (when load)

on a separate issue, still have reports from players that can retake quests that are 1 time (by pressing back on the dialogue screen that finishes the quest), I have updated to the latest quest machine version