Difference between revisions of "Triggers"

From The DarkMod Wiki
Jump to navigationJump to search
Line 47: Line 47:

== trigger_sequencer ==
== trigger_sequencer ==
Needs to be activated by another trigger.  Fires target 0 when first triggered, target 1 when next triggered, etc.  Can repeat the sequence after triggering the last target if desired.
Needs to be activated by another trigger.  Fires target 0 when first triggered, target 1 when next triggered, target 2 when next triggered etc.  Can repeat the sequence after triggering the last target if desired.

== trigger_random ==
== trigger_random ==

Revision as of 14:03, 13 August 2018

There are many different ways of triggering entities, the Trigger entities themselves, as well as through Stim/Response, Conversations, Movers, Objectives, and more. How the trigger occurs will typically dictate which manner you choose for your map.


To create triggers that rely on boundaries (once, multiple and their derivations), you need to drag out a worldspawn brush, right-click, select "Create Entity". (They will not function if abutted against others.) Triggers need to be connected to their subjects, either via "Connect Selected Entities" menu option/shortcut key, or adding "Target", "Target0", "Target1" or subsequent "Target"# spawnargs. Triggers without targets (to be added via a target_changetarget entity later) won't exist, so need a dummy target. The triggers below are listed roughly by frequency of usage, with related triggers beneath.


When the origin of an entity is within the bounds of this entity, the target(s) will be triggered, then the trigger_once is removed. (Note, to resize the brush after creating the entity, select it then press Tab once.)


Similar to trigger_once, but may be set to only respond to the entity specified by the spawnarg, "entityname". Note the entity must move into the boundaries itself, not be moved by the player (AI walking themselves for example). (If you want something to happen based on the player dropping or placing an item somewhere, use the Objectives system instead.)


Similar to trigger_once but will activate again and again, use "Wait" spawnarg to control how many seconds between triggerings.


Similar to trigger_multiple but only reacts to the entity defined by the "entityname" spawnarg.


Also similar to trigger_multiple, but requires the triggering entity to be within 30° of the specified "angle" spawnarg. For details see Trigger Facing.


Most commonly used to trigger many targets, or do so after a delay (per the "delay" spawnarg). May be set to only work once (spawnarg "wait" "-1") or limit firing based upon how many seconds have passed. The "random" spawnarg may be used with "wait" to vary the firings. Very useful as the target of worldspawn, to trigger things at map start (since worldspawn currently only activate one "Target"), or as the target of Objectives.


This will fire at it's targets upon a specific number of times being triggered itself, based upon the "count" spawnarg. If "count" "3" is set, it will do nothing until the third triggering. Set "repeat" to "1" if it should do it again and again instead of just once.


This trigger will fire repeatedly every "wait" # seconds. The spawnarg "start_on" defines if it should do so at the start of the map, or wait to be triggered (defaults to 0, off at map start). Spawnarg "random" adds variability to the triggerings.


Will cause the display to fade or dissolve to a specified color. The spawnarg "fadeColor" specifies which color, and how transparent in RGBA (red, green, blue, and alpha, ranging from 0-1). Default is fade to black: "fadeColor" "0 0 0 1". To fade up from whatever, use alpha of 0, IE to fade up from black, "0 0 0 0". "fadeTime" controls how quickly the fade transpires.


Applied to a worldspawn brush to define boundaries à la a trigger_multiple, by default it causes 10 points of damage/second to the activator (player or AI). It may be triggered on/off. The spawnarg, "delay" may be set to vary frequency of damage application. One of various "def_damage" may be specified, generally found in the root directory of the entities, or to see specific details, in the defs file, "damage.def". Note those referencing "triggerhurt" simply cause damage, while others feature additional effects such as push and knockbacks (launching the player away).

If you need varying amount of damage based on proximity, the Stim/Response system offers control of various types of falloff.

trigger_hurt entities do not need a target. They will damage the player or AI if either enters its bounds. It apparently does not hurt AI if the trigger_hurt is moved into a stationary AI.

trigger_hurt entities can be turned on/off by other triggers.


Akin to trigger_multiple without the need of creating a brush first, and defaults to not being touched by players/AIs, but triggered by other entities/script.


Continuously checks if entities are touching, costly performance wise, probably done via Objectives more efficiently.


Needs to be activated by another trigger. Fires target 0 when first triggered, target 1 when next triggered, target 2 when next triggered etc. Can repeat the sequence after triggering the last target if desired.


When triggered, triggers one of its targets randomly with evenly weighted probability.


Once triggered, activates its targets if <delay> seconds pass in which it is NOT triggered again. You can use this for e.g. the kind of alarm system seen in Calendra's Cistern and one or two other Thief FMs, where a guard presses a button as part of his patrol route, and an alarm goes off if a certain length of time passes without the button being pressed.

Triggering via Path Nodes

Several path nodes will trigger their targets upon AI completing the associated node action (as of TDM v2.02). These include, path_corner (upon reaching), path_turn, path_wait, path_sit, path_sleep and path_anim.

Triggering Stim/Response

To Trigger Something Else:

Any Response type may have an effect of "Trigger", in which another entity selected is triggered. Note the "Trigger" effect is all the way at the bottom of the drop down, which might not be displayed on screen (Toggle Effect is the last displayed on mine), you may cursor down or use the End key to get to Trigger.

Be Triggered:

Within the Stim/Response editor, add a response stim set to "Trigger", now when this entity is targeted, whatever specified effect will occur.

An example would be to not have something able to be frobbed until something obscuring it is removed or opened. Make the response effect "Set Frobable" for the entity in question, and check "frobability" on. Now when the item is triggered, by a door, or frob response on something in front moved/picked up, it will become frobable.

Triggering via Conversation

The command, ActivateTarget will trigger the specified entity at that time in the Conversation script.

Triggering via Doors, Buttons, Levers, Movers

Doors trigger their targets by default upon opening (spawnarg "trigger_on_open" "1"). They may also trigger when completely open by changing "trigger_when_opened" to 1 instead of the default 0, or when fully closed via "trigger_on_close". Note, those conditions on Buttons came from doors, so are counter-intuitive.

Triggering via Objectives

In the Objectives Editor you may select an entity to be triggered upon an objective succeeding or failing. Therefore all the possible objective conditions may become trigger events (knock out an AI, move an object away from another or to a spot, cause another objective to become visible, disappear or complete, etc.)

Triggering via Worldspawn

You may set "Target" on Worldspawn (usually at a trigger_relay since it only may target one entity currently) to cause things to be triggered at map start. If you use this to kill an AI or other affect with audio, note if in range of the player's start, it will be heard during the fade up from black.

Triggering via Lights

Lights trigger their target(s) both upon being extinguished and lit. This is useful to match window glow to actual light condition. Depending on the light, it may be tricky to set the targets however. A basic light entity can simply have target(s) spawnargs, but a candle, lamp or torch with attached flame entity, you need to use the "set" spawnarg. For example, "set target0 on flame" "EntityToBeTriggered".

Trigger a Script

Point any trigger at a target_callscriptfunction entity and give it the spawnarg, "call" ScriptFunctionName, where ScriptFunctionName matches "void ScriptFunctionName()" in the map's .script file. See script invocation for more info.