Page 1 of 2

Quest Tracker event

Posted: Wed Feb 13, 2019 9:43 pm
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.

Re: Quest Tracker event

Posted: Thu Feb 14, 2019 6:40 am
by DragoonHP
I'm sure Tony will give a better response but onQuestTrackingEnabled and onQuestTrackingDisabled

Re: Quest Tracker event

Posted: Thu Feb 14, 2019 7:41 am
by Tony Li
^ Yes, that. In Dialogue System Events or add methods to a script on the Dialogue Manager.

Re: Quest Tracker event

Posted: Thu Feb 14, 2019 12:05 pm
by timbecile
Exactly what I was looking for! Thanks Dragoon and Tony!

Re: Quest Tracker event

Posted: Wed Feb 20, 2019 9:19 pm
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

Re: Quest Tracker event

Posted: Wed Feb 20, 2019 9:25 pm
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.

Re: Quest Tracker event

Posted: Sun Feb 24, 2019 2:35 pm
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.

Re: Quest Tracker event

Posted: Sun Feb 24, 2019 2:59 pm
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.

Re: Quest Tracker event

Posted: Sun Feb 24, 2019 3:22 pm
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.

Re: Quest Tracker event

Posted: Sun Feb 24, 2019 4:20 pm
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);
    }
}