Checking conditions is not correct

Announcements, support questions, and discussion for Quest Machine.
Post Reply
thaptam
Posts: 13
Joined: Wed Aug 07, 2019 12:31 pm

Checking conditions is not correct

Post by thaptam »

Hi Tony,

I got a bug relates to the condition checking. My node has 3 conditions and it requires all of them to be True. But the node became true with only 2 last conditions. The counter condition didn't work.
Untitled.png
Untitled.png (184.09 KiB) Viewed 1052 times
Please help me to fix that. Thank you.

P/S: from my debugging, it looks like the numTrueCondition is not reset when one condition fails, and the callback increase numTrueCondition when other conditions match and ignore the first one.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Checking conditions is not correct

Post by Tony Li »

Hi,

What do you mean by "when one condition fails"? Are you reverting a node back to a previous state? (For example, using the Set Quest Node State quest action.)
thaptam
Posts: 13
Joined: Wed Aug 07, 2019 12:31 pm

Re: Checking conditions is not correct

Post by thaptam »

I made a set of 3 conditions and set the node will be successful when all of the 3 conditions match. The first condition is the counter condition and the next two conditions are Lua variable conditions.

In my case, the first one does not match but the Lua variable conditions have a callback and that causes the issue. After the first checking, everything is fine, but the callback is triggered by the time manager, and that time the Lua variable matches the condition. It increases the value of numTrueCondition and the numTrueConditon larger than the ListCondition.Count. So the node becomes true but the counter condition in the set does not match.

My opinion is when node checks all conditions, it should go through all condition likes A & B & C = true instead of comparing the numTrueCondition with the List Condition Count.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Checking conditions is not correct

Post by Tony Li »

Hi,

Quest Machine works the way it does because some conditions only get one message to turn true (such as the Message Quest Condition).

If the Lua condition can become true and then later become false before all of the conditions are true, use a Parent State Quest Condition. Add A & B & C as separate condition nodes, each leading to a single child node with a Parent State Quest Condition:

qmMultiConditions.png
qmMultiConditions.png (21.53 KiB) Viewed 1042 times

If the Lua condition on C can become false before A & B are true, add a node that checks of C turned false. In this node, reset the nodes above to Active instead of True:

qmMultiConditions2.png
qmMultiConditions2.png (22.11 KiB) Viewed 1042 times

It requires a few more nodes, but it gives you the greatest amount of flexibility.
thaptam
Posts: 13
Joined: Wed Aug 07, 2019 12:31 pm

Re: Checking conditions is not correct

Post by thaptam »

Thanks, Toni. That's very helpful.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Checking conditions is not correct

Post by Tony Li »

Happy to help! :-)
Post Reply