Page 1 of 1

What is a proper way to add Fallout 3 like dialogue options

Posted: Sun May 02, 2021 7:01 pm
by excentio15
Hi everyone

First of all this is a great asset! Simplifies dialogues creation by a lot, recommending it to every team I deal with :)

Now speaking of the question itself:
I'm trying to implement some kind of a fallout 3 like dialogue response options that indicate how much of a specific skill you've got and how much you need to perform a specific action. Here's a quick example

Image

Currently I'm using something like: "([var=MySkill]/20) I can do this myself" in the text block of the dialogue node and extra condition inside of the condition block of a dialogue node, something like: "Variables[MySkill] >= 20" however I get some kind of issues with it, specifically:
1. I have to remember to add the condition or else nothing would work
2. If I want dialogue to be able to pick just a specific option it doesn't work this way, I still get more than 1 response because I have to include blocked entries so player can see the requirements but can't interact with the line

Is there any better way to do what I'm doing? Any chance to simplify this whole thing?

I had a thought about modifying the response button to parse the body text for lua variables and replace the text accordingly AND with this approach I still don't have to block the condition itself so I can turn off the "include blocked entries" option and get my dialogue behave as expected

Thank you very much!

Re: What is a proper way to add Fallout 3 like dialogue options

Posted: Sun May 02, 2021 7:52 pm
by Tony Li
Hi,

Here are some useful links:
The usual approach is to:
  • Include a [lua(code)] tag in Dialogue Text that gets the value of a C# method, such as:
    • Dialogue Text: "[ [lua(GetSpeechRank())] / 50 ] But the girl is sick."
  • Set the Dialogue Manager's Input Settings > Include Invalid Entries, and use the Conditions field to mark the response invalid if the player's speech rank is below a certain value.
  • Branch to success and failure nodes by setting the Conditions fields.
This is a good approach because, when you set the Conditions fields, it adds a "?" icon to the nodes. This makes it clear that the node is doing some kind of check.

Another alternative is to add custom fields to the dialogue entry template. (See Templates.) For example, you could add two fields:
  • A Required Skill field that could be a custom enum such as { None, Speech, Combat, Hacking, etc. }.
  • Skill Rank field such as 50.
You could set the example New Vegas-style response node's Required Skill to Speech and Skill Rank to 50 in the inspector.

Then handle it in a C# script. You could add a script with an OnConversationResponseMenu method or make a subclass of StandardUIMenuPanel. They both require about the same amount of effort. Say you subclass StandardUIMenuPanel and override the SetResponseButton() method. You could do something like:

Code: Select all

protected override void SetResponseButton(StandardUIResponseButton button, Response response, Transform target, int buttonNumber)
{
    base.SetResponseButton(button, response, target, buttonNumber);
    SkillType requiredSkill = (SkillType)Field.LookupInt(response.destinationEntry.fields, "Required Skill");
    if (requiredSkill != SkillType.None)
    {
        int currentRank = GetPlayerRank(requiredSkill);
        int maxRank = Field.LookupInt(response.destinationEntry.fields, "Skill Rank");
        button.text = $"[{requiredSkill} {currentRank}/{maxRank]] {button.text}";
    }
}
There are a few ways you could set up the script to do the skill check, maybe in an OnConversationLine method. (When the player selects the skill response, the Dialogue System will call OnConversationLine with that response entry.)

Re: What is a proper way to add Fallout 3 like dialogue options

Posted: Sun May 02, 2021 10:25 pm
by excentio15
I see this is pretty interesting, thank you very much! I'll give it a try next week

Re: What is a proper way to add Fallout 3 like dialogue options

Posted: Mon May 03, 2021 8:52 am
by Tony Li
Sounds good! If any questions come up, please let me know.