Quest tracker still there after failure/success

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
bluebuttongames
Posts: 91
Joined: Tue Jul 14, 2015 8:22 am

Quest tracker still there after failure/success

Post by bluebuttongames »

Hi there,

As the title says I still have a quest tracking even after it's been failed/completed. What do I need to set to make it dissapear?

I'm triggering the fail/success with the following code:

PixelCrushers.DialogueSystem.DialogueLua.SetQuestField(questName, "State", "failure");

Thanks for the help.

BB
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest tracker still there after failure/success

Post by Tony Li »

Hi,

Use this code instead:

Code: Select all

using PixelCrushers.DialogueSystem;
QuestLog.SetQuestState(questName, QuestState.Failure);
QuestLog.SetQuestState() also updates the tracker, whereas DialogueLua.SetQuestField only sets the Lua field. More info: Setting Quest State.
bluebuttongames
Posts: 91
Joined: Tue Jul 14, 2015 8:22 am

Re: Quest tracker still there after failure/success

Post by bluebuttongames »

Great! Thanks Tony.

While I'm at it is there a way to stop failed quests turning up in the completed tab?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest tracker still there after failure/success

Post by Tony Li »

bluebuttongames wrote:While I'm at it is there a way to stop failed quests turning up in the completed tab?
The quest log window considers quests in the "success" or "failure" states as completed. The easiest way not show failed quests is to set their state to a string that the quest log window doesn't recognize. QuestLog.SetQuestState() also accepts string values. For example:

Code: Select all

QuestLog.SetQuestState(questName, "hiddenFailed");
If you don't want to do that, you could make a custom copy of UnityUIQuestLogWindow, or a subclass that overrides OnQuestListUpdated, and omit failed quests. For example:

Code: Select all

public class MyQuestLogWindow : UnityUIQuestLogWindow {

    public override OnQuestListUpdated() {
        // Rebuild the Quests[] array without failed quests:
        var list = new List<QuestInfo>(Quests);
        list.RemoveAll(q => QuestLog.IsQuestFailed(q.Title));
        Quests = list.ToArray();
        
        // Then update the window with the new Quests[] array:
        base.OnQuestListUpdated();
    }
}
Post Reply