Page 1 of 1

All quest entries successful = master quest marked as success?

Posted: Thu Aug 31, 2017 1:39 pm
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?

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

Posted: Thu Aug 31, 2017 3:25 pm
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.

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

Posted: Thu Aug 31, 2017 4:23 pm
by Abelius
Ok, thank you for clarifying that to me. ;)

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

Posted: Fri Jul 06, 2018 4:57 am
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.

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

Posted: Fri Jul 06, 2018 8:25 am
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);
        }
    }
}

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

Posted: Sun Jul 08, 2018 10:23 pm
by behindname
Thanks a lot! I appreciate your sincere apply.
I'll apply the second solution, the C# coding method.
Thanks again!

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

Posted: Sun Jul 08, 2018 10:37 pm
by Tony Li
Glad to help!

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

Posted: Sun Jul 08, 2018 11:37 pm
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!

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

Posted: Mon Jul 09, 2018 9:30 am
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.