All quest entries successful = master quest marked as success?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

All quest entries successful = master quest marked as success?

Post by Abelius »

Hi there,

I'm creating a 'Meet X and Y NPCs' quest with two subtasks: 'Meet X' and 'Meet Y', which are marked as 'active' as default.

After each dialogue with those NPCs I run a script to mark as 'success' each quest entry. That works and I even see how the subtasks disappear from the Tracker HUD.

But the main quest remains 'active'. I kind of took for granted that if I declare a quest with subtasks, it would be automatically marked as successful when all entries are also marked as successful, but this doesn't seem to be the case.

I guess this is for flexibility purposes, so no big deal if the default behavior is this, but I'd like to have confirmation just in case I'm doing something wrong.

Thanks!

Edit: I've just seen that there is an additional 'done' quest/quest entry state... I wasn't able to find the difference between 'success' and 'done'. Is there a page where those differences are explained?
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22058
Joined: Thu Jul 18, 2013 1:27 pm

Re: All quest entries successful = master quest marked as success?

Post by Tony Li »

That's the default behavior. It won't automatically mark the main quest state as 'success'. Some designers might not want this to happen, so I thought it best to let the designer control it.

'done' is just an alias for 'success'. Some designers prefer to think of a quest state as either active/done, instead of active/success/failure.
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: All quest entries successful = master quest marked as success?

Post by Abelius »

Ok, thank you for clarifying that to me. ;)
Unity 2019.4.9f1
Dialogue System 2.2.15
behindname
Posts: 9
Joined: Wed Jun 27, 2018 4:59 am

Re: All quest entries successful = master quest marked as success?

Post by behindname »

I'd like to mark Master Quest as Success when every sub-quest entry state changed to success.
Is there effective way to implement this? All should I implement this by myself?

If I can count the number of quest entries which state is success, that would be enough.
User avatar
Tony Li
Posts: 22058
Joined: Thu Jul 18, 2013 1:27 pm

Re: All quest entries successful = master quest marked as success?

Post by Tony Li »

Quest Machine can do this automatically, but in the Dialogue System you need to check them manually.

For example, let's say you have a quest "Meet the Gang", with entries to meet Ann, Barb, and Cathy. In a dialogue entry, you can check the entries like this:

Image

This entry checks if the main quest is active, and if all three quest entries are successful. If so, it sets the main quest successful and shows an alert.

To do the same in a script, you could add an OnQuestEntryStateChange method:

Code: Select all

using PixelCrushers.DialogueSystem;
...
void OnQuestEntryStateChange(QuestEntryArgs args)
{
    if (QuestLog.IsQuestActive(args.questName))
    {
        // If quest is active, count how many entries are successful:
        var numEntries = QuestLog.GetQuestEntryCount(args.questName));
        int numEntriesSuccessful = 0;
        for (int i = 1; i <= numEntries; i++)
        {
            if (QuestLog.GetQuestEntryState(args.QuestName, i) == QuestState.Success)
            {
                numEntries++;
            }
        }
        if (numEntriesSuccessul == numEntries)
        {
            // If all entries are successful, complete the quest:
            QuestLog.CompleteQuest(args.questName);
        }
    }
}
behindname
Posts: 9
Joined: Wed Jun 27, 2018 4:59 am

Re: All quest entries successful = master quest marked as success?

Post by behindname »

Thanks a lot! I appreciate your sincere apply.
I'll apply the second solution, the C# coding method.
Thanks again!
User avatar
Tony Li
Posts: 22058
Joined: Thu Jul 18, 2013 1:27 pm

Re: All quest entries successful = master quest marked as success?

Post by Tony Li »

Glad to help!
behindname
Posts: 9
Joined: Wed Jun 27, 2018 4:59 am

Re: All quest entries successful = master quest marked as success?

Post by behindname »

behindname wrote: Sun Jul 08, 2018 10:23 pm Thanks a lot! I appreciate your sincere apply.
I'll apply the first solution. Maintaining default behavior can be useful for the other quest, I suspect.
Thanks again!
User avatar
Tony Li
Posts: 22058
Joined: Thu Jul 18, 2013 1:27 pm

Re: All quest entries successful = master quest marked as success?

Post by Tony Li »

Hi,

If you want to use the second solution only on some quests, you could add a custom field that specifies whether to apply this solution to the quest. For example, let's say the field is a Boolean named "Autocomplete":

Code: Select all

void OnQuestEntryStateChange(QuestEntryArgs args)
{
    if (QuestLog.IsQuestActive(args.questName) &&
        DialogueLua.GetQuestField(args.questName, "Autocomplete").AsBool) //<--ADD THIS
    {
Then set "Autocomplete" true for quests that will use this second solution.
Post Reply