Page 1 of 1

Node True state actions called twice if conditions are immediately met on Active state

Posted: Tue Oct 25, 2022 10:37 am
by nratcliff
I'm currently running into an issue where a quest node's True state actions are called twice when the quest node is activated and its conditions are immediately met.

I have a quest node that looks for a nearby village and adds a waypoint to the player's map if a village is nearby. In some cases, the village could already be nearby, so the condition is met as soon as the quest node is activated when the quest starts.

Image

Image

If a village is already nearby, the condition's SetTrue() method is called right away in StartChecking. This calls QuestNode.OnConditionTrue which invokes SetState(QuestNodeState.True). The problem, is that StartChecking is called from SetState(QuestNodeState.Active)->SetConditionChecking on the node when it is first activated, before the state events are invoked. Because the node's state changes to True via an additional SetState call, the state has changed and the events have already been called by the time the original SetState call moves on to invoking state actions.

Image

Am I doing something wrong or is this possibly a bug in Quest Machine? We're using v1.2.31.

Re: Node True state actions called twice if conditions are immediately met on Active state

Posted: Tue Oct 25, 2022 11:26 am
by Tony Li
Hi,

The Quest Machine Extras page has a patch that should fix this issue. The fix in this patch will also be in the upcoming version 1.2.32.

Re: Node True state actions called twice if conditions are immediately met on Active state

Posted: Tue Oct 25, 2022 1:35 pm
by nratcliff
Thanks Tony! That did the trick.

Re: Node True state actions called twice if conditions are immediately met on Active state

Posted: Tue Oct 25, 2022 1:35 pm
by Tony Li
Glad to help!