Activate next quest node
-
- Posts: 29
- Joined: Fri Jun 02, 2023 8:31 am
Activate next quest node
I am attempting to write a debug command that would allow me to step through a quest. Is there a method that progresses a quest one node? Looked on the forum and API but no luck so far.
Re: Activate next quest node
Hi,
Yes, you can either:
1. Cause the conditions to be true -- for example, call MessageSystem.SendMessage() if the conditions are waiting for a message.
2. Or manually set a node's state by calling QuestMachine.SetQuestNodeState().
Yes, you can either:
1. Cause the conditions to be true -- for example, call MessageSystem.SendMessage() if the conditions are waiting for a message.
2. Or manually set a node's state by calling QuestMachine.SetQuestNodeState().
-
- Posts: 29
- Joined: Fri Jun 02, 2023 8:31 am
Re: Activate next quest node
Is there a way to do it without having to specify the quest node ID? For example, I am hoping to create a debug function that will accept the quest ID as the input and then regardless which node it is on, progress to the next linked node. If the nodes are indexed then move from node n to node n + 1.
Re: Activate next quest node
Hi,
That would be fine if all quests were entirely linear. But Quest Machine is more flexible than that. Your quests can branch, or even loop back on themselves. To do it properly in these cases, make a list of all nodes that are active. Then set them true.
That would be fine if all quests were entirely linear. But Quest Machine is more flexible than that. Your quests can branch, or even loop back on themselves. To do it properly in these cases, make a list of all nodes that are active. Then set them true.
Code: Select all
public void AdvanceQuest(Quest quest)
{
var activeNodes = quest.nodeList.FindAll(node => node.GetState() == QuestNodeState.Active);
activeNodes.ForEach(node => node.SetState(QuestNodeState.True));
}
-
- Posts: 29
- Joined: Fri Jun 02, 2023 8:31 am
Re: Activate next quest node
Is there a way to get the Quest class by its string name?
Re: Activate next quest node
Hi,
What do you mean by quest class?
What do you mean by quest class?
-
- Posts: 29
- Joined: Fri Jun 02, 2023 8:31 am
Re: Activate next quest node
Sorry I mean the Quest asset by its quest ID.
This is the method I am working on.
This is the method I am working on.
Code: Select all
public void AdvanceQuest(string questName)
{
string[] currentQuests = QuestLog.GetAllQuests();
for (int i = 0; i < currentQuests.Length; i++)
{
if(questName == currentQuests[i])
{
Quest quest = //get Quest asset with the string name.
}
}
var activeNodes = quest.nodeList.FindAll(node => node.GetState() == QuestNodeState.Active);
activeNodes.ForEach(node => node.SetState(QuestNodeState.True));
}
-
- Posts: 29
- Joined: Fri Jun 02, 2023 8:31 am
Re: Activate next quest node
I found GetQuestInstance() that should work if I understand it correctly.
Code: Select all
public void AdvanceQuest(string questName)
{
PixelCrushers.QuestMachine.Quest quest = null;
string[] currentQuests = QuestLog.GetAllQuests();
for (int i = 0; i < currentQuests.Length; i++)
{
if (questName == currentQuests[i])
{
quest = QuestMachine.GetQuestInstance(currentQuests[i]);
}
}
if (quest == null) { return; }
var activeNodes = quest.nodeList.FindAll(node => node.GetState() == QuestNodeState.Active);
activeNodes.ForEach(node => node.SetState(QuestNodeState.True));
}