Download attachment
Getting Started
The use of scripted_sequences in maps is one of the things that make single player mapping that much more versatile. Scripted_sequences are used to control npc characters and give them animations; it can used to breathe life into an otherwise still scene.
For this example, we'll be making two npc_citizens carry out their everyday existence. The first one will walk to the couch and sit on it while the other one will try to get a TV working.
Firstly, create a room. Make it a reasonable size; mine was
256x448 (on top view).
Place an
info_player_start and a few
light entities in the room. Now (for the benefit of my example), place a couch in the room, and a TV on a table opposite it.
A nice little scene
Choosing the Animations
Now we're going to set up our scripted sequences. Firstly, let's see what animations we want the NPC's to have. Place an
npc_citizen somewhere in the room, where is not important at the moment. Go into the properties and click the Model tab. Now go through the sequences, click a few to see what they look like. This is the animations library, we need the names of the animations we like to put in the
scripted_sequence.
Okay, so for this example I want to use the
Idle_to_Sit_Chair, you can go and find this to see a demonstration.
Look, he's alive!
Now name the npc. For my example set the
name to
npc_bob, and cut and paste him into a corner (moving them normally after setting up an animation in the model tab can crash hammer, setting it back to
Sequence:
ragdoll can prevent this).
Now we want to place the
scripted_sequence entity. Select it from the entity list and place it on the floor right in front of the couch (it's important not to place it in the couch. Scripts don't work inside props or other entities). The small yellow line in the top view shows which way the
scripted_sequence is facing: you want it facing toward the TV. To change this line, go to the
scripted_sequence properties and change the
angle.
Yellow line is in top left view
Setting up the scripted_sequence
The fun part: go to the
scripted_sequence properties and make the
Target Npc npc_bob. We'll set the entry animation to
Idle_to_Sit_Chair. Set the
action animation to
Sit_Chair and set the
post action animation to
Sit_Chair.
Move to Position should be set to
Walk. You can also make him
run or go to the sequence instantly. Go to the flags tab and tick
Override AI,
Loop in Post idle and
Priority Script. This basically means the NPC will do this despite distractions and will continue sitting, even after the script is finished.
Testing the sequence
Name the
scripted_sequence script_bobsit. Now, create a
func_button on the wall somewhere and set the
Output to:
Onpressed,
Target entity:
script_bobsit,
Via this output:
Begin Sequence. Now would be a good time to test, so compile and load it up. Press the button and see if the npc does the sequence.
Woo, button
Part 2: Fixing the TV
Now we're going to set up the other npc, the one that'll try to get the TV working.
Place another
npc_citizen in another corner of the room.
Name this one
npc_paul. Now place a
scripted_sequence in front of the TV you placed earlier, and set the
angle to face the TV. Set the
Target NPC to
npc_paul. Set the
Entry Animation to
standtocrouchhide, set the
action animation to
crouchidlehide and the
Post action idle Animation to
crouchhidetostand. This time however, the npc will not be looping the animation, in which case the only flags you need to tick are
override AI and
Priority Script. Tick the
Repeatable flag as well.
Name the
scripted_sequence script_paulfix and place another button. This button will be: OnPressed,
Target Entity:
script_paulfix,
Via input:
BeginSequence.
Conclusion
If you've followed this correctly, you should be able to get both npc's going by pressing their individual buttons. If you ticked the
Repeatable flag, you can press the TV guy's button more than once. Compile and test.
Of course, this is just a starting point for what you can do with scripted_sequences. I hope this gives you many ideas and has taught you how to use them effectively.
Full room layout
In action
One thing though, should it not be "breathe" rather than "breath" at the beginning?