[HOWTO] How To: Add Custom Data To Quests
Posted: Sun Apr 05, 2020 9:08 am
This post describes some ways to add custom data to a quest, beyond what you can add in the Quest Editor and by adding custom quest conditions, actions, and UI content. (In most cases, adding data in the Quest Editor and/or custom conditions, actions, and UI content is more than sufficient.)
While you you cannot derive subclasses from Quest, you can add data to its tagDictionary. Example use:
For procedural quests, you can do two things:
1. Assign a delegate method to QuestGeneratorEntity.generatedQuest. This method will be called after generating the quest. You can use it to add more data or otherwise adjust the quest.
Side note: You can also assign a delegate method to QuestGeneratorEntity.updateWorldModel to add more information to the world model than what it normally sees in its Quest Domains. This method is called just before sending the world model to the quest generator.
2. Or derive a subclass of PlanToQuestBuilder and assign it to QuestGeneratorEntity.questGenerator.planToQuestBuilder.
When an NPC generates a quest, it follows these steps:
While you you cannot derive subclasses from Quest, you can add data to its tagDictionary. Example use:
Code: Select all
quest.tagDictionary.AddTag("Difficulty", "Hard");
if (quest.tagDictionary.ContainsTag("Difficulty"))
{
Debug.Log("This quest is: " + quest.tagDictionary.GetTag("Difficulty", "Medium"); // If no tag, assume Medium.
}
1. Assign a delegate method to QuestGeneratorEntity.generatedQuest. This method will be called after generating the quest. You can use it to add more data or otherwise adjust the quest.
Side note: You can also assign a delegate method to QuestGeneratorEntity.updateWorldModel to add more information to the world model than what it normally sees in its Quest Domains. This method is called just before sending the world model to the quest generator.
2. Or derive a subclass of PlanToQuestBuilder and assign it to QuestGeneratorEntity.questGenerator.planToQuestBuilder.
When an NPC generates a quest, it follows these steps:
- Builds a world model.
- Passes the world model to the quest generator, which determines a sequence of Actions to take (called a plan).
- Passes the plan to PlanToQuestBuilder, which turns the Actions into a Quest object and returns it to the NPC.
- The NPC adds the quest to its Quest Giver component's Quests list.