Deus Ex - Logic Triggers

 

Download Tutorial File (9k Zip)

The tutorial file contains a map with showing an example use of LogicTriggers. A description of it is available at the bottom of this article.

 

LogicTrigger

Logic triggers appear to be much more complicated that they really are, provided you can understand a little bit of boolean logic. So I'll take it slow and start right at the beginning.
 

What is Boolean Logic

A boolean value is simple one which is either 1 or 0, on or off, yes or no or true or false (these are all basically different ways of saying the same thing)

Boolean logic is the maths of combining one or more boolean value and producing another boolean value as a result. For example a boolean operator such as AND is used to combine two boolean values, and depending on their values produces a boolean value output, in this case the output is always 0 unless the first AND second values are both 1, in which case the output is also 1.

Boolean operations are often simplified by refering to something called a "truth table" - this simple lists all the different combinations of inputs and whatever the output will be for those inputs. Since LogicTriggers use the OR, AND and XOR boolea operations I will list them here. Finally we have the NOT operation, which only takes 1 input and simply reverses it.

OR

The output is 1 if the first OR the second input is 1, otherwise it is 0.

Input 1 Input 2 Output
0 0 0
0 1 1
1 0 1
1 1 1

AND

The output is 1 if the first AND the second input is 1, otherwise it is 0.

Input 1 Input 2 Output
0 0 0
0 1 0
1 0 0
1 1 1

XOR

The output is 1 if the first AND the second input is 1 OR if the first AND second input is 0, otherwise it is 0. (you can read this as AND-OR if you like).

Input 1 Input 2 Output
0 0 1
0 1 0
1 0 0
1 1 1
NOT

The output is 1 if the input is 0, and the ouput is 0 if the input is 1.

Input Output
0 1
0 1
 

Back to the LogicTrigger

Hopefully this might go some way to telling you how the logic trigger works.

Give the LogicTrigger a Tag name, say 'LogTrigA', and an Event (the thing you want to be trigger if the condition is met).

Then create two other triggers which are going to trigger the LogicTrigger, Trig1 and Trig2. Edit the Group property (found under Object) of the Trig1 and set it to 'LogicGroup1'. Then edit the Group property of Trig2 and set it to 'LogicGroup2'. Set the Event property of both triggers to 'LogTrigA'

Now go back to the LogicTrigger. Set inGroup1 to 'LogicGroup1' and inGroup2 to 'LogicGroup2'. If you want this to be triggered only once then set OneShot to be true, otherwise false.

Back to that Boolean Logic stuff

The two main settings here are the Op property, and the Not property. These provide the the boolean logic for this trigger.

As an example lets say you choose the 'GATE_OR' property for Op and set Not to false. Trig1 and Trig2 are both off. Now someone triggers Trig1 and you look at the truth table above to see if LogicTrigA triggers. A 1 for Trig1 and a 0 for Trig2 gives a 1 output, so LogicTrigA triggers. Now Trig2 gets triggered, and again LogicTrigA triggers its event. Trig1 is triggered again, effectively turning it 'off', but Trig2 is still 'on' so LogicTrigA is triggered again. Finally Trig2 is triggered, turning itself off and this time we are back where we started, both Trig1 and Trig2 off so LogicTrigA doesn't trigger.

Basically each time you get a 1 on the output of the above table the event for LogicTrigA is triggered. If its a 0 nothing happens.

But where would I use this?

A very good question. Here is an example I've come up with.

A security forcefield needs two switches to be both switched in order to shut itself down. The LogicTrigger is set to GATE_AND and OneShot is set to true, i.e. once you've beaten the forcefield thats it.

The trick is that each trigger triggers a dispatcher, which triggers the LogicTrigger twice, with a time delay between them. The player has to run between the two switches and catch them both before the time run out. I've chosen this example to make into a map. The time delay is about 5 second, so let it fail a few times first.

Download Tutorial File (9k Zip)

I made the tutorial map a bit more complicated by including another LogicTrigger, this one however is triggered by two different triggers, only one of which has a valid group. It also has Not set to 'true'. This produces the following truth table effect.

Input 1
(Valid trigger)
Input 2
(Invalid Trigger)
Output
0 0 1
0 1 1
1 0 0
1 1 0

The real second input is always 0, so the output is simple the Not of the first input, but is checked every time the LogicTrigger is triggered. This has the effect of turning the 'failed - too slow' message off after you've successfully opened the forcefield.