top of page

How To: Have an NPC act conditionally

  • tr3lon1st
  • 2. Aug. 2016
  • 4 Min. Lesezeit

The basic setup of an NPC acting a certain way is pretty simple. We place the NPC, the Story Node and create an event that allows the NPC to act whatever it was we set up on the Story Node. But sometimes things are more complicated than that.

Today, we will look at an NPC offering an action based on certain conditions.

Since this tutorial will include a lot of different possibilities, it will be a little more abstract than other Linking & Triggering tutorials already are. So hang in there!

In this case, I will describe the setup that will have an NPC say something on a regular basis, something else when A happens and again something different when B happens. An extension at the end will cover the mutual exclusivity of A and B. For this setup you need:

The NPC and both events are depicted as neutral events, since they can be replaced with practically anything that makes sense. For example, a torch could light up a blue fire emitter when event A occurs and a red fire emitter when event B occurs. In any case, the event requires two statuses to work. A book for example will not work, since the only event it offers is to click it. A torch or a door on the other hand have at least 2 statuses, lit and extinguished or open and closed.

 

First we set up what the NPC says on a regular basis. We start with the NPC, Logic Filter 1 and Story Node 1. This requires 3 links:

Links 1-3 (NPC) When a Luminary clicks this creature, turn on the blue light. (Logic Filter 1) (Logic Filter 1) When both lights turn on, activate the text on this node. (Story Node 1)

(Story Node 1) When the text on this node activates, have this creature say the text. (NPC)

This setup will not work until the very end of this tutorial. So stick to it. However, if it did work already, this setup would be a one-time trigger. We therefore need to implement a timer that will set back the Logic Filter, so clicking the NPC will trigger it again. Make sure the Timer Filter is set to 1 second only! The Timer Filter is required to make the NPC's triggering a text repeatable. It takes 5 links to set this up:

Links 4-5 (Logic Filter 1) When the blue light turns on, start this timer. (Timer Filter 1) (Timer Filter 1) When this timer completes, turn off the blue light. (Logic Filter 1)

The following sets of links will set up events A and B. They are equal in their setup. We will use the next Timer Filter here, so make sure this one is also set to just 1 second! For event A we require 5 more links:

Links 6-10

(NPC) When a Luminary clicks this creature, turn on the blue light. (Logic Filter 2) (Logic Filter 2) When both lights turn on, activate the text on this node. (Story Node 2)

(Story Node 2) When the text on this node activates, have this creature say the text. (NPC)

(Logic Filter 2) When the blue light turns on, start this timer. (Timer Filter 2) (Timer Filter 2) When this timer completes, turn off the blue light. (Logic Filter 2)

Now we add event A to the setup:

Links 11-12

(Event A) When event A enters status 1, turn on the yellow light. (Logic Filter 2) (Event A) When event A enters status 2, turn off the yellow light. (Logic Filter 2)

Event B is set up the very same way and requires 5 more links:

Links 13-17

(NPC) When a Luminary clicks this creature, turn on the blue light. (Logic Filter 3) (Logic Filter 3) When both lights turn on, activate the text on this node. (Story Node 3)

(Story Node 3) When the text on this node activates, have this creature say the text. (NPC)

(Logic Filter 3) When the blue light turns on, start this timer. (Timer Filter 3) (Timer Filter 3) When this timer completes, turn off the blue light. (Logic Filter 3)

Now we add event B to the setup:

Links 18-19

(Event B) When event B enters status 1, turn on the yellow light. (Logic Filter 3) (Event B) When event B enters status 2, turn off the yellow light. (Logic Filter 3)

This setup allows four things to happen:

1. No event triggers the NPC to trigger Story Node 1 2. Event A triggers the NPC to trigger Story Node 2

3. Event B triggers the NPC to trigger Story Node 3 4. Event A & B trigger the NPC to trigger Story Node 2 & 3

The goal is to not allow the NPC to say the text of Story Node 1, if 2 or 3 or both are active. For that we require a 4th Logic Filter set up with the following 6 links:

Links 20-25

(Logic Filter 2) When the yellow light turns off, turn on the blue light. (Logic Filter 4) (Logic Filter 2) When the yellow light turns on, turn off the blue light. (Logic Filter 4)

(Logic Filter 3) When the yellow light turns off, turn on the yellow light. (Logic Filter 4) (Logic Filter 3) When the yellow light turns on, turn off the yellow light. (Logic Filter 4)

(Logic Filter 4) When either light turns off, turn off the yellow light. (Logic Filter 1) (Logic Filter 4) When both lights turns on, turn on the yellow light. (Logic Filter 1)

The final thing that requires this setup to work, is to turn on the yellow light on Logic Filter 1 by default. We need to attach a switch to Logic Filter 1:

Special Link 26

(switch) When the switch turns on or off, turn on the yellow light. (Logic Filter 1)

Make sure that the yellow light of Logic Filter 1 is turned on, when the game goes into Play Mode! The switch can be deleted afterwards.

 

The simple addition of 2 more links can make events A and B mutually exclusive. Simply make sure that when the yellow light of Logic Filter 2 is on that event B is turned off and the other way around:

Links 27-28

(Logic Filter 2) When the yellow light turns on, enter status 2 on event B. (Event B) (Logic Filter 3) When the yellow light turns on, enter status 2 on event A. (Event A)

The TR3TORIALS project provides a collection of tutorials by various authors for the social building game Landmark by Daybreak Games.

© 2016 by TR3LON1ST

bottom of page