[HOWTO] How To: Run a Conversation Only Once

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 20544
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Run a Conversation Only Once

Post by Tony Li »

In your dialogue database, define a variable:

convOnce1.png
convOnce1.png (7.29 KiB) Viewed 35802 times

This example uses a variable named "TalkedToNPC". In practice, you'll probably want to use a variable name that includes the character name, such as "Adam.Talked". The "." will group variables into submenus for tidier organization in dropdown menus. So you could have variables named "Adam.Talked", "Adam.Insulted", "Bob.Talked", etc.

(Alternatively you can define a custom field in the NPC actor.)


In the conversation, set the variable true:

convOnce2.png
convOnce2.png (24.2 KiB) Viewed 35802 times

Then configure your Dialogue System Trigger's Conditions > Lua Conditions to require that the variable is not true yet:

convOnce3.png
convOnce3.png (28.9 KiB) Viewed 35802 times
User avatar
Tony Li
Posts: 20544
Joined: Thu Jul 18, 2013 1:27 pm

Re: How To: Run a Conversation Only Once

Post by Tony Li »

If you want to run a different conversation the second time, here are some suggestions:

1. Add 2 Dialogue System Triggers to the NPC:
  • Set the Conditions on the first to require that Variable["TalkedToNPC"] ~= true. In this case, run the initial conversation.
  • Set the Conditions on the second to require that Variable["TalkedToNPC"] == true. In this case, run a different conversation.
2. Alternatively, you can forgo the variable check in the Dialogue System Trigger and always run one conversation. In this conversation, conditionally branch based on the value of a variable. If no branches' Conditions are currently true, the conversation will be skipped.

For example, in the conversation below the NPC will say "Hi! Nice to meet you." the first time the Dialogue System Trigger runs. The second time the Dialogue System Trigger runs, the NPC will say "Don't talk to me again.". If the Dialogue System Trigger is used after that, it will not start a conversation at all because neither nodes' conditions will be true.

countTimesTalked.png
countTimesTalked.png (16.28 KiB) Viewed 35793 times

Note: You can use cross-conversation links to link these branches to separate conversations. To create a cross-conversation link, inspect a dialogue entry node. In the "Links To:" section select "(Another Conversation)".
Post Reply