+1
Planned

Dialogue conditions don't seem to block actions on the dialogue line

Pyro Game Studio 8 months ago in Dialogue updated by Marti (Lead Developer) 3 months ago 10

In the example below:

All the dialogue lines have conditions. However only the last 2 line have actions.

- The "You've returned with the box! Thank you!" dialogue has an action that sets a quest to completed.

- The "Thank you for all your help my friend!" dialogue has an action that sets the character gesture.

In this example all the conditions work perfectly and the dialogues are hidden when they're supposed to be.. however, when the "You've returned with the box! Thank you!" dialogue condition fails its action is still ran and I get this:

Basically the action is trying to set the quest: "return-to-naja" to complete, but it is already completed. Also when the "Thank you for all your help my friend!" dialogue condition fails, the gesture animation still plays even though the dialogue doesn't appear.

I'm using the latest version of the Dialogue module: 0.5.3

NOTE: I did find a work-around by placing the dialogue lines that have actions as a child of empty dialogue lines with no actions and giving those lines a quick autoplay of 0.5. This seems very hacky but it makes my dialogues work properly.

Unity version:
2019.3
Game Creator version:
1.0.4

Answer

Answer
Not a bug

Hi Pyro. What it's happening is intended by design. If a dialogue line Condition returns false ("You've returned with the box, thank you!") it won't display that line and any of its children. However, it will continue displaying sibling lines below.


The solution to this problem is, as you say at the end, placing the "Thank you for all your help friend" line as a child of the "you've returned with the box. Thank you" line. No need to create empty dialogue lines. So, from what you initially had, all you needed to do is drag the last line and drop it as a child of the "You've returned with the box, thank you" line.


Hope this helps!

Answer
Not a bug

Hi Pyro. What it's happening is intended by design. If a dialogue line Condition returns false ("You've returned with the box, thank you!") it won't display that line and any of its children. However, it will continue displaying sibling lines below.


The solution to this problem is, as you say at the end, placing the "Thank you for all your help friend" line as a child of the "you've returned with the box. Thank you" line. No need to create empty dialogue lines. So, from what you initially had, all you needed to do is drag the last line and drop it as a child of the "You've returned with the box, thank you" line.


Hope this helps!

Hi Marti, the main issue isn't so much with the sibling lines, I know I can shuffle those around. The problem is that the dialogues that conditions return false still run the actions attached to them. Is that happening by design also?

the "You've returned with the box, thank you!" has an action to complete a quest. That action should not run if the condition for that line is false. At least, that's how I thought it should work.

Under review

Correct, that shouldn't happen. Can you post a screenshot of the Condition? Just to make sure it isn't running, can you use the Condition under General that is called Simple Condition? And make it return false.

This will help by dismissing any issues coming from the Condition returning true.

Here is what the condition looks like. It is a Quest condition.

So I did what you suggested and switched to a simple condition and made it always return false. The actions attached to that dialogue line still run.

We are unable to reproduce what you mention. It works fine with all configuration options we've tried. Can you post screenshots that capture the entire Dialogue? Line by line, capture both the Message, Actions & Conditions. Otherwise we can't create the exact Dialogue you did.

Thanks again Marti for testing it. Just a heads up. I'm using 2019.3 (I know that's still considered beta) but I just wanted to make that known for when 2019.3 does become release ready.

Not sure if you've tested my issue in 2019.3

I have the same issue on Unity 2019.3.10f.

This is my dialogue tree I use for testing:

The "Good, talk to you later." will start some quests, while the "Very good" should trigger under a condition. 

 The "Good, talk to you later.":

The "Very good!":


Though the condition is always false, and the dialogue is not triggered, the actions inside the dialogue are triggered - which immediately completed the quests.

Can this be fixed?

Hi again!


I created a quick fix for this bug by adding a check for conditions in "IDialogueItem.cs" line 117 in Run() function:

I also discovered another bug related to conditions... After talking with the NPC and saying yes to the quest (after "Good, talk to you later.") if I talk to the NPC again it will repeat "Good, talk to you later.", thus by passing the condition to the parent dialogue choice. The expected behaviour is that the NPC will not talk, as all root branches are blocked by conditions...

The fix to this is in "Dialogue.cs" line 53, in Run() function:

Cheers, and thanks for being open about the source code so we can add features and fix bugs ;) Game Creator really makes development easy and this kind of gesture from the developer really makes me happy about choosing this tool!

Last point! I found an issue in the last fix, in "Dialogue.cs". Now that I am checking conditions AFTER running the dialogue, if the conditions change in the current dialogue text, the fix does not account for that, so here is a fix to the fix:

Planned

Hi Needless;

You've got a point and thank you very much for spotting this! It's taken a few hours to structure the ramifications of these changes and, although the changes will be very similar to yours, I've found that there are still some cases in which this won't work.

For example, if we happen to have a condition that randomly returns true or false, there might be a case where a Dialogue item returns true (hence executing the item). But when the IDialogueItem is executed, the condition could return false now.

I'm still testing the fix, but I think that I should be able to safely remove ALL condition checks and only leave the one in the Dialogue.cs file (your last screenshot), but change it into:

bool conditionsOk = item.CheckConditions(); // added

if (!conditionsOk) continue;

Not 100% sure yet. I'll be doing some testing and circle back. Cheers!