Quest States in C#
Posted: Mon Sep 02, 2024 10:36 pm
Is there a way to get the state of a current quest through C#? I tried using QuestListener, but it only has conditions for OnEnter, and I would like something more akin to OnStay, since I am activating objects at any point after the quest has been activated. Meaning that if I leave the scene and come back (without using the Save System), I would like it to check the status of the quest and then activate its game object or not.
The reason for this is because some items will be reused for multiple quests but only become available once the quest is first set active. This is the code I was trying out, but it only ever returns Unassigned and doesn't log false when switching state to active:
Or if there's another easier way to do this, I'm all ears. Like maybe I'm not getting that QuestListener fires with OnEnable or something.
The reason for this is because some items will be reused for multiple quests but only become available once the quest is first set active. This is the code I was trying out, but it only ever returns Unassigned and doesn't log false when switching state to active:
Code: Select all
public bool Check()
{
var actorName = actor.GetName();
string questName = DialogueLua.GetActorField(actorName, "Quest").asString;
var state = QuestLog.GetQuestState(questName);
QuestLog.UpdateQuestIndicators(questName);
if (!log) return default;
Debug.Log("Actor: " + actorName + ", State: " + state);
Debug.Log(state == QuestState.Unassigned);
return default;
}