Page 1 of 1

Quest Giver Trigger [SOLVED]

Posted: Sat Dec 28, 2019 12:56 pm
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?

Re: Quest Giver Trigger

Posted: Sat Dec 28, 2019 3:18 pm
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();
        }
    }
}

Re: Quest Giver Trigger

Posted: Sun Dec 29, 2019 7:56 pm
by mschoenhals
This works perfectly!
Thank you. :D

Re: Quest Giver Trigger [SOLVED]

Posted: Mon Dec 30, 2019 9:02 am
by Tony Li
Glad to help!