Condition observer for all quest entries

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
annathehank
Posts: 95
Joined: Sun May 03, 2020 2:17 pm

Condition observer for all quest entries

Post by annathehank »

Hi again!

I have a long-running quest that's going to be updated through most of the game. I'd like to have a little alert pop up on the screen to tell the player the quest has been updated, but not have it tracked. So I set a condition observer up to have the alert show up when a quest entry is set to active. The first thing that happens is the Lua Conditions Wizard will auto swap back to saying all conditions must be true, so alerts aren't popping up unless all the quest states are active. I was curious if there's a Lua code that would make the condition for quest entry state refer to any/all entries in a quest rather than having to individually put each one in to save some time. I poked around in the manual but couldn't find anything so I figured I'd ask before putting all the time in.

If it's not feasible/realistic to show the alert using the condition observer, is there a more streamlined way to play the alert when the quest entries update rather than setting it to play in the conversation node where they update?

Thank you!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Condition observer for all quest entries

Post by Tony Li »

Hi,

I'm glad you asked this question. For what you want to do, don't use a Condition Observer. Instead, add a Dialogue System Events component -- or a script with an OnQuestStateChange() method -- to the Dialogue Manager. The OnQuestStateChange() method / Dialogue System Events > OnQuestStateChange() event will be called when a quest's or quest entry's state changes. Alternatively, you can use OnQuestEntryStateChange() if you're only interested in quest entries and not each quest's main state. Example:

Code: Select all

void OnQuestEntryStateChange(QuestEntryArgs info)
{
    QuestState state = QuestLog.GetQuestEntryState(info.questName, info.entryNumber);
    if (state == QuestState.Active)
    {
        string entryText = QuestLog.GetQuestEntry(info.questName, info.entryNumber);
        DialogueManager.ShowAlert("Quest Entry Active: " + entryText); // Edit: Fixed typo.
    }
}
annathehank
Posts: 95
Joined: Sun May 03, 2020 2:17 pm

Re: Condition observer for all quest entries

Post by annathehank »

Ahh okay yes, much easier!

So I added the system events to the dialogue manager and under On Quest State Change (string) I set the dialogue manager as the game object and chose DialogueSystemController.ShowAlert(string) and set the string to say New Memory. The alert isn't showing up when a quest is updated in conversation. Did I set it up properly or am I missing something?
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Condition observer for all quest entries

Post by Tony Li »

Since it's during a conversation, inspect the Dialogue Manager and tick Display Settings > Alert Settings > Allow Alerts During Conversations.
annathehank
Posts: 95
Joined: Sun May 03, 2020 2:17 pm

Re: Condition observer for all quest entries

Post by annathehank »

Ah yep! That'll do it :lol: Thank you! <3 This works amazingly, but I wanted to take a whack at the scripting for the entries.

Now, I'm still getting a grip on scripting, particularly struggling with how scripts call to each other and all that jazz.

I tried making a script based on the coding you provided. Came up with this.

Code: Select all

using PixelCrushers.DialogueSystem;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

namespace PixelCrushers.DialogueSystem
{
    public class alerts : MonoBehaviour
    {
        void OnQuestEntryStateChange(QuestEntryArgs info)
        {
            QuestState state = QuestLog.GetQuestEntryState(info.questName, info.entryNumber);
            if (state == QuestState.Success)
            {
                string entryText = QuestLog.GetQuestEntry(info.questName, info.entryNumber);
                DialogueManager.Alert("New Memory" + entryText);
            }
        }
    }
}
And there's an error alert 'DialogueManager' does not contain a definition for 'Alert'. I'm sure I'm missing some connector line of code in here :?:
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Condition observer for all quest entries

Post by Tony Li »

Oops, that was a typo. I meant to type "DialogueManager.ShowAlert". I fixed it in my post above.
annathehank
Posts: 95
Joined: Sun May 03, 2020 2:17 pm

Re: Condition observer for all quest entries

Post by annathehank »

Ahh thank you thank you <3
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Condition observer for all quest entries

Post by Tony Li »

Glad to help! :-)
Post Reply