Documentation menu

Build a multi-objective quest

Description: Run several objectives together and branch to different quest endings.

This tutorial continues Build a quest. It creates three objectives that the player can finish in any order. An accusation dialogue then selects a successful or failed ending.

Detective Rowan Hale investigates a death at Blackthorn Manor. The player must inspect the crime scene and recover a ledger. Questioning a witness provides the final lead before an accusation.

Tutorial project. Download the project to follow these steps. The archive also contains create_multi_objective_quest_final with the completed result.

The finished graph

Drag to pan, use the zoom buttons or scroll to zoom, and select Fit graph to see the whole graph.

The supporting dialogues are available in all three formats:

Dialogue PNG SVG Interactive viewer
Crime scene PNG SVG HTML
Accusation PNG SVG HTML
Witness reprimand PNG SVG HTML

The completed quest uses this flow:

Main flow
Quest
  -> Start Dialogue: At the Crime Scene
  -> Inspect the scene
  -> Recover the missing ledger
  -> Question the witness
  -> Gate: all three are complete
  -> Start Dialogue: Make an accusation
  -> Hub: who was accused?
       -> either suspect -> Complete Quest (Success)
       -> witness -> reprimand dialogue -> Complete Quest (Failure)

Parallel listener bodies
InspectedScene flag    -> Update "Inspect the scene"           -> Return
RecoveredLedger flag  -> Update "Recover the missing ledger"  -> Return
QuestionedWitness flag -> Update "Question the witness"        -> Return

Create the characters

Create five Character entities. Add a character explains the complete process. Enter these names, IDs, roles, and stock portraits:

Character External ID Role Stock portrait
Detective Rowan Hale DetectiveRowanHale Player character with Role set to Protagonist male-5.png
Lord Ambrose Blackthorn LordAmbroseBlackthorn Victim male-2.png
Ada Finch AdaFinch Witness female-2.png
Lady Beatrice Blackthorn LadyBeatriceBlackthorn Suspect female-6.png
Julian Blackthorn JulianBlackthorn Suspect male-7.png

The victim doesn't speak in this tutorial, but a character entity makes later expansion easier. The other characters act as dialogue speakers.

The portrait instructions explain how to import several stock images together. Assign the portraits from the table.

The murder mystery characters in the Entities tree

Create the quest and variables

In Quests & Dialogues, add a Quest named BlackthornMurder. Set its title to Murder at Blackthorn Manor and add a short description under Properties → Quest Info. Hide the graph tree and Properties while editing nodes. Narratyr supplies a Complete Quest node. Move it below the entry while building the main path, then reuse it for a successful ending.

Create four variables in the Variables view. Your game changes the first three when the player completes the related activity.

Name Type Default Changed when
BlackthornMurder_InspectedScene boolean false The player inspects the study
BlackthornMurder_RecoveredLedger boolean false The player recovers the ledger
BlackthornMurder_QuestionedWitness boolean false The player finishes questioning Ada
BlackthornMurder_Accused string empty The accusation dialogue records the choice

Game code writes the progress flags. The accusation dialogue writes BlackthornMurder_Accused, which the quest reads after the dialogue ends.

The progress flags and accusation result variable

Add the opening dialogue

Create a Dialogue named BlackthornCrimeScene with the title At the Crime Scene. Choose Dialogue Line to create a Dialogue Node for each speaker below:

Lady Beatrice

Lord Blackthorn lies here in the study. The room remains untouched.

Julian

His ledger is missing. Both heirs now look suspicious.

Connect Julian's line to the End Conversation node that Narratyr created with the graph. Return to BlackthornMurder and add a Start Dialogue after the Quest Node. Select the new node, select Choose Dialogue… in its toolbar, and select the entry of BlackthornCrimeScene. The quest resumes after the conversation ends.

The opening dialogue at the crime scene

Introduce the objectives

After the opening Start Dialogue node, choose Introduce Objective to add three Objective nodes in sequence. Each node introduces its task and immediately continues, so all tasks appear before the quest waits.

Select each objective and edit its inline fields with these values:

Name Type Fields
Inspect the scene Generic No additional fields
Recover the missing ledger Fetch Set itemTypeId to missing_ledger and count to 1
Question the witness TalkTo Set targetId to AdaFinch

Leave Optional and Hidden off. Type tells your game which behavior to monitor. Narratyr doesn't perform the activity. Use Generic for an activity without a matching Fetch, Kill, or TalkTo type.

Objectives for inspecting, fetching, and talking

Wait for all progress

Choose Wait for Condition (Gate) after the third Objective, then select Wait on Expression. Enter this condition:

