[HOWTO] How To: Toggle Another Quest's Tracking When Quest Ends

Announcements, support questions, and discussion for Quest Machine.
Post Reply
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Toggle Another Quest's Tracking When Quest Ends

Post by Tony Li »

To toggle another quest's tracking on or off when a quest is completed, add the following Set Tracking quest action to the quest's Success state Actions list.

SetTrackingQuestAction.cs

Code: Select all

namespace PixelCrushers.QuestMachine
{
    public class SetTrackingQuestAction : QuestAction
    {
        public StringField questID;
        public bool track;

        public override string GetEditorName()
        {
            return (track ? "Track " : "Untrack ") + questID;
        }

        public override void Execute()
        {
            base.Execute();
            var quest = QuestMachine.GetQuestInstance(questID);
            if (quest != null)
            {
                quest.showInTrackHUD = track;
                QuestMachineMessages.RefreshUIs(quest);
            }
        }
    }
}
Post Reply