Trigger Tutorials

Trigger Tutorials

In these tutorials I delve into the intricacies of triggering. There are still dark corners here, for example I tend to get have trouble getting lights to turn on and off properly, but anyway here we go.

Basic trigger_once, trigger_multiple

Reference pages: trigger_once, trigger_multiple

These triggers let you perform basic tasks such as springing an ambush as the player walks down a corridor, or waking up and orienting monsters to the approach of the player. They have a number of fields in common with doors and buttons, so what you already know about doors will be helpful, and the buttons reference page should be easy reading when you've worked through this.

To begin with, both the trigger_once and the trigger_multiple own a brush (or brushes), and they fire (trigger their targets) when a player or monster touches one of these brushes. The difference between them is the that trigger_once removes itself from the map after firing, whereas the trigger_multiple stays behind to fire again. They use the same code, so have the same fields and spawnflags. The one difference is that a trigger_multiple should have a wait field telling it how long to wait before firing again if the entity touching it and causing it to fire is still in contact (by default, it re-fires after .2 seconds, which wastes cycles and can produce bizarre-looking effects).

Some simple fields these triggers have are message, whose value is the message number of a message to be displayed when the trigger fires, soundtype (three numerical values, see the reference page), and the puzzle-fields puzzle_piece1...3, and no_puzzle_msg, which work the same way as they do with doors. And, of course, killtarget (which seems to work with any entity that can trigger another).

A more notable one is delay, whose value is the interval (secs) between when the trigger is triggered, and when it actually fires (this is probably not so useful for these triggers, but is very useful for trigger_relay, which we'll be getting to shortly).

There are also two simple spawnflags, 2 - MONSTERTOUCH, which is supposed to cause the trigger to be fired only by monsters, and 16 - REMOVEPP, which works just like with doors.

So for excercises you can try to produce a monster that is woken up by a trigger_once, or a door that is open when the player walks through a certain part of a corridor.

In Siege

In Siege, there some additional possibilities. In the first place, only trigger_multiple actually occurs in siege.bsp, although trigger_once seems to work. One addition is that the text of messages can be direction specified in the netname field of a trigger_multiple, so that you can provide new messages without using a strings.txt file (this works for trigger_once also, but I don't know about other triggering entities that take message fields).

Two additional new fields are siege_team, with values 1 for defender and 2 for attacker, and impulse, with value 33. A siege_team-value makes the trigger operable only by a member of the specified team. This could be used in to make a door that could be opened only by members of one team or the other (but maybe bashed down by members of either team). In impulse 33 field makes a trigger that doesn't fire until it `used' by the player (the key, in the default setup). This interacts properly with siege_team, making a more secure team-specific door.

Relays

trigger_relays add a lot of flexibility to triggering, and can be used to `script' complex events (but a real scripting language is better, say the Raven designers who are using the one that Rick Johnson has developed for Heretic 2 and Soldier of Fortune). The idea of a trigger_relay is that it fires its targets when it is itself triggered. So the fields that a trigger_relay needs are target and target. A delay field can be used to arrange sequences of events separated by suitably portentious intervals. For example one event might trigger a sound (sound_maker), and also a trigger_relay with a delay-value of 3, which would target a door. So first the sound will be generated, then, three seconds later, the door will open.

In addition to these trigger_relays occur in the maps with a number of fields whose function is unclear, as detailed on the reference page (these might be leftovers from earlier versions of the entity system).


Return to the Tutorials.