Mapping 104: Triggers and Target Entities

Now that you have a basic understanding of the system brushes, it's time to explain the inner guts of triggers and targets. Let's start with Triggers.

### Triggers

In mapping and level design for games, a "trigger" refers to a specific type of entity or object that, when interacted with or activated, triggers a predefined action or set of actions in the game world. Triggers are used to create dynamic and interactive elements within the game environment. Here are some common types of triggers:

1. Trigger Volume: A trigger volume is an invisible three-dimensional region within the game world. When a player or another object enters or exits this volume, a specific event is triggered. For example, entering a trigger volume might activate a door, spawn enemies, or trigger a scripted sequence.
2. Button or Switch: A physical or virtual button that, when activated, triggers a specific action. This action could be opening a door, lowering a bridge, or activating some other element in the game.
3. Event Trigger: Some triggers are tied to specific events in the game. For instance, completing a certain objective might trigger the appearance of a new enemy or the opening of a previously locked area.
4. Scripted Trigger: Triggers can be associated with scripts or sequences of actions that are executed when the trigger is activated. This allows level designers to create complex and dynamic events in response to player actions.
5. Teleportation Trigger: A trigger that, when activated, transports the player or an object to another location in the game world. This is often used to create teleportation systems or to move players between different areas of a map.
6. Sound or Music Trigger: Triggers can be used to control the playback of sound effects or music in response to certain events. For example, entering a specific area might trigger the playback of eerie music.

These are just a few examples, and the specific functionality of triggers can vary depending on the game engine and the preferences of the level designer. Triggers are essential tools for creating dynamic and engaging gameplay experiences by allowing designers to control the flow of the game based on player actions or other in-game events.

Triggers are brush objects that cause an effect when contacted by a living player, usually involving firing targets.

### Creating a Trigger

It's quite easy to create a trigger. To do so, simple create or select a brush and right click on it (or double right click if in camera view) and select one of the trigger types.

For this example, I have chosen trigger\_multiple. You'll notice how the brush shader is automatically changed to the green (player invisible) shader brush. Handy.

From there, press N to bring up your Entity Inspector.

This is where the fun begins. From here you add keys and values from what the entity description provides.

Generally speaking, there are infinite ways to use triggers in your mapping. I'll go over some basics with each commonly-used entity and link a few guides at the end of this post as well.

## Trigger\_Once and Trigger Multiple

These triggers get the most use in mapping, especially MBII which involves a lot of things changing around when you walk through certain triggers or hack certain triggers. If it wasn't obvious already, trigger\_once is a one-time use trigger and trigger\_multiple is something which can be used again more than once.

Let's go over some of most-used cases for these triggers.

#### Flags

* facing - Won't fire unless triggering entity's view angles are within 45 degrees of trigger's angles. This is useful used in combination with use\_botton
* use\_button - Won't fire unless player is in it and pressing use button. This is how you set-up hacking panels.
* fire\_button - Won't fire unless player/NPC is in it and pressing fire button. Keep it off and the trigger will fire simply by walking into it.
* npconly - Only non-player NPCs can trigger this by touch (this including vehicles / droidekas).
* inactive - Start off, has to be activated to be touchable/usable. You need something to fire at this trigger (by giving it a targetname and having something target it)
* multiple - Slightly confusing in name, but essentially by default triggers are fired by one entity. If this is checked, multiple entities can touch this trigger in a single frame and if needed, the trigger can have a wait of > 0. This basically allows a trigger to fire more than once in a single moment, if needed. Two people in this trigger would have it firing twice.

#### Keys & Values

