About Dialogue Actor component

Announcements, support questions, and discussion for the Dialogue System.
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

Does the code "DialogueManager.StartConversation("Some Conversation", actor.transform, conversant.transform);" has the same function if I add Dialogue Actor component to actor and conversant?

If I set up a "Shopkeeper Cindy" or "Shopkeeper Doug", and select he/she as the conversant, can I set Conditions and Scripts base on the real Speaker(Cindy/Doug)? Since the conversation just know Generic Shopkeeper, I did't find a way in Conditions and Scripts to select "Speaker"

On the other hand, through code like DialogueLua.GetActorField(subtitle.speakerInfo.nameInDatabase, "FieldName"), I can get a custom Field from Cindy/Doug. Am I right?
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: About Dialogue Actor component

Post by Tony Li »

CHOPJZL wrote: Sun Mar 07, 2021 10:25 amDoes the code "DialogueManager.StartConversation("Some Conversation", actor.transform, conversant.transform);" has the same function if I add Dialogue Actor component to actor and conversant?
Yes. It associates actor.transform with the conversation's actor and conversant.transform with the conversation's conversant.
CHOPJZL wrote: Sun Mar 07, 2021 10:25 amIf I set up a "Shopkeeper Cindy" or "Shopkeeper Doug", and select he/she as the conversant, can I set Conditions and Scripts based on the real Speaker(Cindy/Doug)? Since the conversation just knows Generic Shopkeeper, I didn't find a way in Conditions and Scripts to select "Speaker"
Add "Shopkeeper Cindy" and "Shopkeeper Doug" as actors in your database, in addition to "Generic Shopkeeper Placeholder".

Write your conversation using Generic Shopkeeper Placeholder.

When you pass Shopkeeper Cindy as the conversant, Variable["Conversant"] will be "Shopkeeper Cindy", and Variable["ConversantIndex"] will be "Shopkeeper_Cindy". To you can check Shopkeeper Cindy's IsStoreOpen field like this:

Code: Select all

Actor[Variable["ConversantIndex"]].IsStoreOpen == true
CHOPJZL wrote: Sun Mar 07, 2021 10:25 amOn the other hand, through code like DialogueLua.GetActorField(subtitle.speakerInfo.nameInDatabase, "FieldName"), I can get a custom Field from Cindy/Doug. Am I right?
Only if Cindy and Doug are in the database. Otherwise nameInDatabase will be "Generic Shopkeeper Placeholder".
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

Hi,

Today I tried to set a Private Hart's DisplayName in Script. But the Actor's name is unchanged through out the conversation. Then the name changed when I speak to him again for another conversation.

I saw there is a post about having a fixed button list to limit the menu panel to only show several of the responses. If I add a Timeout and set the Timeout Action to Choose Random Response, Will that be risky to select a response that is not shown in the menu?

Is there a way to order the responses at random by weight factor(such as Custom Field)? It's better to be able to set some branches to be at front, and others sort randomly. This question is related to above one. So that it is able to add some variaty to the conversation, and I can set the Timeout Action to Choose First Response.
Then I saw this post. Now the problem become how to shuffle by weight factor.

The same queston to random bark and RandomizeNextEntry() for Npc dialogue, seems there is no Response[] for me to shuffle.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: About Dialogue Actor component

Post by Tony Li »

Hi,
CHOPJZL wrote: Tue Mar 09, 2021 6:07 amToday I tried to set a Private Hart's DisplayName in Script. But the Actor's name is unchanged through out the conversation. Then the name changed when I speak to him again for another conversation.
See the Discover Name Example on the Dialogue System Extras page. It shows how to change the Display Name in the middle of a conversation.
CHOPJZL wrote: Tue Mar 09, 2021 6:07 amI saw there is a post about having a fixed button list to limit the menu panel to only show several of the responses. If I add a Timeout and set the Timeout Action to Choose Random Response, Will that be risky to select a response that is not shown in the menu?
Using that technique, yes. Instead, set it to Custom and use a custom handler. Or Choose First Response if you use your idea below.
CHOPJZL wrote: Tue Mar 09, 2021 6:07 amIs there a way to order the responses at random by weight factor(such as Custom Field)? It's better to be able to set some branches to be at front, and others sort randomly. This question is related to above one. So that it is able to add some variaty to the conversation, and I can set the Timeout Action to Choose First Response.
Then I saw this post. Now the problem become how to shuffle by weight factor.
Base your script off the one in that post. You can add a new custom field to your dialogue entry template (e.g,. "Weight Factor"). In your OnConversationResponseMenu() method, use the Weight Factor field instead of randomly sorting everything with equal weight. To get the Weight Factor value for a response's dialogue entry:

Code: Select all

Response response = responses[i];
float weightFactor = Field.LookupFloat(response.destinationEntry.fields, "Weight Factor");
CHOPJZL wrote: Tue Mar 09, 2021 6:07 amThe same queston to random bark and RandomizeNextEntry() for Npc dialogue, seems there is no Response[] for me to shuffle.
Barks don't provide a way to change that. It's probably better if you handle it manually:

Code: Select all

var conversationModel = new ConversationModel(DialogueManager.masterDatabase, "Bark Conversation", speaker, listener, false, null);
Response[] = conversationModel.firstState.npcResponses;
// (Shuffle responses here.)
DialogueManager.BarkString(response[0].destinationEntry.currentDialogueText, speaker);
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

How about RandomizeNextEntry() for Npc dialogue? Is it possible for you to make the Random logic virtual? Maybe take the npcResponses of the current state as the parameter.

About this post, I tried the example, But the "Response Menu Panel" dosen't get active at NPC line 4.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: About Dialogue Actor component

Post by Tony Li »

CHOPJZL wrote: Tue Mar 09, 2021 9:58 amHow about RandomizeNextEntry() for Npc dialogue? Is it possible for you to make the Random logic virtual? Maybe take the npcResponses of the current state as the parameter.
I don't follow. For barks or conversations? I can add a hook where you can assign a replacement for the random selection code.
CHOPJZL wrote: Tue Mar 09, 2021 9:58 amAbout this post, I tried the example, But the "Response Menu Panel" dosen't get active at NPC line 4.
Which example? There are two.
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

I don't follow. For barks or conversations? I can add a hook where you can assign a replacement for the random selection code.
It's best to have both. For now it's GetNextIndex(int numEntries) for bark, GetRandomNPCEntry() for conversation.
Which example? There are two.
It's the second example, the NPC line 3 set "Response Menu Panel" inactive, and NPC line 4 should set it active again.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: About Dialogue Actor component

Post by Tony Li »

CHOPJZL wrote: Tue Mar 09, 2021 7:39 pm
Which example? There are two.
It's the second example, the NPC line 3 set "Response Menu Panel" inactive, and NPC line 4 should set it active again.
It seems to work correctly as designed. Maybe it just doesn't do what you're expecting.
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

I opened a new project, and yes, it works properly.

I don't know why in my old project in NPC line 4 the setactive called and seems work, but still the "Response Menu Panel" remain inactive :o
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

Hi,

How to set the Actor's subtitle color if there is no Dialogue Actor component of him in the scene?

About "Typed" message, If there are 2 conversation running at the same time, will the "Typed" message be conflict?

Is it possible to start 2 entry at the same time as a group, or start the second entry before the first finishes, and the first entry's sequence don't need to stop. As for UI, let's take 2 different NPC panel for an example.
Post Reply