Page 1 of 1

Simultaneous Conversation Issues

Posted: Fri Jan 06, 2023 6:30 pm
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!

Re: Simultaneous Conversation Issues

Posted: Fri Jan 06, 2023 7:09 pm
by Tony Li
Hi,

What version of the Dialogue System are you using? Can you update to the latest?

Re: Simultaneous Conversation Issues

Posted: Fri Jan 06, 2023 7:41 pm
by tomwilhelm
I am using version 2.2.33

Re: Simultaneous Conversation Issues

Posted: Fri Jan 06, 2023 11:12 pm
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.

Re: Simultaneous Conversation Issues

Posted: Sat Jan 07, 2023 5:42 pm
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!

Re: Simultaneous Conversation Issues

Posted: Sat Jan 07, 2023 9:08 pm
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.

Re: Simultaneous Conversation Issues

Posted: Mon Jan 09, 2023 3:18 pm
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!

Re: Simultaneous Conversation Issues

Posted: Mon Jan 09, 2023 3:29 pm
by Tony Li
Glad to help!