Page 1 of 1

Interrupt conversation with lower priority

Posted: Mon Aug 07, 2023 5:32 am
by OceaneM
Hello there,
I saw that there was a priority system between entries in the same conversation. I was wondering if there was a priority system between the conversations themselves?
There is an option in the DialogueSystemController "interruptActiveConversations" that lets you interrupt an active conversation. I'd like to be able to interrupt it only if the new conversation has a higher priority than the current one.
Is this possible?
What would be the best way to do this?

Thanks a lot for your help!

Re: Interrupt conversation with lower priority

Posted: Mon Aug 07, 2023 12:02 pm
by Tony Li
Hi,

There isn't anything built in. However, the Dialogue System is easily extended. You can add a custom field to your conversation template (see Templates) to specify priority. Then, if you're using Dialogue System Trigger components, override the DoConversationAction() method. For example, if your conversations have a custom Number field named "Priority", you could make a subclass of DialogueSystemTrigger similar to this:

Code: Select all

public class PrioritizedDialogueSystemTrigger : DialogueSystemTrigger
{
    protected override void DoConversationAction(Transform actor)
    {
        if (DialogueManager.isConversationActive)
        {
            var currentConversation = DialogueManager.masterDatabase.GetConversation(DialogueManager.lastConversationStarted);
            var newConversation = DialogueManager.masterDatabase.GetConversation(conversation);
            if (currentConversation.LookupInt("Priority") > newConversation.LookupInt("Priority"))
            {
                return; // Current conversation's priority is higher, so don't start new one.
            }
        }
        base.DoConversationAction(actor);
    }
}

Re: Interrupt conversation with lower priority

Posted: Tue Aug 08, 2023 8:42 am
by OceaneM
This looks exactly like what I needed. Thank you a lot

Re: Interrupt conversation with lower priority

Posted: Tue Aug 08, 2023 10:09 am
by Tony Li
Glad to help!