CBaseTrigger

From Source Entities
(Redirected from Trigger)
Jump to navigation Jump to search

Code classes:

CBaseTrigger is a base class for all trigger entities. Usually triggers are tied to a brush that causes them to react in some way when another entity enters that volume.

Classnames:

Triggers may also be point entities that simply specify a volume with their Minimum Bounding Box Size (mins) and Maximum Bounding Box Size (maxs). Defining the volume this way is easier to do for entities that are created post-compile, but usually the method isn't sought by level designers because brushes are easier to manipulate.

Tip: Many projectile entities are coded to not activate triggers. If a trigger doesn't work, try detecting them with func_breakable and filter_activator_class!

Tip: Remember to set the spawnflags keyvalue when trying to use base trigger functions such as OnStartTouch on a trigger which doesn't show them in Hammer. They are there, and it's unlikely that they've been inhibited.

ConVars/Commands[edit | edit source]

ConVar/CommandParameters or default valueParameter TypeEffect
showtriggers00 disables, 1 enablesMakes brush triggers visible on spawn. Mins/maxs entities can use ent_bbox.
showtriggers_toggleMakes brush triggers invisible or visible instantly.

Flags[edit | edit source]

  • 1: Clients (players) may trigger. (Not in Asw.png.)
  • 2: NPCs may trigger.
  • 2: Asw.pngMarines and Aliens may trigger.
  • 8: Physics Objects may trigger.
  • 16: Only player ally NPCs - NPCs must be player allies to trigger. Sets NPCs automatically.
  • 16: Asw.pngOnly marines may trigger.
  • 32: Only clients in vehicles - Players must be in a vehicle to trigger. Sets Clients automatically. (Not in Asw.png.)
Bug: Seems like this only detects once? Observed on trigger_teleport.
  • 64: Everything (not including physics debris) may trigger.
  • 512: Only clients not in vehicles may trigger. Sets Clients automatically. (Not in Asw.png.)
  • 1024: Physics debris may trigger. Debris objects are usually small and not solid to players.
  • 2048: Only NPCs in vehicles - NPCs must be in a vehicle to trigger.
  • 4096: Css.pngDods.pngTf2.pngDisallow Bots from triggering.
  • 4096: Correctly account for object mass (trigger_push used to assume 100Kg) and multiple component physobjs (car, blob...) for trigger_push only. (available in all games since Asw.png)


Editors: 
Alien Swarm is able to detect players with the exact same flags used in HL2 because asw_marines actually are both player allies and npcs.

Keyvalues[edit | edit source]

Master (master) <target_destination>
Name of a multisource that will allow or disallow the trigger to fire depending on if the multisource has been Used. This is obsolete through multiple means in Source.
Filter Name (filtername) <filterclass>
A filter entity to test potential activators against.
Start Disabled (StartDisabled) <boolean>
Stay inactive until Enabled.

Inputs[edit | edit source]

TouchTest
For testing if something is currently touching the trigger. Fires either the OnTouching or OnNotTouching output.
StartTouch (Not in FGD)
Fires the OnStartTouch output.
EndTouch (Not in FGD)
Fires the OnEndTouch output.
DisableAndEndTouch  (only available in Hl2.pngHalf-Life 2: DeathmatchCss.pngDods.pngTf2.png)
Disables this trigger and acts as if all currently touching entities have stopped touching it immediately.
Enable
Makes the entity active.
Disable
Makes the entity inactive.
Toggle
If on, turn off. If off, turn on.

Outputs[edit | edit source]

OnStartTouch
Fired when a valid entity starts touching this trigger.
OnStartTouchAll
Fired when a valid entity starts touching this trigger, and no other entities are already touching it. If there are any other entities touching the trigger when a new one begins to touch, only OnStartTouch will fire.
OnEndTouch
Fired when a valid entity stops touching this trigger.
Warning: If the !activator of this output is a player who disconnected, any entity trying to see what the activator was can cause a crash.
OnEndTouchAll
Fired when all valid entities stop touching this trigger.
OnTouching
Fired if something is currently touching this trigger when sent TouchTest.
OnNotTouching
Fired if nothing is currently touching this trigger when sent TouchTest.