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

Announcements, support questions, and discussion for Quest Machine.
Post Reply
User avatar
nratcliff
Posts: 23
Joined: Tue Sep 27, 2022 10:47 am

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

Post 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.
Lead Dev @ aesthetic.games
Creator of Easy Feedback Form
User avatar
Tony Li
Posts: 22129
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
User avatar
nratcliff
Posts: 23
Joined: Tue Sep 27, 2022 10:47 am

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

Post by nratcliff »

Thanks Tony! That did the trick.
Lead Dev @ aesthetic.games
Creator of Easy Feedback Form
User avatar
Tony Li
Posts: 22129
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Glad to help!
Post Reply