Page 1 of 1

How to change/empty Conversant in the middle of a conversation?

Posted: Sat Mar 17, 2018 3:30 pm
by Abelius
Hi there,

This should be easy enough but for some reason, I can't find any straightforward method to just change the Conversant to none.

I have my reasons for not using the recommended method of using Actors or invoking conversations with a set Conversant name.

Is there a hidden sequence or Lua command that can do this in a node?

Thanks.

Re: How to change/empty Conversant in the middle of a conversation?

Posted: Sat Mar 17, 2018 4:40 pm
by Tony Li
Hi,

Do you mean in the editor at design time? If so, you can click on the node to inspect it, and then change the Conversant dropdown to (None):

Image

Re: How to change/empty Conversant in the middle of a conversation?

Posted: Sat Mar 17, 2018 6:08 pm
by Abelius
Nope, I mean at runtime through a command. Is it possible?

Re: How to change/empty Conversant in the middle of a conversation?

Posted: Sat Mar 17, 2018 7:42 pm
by Tony Li
It's all possible. I'll outline a few possibilities, since I don't know exactly what you're aiming to do.

If you want to replicate a change to the Conversant dropdown at runtime, you'll need to change the dialogue database. By default, the Dialogue System doesn't instantiate a copy of the database at runtime. It reads directly from the asset. If you change the database at runtime, it will change the asset. You can tell the Dialogue System to instantiate a copy by ticking the Dialogue Manager's Instantiate Database checkbox. Then you'll need to change the dialogue entry node's conversant ID:

Code: Select all

var entry = DialogueManager.MasterDatabase.GetDialogueEntry(conversationID, entryID);
entry.conversantID = some-actor-ID; // or zero for none.
To do this in a node's Sequence or Script field, you'll need to write a custom Lua function or sequencer command that uses C# code similar to above.


If, on the other hand, you want to change the conversant name that's shown in Dialogue Text (e.g,. "Hi, I'm [var=Conversant].") for the currently-running instance of the conversation, set the Conversant variable:

Code: Select all

DialogueLua.SetVariable("Conversant", "some-name");
You can also change the actor's Display Name field. Some games set NPCs' Display Name to "???" until the player learns the NPC's name. In the node where the NPC introduces itself, it sets the Display Name to the NPC's real name.

Code: Select all

DialogueLua.SetActorField("Superman", "Display Name", "Clark Kent");

If, on the other other hand, you want to change the internal information that the active conversation uses, such as the transform that Camera() sequencer commands focus on, you'll need to change the conversation model's CharacterInfo:

Code: Select all

DialogueManager.ConversationModel.ConversantInfo.transform = someOtherTransform;
However, the typical way to use a different GameObject for the conversant is to supply it to DialogueManager.StartConversation() or assign it to the Conversation Trigger's Conversant field. Note that if you supply null, the Dialogue System will automatically try to find a GameObject whose name (or override name) matches the actor's name.

Re: How to change/empty Conversant in the middle of a conversation?

Posted: Sun Mar 18, 2018 7:25 pm
by Abelius
Ah, I forgot the DB behaves like that. :P

Well, it seems too much hassle for what I want to achieve, which is simply having three different subtitle colors according to the NPC that is talking.

What I'm doing right now is using three Unity objects: Player, NPC and NPC_Female. The three of them have different subtitle colors by the use of the Actor Subtitle Color (?) component.

This is good enough for calling conversations with Actor and Conversant fields empty and setting nodes to those generic Actors names in the DB (I don't use specific actors for each NPC), so the correct color is used every time.

However, before I used this approach I created a lot of conversations with just Player and NPC, until I realized the need for a third differentiating color for three-way conversations between the player and a couple, so I created that NPC_Female object with that subtitle color component.

The only thing I needed was to set the Conversant field to NPC_Female in the conversations that involved a female NPC and all NPC nodes were colored with the NPC_Female color... but when the conversation ALSO involves a male NPC, the Conversant field still takes precedence and male nodes are colored in the female color.

So, that's why I was wondering if I could use a sequence command to change the applicable Conversant field on the fly, so if I have like five or more sequential nodes that involve a specific gender, I could just introduce that command to switch between NPC and NPC_Female conversants before parsing those nodes. And when they finished, changing it back.

However, I think this will be complicating things too much for such a cheap way to not setting female nodes to their appropriate actor. In fact, I've assigned NPC_Female actor with a node color that clearly states its nature and the trees look much nicer now.

So this wall of text was just a waste of time, now that I think about it... :lol:

Well, I guess I like to write.

Thank you anyway!

Re: How to change/empty Conversant in the middle of a conversation?

Posted: Sun Mar 18, 2018 8:13 pm
by Tony Li
It might have been easier to modify Actor Subtitle Color script. In fact, more than one project has done a variation on this approach:

1. Add a custom field named "Subtitle Color" to actors, which specifies a web color (e.g., #ff00ccff).

2. Add a script to the Dialogue Manager with an OnConversationLine(subtitle) method. Look up the actor by subtitle.speakerInfo.nameInDatabase, and get its "Subtitle Color" field. If it exists, wrap subtitle.formattedText.text in a rich text code with that color.

Re: How to change/empty Conversant in the middle of a conversation?

Posted: Tue Mar 20, 2018 3:45 pm
by HawkX
Hey Tony!

It's been quite a while :) -- we havent spoken since august... had some trouble with node.js, aauth2.0 and other super complicated stuff i dont understand the half of it... anyway its 99% fixed now so our game should release soon!

also sorry to original author for hijacking this post, but it seemed SUPER close to what i need to do... just need a tiny bit of extra info...

I am using a custom name for the player character [var=GV.stringPlayerName]

that works fine, however, that string variable gets updated at runtime (probably after the dialogue manager loads up) since its networking and getting profile name off the game server... so i want to "refresh" it after it has loaded...

I am guessing this code you posted above would work in my case :
DialogueLua.SetActorField("Player", "Display Name", "[var=GV.stringPlayerName]");

my question is simply this, where do i enter that so that it works? -- and did i do some syntax error while writing it? :)

thanks as always, and sorry for the hijack! :)

Re: How to change/empty Conversant in the middle of a conversation?

Posted: Tue Mar 20, 2018 3:58 pm
by Tony Li
Hi! Good to hear from you. I think it can be simpler than that. Try these steps:

1. In the Dialogue Editor, on the Actors tab, inspect the Player.
- Tick Use Display Name.
- Set Display Name to: "[var=GV.stringPlayerName]" (without quotes).

2. At runtime, update the GV.stringPlayerName variable. You can do this in code:

Code: Select all

DialogueLua.SetVariable("GV.stringPlayerName", "Tommy Salami");
This way, you shouldn't have to use DialogueLua.SetActorField() at all.

BTW, version 1.7.7.3 just released. It lets you apply filters in the Dialogue Editor. So if you only want to see your global variables the Variables tab, you can type "GV." into the filter field. It's handy if you have a lot of variables (or quests, or actors, etc.). As always, before importing any update of any asset, it's a good idea to back up your project just in case.

Re: How to change/empty Conversant in the middle of a conversation?

Posted: Tue Mar 20, 2018 9:23 pm
by HawkX
Thank you very much once more! :)

Worked perfectly!

Sorry again to Abelius ;)

Re: How to change/empty Conversant in the middle of a conversation?

Posted: Wed Mar 21, 2018 6:55 am
by Abelius
No problem man. ;)