Page 1 of 2

Bark priority

Posted: Wed Aug 24, 2016 11:55 am
by ReimG
Hi everyone,

Is there a way to give priorities to barks? I mean if a character barks at random and when my player gets near them I want to play a specific bark. But the problem is that when this specific bark is playing it can be interrupted by this random bark. I can't disable this random barks, because they are run from AC, as well as this specific bark. So I would need to give barks a priority and play them only if their priority is higher then currently playing bark. I know that there are priorities but as I tested them, they don't work that way and from what I understand, they are meant for something different.

Re: Bark priority

Posted: Wed Aug 24, 2016 1:28 pm
by Tony Li
Hi,

There is no built-in priority to block barks. The Priority dropdown (Normal, AboveNormal, BelowNormal, etc.) specifies the order in which the Dialogue System should check entries when looking for a valid entry to use.

However, here are two ways to block the random bark.

First, let's say you have an NPC "Fred" with two bark conversations: "Specific Barks" and "Random Barks":

Specific Barks
  • "Welcome to our town, stranger!"
Random Barks
  • "It sure is cloudy today."
  • "A bit chilly, too."
  • "I wonder if it will rain."

Option #1: Disable the Bark On Idle component.
This only works if you're using Bark On Idle, of course. Use the SetEnabled() sequencer command to temporarily disable the Bark On Idle component during the specific bark:

Specific Barks
  • "Welcome to our town, stranger!"
    Sequence: SetEnabled(BarkOnIdle,false,Fred); SetEnabled(BarkOnIdle,true,Fred)@{{end}}

Option #2: Use a variable to block the random bark.
Define a Boolean variable such as "Fred_IsBarkingSpecific".

In Specific Barks, use the SetVariable() sequencer command to set the variable true while the bark is playing:

Specific Barks
  • "Welcome to our town, stranger!"
    Sequence: SetVariable(Fred_IsBarkingSpecific,true); SetVariable(Fred_IsBarkingSpecific,false)@{{end}}
In Random Barks, add Conditions to all entries to require that this variable is false:

Random Barks
  • "It sure is cloudy today."
    Conditions: Variable["Fred_IsBarkingSpecific"] == false
  • "A bit chilly, too."
    Conditions: Variable["Fred_IsBarkingSpecific"] == false
  • "I wonder if it will rain."
    Conditions: Variable["Fred_IsBarkingSpecific"] == false

Re: Bark priority

Posted: Wed Aug 24, 2016 1:59 pm
by ReimG
Thank you for your answer and solutions :D. It is a pity that there isn't a priority for barks, because both solutions won't work in my situation (too many barks to specify variable for all of them and check them independently :P)

Re: Bark priority

Posted: Wed Aug 24, 2016 2:37 pm
by Tony Li
I'll look into adding bark priority in the next release. You're the first person to ask for it, but it's a great idea.

Re: Bark priority

Posted: Fri Aug 26, 2016 11:06 am
by ReimG
That's great :D. Unfortunately we need it in near future, so I have an idea how to implement it in a dirty way. I want to remember priorities in some other script and than attach my script to bark events and save them on dictionary with information about actor and priority. However I can't get any events when bark starts or ends. According to documentation: http://www.pixelcrushers.com/dialogue_s ... vents.html
Add this component to the Dialogue Manager or any character that you want to handle events.
I should be able to get all bark events by attaching it to Dialogue Manager, but unfortunately adding it to the Dialogue Manager does nothing and adding it to every character and setting it to send messages to one script is cumbersome.

Is there a way to attach my script to bark events directly and get which character is barking?
Big plus if it is possible to get "Dialogue Entry": http://www.pixelcrushers.com/dialogue_s ... entry.html of the bark. Then I can add priority field (and if there is no such field I can just assume that it has the lowest priority).

Re: Bark priority

Posted: Fri Aug 26, 2016 11:50 am
by Tony Li
The next update (with bark priority) will be released early next week, probably Monday.

In the meantime, make sure your script methods have the right syntax and you're using methods that will be called on the Dialogue Manager. (See Script Messages.) OnBarkStart and OnBarkEnd are not sent to the Dialogue Manager. Only OnBarkLine is sent to the Dialogue Manager. Try attaching this to the Dialogue Manager:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class BarkLogger : MonoBehaviour {
    void OnBarkLine(Subtitle subtitle) {
        var priority = Field.LookupInt(subtitle.dialogueEntry.fields, "Priority");
        Debug.Log("OnBarkLine: " + subtitle.speakerInfo.Name + ": " + subtitle.formattedText.text +
            ", Priority: " + priority, subtitle.speakerInfo.transform);
    }
}
Alternatively, you can add a Dialogue System Events component to the Dialogue Manager:

Image

Then you can assign a method on any GameObject similar to how you would assign a method to a UI Button's OnClick() event.

(Note that, once again, the Dialogue Manager will only handle OnBarkLine events, so don't assign anything to the OnBarkStart or OnBarkEnd events.)

Re: Bark priority

Posted: Fri Aug 26, 2016 12:03 pm
by ReimG
Wow, I thought it will take longer till next release. :D In that case it is not a problem to wait a little longer :D. Thank you for everything.

Re: Bark priority

Posted: Fri Aug 26, 2016 12:23 pm
by Tony Li
You're welcome! It's going to be a relatively small maintenance release with only a few new features such as bark priority.

Re: Bark priority

Posted: Mon Sep 05, 2016 10:48 am
by ReimG
Hi,

I updated the Dialogue System, but I don't see where to change the priority for barks. Could you tell me where can I change it? Are they the same as the links priority?

Re: Bark priority

Posted: Mon Sep 05, 2016 11:11 am
by Tony Li
Hi,

It's not a built-in dropdown. You must add a custom Number field named "Priority". More details here. If you have any difficulty setting this up, please let me know. I'll be happy to help.