Page 1 of 1
How can I prevent characters within a group from repeating the same dialogue?
Posted: Mon Jun 19, 2023 12:00 am
by ds2497
Hi there!
I've been working on a scenario for two days, but I haven't been able to make it work. I believe this is a common situation in games, here is the scenario:
There are three soldiers, A, B, and C, who share a secret dialogue. The player will talk to them and gather information, but only the last NPC will provide vital information. Regardless of the order of conversation, the player will always receive Pointless Info 1, Pointless Info 2, and Vital Info. In other words, if the player speaks to the NPCs in the order of A => B => C, soldier C will provide the vital information necessary for the quest. If the player speaks to the NPCs in the order of C => A => B, then soldier B will give the vital information. In addition, the player cannot talk to the same NPC three times to obtain the vital information.
I've tried using custom Lua, quest counter(I have Quest Machine in my project) and writing my own code to keep track of the NPCs the player has talked to, but I haven't had any luck. I'm wondering if you could recommend an approach to achieve this? How should I setup the conditions?
Thanks!
Re: How can I prevent characters within a group from repeating the same dialogue?
Posted: Mon Jun 19, 2023 8:49 am
by Tony Li
Hi,
Will all 3 characters share the same lines of dialogue? If so, you can make them share the same conversation. To use different actors for the same conversation, see:
Character GameObject Assignments
If that's what you're looking for, let me know. I can put together a small example scene for you. It would use DS variables to remember that an actor has said A, B, or C lines.
Re: How can I prevent characters within a group from repeating the same dialogue?
Posted: Mon Jun 19, 2023 10:23 am
by ds2497
Yes, three characters share the same dialogue named "Secret." For the "Secret" dialogue, I have set the "Common Actor" for the Actor field, while the NPCs' Actor fields are set up as "Soldier A," "Soldier B," and "Soldier C."
This is likely a logical problem. If you could provide me with a demo, it would be very helpful!
Re: How can I prevent characters within a group from repeating the same dialogue?
Posted: Mon Jun 19, 2023 10:44 am
by Tony Li
Re: How can I prevent characters within a group from repeating the same dialogue?
Posted: Mon Jun 19, 2023 12:56 pm
by ds2497
Hi Tony,
Thanks for providing the example scene! I just had a look at it and I'm wondering what would happen if the player keeps talking to the same soldier? This is one problem I'm trying to solve. From my understanding, the dialogue would need to keep track of which soldiers have already responded to the player, and only then can it prevent the player from speaking to the same actor again.
Please let me know if my understanding is incorrect. Thank you!
Re: How can I prevent characters within a group from repeating the same dialogue?
Posted: Mon Jun 19, 2023 2:31 pm
by Tony Li
Hi,
Oh, sorry, I misunderstood. I thought the player could keep speaking to the same actor to get more info. If they have to speak to a different actor each time, you can use variables to keep track of which actors the player has already spoken to. See:
How To: Run a Conversation Only Once
Re: How can I prevent characters within a group from repeating the same dialogue?
Posted: Mon Jun 19, 2023 11:04 pm
by ds2497
Hi Tony,
Thank you for your reply!
In order to address this issue using variables, I believe it requires something like "Talked{{CurrentActor}}" that can access the current actor's ID and incorporate it into the variable's name. If I were to use a variable like "TalkedNpc", it would lead to the second soldier considering himself already spoken to the player after the player has spoken to the first soldier. This occurs because they share the same dialogue.
Fortunately, I managed to resolve the problem by utilizing a quest counter and a custom Lua script. I will provide the approach here for anyone else encountering a similar issue.
For the custom Lua script:
For dialogue conditions and scripts:
For the second node, the condition counter would be 1 instead of 0, and the script counter would be 2 instead of 1. As for the third soldier, the counter would also increase by 1.
Thank you very much for your help!
Re: How can I prevent characters within a group from repeating the same dialogue?
Posted: Tue Jun 20, 2023 9:41 am
by Tony Li
Hi,
Thanks for sharing your solution!
You could also use the Variable["ConversantIndex"] variable. When talking to Soldier A, its value will be "Soldier_A". When talking to Soldier B, its values will be "Soldier_B".
Then you can define variables "Talked_To_Soldier_A" and "Talked_To_Soldier_B".
In your conversation, you can set these variables like this:
- Script: Variable["Talked_To_" .. Variable["ConversantIndex"]] = true
When talking to Soldier A, this is equivalent to:
- Script: Variable["Talked_To_Soldier_A"] = true
Similarly, you can check if the player has talked to Soldier A like this:
- Conditions: Variable["Talked_To_" .. Variable["ConversantIndex"]] == true
Re: How can I prevent characters within a group from repeating the same dialogue?
Posted: Tue Jun 20, 2023 9:44 am
by ds2497
Got it, thanks for sharing!