Simultaneous Conversation Issues

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
tomwilhelm
Posts: 13
Joined: Sun Jan 24, 2021 6:18 pm

Simultaneous Conversation Issues

Post by tomwilhelm »

Hey,
I'm working on a project where NPCs can start conversations with other NPCs. I've tested this and it supports multiple NPC to NPC conversations at once without issue. The problems spring up when the player gets involved. I've come across at least two issues and I think I've found workarounds for each.


The first issue is related to ConversationView. When a conversation starts a new ConversationView is created which listens to IDialogUI.SelectedResponseHandler. ConversationView.SelectResponse(SelectedResponseEventArgs e) is called on all active views whether or not it's associated with that conversation. This method stops the related Sequencer which means all other conversations can't be completed. Here is my suggested workaround:

Code: Select all

public void SelectResponse(SelectedResponseEventArgs e)
{
	int id = -1;
	if (lastSubtitle != null)
	{
		id = lastSubtitle.dialogueEntry.conversationID;
	}
	else if (_subtitle != null)
	{
		id = _subtitle.dialogueEntry.conversationID;
	}
	if (e.DestinationEntry.conversationID != id)
	{
		return;
	}
	StopResponseMenuSequence();
	ui.HideResponses();
	if (SelectedResponseHandler != null) SelectedResponseHandler(this, e);
}

The second issue is related to ConversationModel. When multiple conversations are running at once the Lua Dialog table can become stale. if more than one conversation is active, I receive a Lua exception when an entry used a condition like 'Dialog[2].SimStatus == "WasDisplayed"'. My fix was adding this snippet to EvaluateLinksAtPriority which seems to work.

Code: Select all

Lua.Run(string.Format("Dialog = Conversation[{0}].Dialog", new System.Object[] { newConversationID }));
I realize my use case is unique but I'm not a fan of changing the package code just to fit this project. Let know if I'm missing something or if there's a better approach.
Thanks!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Simultaneous Conversation Issues

Post by Tony Li »

Hi,

What version of the Dialogue System are you using? Can you update to the latest?
tomwilhelm
Posts: 13
Joined: Sun Jan 24, 2021 6:18 pm

Re: Simultaneous Conversation Issues

Post by tomwilhelm »

I am using version 2.2.33
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Simultaneous Conversation Issues

Post by Tony Li »

Hi,

Regarding the first issue, every conversation must use a separate dialogue UI. You can use an Override Dialogue UI or Override Display Settings components.

Regarding the second issue, I'll look into this and make sure it updates the Dialog[] table reference properly with each entry.
tomwilhelm
Posts: 13
Joined: Sun Jan 24, 2021 6:18 pm

Re: Simultaneous Conversation Issues

Post by tomwilhelm »

Hey,
Thanks for the reply. I appreciate you looking into the second issue.

On the first issue. I've created a class that inherits from StandardDialogueUI that can support multiple conversations. The desired UI look I'm going for is to display all the subtitles uniformly in the lower third of the screen like a cinematic. The DialogueUI can track the subtitles and vertically stack them based on priority and context when multiple subtitles are active. This approach is working fine except for ConversationView.SelectResponse(SelectedResponseEventArgs e). I haven't used Override Dialogue UI or Override Display Settings components before. How can I achieve this desired look with the override approach?
Thanks!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Simultaneous Conversation Issues

Post by Tony Li »

Hi,

Given your unique requirements, you may prefer to bypass all the baggage of StandardDialogueUI and write a more straightforward implementation of IDialogueUI that only does exactly what you want to do with multiple conversations going into the same UI. You can duplicate TemplateDialogueUI.cs and copy over your code where the comments indicate.

Alternatively, you could make a subclass of StandardUIResponseButton for your response buttons, and override the OnClick() method to call the specific ConversationView's response handler.
tomwilhelm
Posts: 13
Joined: Sun Jan 24, 2021 6:18 pm

Re: Simultaneous Conversation Issues

Post by tomwilhelm »

Hey,
Thanks for the feedback. That pointed me in the right direction. I made an override of OnClick(object data) in my subclass of StandardDialogueUI.

Code: Select all

public override void OnClick(object data)
{
	var r = data as Response;
	var actives = DialogueManager.instance.activeConversations;
	var convo = DialogueManager.instance.masterDatabase.GetConversation(r.destinationEntry.conversationID);
	foreach (ActiveConversationRecord conversation in actives)
	{
		if (conversation.conversationTitle == convo.Title)
		{
			conversation.conversationView.SelectResponse(new SelectedResponseEventArgs(r));
			return;
		}
	}
}
To keep Lua Dialog table in sync I added this component to the Dialogue Manager.

Code: Select all

using PixelCrushers.DialogueSystem;
using UnityEngine;

public class PrepareDialogueEntry : MonoBehaviour
{
	public void OnPrepareConversationLine(DialogueEntry entry)
	{
		Lua.Run(string.Format("Dialog = Conversation[{0}].Dialog", new System.Object[] { entry.conversationID }));
	}
}
I appreciate you help.
Thanks!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Simultaneous Conversation Issues

Post by Tony Li »

Glad to help!
Post Reply