Page 1 of 1
Get quest ID
Posted: Fri May 24, 2019 10:26 am
by onpocket
Hi Toni!
The subject of the topic is pretty self explanatory! I am looking for a way of getting the quest ID. Is this by any means possible?
Best regards,
João
Re: Get quest ID
Posted: Fri May 24, 2019 10:39 am
by Tony Li
Hi,
Are you looking for a Dialogue System quest ID or a Quest Machine quest ID?
For the Dialogue System, the quest ID is the quest's Name field:
There's also an internal ID number, but in general you should never need to access it.
The quest's Name is used in Lua functions such as SetQuestState() and in C# methods such as QuestLog.SetQuestState():
Re: Get quest ID
Posted: Fri May 24, 2019 11:03 am
by onpocket
Hi Toni!
I have been looking to the Dialogue System quest ID.
I am trying to get the quest data (id, title, description, quest state) and with that populate a custom class of my own. In that class, let's call it "Quest", i will be adding some other relevant variables to me, such as the "start_timestamp" and "end_timestamp" and "quest_dependencies[] {quest_id_0, quest_id_1, ...}" (do not ask me how i will implement this last one, because i do not know it myself... Still need to figure it out
).
Anyway, as you can see since i need the quest IDs i would like to have the "original" ones instead of generating my own with methods like "System.Guid.NewGuid" which return enormous IDs that do not correlate with the Dialogue System quest IDs.
Thank you in advance,
João
Re: Get quest ID
Posted: Fri May 24, 2019 11:22 am
by Tony Li
Hi João,
You can either use the quest Name field as its unique ID, or you can use its internal ID number. To get the internal ID number:
Code: Select all
int id = DialogueManager.masterDatabase.GetItem("Get the Launch Codes").id;
To list all IDs:
Code: Select all
foreach (var quest in DialogueManager.masterDatabase.items)
{
if (!quest.IsItem) Debug.Log("Quest " + quest.Name + " ID = " + quest.id);
}
IDs are only valid for quests that are defined in the dialogue database. The information about these quests are also present in the Dialogue System's Lua environment.
If you create new quests at runtime, their information will only be in the Lua environment. You can use the
QuestLog and
DialogueLua classes to access them. To list all quests:
Code: Select all
string[] allQuests = QuestLog.GetAllQuests(QuestState.Unassigned | QuestState.Active | QuestState.Success);
The QuestLog class has many other methods to get and set information.
To get or set a specific field, you can also use DialogueLua:
Code: Select all
int numPasswordAttempts = DialogueLua.GetQuestField("Get the Launch Codes", "Password Attempts").asInt;
DialogueLua.SetQuestField("Get the Launch Codes", numPasswordAttempts + 1);
I hope this information helps. If you have more specific requirements, I may be able to provide clearer information.
Re: Get quest ID
Posted: Mon May 27, 2019 9:35 am
by onpocket
Once more you've made my day! Thank you so much!
Best regards,
João
Re: Get quest ID
Posted: Mon May 27, 2019 11:35 am
by Tony Li
Happy to help!