$sequence

It defines a skeletal animation. It can be used either on its own, or, to make use of Source's more advanced skeletal animation features, in conjunction with one or several $animations.
:
== Usage ==
$sequence has two modes. One directly accesses a single skeletal animation (SMD or DMX), while the other needs intermediate $animations.
 $sequence <name> <skeletal animation SMD/DMX> <simple options> {		// opening brace must be on the same line as the command
 	// braces can be ommitted if nothing is in them
 	<advanced options>
 	<events>
 	<simple options>
 }
 $sequence <name> <simple options> {		// opening brace must be on the same line as the command
 	<$animation name(s)>
 	<advanced options>
 	<events>
 	<simple options>
 }
=== Examples ===
$modelname		"weapons/shell.mdl"
$cdmaterials		"models/weapons/"
$body		shell	"shell-ref"
$sequence idle	"shell-idle"
$animation a_strokechin "strokechin" subtract idle 0
$sequence strokechin {
	a_strokechin
	delta
}
$sequence run_holding_all {
	a_runS a_runSE a_runE a_runNE a_runN_SMG a_runNW a_runW a_runSW a_runS
	blendwidth 9
	blend move_yaw -180 180
	addlayer layer_run_holding
	ACT_RUN_RIFLE 1
	node "running"
}
== Options ==
=== Simple ===
; <string|name>
: The name of the animation. Will appear in HLMV, Hammer, etc.
; <string|Skeletal animation file>
: Path to the $sequence's source file. By including this, you tell studiomdl that you are using the simple version of the command.
; frame <int|start frame> <int|end frame>
; frames <int|start frame> <int|end frame>
: Specifies a range of frames to extract from the source animation. Useful for trimming off frames not used in a particular animation.
:: For example, if the source animation contains 80 frames (range of 0-79) but this animation should only play the last 30 frames, then frames 50 79 will load only those frames.
: Can also be used to extract a single frame of animation by making the start and end frames match.
: frames and frame are interchangeable.
: 
: 
: 
; numframes <int|frames>
: Forces an animation to be a specified number of frames, either by clipping the animation or by duplicating the last frame until it has been padded with enough.
: If used in conjunction with frame/frames, then it will respect the start frame. When it specifies fewer frames, it will cut the animation short. However, when it specifies more frames, it will repeat the last frame to meet the frame limit.
:: For instance, frames 10 12 numframes 12 will result in the animation extracting only frames 10 through 12, but frame 12 will be repeated to meet the 12 total frames specified, as if it was the real end of the animation.
; origin <float|x> <float|y> <float|z>
: Adjusts the position of the animation within its own local space.
; angles <float|x> <float|y> <float|z>
: Adjusts the rotation of the animation within its own local space.
; rotate <float|angle>
: Identical to angles, but it only rotates along the Z axis.
; scale <float|scale>
: Multiplies the size of the skeleton in this sequence. Negative values are accepted.
; reverse 
: Reverses the animation.
; loop
: Marks the sequence as being a looping animation that will play continuously, and causes StudioMDL to perform some cleanup on the first & last frames.
: The sequence will no longer be able to interrupt itself, if asked to play while currently playing.
; hidden
: Prevents the $sequence from being listed in user interfaces. Useful for sequences which serve only as layers of others.
; noanimation
: Forces the sequence to have a zero-weight animation. Effectively ignores frame/frames, but will respect numframes.
: Equivalent to using a $weightlist that removes the weight of all bones. Useful for creating special composite sequences comprised only of added or blended layers.
; fps <float|frames per second>
: Override the framerate of the animation. If unspecified, defaults to 30.
: 
: 
; <string|motion extract axis>
: Movement animations are easier to create if the model actually moves forwards, but for playback in-game it must "walk on the spot". This command resolves the issue by stripping root bone translation from an animation.
:: You can add walkframe <int|endframe of motion extraction> at the same line before specifying axis to limit motion extraction for specific part of animation. 
:: 
:: 
$sequence sword_attack {
	"knight_anims/sword_attack"
	ACT_SPECIAL_ATTACK1 1
	fadein 0.2
	fadeout 0.2
	fps 30
	walkframe 10 LX LY LZR //motion extraction from the start to 10 frame
	walkframe 30 LX LY LZR //motion extraction from 10 to 30 frame
	LX LY LZR //motion extraction from 30 frame until the end of animation
}
:Accepted axes are:
:* X, Y, Z, XR, YR, and ZR - R stands for 'rotation'.
::
:* LX, LY, LZ, LXR, LYR, and LZR - the root bone moves along the axis until the animation is half complete, then moves back to its original position. 
:* LM - specifies that the motion extraction should be treated as linear
:* LQ - specifies that the motion extraction should be treated as quadratic
: This command is also available on $animations.
; activity <string|name> <float|weight>
: Links the sequence to an activity.
: 
: If more than one $sequence has the same activity, then the weight specifies how likely this sequence is to be picked when that activity is called. The odds of any particular $sequence playing is simply its weight over the sum of all other weights.
:: For example, if a $sequence named swing_a has a weight of 2, and another $sequence named swing_b has a weight of 1, then there is a 2/3 chance for swing_a to play instead of swing_b.
:: 
; autoplay
: Makes the sequence play at all times, on top of any other animations, no matter what the model is doing. Good for blended breathing animations and other automated motion. If a model has multiple autoplay $sequences, they’re layered in the order that they appear in the QC. 
; addlayer <string|other $sequence name>
: Play another sequence on top of this one. The animations begin and end together, so discrepancies in their total run time (framerate * number of frames) will proportionately affect the added layer's framerate, if applicable. The other $sequence doesn't have to be above the current one.
: This is generally used to add either delta-ed layers such as aim matrices or specially weighted layers that only affect specific bones.
: The other $sequence can be declared ahead of time if it will be imported at runtime.
; blendlayer <string|other $sequence name> <int|startframe> <int|peakframe> <int|tailframe> <int|endframe> [options...]
: Similar to addlayer, but the new sequence only plays over specified frames, and it accepts a number of options.
: The animation starts at 0% intensity on startframe, reaches 100% intensity on peakframe, starts to fade away on tailframe, and fully fades out on endframe.
: Options:
:; spline
:: Instead of fading the layer linearly, fade it with a spline curve.
:; xfade
:: The layer will only fade in and not back out.
:; poseparameter <string|name>
:: Allows a pose parameter to control the fading of the layer instead of the parent $sequence's frame. When this option is present, the frame range is instead used to determine how the pose parameter's value should make the layer fade in/out.
::: Example: blendlayer aimmatrix -1 0 0 1 poseparameter move_x
param value: -2.000 -1.500 -1.000 -00.80 -00.60 -00.40 -00.200 000.00 00.200 00.400 00.600 00.800 1.0000 1.5000 2.0000
layer weight: 0.000% 0.000% 0.000% 20.00% 40.00% 60.00% 80.00% 100.0% 80.00% 60.00% 40.00% 20.00% 0.000% 0.000% 0.000%
:::: These values will change when making use of the spline option, but will still start and end at the same time.
:; noblend
:: Causes the layer to stop fading in/out entirely and always be at 100% intensity while active. This also makes the layer ignore sequence transitions.
:: 
:; local
:: Marks the layer as a local context sequence. This blends the layer with the main sequence before the main sequence's keyframes are actually applied to the bones. This is mainly useful for sequence transitions, which otherwise fade layers separately from the main sequence.
: 
; worldspace
: When used as a layer, calculates the bone positions in worldspace instead of relative to the parent animation. 
: 
; worldspaceblend
: 
; snap
: Remove all blending when transitioning to this animation. This is useful for reaction animations that are the result of sudden and violent changes in the model's state, such as a creature flinching or a weapon firing.
: 
; realtime
: Normally, when a sequence is asked to play, it will start at frame 0, and can be subjected to FPS changes by any parent sequence that's adding it via blendlayer. This option changes this so that the animation is instead synchronized with the map clock. Useful for adding layers that shouldn't play at the same rate as their parent $sequence, such as breathing.
: 
; fadein <float|seconds>
: Override how long this animation spends fading in. Default is 0.2.
: 
; fadeout <float|seconds>
: Override how long this animation spends fading out. Default is 0.2.
; weightlist <string|weightlist name>
: Selects a weightlist to apply to this sequence.
: If a default weightlist is used, this will override it with the specified weightlist for this animation.
; worldrelative 
: 
; localhierarchy <string|bone name> <string|new parent name> [range <int|startframe> <int|peakframe> <int|tailframe> <int|endframe>]
: Changes a bone's parent for this animation only. "" can be used to remove the parent of a bone.
: This is primarily useful for ensuring that a bone blends correctly. As an example, if a weapon is normally held in the right hand, but during this animation it's held in the left hand, it will blend as if it were being held by the right hand. This option can then be used to make it blend relative to the left hand instead, which will remove the jittering caused by blending.
: range is optional, and requires four frame numbers that specify how the hierarchy should be blended over the specified frames.
: 
; compress <int|frameskip>
: Saves only every frameskip frame of the input animation, starting at frame 0. A value of 1 or below does nothing.
; posecycle <string|pose parameter>
: Makes the specified pose parameter control the animation frame instead of the specific animation that should play in a blend sequence.
: You can use it to more easily create a detailed (but entirely linear) blend sequence. Not often used in the SDK, but is faster to set up & has no limit on the number of blended $animations.
: The pose parameter's min & max values will determine where the animation starts & ends. Below is an example of a parameter with a range of -180 to 180, being used on an animation with 9 total frames (range 0-8):
param value: -180.0 -135.0 -90.0 -45.0 0.0 45.0 90.0 135.0 180.0
anim frame: 0 1 2 3 4 5 6 7 8
: 
=== Advanced ===
In addition to all simple options:
; delta
: Tells Source that the $animations referenced in this sequence have all been subtracted. The $sequence will be played on top of whatever sequences are currently playing, rather than overriding them. 
; predelta
: The compliment to the "presubtract" command, this tells the animation compositing system to add the current bone setup on top of a different frame of reference instead of overriding each bones’ animation based on the typical cross-fade weighting scheme.
; blend <string|name> <float|min value> <float|max value>
; blendwidth <int|width>
; blendref <string|name>
; blendcomp <string|name>
; blendcenter <string|name>
; calcblend <string name> <string attachment> <XR YR ZR>
: See Blend sequence.
; ikrule
: See $ikchain.
; iklock
: Freezes the bone specified in an $ikchain.
: See $ikchain.
; activitymodifier <string|modifier> 
: 
=== Miscellaneous ===
;node (name)
:Tags the sequence as belonging to a point on the sequence transition graph table. This is for animations which don’t change graph state, such as looping animations. Multiple sequences can be at the same entry in the graph table, at which point they won’t need transition animations to move between each other.
:Alternatively, you can have them at different points and expressly skip transitions (see $skiptransition). Sequences with no declaration are assumed at the root node and the transition graph assumes any sequence can move from the root node or to the root node without a intermediate transition. 
;transition (from) (to)
:This specifies that the animation enters from one point on the node graph and exits at another point. This is used to play transitional sequences such as walk_to_stand, run_to_crouch, etc. 
;rtransition (name1) (name2)
:Same as transition, but flags the sequence as able to be run in reverse order. This was used for the Tentacle in Half-Life; except for special cases, using this isn't recommended. 
;exitphase (phase)
:When transitioning between looping animations, such as "stand_to_run", this tells the movement system where to start the next sequence, assuming it’s looping. It’s also assumed that you’ve made all the sequences that share the next node to be phase matched (see startloop). 
;$skiptransition (name1) (name2) [(name3) ...]
:This adds a rule to the transition graph to allow direct movement between all the named nodes. This is useful for transitions between unique named nodes that that may not require any specific intermediate animation. This is how to avoid the transition graph from forcing "walk" to "run" to instead be a "walk" to "stand" to "run" transition. 
;keyvalues { [stuff] }
:Add a keyvalue block (see $keyvalues) to a specific sequence. This is used for setting up gestures for Faceposer.
== Events ==
A $sequence can have certain Animation Events occur at different times during the animation, like so:
$sequence tentacle_grab "tentacle_grab" {
 fps 15
 { event 1000 1 }
 { event 1004 4 "*scientist/scream02.wav" }
 { event 1003 18 "smash" }
 { event 1004 65 "*scientist/c1a4_sci_tent.wav" }
}
s