Ways to display new unlocked dialogue lines + ending bark on dialogue start

Announcements, support questions, and discussion for the Dialogue System.
KayVen
Posts: 13
Joined: Mon Apr 12, 2021 1:58 am

Re: Ways to display new unlocked dialogue lines + ending bark on dialogue start

Post by KayVen »

Wonderful, thank you for looking into it! It works fine for me now as well.

I see - for prototyping purposes, the SimStatus works just fine!
I've tested the custom variable approach as well - however even with individual variables, the indicator is still displayed even for locked nodes. For example, NPC has dialogue option A available at the start, but the player can unlock the option B after a condition is met. The way I set it up was to create a variable for every dialogue option and have it set true when the option is selected. Is there a way to have the indicator count only "unlocked" options?
I thought that maybe there is a way to create variables at runtime so after the condition for option B was met, it would create the variable for the dialogue option? Or maybe have some kind of "Locked" variable to determine whether the indicator registers the dialogue option at all?

So far I've only managed to have it run for one NPC (while having the script attached to Dialogue Manager and SpriteRenderer on the NPC), is there a way to have it for more NPC? Having the indicator prefab for each NPC with SpriteRendered and script component didn't work.
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Ways to display new unlocked dialogue lines + ending bark on dialogue start

Post by Tony Li »

The script should be on the NPC's main GameObject or the SpriteRenderer GameObject. If it's not working, then the conversation isn't using the NPC's GameObject as the conversation conversant. The only GameObjects to receive the "OnConversationEnd" message are the Dialogue Manager, conversation actor, and conversation conversant. To verify which GameObjects are being used as the actor and conversant, temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. When you start a conversation, look for a line like:

Dialogue System: Starting conversation 'XXX' with actor=YYY and conversant=ZZZ

where YYY and ZZZ are the actor and conversant GameObjects.

---

Figuring out when a conversation has more unread content is more of a logic question.

It's easy to determine if a conversation has any content at all to show. Just check if DialogueManager.ConversationHasValidEntry() is true.

But to determine if a conversation has any unread content that's currently unlocked, you'll need to do something custom. Two approaches:

1. Requires scripting: Write some code to traverse the conversation tree checking for nodes whose SimStatus is "Untouched". But you'll need to also stop traversing a branch of the tree at any nodes whose Conditions currently evaluate to false.

2. Or manually: For each NPC, you could manually maintain a single variable that indicates whether the NPC has unread content. Take the example conversation below. Let's say it's assigned to NPC1, and you've created a variable NPC1HasUnread whose initial value is true.

unlocked.png
unlocked.png (21.62 KiB) Viewed 394 times

In node A, you can set NPC1HasUnread to false.

In node B, assuming this unlocks the middle (C) branch, set NPC1HasUnread to true.

In node C, set NPC1HasUnread to false. In D, set it to true.

In node E, set it to false for the final time.

Then your script can simply check the variable. Replace the CheckSimStatus method with something like:

Code: Select all

[VariablePopup] public unreadVariable; // Assign in inspector.
 
    void CheckUnreadVariable()
    {
        indicator.enabled = DialogueLua.GetVariable(unreadVariable).asBool;
    }
KayVen
Posts: 13
Joined: Mon Apr 12, 2021 1:58 am

Re: Ways to display new unlocked dialogue lines + ending bark on dialogue start

Post by KayVen »

I see, thank you Tony!
I wonder, this runs into problems when using response menus, doesn't it? Anytime the dialogue branches, it probably won't help to have this unread variable, as if there are two outcomes of the dialogue, depending on the branch, there needs to be a way to recognize if the player has already seen an option but hasn't chosen it yet - I read that there is such things as "WasOffered" for SimStatus, but I'm not sure if it's of any use here, if I'm understand it correctly.
Let's say I have two branches, A and B. Would it help to do something like this: in the outcome of B, check if node A was is an Old Response, if something like that possible is at all possible? If yes, then set variable of Unread to false.

I'm sorry if this is getting ridiculous x_x
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Ways to display new unlocked dialogue lines + ending bark on dialogue start

Post by Tony Li »

Hi,

You could use SimStatus in combination with your "unread" variable.

Say the NPC's node is [1], and it links to two player responses: [2] and [3].

When the player selects [2], you could check if the player has already selected [3]. If so, set the unread variable false. And the opposite if the player selects [3].
KayVen
Posts: 13
Joined: Mon Apr 12, 2021 1:58 am

Re: Ways to display new unlocked dialogue lines + ending bark on dialogue start

Post by KayVen »

Ha, that seems like exactly what I've been looking for!
I tried it with approach that you've suggested earlier + this lua script that checks the SimStatus and then sets the variable:

Code: Select all

if Dialog[1].SimStatus =="WasOffered" then Variable["WalterHasUnread"] = true end;
and it seems like it indeed works ^^ Super neat, thank you so much Tony!
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Ways to display new unlocked dialogue lines + ending bark on dialogue start

Post by Tony Li »

Great! Glad I could help.
Post Reply