Question about locking dialogue

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Boydy111
Posts: 19
Joined: Sun Jul 28, 2024 12:20 am

Question about locking dialogue

Post by Boydy111 »

Hi

I'm just trying to figure out how to do this, apologies if this has already been answered somewhere:

I have a conversation for an NPC that has a reputation requirement for a locked dialogue entry that they should be unable to click on, I want to make it clear to the player that this dialogue exists so they know to come back when they have a higher reputation.

My issue is, I want entry (A) to show as invalid when the player is under the reputation, and when they are over it, for it not to show up at all, since the other entry (B) will be available in its place
Capture.PNG
Capture.PNG (57.14 KiB) Viewed 551 times
Essentially its the fallout skill check dialogue but instead of being able to fail and have alternate dialogue, you're just not able to choose that option until you reach the required rep
User avatar
Tony Li
Posts: 23251
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question about locking dialogue

Post by Tony Li »

Hi,

If you bear with me below, we'll build up to the answer:

Normally you'd tick the Dialogue Manager's Display Settings > Input Settings > Include Invalid Responses and set the [em#] Tag For Invalid Responses dropdown. This will make response menus include all dialogue entries whose Conditions are false, styling them according to the style set for the em# emphasis setting. You can specify emphasis settings in the Dialogue Editor's Database section > Database Properties > Emphasis Settings. This is covered in How To: Do Skill Checks in Conversations.

However, you only want to show some invalid entries (i.e., entries whose Conditions are false), not all invalid entries. This post, which is also linked in the how-to article above, explains how to only show certain invalid dialogue entries but not others.

But even this doesn't quite get you where you want to be. You'll also want to completely hide the response option when the player has sufficient reputation. Here's one idea to accomplish that:

1. Remove entry (A) entirely.

2. On entry (B), add a custom text field named "RequirementText" and set it to "(Requires 20 rep)".

3. Add a script with an OnConversationResponseMenu(Response[]) method to the Dialogue Manager. Something like:
Spoiler

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class HandleRequirementText : MonoBehaviour
{
    void OnConversationResponseMenu(Response[] responses)
    {
        foreach (Response response in responses)
        {
            if (!response.enabled) // response's Conditions are false
            {
                var requirementText = Field.LookupValue(response.destinationEntry.fields, "RequirementText");
                response.formattedText.text = $"{requirementText} {response.formattedText.text}";
            }
        }
    }
}
When (B)'s Conditions are true (i.e., rep > 20), the response button will appear normally.

When (B)'s Conditions are false, the response button will appear but be non-interactable, and the entry's RequirementText field will be prepended to the button text.
Boydy111
Posts: 19
Joined: Sun Jul 28, 2024 12:20 am

Re: Question about locking dialogue

Post by Boydy111 »

Cheers once again Tony,

I knew I was missing a piece of the puzzle somewhere after implementing the show some invalid entries

This works a treat!
User avatar
Tony Li
Posts: 23251
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question about locking dialogue

Post by Tony Li »

Great! I'm glad that helped.
Post Reply