Page 1 of 1
Different redaction for the same dialgue node.
Posted: Sat May 29, 2021 12:03 am
by perezbalen
I want to use a dialogue node several times. But have the same node say something different every time (mostly). For instance, you say hello to the shopkeeper. The first time he answers. “Welcome” the second time, “welcome back.” The third time “have I seen you before?”
And I want to do this a lot.
Following the barks and quest video tutorial, I can get this behavior. But this makes the dialogue tree super complex, extremely fast.
So, my question is, has someone found a better way to do this? I was thinking having each dialogue node look at an array or lists of responses and having a function to go one by one each time, or maybe choose randomly.
Thanks.
Re: Different redaction for the same dialgue node.
Posted: Sat May 29, 2021 8:24 am
by Tony Li
Hi,
For a non-scripting option, you can link the <START> node to several dialogue nodes, each one with a different line of text ("Welcome", "Welcome back", "Hi there", etc.). You can put Conditions on them so that, for example, "Welcome back" only appears if the player has spoken to the NPC before.
In addition, you can use the RandomElement() Lua function if you want to include random text:
- Dialogue Text: "[lua(RandomElement( "Welcome|Welcome back|Hi there" ))]"
Or:
- Dialogue Text: "[lua(RandomElement( "Welcome|Welcome back|Hi there" ))], [lua(RandomElement("friend|buddy"))]"
I prefer to use the techniques above because they keep the text options visible and in one place. However, if you want to do it in a script, you can use an
OnConversationLine method to preprocess the text before it's displayed. For example, say you set a convention that the substring "{greeting}" should be replaced by a random greeting. Then your method might look like:
Code: Select all
public string[] greetings = new string[] { "Welcome", "Welcome back", "Hi there" };
void OnConversationLine(Subtitle subtitle) // Make sure script is on Dialogue Manager or conversation participant.
{
if (subtitle.formattedText.text.Contains("{greeting}"))
{
string randomGreeting = greetings[Random.Range(0, greetings.Length)];
subtitle.formattedText.text = subtitle.formattedText.text.Replace("{greeting}", randomGreeting);
}
}
Re: Different redaction for the same dialgue node.
Posted: Sat May 29, 2021 8:54 pm
by perezbalen
Thanks. Gonna try it.