How to set and get if a Quest is being tracked or not

Announcements, support questions, and discussion for Quest Machine.
Post Reply
Obi
Posts: 3
Joined: Fri Apr 15, 2022 10:20 am

How to set and get if a Quest is being tracked or not

Post by Obi »

How can I use the APIs to set a quest to being tracked and get the same?

Also, is there a way to force run actions for a QuestNode? The reason I am asking is because I have a more complicated track objective system, so I need to know what quest node of a tracked quest is active and then run a custom function to set the objective tracking (which may be in a different scene).

Thanks
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to set and get if a Quest is being tracked or not

Post by Tony Li »

Hi,
Obi wrote: Fri May 13, 2022 1:38 amHow can I use the APIs to set a quest to being tracked and get the same?
Use QuestMachine.GetQuestInstance() to get a reference to the player's instance of the quest. Then check/set its showInTrackHUD property:

Code: Select all

// Track the quest with ID "Get Maguffin" on the player journal with ID "Player":
var quest = QuestMachine.GetQuestInstance("Get Maguffin", "Player");
if (quest != null) quest.showInTrackHUD = true;
Obi wrote: Fri May 13, 2022 1:38 amAlso, is there a way to force run actions for a QuestNode? The reason I am asking is because I have a more complicated track objective system, so I need to know what quest node of a tracked quest is active and then run a custom function to set the objective tracking (which may be in a different scene).
To answer your question first, it's not common to manually run a quest node's actions. But you can do it like:

Code: Select all

var quest = QuestMachine.GetQuestInstance("Get Maguffin", "Player");
var questNode = quest.GetNode("Some Node ID");
var activeStateInfo = questNode.GetStateInfo(QuestNodeState.Active);
activeStateInfo.actionList.ForEach(action => action.Execute());
However, that may not be what you need. Here's some additional info that may be helpful:

When quest info changes, Quest Machine uses the MessageSystem to send a message QuestMachineMessages.RefreshUIs. You can add a message listener to do something when it hears that message.

It's possible for a quest to have more than one active node at a time. To get a list of all active nodes:

Code: Select all

var activeNodes = quest.nodeList.FindAll(node => node.GetState() == QuestNodeState.Active);
Post Reply