Page 1 of 1
Checking if the player went through all branches
Posted: Wed Dec 02, 2020 12:35 pm
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.
Re: Checking if the player went through all branches
Posted: Wed Dec 02, 2020 1:28 pm
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.
Re: Checking if the player went through all branches
Posted: Wed Dec 02, 2020 2:40 pm
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 (25.87 KiB) Viewed 694 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.
Re: Checking if the player went through all branches
Posted: Wed Dec 02, 2020 2:47 pm
by Tony Li
Good point. I updated the conditions in my previous reply. I think that should work the way you want.
Re: Checking if the player went through all branches
Posted: Mon Dec 14, 2020 3:25 pm
by Strig
Thanks! That solved it - at least for now, I think.
Re: Checking if the player went through all branches
Posted: Mon Dec 14, 2020 3:46 pm
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.