Scripted sequence

From Valve Developer Community
Revision as of 00:15, 13 June 2009 by Corewarp (talk | contribs)
Jump to: navigation, search


Entity description

Grabs an NPC and makes them play a specified set of animations. The NPC can be told to move to the scripted sequence position or can be told to play the script wherever they currently are. Multiple scripted sequences of the same name will frame-synchronize in the action animation once all the actors have moved to position. This allows tight interaction between actors (one actor grabbing another, hitting them, etc.) The flow is as follows:

  1. Move to position using the specified movement animation. If "Move to Position" is set to "None", skip to step 2.
  2. If forced to wait for another actor to move to position, play the pre-action idle animation, otherwise skip to step 3. If there is no pre-action idle specified, "ACT_IDLE" is used.
  3. Fire the "OnBeginSequence" output.
  4. Play the action animation. If no action animation is specified, skip to step 5.
  5. Play the post-action idle animation. If none is specified, skip to step 6. If the "Loop in Post Idle" spawnflag is set, keep playing the post-action idle until the script is canceled. If no post-action idle animation is specified, "ACT_IDLE" is used.
  6. Fire the "OnEndSequence" output.
  7. If a next script to play is specified, hand the NPC to the next script and repeat this process for that script.

The "MoveToPosition" input runs steps 1 and 2, then waits while playing the pre-action idle animation until the "BeginSequence" input is received.



Name (targetname) <string>
The targetname that other entities refer to this entity by.
Entity Scripts (vscripts) <scriptlist> (in all games since <Left 4 Dead 2>)
Space delimited list of VScript files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions.
Script think function (thinkfunction) <string> (in all games since <Left 4 Dead 2>)
Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call.
Note.png Note: Try to avoid expensive operations in this function, as it may cause performance problems.


Parent (parentname) <targetname>
Specifies a movement parent. An entity will maintain its initial offset from its parent. An attachment point can be added to the end of the name, separated by a comma.


Pitch Yaw Roll (Y Z X) (angles) <angle>
This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
  • DXLevelChoice:
Minimum DX Level (mindxlevel) <choices>
The entity will not exist if the engine is running outside the given range of DirectX Versions. Replaced by SystemLevelChoice from <Left 4 Dead> Left 4 Dead onwards.
Warning.png Warning: If these are used, the object may break when the user switches their DirectX settings.
Maximum DX Level (maxdxlevel) <choices>
  • m_iszEntity
<target_destination> The name or class name (such as "npc_zombie") of an NPC to use for this script.
  • m_iszIdle
<string> The name of the sequence (such as "idle01") or activity (such as 'ACT_IDLE') to play before the action animation if the NPC must wait for the script to be triggered. Use "Start on Spawn" flag or "MoveToPosition" input to play this idle animation.
  • m_iszPlay
<string> The name of the main sequence (such as 'reload02') or activity (such as "ACT_RELOAD") to play.
  • m_iszPostIdle
<string> The name of the sequence (such as "idle01") or activity (such as "ACT_IDLE") to play after the action animation.
  • m_iszCustomMove
<string> Used in conjunction with the 'Custom movement' setting for the "Move to Position" property, specifies the sequence (such as 'crouch_run01') or activity (such as "ACT_RUN") to use while moving to the scripted position.
  • m_flRadius
<float> Radius to search within for an NPC to use. 0 searches everywhere.
  • m_flRepeat
<float> Repeat Rate ms
  • m_fMoveTo
<choices> Move to Position"
Literal Value Description
0 No
1 Walk
2 Run
3 Custom movement
4 Instantaneous
5 No - Turn to Face
  • m_iszNextScript
<target_destination> The name of the script to run immediately after this script completes. The NPC will not return to AI between the two scripts.
  • m_iszEntry (in all games since <Half-Life 2: Episode One><Half-Life 2: Episode One>)
<string> The name of the sequence (such as "reload02") or activity (such as "ACT_RELOAD") to play when the sequence starts, before transitioning to play the main action sequence.
  • m_bLoopActionSequence (in all games since <Half-Life 2: Episode One><Half-Life 2: Episode One>)
<boolean> Loop Action Animation?
  • m_bSynchPostIdles (in all games since <Half-Life 2: Episode One><Half-Life 2: Episode One>)
<boolean> Synch Post Idles?
  • onplayerdeath (in all games since <Half-Life 2: Episode One><Half-Life 2: Episode One>)
If set, NPC will cancel script and return to AI


  • 4 : Repeatable
  • 8 : Leave Corpse
  • 16 : Start on Spawn - Note: this activates the "MoveTo" action only. Action Animation will occur only after the scripted_sequence has been otherwise triggered.
  • 32: No Interruptions
  • 64: Override AI
  • 128: No Script Movement
  • 256: Loop in Post Idle
  • 512: Priority Script



Removes this entity from the world.
Removes this entity and its children from the world.
Note.png Note: Entities already remove orphaned children upon being removed, but this input removes all children on the same frame, being marginally faster than Kill.
AddOutput <string>
Adds a keyvalue/output to this entity. It can be potentially very dangerous, use with care.
KV Format: <key> <value>
I/O Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite>
FireUser1 to FireUser4
Fire the OnUser outputs; see User Inputs and Outputs.
Use  !FGD
Same as a player invoking +use; may not do anything depending on the entity. Can also be invoked by firing an output that does not specify an input.
RunScriptFile <script> (in all games since <Left 4 Dead 2>)
Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode <string> (in all games since <Left 4 Dead 2>)
Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console.
Bug.png Bug: In <Left 4 Dead 2>, the code is executed in the script scope of the entity that fires the output, not the one receiving the input.
Warning.png Warning: Never try to pass string parameters to a script function with this input. It will corrupt the VMF structure because of the nested quotation marks, which then must be removed manually with a text editor.
CallScriptFunction <string> (in all games since <Left 4 Dead 2>) !FGD
Execute a VScript function in the scope of the receiving entity.
SetLocalOrigin <coordinates> (in all games since <Alien Swarm>) !FGD
Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.
SetLocalAngles <angles> (in all games since <Alien Swarm>) !FGD
Set this entity's angles.


SetParent <string>
Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment <string>
Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
SetParentAttachmentMaintainOffset <string>
As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
Removes this entity from the the movement hierarchy, leaving it free to move independently.
  • BeginSequence
Summons an NPC to act out the scripted sequence.
  • MoveToPosition
Summons an NPC to the script location. They will play their scripted idle (or "ACT_IDLE" if none is specified) until "BeginSequence" is triggered.
  • CancelSequence
Stops the scripted sequence. If fired after a sequence starts, this input will not take effect until the NPC finishes playing the scripted action animation.



OnUser1 to OnUser4
These outputs each fire in response to the firing of the like-numbered FireUser1 to FireUser4 Input; see User Inputs and Outputs.
OnKilled  (only in <Left 4 Dead><Left 4 Dead 2>)
This output fires when the entity is killed and removed from the game.
  • OnBeginSequence
Fires when the action animation begins playing.
  • OnEndSequence
Fires when the action animation completes.
  • OnScriptEvent(01-08)
Fires when a 'trigger' anim event occurs while playing the script. Use { event 1003 framenum (1-8) } in the QC.

Locating animations

You can use the model tab in the entity window.


You can use the Half-life Model Viewer tool to see all the available sequences(Animations) for the model you're using. You can find the application in the Source SDK.

When you've launched the tool go to File and load the model you want. Then go to the Sequence tab and select an animation from the dropdown menu to get the model you've select to play that animation or sequence.

What it looks like: Hlmw.jpg

See also