Tutorials

Introduction


How to create triggers


Each entity that has a targetname key can be triggered, unlocked or inhibited using a button, a trigger or an event. Basically, all you need to do is link the target key of a trigger entity to the targetname of another entity. Here's a list of entities you can use as a trigger. Note that even trigger entities can be locked/unlocked/offline/online using another activator. Note: all triggers (entities calling the G_UseTargets function) can also use the "killtarget" key value pair, which deletes an entity.
Classname, Key name, Trigger condition(s)
cast_bitch deathtarget On death
cast_dog deathtarget On death
cast_punk deathtarget On death
cast_runt deathtarget On death
cast_shorty deathtarget On death
cast_thug deathtarget On death
cast_whore deathtarget On death
func_explosive target On death
func_button target When activated by the player
func_door target When fully opened
func_door_rotating target When fully opened
func_door_secret target When fully opened
item_# target When picked up
key_# target When picked up
ammo_# target When picked up
weapon_# target When picked up
hmg_mod_cooling target When picked up
pistol_mod_damage target When picked up
pistol_mod_reload target When picked up
pistol_mod_rof target When picked up
target_explosion target When triggered
func_timer target Every wait seconds
trigger_always target Always
trigger_counter target When triggered count times
trigger_relay target After delay seconds, must be triggered
trigger_key target If the player has the correct key, must be triggered
trigger_multiple target When a living entity touches it or when triggered
trigger_once target When a living entity touches it or when triggered, works once only
trigger_motorcycle target In Skidrow only (worldspawn Episode number set to 1), this trigger will activate its target if the player has the Battery and touches the trigger_motorcycle brush (every props_motorcycle entity is removed from the map). If the player doesn't own the Battery, the EP_SKIDROW_FOUND_BIKE flag is registered.


Let's get started with the easiest example: a func_button triggering a func_door, then let's have some fun using other ways than the func_button to make that door open.

Test 1. Let's make a simple brush, tie it to a func_button entity. Open the proprieties box and let's set the key value pair "target" "door1". Now, create a new brush and tie it to a func_door entity. Open the proprieties box and let's set the key value pair "targetname" "door1". We're done, let's compile and test. When the func_button is activated by the player, the door opens. That was easy. Let's try something else!

Test 2. Remove the func_button entity and add a cast_bitch entity to the map, open the proprieties box and set her key value pair "deathtarget" "door1". You may also wish to set her key value pair "health" "10" and add a gun nearby. Let's compile again and test. She's barely stone cold dead that the door opens. I'm sure you got the point by now, but let's try a few more things.

Test 3. Remove the cast_bitch entity and create a func_timer entity. Open the proprieties box and set the key value pair "target" "door1", "wait" "3" and don't forget to set "spawnflag" 1 (START_ON). Compile and test. Now, the doors activate every 3 seconds!

Test 4. Edit the proprities for func_timer and set the key value pair "targetname" "timer1". Now, create a button like we did the very first time but set its key value pair "target" "timer1". Compile and test. Now, you can toggle the auto-3 second delay between each activation of the doors, with the button.

Test 5. You may try to make an offline trigger_once. Create a brush big enough for the player to go through, tie it to a trigger_once entity. Open the proprieties box and set the key value pair "target" "door1", "targetname" "trigger1" and set "spawnflag" 4 (TRIGGERED). Now, create a button like in the first example and set key value pair "target" "trigger1". Now, in order to trigger the door by walking through the trigger_once, the player must first turn the switch on.

Test 6. Now, let's try this: two buttons, one door. First, create both buttons, set their key value pair "target" "counter" and "wait" "-1". Now, create a brush and tie it to a trigger_counter entity. Open the proprieties box and set its key value pair "targetname" "counter", "target" "door1", "counter" "2" and set its "spawnflags" 1. When a button is activated, the trigger_counter counter's increase by one, when the counter equals the "counter" key value, the target is triggered.

Download the example map (includes an overkill example of triggers).

How to create cutscenes


A cutscene is made of one or more sequences lasting a definite time. Each "camera" will represent a single sequence. Cameras can only travel using constants so it's not possible to move them around using waypoints like you would with a NPC.

The fade-in (black to picture) and fade-out (picture to black) features are rather tricky to use. Set the "duration" key on misc_use_cutscene to define how much seconds the fade-in process will take (important: the fade-in ALWAYS occurs on map load, even if the misc_use_cutscene is not triggered yet), you MUST use the fade-in feature if you used a fade-out before. The fade-out feature works just the same: use the "duration" key on misc_cutscene_camera to define the fade-out time. It may be called only when a new map is loaded at the end of the cutscene because the screen stays black even when the controls are given back to the player (and the fade-in can only be done on map load).

Two more things: "cameravel", "cameravelrel" and "rotate" values defines the maximum velocity, not the actual velocity. It means that the camera will NOT move if you forget to set an acceleration value with the "accel" key and a move time with the "reactdelay" key. Also, the player WILL suffer any radius damage the cameras takes, so be very careful.

Here's a list of all key value pairs available for the misc_cutscene_camera entity.
Key, Usage
targetname This camera's ID
target ID of the camera to trigger after wait seconds. If none, the cutscene is over
cameraorigin By default, the camera is located where the misc_cutscene_camera entity is. However, you can override the origin of the camera with this key, using a vector (X Y Z). Note that if parent misc_use_cutscene entity for this cutscene's "debug" value is "1", the final origin of current camera is displayed in-game.
cameraangle Absolute angles for the camera when first triggered (like "angle" but with extra X and Y orientations). X Y Z vector.
rotate X Y Z maximal rotational velocity, this value depends on "accel" and "decel".
target2 ID of the entity to point to (overrides angles)
cameravel [forward] [right] [up] speed to move from initial angle
cameravelrel [forward] [right] [up] speed to move relative to current frame angle
wait Time before switching to next camera in seconds (default=5)
accel Acceleration rate when starting to move
decel Deceleration rate when approaching the end of "reactdelay"
delay Delay before starting to move ("decel" and "accel" must be set)
reactdelay Moving time ("accel" must be set, if there's no "decel", the camera will never stop moving)
duration Fade out time in seconds, this event is triggered after "delay"+"reactdelay" seconds (the camera has stopped moving and/or when the camera wait delay is over).
name Sound to play when triggered (.wav)
sight_target Talking actor (if "name" is set)
deadticks Field of view of this camera (default=90)
scriptname Script name to trigger when starting the camera (see "Scripts names")
count Usage unknown, leave it alone


First, you need to create a trigger (see "How to create triggers" tutorial), this will allow you to trigger a misc_use_cutscene entity and special events if you want (like speeches, moving characters, exit level and such). Link the misc_use_cutscene to your first misc_cutscene_camera (the first sequence). The most important key value pair is "wait", which defines the duration (in seconds) of the sequence. Once the sequence is over, the misc_cutscene_camera will trigger another misc_cutscene_camera defined in the key value pair "target". When there is no more camera, the cutscene is over and the player can move again.

Download the example map.