Page 1 of 1

Trigger specific bark

Posted: Sun Aug 29, 2021 5:06 pm
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!

Re: Trigger specific bark

Posted: Sun Aug 29, 2021 5:51 pm
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");

Re: Trigger specific bark

Posted: Sun Aug 29, 2021 7:24 pm
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?

Re: Trigger specific bark

Posted: Sun Aug 29, 2021 8:10 pm
by Tony Li
Hi,

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