Quick Tip: Custom Quest States

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 22655
Joined: Thu Jul 18, 2013 1:27 pm

Quick Tip: Custom Quest States

Post by Tony Li »

In version 1.7.7 (and in a patch for 1.7.6 available on the customer download page), the QuestLog class will now let you assign a replacement function to QuestLog.StringToState. You can use this to handle custom quest state string values.

For example, say you're using an additional, custom quest state called "pending" by setting a dialogue entry node's Script field to:

Code: Select all

Quest["My Quest"].State = "pending";
And you want this to show up in the quest log window as an active quest.

To do this, create a new script called, say, CustomQuestStates.cs, and add it to the Dialogue Manager. The script should look something like this:

CustomQuestStates.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class CustomQuestStates : MonoBehaviour {

    void Start() {
        QuestLog.StringToState = CustomStringToState; // Insert our replacement "StringToState" function.
    }
   
    QuestState CustomStringToState(string s) {
        // Convert any special quest state string values to their appropriate QuestState type:
        if (s == "pending") return QuestState.Active;

        // Otherwise just use the defaults for "unassigned", "active", "success", etc:
        return QuestLog.DefaultStringToState(s);
    }
} 
The script above augments the QuestLog class to handle your custom state "pending". Since the quest log window and quest tracker HUD get their information from the QuestLog class, you don't need to make any changes to quest log window or tracker HUD scripts.
Post Reply