Trigger specific bark

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jsebastian
Posts: 5
Joined: Sun Apr 04, 2021 10:01 pm

Trigger specific bark

Post by jsebastian »

I'm having difficulty figuring out how I can trigger a specific bark in a specific conversation. Here's what I'm attempting to do:

Sorry if I'm going the wrong way about this but my NPC's all have some stock messages they'll say, just in somewhat different ways. These are things like "Shields low" "hull damaged", but again, they'll all say these barks in a little different way depending on their personality.

My plan was to organize these barks by having the conversation of the barks be specific to the NPC character. I.E. "BobHealthBarks", "JohnHealthBarks". Then, each node would have the SAME name such as "ShieldsLow", "HullDamaged" This way all I have to do is load the right conversation, then I always know when Dialogue Entry I need, as the name of the dialogue entry is always the same.

An important note is that these barks will be triggered by external events. Maybe the start of a mission after some amount of delay, or when the NPC's shields drop to zero, etc.

I suppose instead of picking a specific bark directly, I could set conditionals on the dialogue entries, and try to trigger after evaluating those conditionals, but this probably won't work in other situations when I need to trigger a bark to indicate that some scene event has happened, and that use case is a bit more difficult to manage via conversation dialogue entry conditionals.

I could also trigger a bark directly with text in the inspector using the Dialogue System Trigger, and set the Bark Source to "Text" but I think that defeats the purpose of the organization provided by your great tool.

How can I trigger a bark from a specific Dialogue Entry inside of a specific Conversation, or, how can i do this in a better way?

Thanks in advance!
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trigger specific bark

Post by Tony Li »

Hi,

Use dialogue entry Conditions. A few notes:
  • You can use Variable["Actor"] or Variable["ActorIndex"] in your Conditions to identify the current barker. This way you can use the same conversation for all NPCs. (more info)
  • You can also register your own C# methods as Lua functions that dialogue entry Conditions can query.
  • Or you can use DialogueLua.SetVariable() to set Dialogue System variables before calling DialogueManager.Bark(), and your Conditions can check those variables.
Alternatively, you can grab exactly the dialogue entry you want, create a Subtitle object out of it, and call BarkController.Bark(subtitle). Example of grabbing the dialogue entry:

Code: Select all

var barkConversation = DialogueManager.masterDatabase.GetConversation("HealthBarks");
var barkEntry = barkConversation.dialogueEntries.Find(entry => entry.Title == "ShieldsLow");
jsebastian
Posts: 5
Joined: Sun Apr 04, 2021 10:01 pm

Re: Trigger specific bark

Post by jsebastian »

This is a great idea.

However, it looks like from the documentation the

Code: Select all

DialogueManager.Bark() 
function will pick a random bark from the conversation list. Is there any way to ensure that the conditions are evaluated before a bark is picked?
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trigger specific bark

Post by Tony Li »

Hi,

It'll pick randomly (or in order if you specify) only from the entries whose Conditions are true.
Post Reply