Scene Triggers

From Valve Developer Community
Jump to: navigation, search

Prerequisites


Introduction

Scenes are able to fire map triggers for AI entities. To do this, a Valve Choreography Data (.vcd) file will work in conjunction with outputs on a logic_choreographed_scene entity to arrange inputs on AI entities. In this article, fire trigger events will be used in two examples. In Example #1, an AI entity will fire an input on itself. In Example #2, an AI entity will fire an input on a non-AI entity.

Warning.pngWarning:For the purposes of this article, do not use quotes or periods in any of the fields to be filled.

Overview for Example #1

  • Create a scene with a fire trigger event for a npc_strider actor
  • Create a map with a simple room, a trigger brush, and configured entities
  • Compile and play the map


Scenario for Example #1

A Strider will break itself to pieces. This level will involve an info_player_start and a npc_strider. A trigger_once brush will be placed on the spawn zone, and will trigger two entities: ai_relationship and logic_choreographed_scene. The ai_relationship will change the disposition of the strider to be neutral to the player, and the logic_choreographed_scene will involve the npc_strider to fire its Break input on itself.

Creating the Strider Scene

Make a new scene named “BreakStrider" with one actor, named Strider (!Target# names can also be used. See the Choreography Implementation article for more details.) Create a channel under Strider named “FireTrigger", and create a "Fire Trigger" event. In the event’s properties, put “Breaker" in the name field, select “1" from the scene trigger field’s drop-down menu, and put “0" in the absolute start time field. Hit OK afterwards. (This tells the game that the fire trigger event will occur immediately after the scene starts and will only be used by the actor Strider.) Save the scene.

The scene with properties for a fire trigger event.


Creating the Strider Map

Make a new map named “StriderBreak". Create a 832 x 832 x 832 unit block, and hollow out the walls by -32 units. Next, place an info_player_start entity in an acceptable spot, preferably near one of the walls and centered. Set the angle to the opposite of the wall, to give the player a good view of the room. After that, place a npc_strider entity in the map far enough from the info_player_start so that the player will be able to see most of the strider from a distance.

The view of the npc_strider from the info_player_start.

(The teal box is the npc_strider.)


Name the strider “Strider" (The same name as the actor.) Since Striders are naturally hostile to the player, the disposition of the Strider will need to be changed. Place an ai_relationship entity in the map. Name it “Neutral", choose “Strider" as the subject, put “!player" as the target, set the disposition as “Neutral", and fill in “100" for the disposition priority. Close the property box.


Next, place a logic_choreographed_scene entity in the map. Name it “BreakScene", and browse for the .vcd file previously created for the scene file field. Set target 1 as “Strider". Add the following output:


My output named: OnTrigger1

Target entities named: Strider

Via this input: Break


(This tells the game that when scene trigger “1" in the .vcd file is reached, the entity named “Strider" will use the Break input specified in npc_strider. OnTrigger# corresponds with the value in the Scene Trigger field; OnTrigger4 will only be started by a fire trigger event with a scene trigger value of 4, for example.)


Finally, the ai_relationship and logic_choreographed_scene entities must be triggered themselves. A trigger brush will be placed on the info_player_start so that the triggering will occur as the map starts. Create a brush on the info_player_start, and tie it to a trigger_once entity. Add the following outputs to the brush:


My output named: OnTrigger

Target entities named: Neutral

Via this input: ApplyRelationship


My output named: OnTrigger

Target entities named: BreakScene

Via this input: Start

After a delay in seconds of: 1


Outputs for the trigger brush


Push F9 for Run Map window. Run BSP, VIS, and RAD on normal, and push OK to compile the map. Run HL2 afterwards, and load the map. The scene will play and produce the expected results.

This ends Example #1.

Overview for Example #2

  • Create a scene with an NPC firing a trigger to open a door
  • Create a room with a prop_door_rotating, a npc_breen, and other required entities
  • Compile and play the map


Scenario for Example #2

A NPC will walk to a door, temporarily wait, and open the door. This level will involve a info_player_start, a trigger_once brush, a logic_choreographed_scene, a npc_breen, a prop_door_rotating, and an info_target. As the player spawns, the trigger_once brush will start the logic_choreographed_scene. The scene will tell the npc_breen to walk to the info_target, wait for one second, and fire a scene trigger to open the prop_door_rotating.


Creating the Door Scene

Make a new scene call “OpenDoor". Name the actor “!Target1" and create two channels. Name the first channel “moveto" and the second channel “firetrigger". Create a Move To event in the “moveto" channel, give the event a name, put “spot" in the “Move to Actor" field, choose “Walk" in the field below, set the start time to “0", set the end time to “2", and push OK. In the “firetrigger" channel, create a Fire Trigger event. Name the event “Open the door", select “8" in the “Scene Trigger" field, set the start time to “3", and push OK.

The scene is now created. This .vcd will dictate that as the scene begins, the actor assigned to Target 1 in the logic_choreographed_scene will immediately spend two seconds moving to the entity named “spot". Afterwards, one second will pass, and the actor will fire the input specified in the OnTrigger8 output of the logic_choreographed_scene.


Creating the Door Map

Create a new map named “DoorOpen". Make a 320 x 320 x 320 unit block, and hollow out the room by -32 units. Place an info_player_start, a trigger_once, and a logic_choreographed_scene in the map. Move these three entities to a position similar to the prior map with the Strider. Now, place a prop_door_rotating entity in the middle of the map. Change the default settings for the fields specified with the following:


Name: Door

World model: models/props_c17/door01_left.mdl

Skin: 2

Delay before close (-1 stay open...): 5


Position the prop_door_rotating so that that it doesn’t clip into any surfaces, and that the front or back of the door would face the info_player_start. Rotate the info_player_start accordingly. Now, create an info_target and place it on the opposite side of the door that the player is facing at. Name it “spot" (the name of the target for the actor to move towards), and position it slightly above the floor. Lastly, create an npc_breen entity, place it near the wall opposite of the info_player_start, and rotate it so that it faces the prop_door_rotating. The map should look somewhat like this:

The layout of Example #2


Give the npc_breen entity a name, and open up the properties for the logic_choreographed_scene. Name it "LCS1", specify the path to OpenDoor, set “Target 1" to the npc_breen, and add the following output:


My output named: OnTrigger8

Target entities named: Door

Via this input: Open


Finally, add an output to the trigger_once as follows:


My output named: OnTrigger

Target entities named: LCS1

Via this input: Start


Compile and play the map. The scene will play as expected. This ends Example #2.


Conclusion

By using fire trigger events, scene designers can have more control over actors, such as the number of triggers to be fired per actor and when. Appropriate usage of fire trigger events can make one’s choreography more cohesive.

If one were to fire an input on a non-AI entity, a NPC is required for the scene. Defining the non-AI entity as an actor in a scene and adding the appropriate outputs will result in the engine not being able to find the actor. Passing the scene trigger through the AI entity makes said entity "bridge" the connection between a .vcd file and a non-AI entity.


Example Archive

An example archive is included with this article.