Skip to content

Branch a conversation

Designer · 40 min · No code

Result: an NPC who says different things depending on the state of the game: whether a quest has been done, how strong the party is, and what the party carries. The conversation is a chain of nodes you can put anything between.

Before you start

Conditions, not player choices

XenoCore dialogue branches on game state. It has no node for the player picking a reply from a list. A yes/no answer is available only through a quest offer (Accept or Decline), or through your own widget between two lines.

The nodes

Right-click in the graph and search by name. They live under XenoCore › Dialogue, XenoCore › Quest and XenoCore › NPC in the node menu.

Node What it does Pins
Show Dialogue Shows one line and waits for the player to press A Speaker, Line, Source in; Advanced fires on the press. Does not close the box.
Play Dialogue Plays a whole list of lines, then closes the box Lines in; Completed fires after the box closes
Close Dialogue Takes the box down and gives the player back movement and camera No target pin. Does nothing if no conversation is open, so it is safe at the end of every branch.
Offer Quest Shows the quest panel and waits for an answer Quest, Giver in; Accepted or Declined fires, never both
Get Party Quests The party's quest record Use it to ask about quests
Get Lines For (XenoCore › NPC) One of this NPC's authored line lists Which: Greeting, Accepted, Declined, In Progress, Turn In

Show Dialogue, Play Dialogue and Offer Quest are latent: the graph pauses on them and carries on from an output pin later. Chain the next node from that output pin, never from the plain exec pin beside it.

Steps

1. Make an NPC Blueprint of your own

Branching needs a graph, so this NPC gets its own Blueprint.

  1. Right-click Characters/NPC/B_XenoCore_Npc and choose Create Child Blueprint Class. Name it B_MyGame_Npc_Elder and move it to MyGame/NPCs.
  2. Open it. In Class Defaults, set Display Name. Quest is empty and Has Quest is off already: the base Blueprint starts blank.
  3. In the Event Graph, right-click, search for On Interact (XenoCore › NPC) and add it.

Adding the event in the child replaces the parent's default graph for this NPC. To keep the parent's behaviour for some cases, right-click the event and choose Add call to parent function.

The parent's graph is also where a shop opens and where Member To Recruit joins the party. If your elder should recruit someone, call Try Recruit (XenoCore › NPC › Recruit) at the end of the branch that should do it; it does nothing on an NPC with no member set. Talk-to objectives still count without it: they are counted before the graph runs.

2. Branch on a quest

This elder thanks the party once a quest is done. Use any quest asset, for example Quests/DA_XenoCore_Quest_Monster01.

  1. From On Interact, add Get Party Quests, then from its result Get Status, with Quest set to the quest asset.
  2. Add Switch on EXenoCoreQuestStatus on the result.
  3. From Complete: Show Dialogue (You cleared the storehouse. Thank you.), then from its Advanced pin, Close Dialogue.
  4. From every other output: Show Dialogue (The storehouse is still overrun...), then from its Advanced pin, Close Dialogue.

The quest status is saved with the game, so this branch survives a save and reload.

Status Meaning
Unknown Never offered or never answered
Declined Turned down; can still be offered
Active Accepted, objectives outstanding
Ready To Turn In Every objective met
Complete Handed in and paid

3. Branch on the party

Other things worth asking, all pure nodes:

Question Node Category
Does the party carry an item? Get Party Item Count (Item Def) > 0 XenoCore › Inventory
Is a quest offerable right now (gates met, never answered)? Is Offerable XenoCore › Quest
Is a quest ready to hand in? Is Ready To Turn In XenoCore › Quest

Each drives a Branch into different Show Dialogue chains.

4. Do something between two lines

Because the conversation is an ordinary graph, you can put any node between two Show Dialogue nodes: give an item (Add Item To Party), take one (Remove Item From Party), offer a quest, open a shop, play a sound. For example:

  1. Show Dialogue (Take this. It was my father's.)
  2. From Advanced: Add Item To Party, Item Def your item.
  3. Show Dialogue (Look after it.) → Close Dialogue.

To stop the NPC handing it over twice, branch on Get Party Item Count first.

A pause longer than 2 seconds closes the box

Between two lines nothing is waiting for the player, so a conversation left open for more than 2 seconds with no line on screen is treated as abandoned and closed (see If it doesn't work below). A Delay of 3 seconds between two Show Dialogue nodes therefore closes the box, and the next line opens it again: a visible blink, with a warning in the log. Keep pauses under 2 seconds. A quest, trade or shop panel open between two lines does not count; the timer waits for it.

Fails silently: variables on the NPC are not saved

A boolean you add to the NPC Blueprint ("already gave the gift") resets when the map reloads or a save is loaded. Branch on something the game saves: quest status, or what the party carries.

5. Place it

  1. Compile and Save the Blueprint.
  2. Drag B_MyGame_Npc_Elder from the Content Browser into your map.
  3. Save the level.

Test it

  1. Press Play, walk up to the elder and press A (keyboard E) to talk. You get the "still overrun" branch.
  2. Complete the quest your Switch reads (or, for a quick test, use a quest you can finish fast).
  3. Talk to the elder again. You get the thank-you branch.

If it doesn't work

The box closes by itself after 2 seconds, with a warning

Show Dialogue leaves the box up by design, so every branch must end in Close Dialogue (or be a Play Dialogue, which closes itself). A branch that simply stops is caught: after 2 seconds the box closes and the Output Log shows a LogXenoDialogue warning naming the NPC, "...was left open with no line waiting - closing it. End every chain of Show Dialogue nodes in its On Interact with Close Dialogue." Find the branch that ends without it and add the node.

Fails silently: the conversation stops after the first line

The next node is wired to the plain exec output of Show Dialogue instead of Advanced. The plain output fires immediately, before the player presses anything.

The parent's quest behaviour still runs

You called the parent function, or the child has no On Interact of its own. Check the graph.

Fails silently: the gift is handed over every time

A variable on the NPC is not saved (see step 4). Branch on Get Party Item Count or a quest's status instead.

Going further