Page 1 of 1

Quest tracker still there after failure/success

Posted: Wed Apr 06, 2016 5:27 pm
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

Re: Quest tracker still there after failure/success

Posted: Wed Apr 06, 2016 8:11 pm
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.

Re: Quest tracker still there after failure/success

Posted: Thu Apr 07, 2016 5:09 pm
by bluebuttongames
Great! Thanks Tony.

While I'm at it is there a way to stop failed quests turning up in the completed tab?

Re: Quest tracker still there after failure/success

Posted: Thu Apr 07, 2016 8:56 pm
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();
    }
}