Hi Alfonso!
It depends on how you change the quest state.
If you change it with a trigger such as
Dialogue System Trigger, you can configure the trigger to show an alert message, send a message to another GameObject, etc.
If you change the quest state during a conversation, you can use the Script field to set Variable["Alert"]. This will show an alert message when the conversation is done. For example:
Script:
Code: Select all
Quest["Escape"].State = "success";
Variable["Alert"] = "You escaped the dungeon!"
You can also use the
SetActive() sequencer command to activate GameObjects. For example, say you want to activate a GameObject named "ratSpawner":
Sequence:
You can also
register one of your C# methods as a Lua function and call it in the Script field:
Script:
Code: Select all
ActivateQuest("Kill 5 Rats", "ratSpawner");
And your C# method:
Code: Select all
void ActivateQuest(string title, string gameObjectToActivate) {
QuestLog.StartQuest(title);
Tools.GameObjectHardFind(gameObjectToActivate).SetActive(true);
DialogueManager.ShowAlert("New Quest: " + title);
}
You can also use a
Condition Observer or
Quest State Observer. These are polling methods, which means they run on a regular frequency, so they're not necessarily as efficient as the other methods above.
Condition Observer is a component. You can set it to check every 1 second, for example. It can check the quest state. When it changes to a specific value, it can run actions such as showing alert messages, etc.
QuestLog.SetQuestStateObserver() is a method. It registers a C# method that will be called when the quest state changes. But it
only checks for quest state changes at specified times: every Update(), every dialogue entry, or only at the end of conversations. For example:
Code: Select all
QuestLog.AddQuestStateObserver("Kill 5 Rats", LuaWatchFrequency.EndOfConversation, OnQuestStateChanged);
void OnQuestStateChanged(string title, QuestState newState) {
if (string.Equals(title, "Kill 5 Rats") && (newState == QuestState.Active)) {
ratSpawner.SetActive(true);
}
}