Page 1 of 1

Checking conditions is not correct

Posted: Tue Jul 21, 2020 3:39 am
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 1038 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.

Re: Checking conditions is not correct

Posted: Tue Jul 21, 2020 8:38 am
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.)

Re: Checking conditions is not correct

Posted: Tue Jul 21, 2020 11:01 pm
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.

Re: Checking conditions is not correct

Posted: Wed Jul 22, 2020 10:27 am
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 1028 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 1028 times

It requires a few more nodes, but it gives you the greatest amount of flexibility.

Re: Checking conditions is not correct

Posted: Thu Jul 23, 2020 12:28 am
by thaptam
Thanks, Toni. That's very helpful.

Re: Checking conditions is not correct

Posted: Thu Jul 23, 2020 8:15 am
by Tony Li
Happy to help! :-)