Quest Tracker event

Announcements, support questions, and discussion for the Dialogue System.
timbecile
Posts: 110
Joined: Mon Mar 12, 2018 11:00 pm

Quest Tracker event

Post by timbecile »

Hey Tony,

Is there an event I can listen for when a user turns on and off the quest tracker?

I'm using the Compass Navigator Pro asset, and I want to turn on or off destinations when the player is tracking a quest.
DragoonHP
Posts: 62
Joined: Tue Jan 15, 2019 8:17 am

Re: Quest Tracker event

Post by DragoonHP »

I'm sure Tony will give a better response but onQuestTrackingEnabled and onQuestTrackingDisabled
User avatar
Tony Li
Posts: 21080
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Tracker event

Post by Tony Li »

^ Yes, that. In Dialogue System Events or add methods to a script on the Dialogue Manager.
timbecile
Posts: 110
Joined: Mon Mar 12, 2018 11:00 pm

Re: Quest Tracker event

Post by timbecile »

Exactly what I was looking for! Thanks Dragoon and Tony!
timbecile
Posts: 110
Joined: Mon Mar 12, 2018 11:00 pm

Re: Quest Tracker event

Post by timbecile »

Tony,

How do I subscribe to these events? I think I would rather have the triggers in script rather than using the Dialog System Events script
User avatar
Tony Li
Posts: 21080
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Tracker event

Post by Tony Li »

Hi,

Here's the list of quest methods you can add to a script on the Dialogue Manager: Script Methods - Quest-Related.

You can also register for "update quest tracker" events from anywhere. Example:

Code: Select all

void OnEnable() {
    DialogueManager.instance.receivedUpdateTracker += OnUpdateTracker;
}

void OnDisable() {
    DialogueManager.instance.receivedUpdateTracker -= OnUpdateTracker;
}

void OnUpdateTracker() {
    Debug.Log("A quest state changed. Update the tracker.");
}
The QuestLog class also has several delegates that you can hook into.
timbecile
Posts: 110
Joined: Mon Mar 12, 2018 11:00 pm

Re: Quest Tracker event

Post by timbecile »

Hey Tony,

Got it working great, but ran into a little issue. When the player completes the quest, the tracking goes away on the UI, but my script that listens for the OnQuestTrackingDisabled never got a disable tracking message for the finished quest.
User avatar
Tony Li
Posts: 21080
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Tracker event

Post by Tony Li »

Technically is still trackable. If you were to set the quest state back to active, it would appear in the tracker. (Some games do have quests that bounce back and forth between active and success.)

Listen for OnQuestStateChange(questName), too.
timbecile
Posts: 110
Joined: Mon Mar 12, 2018 11:00 pm

Re: Quest Tracker event

Post by timbecile »

That's what I was thinking, but does it pass the quest name AND the new state? I wouldn't want to turn off the tracking just because the state changed.
User avatar
Tony Li
Posts: 21080
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Tracker event

Post by Tony Li »

Use the QuestLog class to check the state:

Code: Select all

void OnQuestStateChange(string quest)
{
    if (QuestLog.IsQuestDone(quest))
    {
        QuestLog.SetQuestTracking(quest, false);
    }
}
Post Reply