Checking if the player went through all branches

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Strig
Posts: 40
Joined: Fri Aug 21, 2020 12:33 pm

Checking if the player went through all branches

Post by Strig »

Hello, I'm making a randomizing system like this:

The player reaches a point in the conversation with an NPC involving a group Node with a number of branches. After the player goes through every branch at least once, I want the conversation to transition into a math.random between all branches.

How can I do that? My original line of thought was to make a local variable and change it every time a branch ends, and after it reaches the highest possible value, make the dialogue go through a separate Node with math.random.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Checking if the player went through all branches

Post by Tony Li »

That'll work. Let's say you have 3 nodes: A, B, C. You could define a variable "branchesVisited" initially set to zero. Then set up the nodes like this:
  • Group Node linked to A, B, C: Condition: branchesVisited==3, Script: RandomizeNextEntry()
  • A: Condition: branchesVisited==0 or branchesVisited == 3, Script: branchesVisited=1
  • B: Condition: branchesVisited==1 or branchesVisited == 3, Script: branchesVisited=2
  • C: Condition: branchesVisited==2 or branchesVisited == 3, Script: branchesVisited=3
Make sure the group node is first in the list. (Inspect the previous node and check the Links To: section at the bottom.)

EDIT: Updated conditions.
Strig
Posts: 40
Joined: Fri Aug 21, 2020 12:33 pm

Re: Checking if the player went through all branches

Post by Strig »

Hi, Tony! Thanks for the reply!

I ran a few tests and I think that this way only works if I wanted to randomize between nodes located after the branches in question. What I want to do is actually rerun the branches, like this:
Captura de Tela (179).png
Captura de Tela (179).png (25.87 KiB) Viewed 695 times
The Group Node is supposed to randomize between the branches below it after going through them all at least once. I tried setting a different variable for this, but right now the only solution I can see is making two group nodes - one that gives the branches a pass before they are all read and then another one that acts as the randomizer, after branchesVisited is equal to the number of branches.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Checking if the player went through all branches

Post by Tony Li »

Good point. I updated the conditions in my previous reply. I think that should work the way you want.
Strig
Posts: 40
Joined: Fri Aug 21, 2020 12:33 pm

Re: Checking if the player went through all branches

Post by Strig »

Thanks! That solved it - at least for now, I think.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Checking if the player went through all branches

Post by Tony Li »

Sound good! If you come up with any cases that you'd like to handle that the current conditions don't handle, just let me know.
Post Reply