(
  BlackthornMurder_InspectedScene
  and BlackthornMurder_RecoveredLedger
  and BlackthornMurder_QuestionedWitness
)

The Gate resumes only after all three values become true. The game can update them in any order. Introducing objectives in sequence doesn't require the player to complete them in sequence.

For a condition with several clauses, wrap the expression in parentheses and place each and or or clause on another line. This formatting keeps the Gate narrow and shows the grouping.

The Gate waiting for all progress flags

Update objectives from listeners

The Gate controls the main flow, but each objective should update as soon as its activity finishes. Use Listen for Event to add three Event Listener nodes away from the main path. To edit a listener’s name or description, select it and choose Properties in its node toolbar. The canvas popup works with the side panel hidden. Close it when you finish.

Select Expression in each listener's Wait on toolbar and enter its condition below.

Listener condition Update Objective target
BlackthornMurder_InspectedScene Inspect the scene
BlackthornMurder_RecoveredLedger Recover the missing ledger
BlackthornMurder_QuestionedWitness Question the witness

Connect each Event Listener to an Update Objective node. Keep Quest set to Current quest and select the matching Objective on the node. In the toolbar beneath it, select the Completed checkmark under Status. Choose Return from Flow to add a Return after each update.

Leave Async off because these short branches don't pause. Return resumes the flow that was active when the value changed.

An Event Listener runs when its condition changes from false to true. The matching objective completes immediately, while the main flow can remain at the Gate. Each listener runs independently, so the player can finish the tasks in any order.

Listeners update individual objectives, and one Gate checks overall progress.

Event Listener branches completing the objectives

Create the accusation dialogue

Add a Dialogue named BlackthornAccusation. Set Rowan Hale as the speaker and enter this opening line:

One of you killed Lord Blackthorn.

Choose Dialogue Line to add another Dialogue Node with Rowan as its speaker. Leave the line empty and add these choices:

  • Accuse Lady Beatrice.
  • Accuse Julian.
  • Accuse Ada, the witness.

The choices belong to the node for Rowan because the player selects the detective's words. Move the graph's existing End Conversation node to the right to leave space for the Instructions. Choose Execute Instruction to create an Instruction node for each choice, then connect all three Instructions to that ending. Name each Instruction after its choice and assign the matching value:

The accusation dialogue with three choices

BlackthornMurder_Accused = "LadyBeatrice"
BlackthornMurder_Accused = "Julian"
BlackthornMurder_Accused = "Ada"

When the dialogue ends, the quest resumes after its Start Dialogue node.

An accusation choice storing Ada in the result variable

Branch on the accusation

Return to BlackthornMurder. Add Start Dialogue after the Gate and select the entry of BlackthornAccusation. The quest pauses while the dialogue runs and continues after the player selects an accusation.

Choose Branch on Conditions to add a Hub Node after Start Dialogue. Create three outputs with these conditions:

BlackthornMurder_Accused == "LadyBeatrice"
BlackthornMurder_Accused == "Julian"
BlackthornMurder_Accused == "Ada"

The Hub immediately follows the output with a true condition. The Gate waited for progress, while the Hub selects from an existing result.

The quest starting the accusation dialogue and branching through a Hub

Add the endings

Use the Complete Quest node that Narratyr created with the quest for the Lady Beatrice output. Add another for Julian's output. Leave both endings set to Success. Either suspect produces a successful result for this tutorial.

For the Ada output, create a short Dialogue named WitnessReprimand. Start it from the Ada branch and add this line:

Lady Beatrice

Detective, Ada is the witness. Stop accusing the person who called for help.

Connect the final line to the dialogue's existing End Conversation node, then connect its quest branch to a Complete Quest node. Select Failure in its Status toolbar. Leave the End Quest and Return behavior buttons unselected to use the standalone quest default. Both suspect branches succeed, while the witness accusation fails after the reprimand.

Lady Beatrice reprimanding the detective

The successful suspect branches and failed witness branch

Arrange the completed graph

Use Auto Arrange on the quest. The main path should run from the objective introductions to the Gate and accusation dialogue. The Hub branches to two Success nodes and one reprimand that ends in Failure. Each Event Listener remains outside the main path and ends with Return.

If Narratyr warns that rearranging may change execution order, choose Arrange Anyway. These listeners update separate objectives, so their relative order doesn't affect this quest.

The arranged multi-objective quest

You can extend this pattern with another objective. Introduce the objective, add a listener that updates it, and add its condition to the final Gate. The listener maintains the objective state, while the Gate defines when the main flow continues.