Custom trigger of conversation (How to get dropdown from database)

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
nicmar
Posts: 133
Joined: Wed Aug 21, 2019 2:39 am

Custom trigger of conversation (How to get dropdown from database)

Post by nicmar »

I have a custom interaction system, where I have a reaction called DialogueReaction that shall start a conversation.

I could add a Dialogue System Trigger to the gameobject, set everything up there, and trigger the OnUse method, but to make it easier for my level designer, I'd like to keep it simple and only show a few options.

Is there a way to reference a database, and get some dropdowns, similar to the Dialogue System Trigger?

I got this far, but then I don't know how to get the strings from the database to show up:

Code: Select all

[SerializeField] 
 private DialogueDatabase referenceDatabase; 

[ValueDropdown(nameof(GetConversations))]
[SerializeField] 
private string conversationTitle;
I'm using Odin Serializer, which has some pretty neat features to make dropdowns, like above, but I need a method that returns the references, like this:

Code: Select all

private IList<ValueDropdownItem<int>> GetConversations()
{
	return new ValueDropdownList<int>
	{
		{ "The first option",	1 },
		{ "The second option",	2 },
		{ "The third option",	3 },
	};
}
But I have no clue on how to read referenceDatabase from a method, and how to iterate through it to get the strings I need.

When I have that, I guess I can just:

Code: Select all

DialogueManager.StartConversation(conversationTitle);
Also, I'm a little worried/confused about the string references everywhere. Will dialogues break if I rename a conversation or an actor, or is there a way to prevent that from happening?
Working on SpaceChef - A wacky open world space western, featuring a chef with nothing to loose, after he loses everything.. ;) Follow our work on @BlueGooGames.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom trigger of conversation (How to get dropdown from database)

Post by Tony Li »

Hi,
nicmar wrote: Thu Aug 29, 2019 6:59 amIs there a way to reference a database, and get some dropdowns, similar to the Dialogue System Trigger?
Yes. You can add attributes such as [ConversationPopup]: Dialogue System Attributes
nicmar wrote: Thu Aug 29, 2019 6:59 amAlso, I'm a little worried/confused about the string references everywhere. Will dialogues break if I rename a conversation or an actor, or is there a way to prevent that from happening?
Yes and no. If you rename a conversation's Title or an actor's Name, it will break references. Unfortunately there's no way around this while still supporting text-based export/import to formats such as Excel (CSV), articy:draft, and Chat Mapper. However, you can change an actor's or quest's Display Name, and this will not affect references. The Display Name is used in all UIs. Remember also that conversation titles can include "/" characters to group them into submenus in the editor and in [ConversationPopup] dropdowns.
nicmar wrote: Thu Aug 29, 2019 6:59 amWhen I have that, I guess I can just:

Code: Select all

DialogueManager.StartConversation(conversationTitle);
Yes. You may want to specify the actor and conversant GameObjects to DialogueManager.StartConversation:

Code: Select all

DialogueManager.StartConversation(conversationTitle, actor.transform, conversant.transform);
Otherwise the Dialogue System will attempt to find the correct GameObjects by checking the GameObjects with Dialogue Actor components. If it doesn't find a Dialogue Actor that matches the characters in the conversation, it will look for GameObjects whose GameObject names match the characters' names. (See Character GameObject Assignments for a discussion).
nicmar
Posts: 133
Joined: Wed Aug 21, 2019 2:39 am

Re: Custom trigger of conversation (How to get dropdown from database)

Post by nicmar »

Thanks a lot, I will try that.

How can I extract the actor and conversant string names from the selected conversation and use that? I looked at it a bit, and it seemed like it has ActorID and ConversantID, and I don't know how to look that up to find the String-name of the actor. Do I need to traverse the database somehow?

Or is that what it's doing behind the scenes if I don't send along those parameters? The point was that in some cases (you might remember from another thread) it didn't choose the correct actor, so I'd like to preset the player as actor in case the auto-detection fails.
Working on SpaceChef - A wacky open world space western, featuring a chef with nothing to loose, after he loses everything.. ;) Follow our work on @BlueGooGames.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom trigger of conversation (How to get dropdown from database)

Post by Tony Li »

nicmar wrote: Thu Aug 29, 2019 9:39 amHow can I extract the actor and conversant string names from the selected conversation and use that? I looked at it a bit, and it seemed like it has ActorID and ConversantID, and I don't know how to look that up to find the String-name of the actor. Do I need to traverse the database somehow?
Use the DialogueDatabase class. At runtime, use DialogueManager.masterDatabase. In an editor script, you need a reference to a dialogue database. (You can use EditorTools.FindInitialDatabase() if the currently-open scene has a Dialogue Manager.)

To get a conversation, use DialogueDatabase.GetConversation(x), where x is a conversation ID or title. It returns a Conversation object with properties such as ActorID and ConversantID.

To get an actor, use DialogueDatabase.GetActor(x), where x is an actor ID or name.
nicmar wrote: Thu Aug 29, 2019 9:39 amOr is that what it's doing behind the scenes if I don't send along those parameters? The point was that in some cases (you might remember from another thread) it didn't choose the correct actor, so I'd like to preset the player as actor in case the auto-detection fails.
That's what it's doing behind the scenes if you don't send those parameters.
nicmar
Posts: 133
Joined: Wed Aug 21, 2019 2:39 am

Re: Custom trigger of conversation (How to get dropdown from database)

Post by nicmar »

Thanks a thousands, amazing response as always!
Working on SpaceChef - A wacky open world space western, featuring a chef with nothing to loose, after he loses everything.. ;) Follow our work on @BlueGooGames.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom trigger of conversation (How to get dropdown from database)

Post by Tony Li »

Glad to help! :-)
Post Reply