Check for existing quest content: possible categories

Announcements, support questions, and discussion for Quest Machine.
Post Reply
fbit
Posts: 30
Joined: Fri Nov 30, 2018 9:30 am

Check for existing quest content: possible categories

Post by fbit »

Hello once again!

Is it possible to check if a quest has a quest content of the type "Alert"? I have tried it and somehow it did not work.. so, I have just found the following in the script QuestStateInfo:

Code: Select all

public static int NumContentCategories = Enum.GetNames(typeof(QuestContentCategory)).Length - 3; // Omit Alert, Offer & OfferConditionsUnmet.
Why aren't the categories "Alert", "Offer" and "OfferConditionsUnmet" added as an index to the categorizedContentList in the class QuestStateInfo? Is this why I could not check if a specific quest had an alert content or not?

Also, I would like to suggest a check for the return of GetContentList at QuestNode.cs in line 526 (like e.g. stateInfo.GetContentList(category)?.Count). As already mentioned, I tried to get the content list for the category "Alert" and therefore received a NullPointerException as there were not found any content list for this category:

Code: Select all

return stateInfo !=  && stateInfo.GetContentList(category).Count > 0;
Hopefully I could explain my issues well enough - anyway, I am looking forward to your response!

Greetings,
Franca
User avatar
Tony Li
Posts: 22000
Joined: Thu Jul 18, 2013 1:27 pm

Re: Check for existing quest content: possible categories

Post by Tony Li »

Hello Franca,
fbit wrote: Wed Jan 09, 2019 6:30 amIs it possible to check if a quest has a quest content of the type "Alert"?
Yes. Alert content is contained inside Actions, in an AlertQuestAction. This code will list all Alert content:
Spoiler

Code: Select all

using PixelCrushers.QuestMachine;
using System.Collections.Generic;
using UnityEngine;

public class ReportAlertContent : MonoBehaviour
{
    public Quest quest;

    void Start()
    {
        Debug.Log("Alert Content Report:");
        foreach (var questStateInfo in quest.stateInfoList)
        {
            LogAlertContentInActions(questStateInfo.actionList);
        }
        foreach (var questNode in quest.nodeList)
        {
            foreach (var questNodeStateInfo in questNode.stateInfoList)
            {
                LogAlertContentInActions(questNodeStateInfo.actionList);
            }
        }
    }

    void LogAlertContentInActions(List<QuestAction> actionList)
    {
        foreach (var questAction in actionList)
        {
            if (questAction is AlertQuestAction)
            {
                var alertQuestAction = questAction as AlertQuestAction;
                foreach (var questContent in alertQuestAction.contentList)
                {
                    Debug.Log("Alert Content: " + questContent.GetType().Name + ": " + questContent.originalText);
                }
            }
        }
    }
}
fbit wrote: Wed Jan 09, 2019 6:30 amWhy aren't the categories "Alert", "Offer" and "OfferConditionsUnmet" added as an index to the categorizedContentList in the class QuestStateInfo?
This is because they don't apply directly to individual quest states. QuestStateInfo contains information for a specific quest state (WaitingToStart, Active, Successful, etc.). Individual quest states don't have Offer content or OfferConditionsUnmet content. And Alert content is nested deeper inside quest state info, in the quest state's Actions.
fbit wrote: Wed Jan 09, 2019 6:30 amAlso, I would like to suggest a check for the return of GetContentList at QuestNode.cs in line 526 (like e.g. stateInfo.GetContentList(category)?.Count). As already mentioned, I tried to get the content list for the category "Alert" and therefore received a NullPointerException as there were not found any content list for this category:

Code: Select all

return stateInfo !=  && stateInfo.GetContentList(category).Count > 0;
Thank you. I'll fix that in the next update.
fbit
Posts: 30
Joined: Fri Nov 30, 2018 9:30 am

Re: Check for existing quest content: possible categories

Post by fbit »

Hi Tony,

Thanks again for your informative answer!
Tony Li wrote: Wed Jan 09, 2019 12:59 pm Alert content is nested deeper inside quest state info, in the quest state's Actions.
I have not noticed this yet, this is good to know!
Tony Li wrote: Wed Jan 09, 2019 12:59 pm QuestStateInfo contains information for a specific quest state (WaitingToStart, Active, Successful, etc.). Individual quest states don't have Offer content or OfferConditionsUnmet content.
And this makes sense to me now, too. Thanks.
User avatar
Tony Li
Posts: 22000
Joined: Thu Jul 18, 2013 1:27 pm

Re: Check for existing quest content: possible categories

Post by Tony Li »

You're welcome! :-)
Post Reply