Page 1 of 1

Show active quest name in dialogue text

Posted: Tue Feb 13, 2024 7:58 am
by VillVarh
Hello. I want NPC to tell me the active quest name in teh dialogue text how can i do this? Ty in advance

Re: Show active quest name in dialogue text

Posted: Tue Feb 13, 2024 9:17 am
by Tony Li
Hi,

You'll typically write your conversation tree so it checks which quests are active and goes down the appropriate branch. For example, say you have three quests to find the Scepter, Sword, and Crown. Your conversation might look like this:

multiQuestConversation.png
multiQuestConversation.png (24.27 KiB) Viewed 221 times

This is a simplified version. You might want to include conditions to check if the quest hasn't been started yet, in order to offer the quest to the player. Note above that you can use the "..." dropdown wizard to specify the Conditions so you don't have to type anything.

I added a default greeting ("Hello") that the NPC will say if none of the prior nodes' Conditions are true -- that is, if no quest is active.

Re: Show active quest name in dialogue text

Posted: Wed Feb 14, 2024 10:14 am
by VillVarh
I think you missunderstood me. I want the npc to say me the active quest name in the dialogue. When i talk to the npc it will tell me "You can't go there because (current active quest name here) is not completed". How can i achieve this.

Re: Show active quest name in dialogue text

Posted: Wed Feb 14, 2024 11:07 am
by Tony Li
Hi,

How does the NPC know which quest is the active quest?

In the Dialogue System, multiple quests can be active at the same time. If the NPC knows which possible quests could be active, you could set up your conversation like my example above. Example:

multiQuestConversation2.png
multiQuestConversation2.png (34.51 KiB) Viewed 215 times

If you don't know the quests ahead of time, you can write a C# function to identify the first active quest:

Code: Select all

public string GetActiveQuest()
{
    var quests = QuestLog.GetAllQuests(); // Gets all active quests
    return (quests.Length >= 1) ? quests[0] : string.Empty;
}
Then register this method with Lua.

Finally, set up a conversation like this:

multiQuestConversation3.png
multiQuestConversation3.png (19.26 KiB) Viewed 215 times

Re: Show active quest name in dialogue text

Posted: Thu Feb 15, 2024 2:31 am
by VillVarh
Thank you this is what i wanted!

Re: Show active quest name in dialogue text

Posted: Thu Feb 15, 2024 8:22 am
by Tony Li
Glad to help!