Get quest ID

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
onpocket
Posts: 13
Joined: Fri Feb 01, 2019 5:04 am

Get quest ID

Post 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
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Get quest ID

Post 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:

Image

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():

Image
onpocket
Posts: 13
Joined: Fri Feb 01, 2019 5:04 am

Re: Get quest ID

Post 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 :P).

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
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Get quest ID

Post 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.
onpocket
Posts: 13
Joined: Fri Feb 01, 2019 5:04 am

Re: Get quest ID

Post by onpocket »

Once more you've made my day! Thank you so much!

Best regards,
João
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Get quest ID

Post by Tony Li »

Happy to help!
Post Reply