Procedural quests generation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Sam3DX
Posts: 2
Joined: Fri Dec 31, 2021 11:03 am

Procedural quests generation

Post by Sam3DX »

Happy New Year, folks! 🎉

I want to build all the game dialogue/quest mechanics around the versatile handcrafted dialogue trees so I probably would prefer to stick with DS instead of generate quests with QuestMachine. But it will be great to have a procedural quests as well. I found that it’s possible to add a new databases at runtime and even import it from xml. So, I wonder if it’s possible to generate a quest as an .xml (.csv, or something) on runtime, import it to main database and proceed with it as a regular quest?

And if it’s possible, is it actually a good idea or it’s rather “doable, but totally unconventional and you’d better not”

If it’s ok, can you show me the way to the API I will need to implement this?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Procedural quests generation

Post by Tony Li »

Hi,

For quests, you can use the QuestLog class. You don't need to create a new database.

However, if you need to create a new conversation for the quest, you will need to create a new database at runtime.

Example:

Code: Select all

using PixelCrushers.DialogueSystem; // (Put at top of script.)
...
string questName = "Find the Maguffin";
string activeDescription = "You must find the Maguffin.";
string successDescription = "You found the Maguffin.";
string failureDescription = "You failed to find the Maguffin.";
QuestLog.AddQuest(questName, activeDescription, successDescription, failureDescription, QuestState.Unassigned);
Or, from JSON:

JSON file:

Code: Select all

{
    "questName": "Find the Maguffin",
    "activeDescription": "You must find the Maguffin.",
    "successDescription": "You found the Maguffin.",
    "failureDescription": "You failed to find the Maguffin."
}

Code: Select all

[System.Serializable]
public class QuestInfo
{
    public string questName;
    public string activeDescription;
    public string successDescription;
    public string failureDescription;
}
...
QuestInfo info = JsonUtility.FromJson<QuestInfo>(yourJsonText);
QuestLog.AddQuest(info.questName, info.activeDescription, info.successDescription, info.failureDescription, QuestState.Unassigned);
(You can use XML the same way, but I think JSON is a simpler format.)
Sam3DX
Posts: 2
Joined: Fri Dec 31, 2021 11:03 am

Re: Procedural quests generation

Post by Sam3DX »

Sounds like exactly what I need, thanks a lot!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Procedural quests generation

Post by Tony Li »

Glad to help!
Post Reply