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?
Procedural quests generation
Re: Procedural quests generation
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:
Or, from JSON:
JSON file:
(You can use XML the same way, but I think JSON is a simpler format.)
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);
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);
Re: Procedural quests generation
Sounds like exactly what I need, thanks a lot!
Re: Procedural quests generation
Glad to help!