From 5c669f4b3a772fee96c8e4e10ecc6d32984e890a Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:54:10 +1100 Subject: [PATCH] change to trackedQuestId, add currentQuestId --- source/game/StarQuestManager.cpp | 8 ++++++++ source/game/StarQuestManager.hpp | 2 ++ source/game/scripting/StarPlayerLuaBindings.cpp | 8 ++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/source/game/StarQuestManager.cpp b/source/game/StarQuestManager.cpp index 876f0b8..df8a19a 100644 --- a/source/game/StarQuestManager.cpp +++ b/source/game/StarQuestManager.cpp @@ -273,6 +273,10 @@ List QuestManager::listFailedQuests() const { return result; } +Maybe QuestManager::currentQuestId() const { + return m_trackedQuestId; +} + Maybe QuestManager::currentQuest() const { auto questId = m_onWorldQuestId.orMaybe(m_trackedQuestId); if (questId && isActive(*questId)) { @@ -283,6 +287,10 @@ Maybe QuestManager::currentQuest() const { return {}; } +Maybe QuestManager::trackedQuestId() const { + return m_trackedQuestId; +} + Maybe QuestManager::trackedQuest() const { if (m_trackedQuestId && isActive(*m_trackedQuestId)) { auto current = getQuest(*m_trackedQuestId); diff --git a/source/game/StarQuestManager.hpp b/source/game/StarQuestManager.hpp index 3d7ee22..549f13b 100644 --- a/source/game/StarQuestManager.hpp +++ b/source/game/StarQuestManager.hpp @@ -52,7 +52,9 @@ public: List listCompletedQuests() const; List listFailedQuests() const; + Maybe currentQuestId() const; Maybe currentQuest() const; + Maybe trackedQuestId() const; Maybe trackedQuest() const; Maybe getQuestIndicator(EntityPtr const& entity) const; diff --git a/source/game/scripting/StarPlayerLuaBindings.cpp b/source/game/scripting/StarPlayerLuaBindings.cpp index 15ad1dd..ea902ab 100644 --- a/source/game/scripting/StarPlayerLuaBindings.cpp +++ b/source/game/scripting/StarPlayerLuaBindings.cpp @@ -484,8 +484,8 @@ LuaCallbacks LuaBindings::makePlayerCallbacks(Player* player) { return player->questManager()->hasCompleted(questId); }); - callbacks.registerCallback("trackedQuest", [player]() { - return player->questManager()->trackedQuest(); + callbacks.registerCallback("trackedQuestId", [player]() { + return player->questManager()->trackedQuestId(); }); callbacks.registerCallback("setTrackedQuest", [player](Maybe const& questId) { @@ -496,6 +496,10 @@ LuaCallbacks LuaBindings::makePlayerCallbacks(Player* player) { return player->questManager()->canTurnIn(questId); }); + callbacks.registerCallback("currentQuestId", [player]() { + return player->questManager()->currentQuestId(); + }); + callbacks.registerCallback("currentQuest", [player]() -> Json { auto maybeQuest = player->questManager()->currentQuest(); if (maybeQuest) {