Add Money

This quest requires the party to add at least 100 gold for completion, but it is not auto completed. Instead, the player must click the UI Button, which will check if the quest has been successful.

Quest Details

The "Add Money" group quest requires the party to add at least 100 gold to their total. Viewing it in the Inspector we can see that it has one Quest Step, and one Quest Condition for success. The success is based on the Blackboard value/topic "Party" "Gold", which is an int. The Value Comparison is "Greater Than Or Equal To" and the Value is 100.

This is an example of a quest that is not present at the start, and can be repeated. In the demo scene, players must click the "Start Quest: Add 100 Gold" to obtain the quest. The current gold value is saved at that point.

After successfully completing the quest, the button can be clicked again to start the quest again, this time saving the new, higher gold value. This can be repeated indefinitely.

This Quest will not automatically succeed. Instead, the player must click the "Complete Gold Quest" button in the scene to "turn in" the quest, and only then will the conditions be checked. If the conditions are met, the Quest will be complete, otherwise, it will not.

The object Quest Demo has a script QuestDemoTurnInQuest.cs which handles the input from the UI Button "Complete Gold Quest". Perhaps your game requires players to talk to an NPC to turn in a quest, or perhaps the Quest is checked only when they try to enter a building, one which can not be entered unless the quest is complete.

How you implement the system is entirely up to you, and there are many, many ways to do so.

The "Add Money" demo quest will Subscribe to Blackboard, but will not Query Every Frame. The demo scene will submit the partys gold to the Blackboard with the Topic/Subject "Party" "Gold". When the required value is met, the QuestStep will be marked as Successful, but the GameQuest itself will not, because the Auto Succeed value is false.

Because the Can Revert option is true, if the value goes below 100, it will be marked "In Progress".

With Query Every Frame off, the QuestSteps can only be marked successful manually (via your custom code), or via Blackboard Note notifications. As Subscribe To Blackboard is true, this is how the QuestSteps know the gold value has been reached.

The custom demo script QuestDemoPartyStats.cs submits the updated gold to the blackboard in the AddGold() method:

blackboard.UpdateNote("Party", "Gold", Gold);

By default, a notification will be sent.

The custom script QuestDemoTurnInQuest.cs, when prompted, will first call the QuestStepTicks() method on the GameQuest, which makes each QuestStep check their status.

It then checks the status of the GameQuest itself. If the quest status is already set to Succeeded, then it means we've already run this process, and we should not complete the quest again. Otherwise, if quest.Complete == true, then we will call the quest.CompleteQuest() method, which runs the actions to occur when a quest is finally completed successfully.

QuestDemoTurnInQuest.cs
public void TurnInQuest(string uid)
{
    // Try to get the In Progress GameQuest of this uid
    if (!data.partyQuests.TryGetInProgress(uid, out GameQuest quest))
        return;
            
    // Run the Ticks on the QuestSteps, which may set it to Complete if all conditions are met
    quest.QuestStepTicks();

    if (quest.Complete)
    {
        Debug.Log($"QUEST {quest.objectName} COMPLETE!");
        quest.CompleteQuest();
        return;
    }
            
    Debug.Log($"Quest {quest.objectName} is not yet complete.");
}

Each QuestStep can only have one Condition that has Save start value marked true. This is because the value is saved in the Blackboard using the GameQuest gameUid and the QuestStep name.

If you need a quest to have multiple conditions of this kind, you can create multiple QuestSteps.

Not all Condition types have the option to save the current value. The BlackboardValueNumber condition does, as one example.

Last updated