[HOW TO] Get the current Speaker in a Response.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
whitecrow_dev
Posts: 6
Joined: Thu Dec 15, 2022 8:30 am

[HOW TO] Get the current Speaker in a Response.

Post by whitecrow_dev »

Hi!

So I have a conversation between 2 intial npcs : A and B.
Then I want the Player 'C' to burst in and ask a question seleted from a Response menu to npc D.
How do I get the Player, thus the Speaker, thus 'C' Actor's info, that contains its name etc?
Same question, what if I have many 'IsPlayer' actors and not just one?
The subtitle info I get is always the subtitle from before, and thus the speaker and listener are incorrect as they provide A and B instead of C and D.

Thanks,
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HOW TO] Get the current Speaker in a Response.

Post by Tony Li »

Hi,

I'm not sure if you're planning to "hot swap" characters in conversations. If so, here are some details:
Swapping Characters
When you write a conversation in the Dialogue Editor (or any external editor such as articy:draft), you will assign a primary actor and primary conversant:

primaryActorConversant.png
primaryActorConversant.png (49.39 KiB) Viewed 339 times

As you can see above, you can use the markup tags [var=Actor] and [var=Conversant] in dialogue text to include these characters' names in the text.

These two characters (the primary actor and conversant) are flexible at runtime. You can configure a Dialogue System Trigger and assign NPC3 to its Conversation Conversant field. Then every node that's assigned to NPC1 will be spoken by NPC3 instead, and [var=Conversant] will show NPC3's name.
When the active conversation is in a state where only player nodes are available, like below:

abcd.png
abcd.png (51.85 KiB) Viewed 339 times

then it will show a response menu. If any NPC nodes are available, it will always choose the NPC node instead of showing a response menu.

When it show the 3 responses shown above (What time is it? How's the weather? Got any gum?), the current subtitle will be NPC A's "La di da...". It will not be any of the responses since you haven't selected a response yet. If you're looking at the property DialogueManager.currentConversationState, its subtitle property will be NPC A's "La di da...". Its pcResponses[] property will contain the responses that will be offered in the menu.

Note that the third response (Got any gum?) is assigned to an additional Player E. If you select this response, Player E will say it.
whitecrow_dev
Posts: 6
Joined: Thu Dec 15, 2022 8:30 am

Re: [HOW TO] Get the current Speaker in a Response.

Post by whitecrow_dev »

Hi Tony,

Thank you for your answers.

The situation I'm describing is more like this:
Letter#1 an Letter#2 being the conversants.
Actor C isPlayer. Actors A, B, D are npcs.
The problem is: when I reach the Response part 'C and B' I wish to get these Actors.
But the IDialogueUI.ShowResponse gives me the Subtitle 'D and A'.
If from there I added another node with 'E and B' (E being another isPlayer), then the Subtitle would give me 'D and A'.
Not useful when I want to show the portrait of the 2 conversants.
as.jpg
as.jpg (32.04 KiB) Viewed 305 times
I solved this:
Modifying IDialogueUI.ShowResponse as follows:

Code: Select all

void ShowResponses(Subtitle currentSub, Subtitle lastSubtitle, Response[] responses, float timeout);
And ConversationController.OnFinishedSubtitle's call to this method to:

Code: Select all

var firstSubInResponse = m_model.GetState(m_state.pcResponses[0].destinationEntry).subtitle;
m_view.StartResponses(firstSubInResponse, m_state.subtitle, m_state.pcResponses);
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HOW TO] Get the current Speaker in a Response.

Post by Tony Li »

That will work. The StandardDialogueUI's StandardUIMenuPanel has a similar option: When showing a response menu, it will show the portrait of the actor in the first player response.

Note: I recommend making changes in your own code; do not directly modify any Dialogue System scripts. Otherwise, when you update the Dialogue System, you could lose your customizations to the Dialogue System scripts.
Post Reply