QuestIndicatorManager with singleton QuestGiver

Announcements, support questions, and discussion for Quest Machine.
Post Reply
PopQuizHotshot
Posts: 5
Joined: Sun Sep 11, 2022 7:30 pm

QuestIndicatorManager with singleton QuestGiver

Post by PopQuizHotshot »

I’d like to attach a QuestGiver script to my QuestMachine prefab singleton, and use it as the sole source for giving quests. There’s a couple reasons for this:

1. Simplifies how we give quests. GiveQuest(“global”, “questName”), instead of having to put down the NPC name directly.

2.Only two places where data needs to be saved. The player, and the QuestGiver on the QuestMachine prefab (instead of having to save each QuestGiver NPC)

Of course there are several downsides to this system, but the one I want to address is that using this pattern disables my ability to use the QuestIndicatorManager/QuestIndicatorUI to highlight NPCs of interest. Is there any good way of getting this functionality back while using the singleton QuestGiver?
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: QuestIndicatorManager with singleton QuestGiver

Post by Tony Li »

Hi,

You can still use Quest Indicator Managers on NPCs of interest. You just need to use Set Indicator quest actions manually to tell those NPCs to show indicators.
PopQuizHotshot
Posts: 5
Joined: Sun Sep 11, 2022 7:30 pm

Re: QuestIndicatorManager with singleton QuestGiver

Post by PopQuizHotshot »

Hi Tony,

I have a quest with a WaitingToStart SetIndicator action, but I think it's being intercepted when the scene starts by this line in MessageSystem.cs

Code: Select all

if (x.frameAdded == Time.frameCount) continue;
PopQuizHotshot
Posts: 5
Joined: Sun Sep 11, 2022 7:30 pm

Re: QuestIndicatorManager with singleton QuestGiver

Post by PopQuizHotshot »

I... kind of gave up on trying to do the single QuestGiver instance implementation, so I added a QuestGiver component to the applicable NPCs, and everything works except for one thing.

I'm using EasySave3, and quest indicators seem like they always load to their initial state when returning to the scene (like it's our first time visiting). The save system seems to be working because the NPC no longer has quests to offer. The indicator does goes away after talking to the NPC.

Edit: Occasionally it won't happen. possible race condition somewhere... :cry:
Last edited by PopQuizHotshot on Thu Sep 15, 2022 3:35 pm, edited 3 times in total.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: QuestIndicatorManager with singleton QuestGiver

Post by Tony Li »

Hi,

Sorry I haven't had a chance to reply. I'm working on a patch that makes that line no longer necessary. I'll try to post it here by the end of the day.
PopQuizHotshot
Posts: 5
Joined: Sun Sep 11, 2022 7:30 pm

Re: QuestIndicatorManager with singleton QuestGiver

Post by PopQuizHotshot »

PopQuizHotshot wrote: Thu Sep 15, 2022 3:12 pm I... kind of gave up on trying to do the single QuestGiver instance implementation, so I added a QuestGiver component to the applicable NPCs, and everything works except for one thing.

I'm using EasySave3, and quest indicators seem like they always load to their initial state when returning to the scene (like it's our first time visiting). The save system seems to be working because the NPC no longer has quests to offer. The indicator does goes away after talking to the NPC.

Edit: Occasionally it won't happen. possible race condition somewhere... :cry:
I'm now preventing this from happening with a CustomQuestIndicatorManager subclass:

Code: Select all

    private IEnumerator DelayedRepaintCoroutine() {
        yield return null;
        Repaint();
    }

    protected override void OnDestroy() {
        StopAllCoroutines();
        base.OnDestroy();
    }
Starting the DelayedRepaintCoroutine in Start() works, but the indicator will still flash for a split second when the scene loads.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: QuestIndicatorManager with singleton QuestGiver

Post by Tony Li »

Hi,

Are you using a QuestIndicatorSaver component on your QuestIndicatorManager? (And changing scenes using the save system?)

The Dialogue System Extras page has a SaveSystemPrefabs package that also works with Quest Machine, since they use the same save system. It has a preconfigured Save System prefab that handles scene transitions with a fade out -> loading screen -> fade in if that's any help.
PopQuizHotshot
Posts: 5
Joined: Sun Sep 11, 2022 7:30 pm

Re: QuestIndicatorManager with singleton QuestGiver

Post by PopQuizHotshot »

Oh, I wasn't aware of the QuestIndicatorSaver! I'm currently on QuestMachine v1.2.17. Sorry, I probably should've started off with that.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: QuestIndicatorManager with singleton QuestGiver

Post by Tony Li »

Hi,

Please try backing up your project (just to be on the safe side) and then updating to the latest Quest Machine version so you can get QuestIndicatorSaver and all of the other improvements to Quest Machine. If that doesn't resolve the issue, let me know.
Post Reply