* wait - Seconds between triggering, 0 default, number < 0 means one time only. *Generally speaking, you want to give most triggers a wait of some kind to avoid flooding or crashing issues*...
* random - Wait variance, default is 0.
* delay - How many seconds to wait to fire targets after tripped.
* hiderange - As long as NPC's head is in this trigger, NPCs out of this hiderange cannot see him. If you set an angle on the trigger, they're only hidden from enemies looking in that direction. The player's crouch viewheight is 36, his standing viewheight is 54. So a trigger that should hide you when crouched but not standing should be 48 tall.
* target2 - The trigger will fire this only when the trigger has been activated and subsequently 'cleared'( once any of the conditions on the trigger have not been satisfied). This will not fire the 'target' more than once until the 'target2' is fired (trigger field is 'cleared').
* speed - How many seconds to wait to fire the target2, default is 1.
* noise - Sound to play when the trigger fires (plays at activator's origin).
* NPC\_targetname - Only the NPC with this NPC\_targetname fires this trigger.
* team - If set, only this team can trip this trigger. NOTE: MBII and JKA have their teams swapped!
	+ 0 - any
	+ 1 - red
	+ 2 - blue

* soundSet - Ambient sound set to play when this trigger is activated, you can find the soundset names in MBAssets3.pk3/sounds directory
* **usetime** - If specified (in milliseconds) along with the USE\_BUTTON flag, will require a client to hold the use key for x amount of ms before firing.
	+ *I've highlighted and underlined this key because it's rather important to know how to activate the 'hacking' aspect to triggers.*
* 'script\_targetname' - Referred to by script as the recipient of set of instructions. Most entities can use this key. This is useful for when you get into scripting and you need to target your entity.
* MB2 Specific Keys & Values
* 'min\_players' / max\_players if TotalPlayers < min\_players or TotalPlayers > max\_players then the inactive is turned on for whatever this trigger targets. This essentially turns your trigger into a trigger\_disable, depending on the size of the server population.
* 'nopush' - How many seconds activator of trigger should be immune to force push and pull.
* 'doorTrigger' - Set to 1 to allow spectators to teleport to the other side of a closed door. Trigger must directly target func\_door and should exist on both sides of the door, the same as automatic door triggers.

#### Applicable only during Siege gametype (of which MBII is)

* teamuser - If 1, team 2 can't use this. If 2, team 1 can't use this. This is nearly identical to "team" key except it works for siege gametype only.
* siegetrig - If non-0, can only be activated by players carrying a misc\_siege\_item which is associated with this trigger by the item's goaltarget value.
* teambalance - If non-0, is 'owned' by the last team that activated. Can only be activated by the other team if the number of players on the other team inside the trigger outnumber the number of players on the owning team inside the trigger.
* target3 - Fire when activated by team1 (red in mbii, blue in jka)
* target4 - Fire when activated by team2 (blue in mbii, red in jka)
* idealclass - Can only be used by this class/these classes. You can specify use by multiple classes with the use of, e.g.: 'Imperial Medic|Imperial Assassin|Imperial Demolitionist'

## Trigger\_Always

A rather simple trigger compared to the others. Target this at whatever you want to fire at round start!

## Trigger\_Capture

This is an MBII-specific trigger which has a lot of powerful uses for objectives.

MBII maps have a few other entities which help with visual clarity for capturing. You do not need to use these in order to make the capture point work, but it is suggested you add a few entities, we'll use mb2\_dotf's setup as an example:

A trigger\_capture, trigger\_multiple, misc\_hologram and func\_usable and info\_siege\_objective are the main entities used for this to work.

Here is the breakdown of how things work:

The trigger\_capture targets the misc\_hologram which targets the final obj (info\_siege\_objective). The info\_siege\_objective is connected to the .siege file, objective 2 is the final objective and ends the round.

There is also a func\_usable (which has nodraw shader on every side except the outside, meaning you can walk through it) with the outside shader using mp/cq\_border). Purely visual, this is the blue/red capture shader.

There is also a trigger\_multiple which triggers either blue or red team target\_print.

## Trigger\_Hurt / Trigger\_Heal

These work as you would expect, generally speaking you can find out how to hurt or heal your players by experimenting with interacting!

## Trigger\_Push

Have this targeting an info\_null. If a player goes into this, it should yeet him towards that info\_null. Side note: you can use this inside water to create a slow forced push by checking the 'linear' flag. Nice way to force people down the river.

While almost everything could be done with a single trigger class and different targets, triggered effects could not be client side predicted (push and teleport).

## Trigger\_Teleport

Allows client side prediction of teleportation events. Must point at a target\_position or misc\_teleporter\_dest, which will be the teleport destination.

If the spectator flag is set, only spectators can use this teleport. Spectator teleporters are not normally placed in the editor, but are created automatically near doors to allow spectators to move through them.