Quest Giver Trigger [SOLVED]

Announcements, support questions, and discussion for Quest Machine.
Post Reply
mschoenhals
Posts: 118
Joined: Thu Dec 19, 2019 7:38 am

Quest Giver Trigger [SOLVED]

Post by mschoenhals »

Hi,
I'm wondering if there's a better way to trigger the next quest when coming from the same quest giver? Right now, if the player returns to a quest giver and talks to a quest giver, the previous quest ends and is given an award. To trigger the next quest from the quest giver, the player has to walk away and then come back (seeing the exclamation mark above the quest giver).

Is there another way to trigger the next quest? Possibly not leave the quest giver but when hitting close on the dialogue box, that brings up the next? Or another solution?
Last edited by mschoenhals on Sun Dec 29, 2019 7:57 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Giver Trigger

Post by Tony Li »

Hi,

I'll add this in the next update. In the meantime, you can replace your QuestGiver components with this QuestGiverCustom script:

QuestGiverCustom.cs

Code: Select all

using PixelCrushers.QuestMachine;

public class QuestGiverCustom : QuestGiver
{
    private UnityUIQuestDialogueUI dialogueUI;

    public override void Start()
    {
        base.Start();
        dialogueUI = QuestMachine.defaultQuestDialogueUI as UnityUIQuestDialogueUI;
    }

    protected override void ShowActiveQuest(Quest quest)
    {
        base.ShowActiveQuest(quest);
        // Disable the Close button's default event (Hide) and call our custom method instead.
        dialogueUI.closeButton.onClick.SetPersistentListenerState(0, UnityEngine.Events.UnityEventCallState.Off);
        dialogueUI.closeButton.onClick.AddListener(OnCloseActiveQuest);
    }

    protected void OnCloseActiveQuest()
    {
        // Re-enable the Close button's default event and remove out custom method.
        dialogueUI.closeButton.onClick.SetPersistentListenerState(0, UnityEngine.Events.UnityEventCallState.RuntimeOnly);
        dialogueUI.closeButton.onClick.RemoveListener(OnCloseActiveQuest);

        // Check if there are any new offerable quests. If so, show it. Otherwise close.
        RecordQuestsByState();
        if (offerableQuests.Count > 0)
        {
            StartMostRelevantDialogue();
        }
        else
        {
            dialogueUI.closeButton.onClick.Invoke();
        }
    }
}
mschoenhals
Posts: 118
Joined: Thu Dec 19, 2019 7:38 am

Re: Quest Giver Trigger

Post by mschoenhals »

This works perfectly!
Thank you. :D
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Giver Trigger [SOLVED]

Post by Tony Li »

Glad to help!
Post Reply