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!
Condition observer for all quest entries
Re: Condition observer for all quest entries
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:
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.
}
}
-
- Posts: 95
- Joined: Sun May 03, 2020 2:17 pm
Re: Condition observer for all quest entries
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?
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?
Re: Condition observer for all quest entries
Since it's during a conversation, inspect the Dialogue Manager and tick Display Settings > Alert Settings > Allow Alerts During Conversations.
-
- Posts: 95
- Joined: Sun May 03, 2020 2:17 pm
Re: Condition observer for all quest entries
Ah yep! That'll do it 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.
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
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);
}
}
}
}
Re: Condition observer for all quest entries
Oops, that was a typo. I meant to type "DialogueManager.ShowAlert". I fixed it in my post above.
-
- Posts: 95
- Joined: Sun May 03, 2020 2:17 pm
Re: Condition observer for all quest entries
Ahh thank you thank you <3
Re: Condition observer for all quest entries
Glad to help!