$definemacro

From Valve Developer Community
Jump to: navigation, search

The $definemacro QC command defines a string substitution macro. A macro can be used as a short hand way to specify other QC commands. The macro creates a block a named block of text, that when referred to will virtually insert that text into the QC file, along with replacing the named parameters with the specified values.

Syntax

$definemacro (macroname) [arg_name1] [arg_name2] [...] \\
  • Defines a string substation macro.
  • The macro definition begins on the next line, and all subsequent lines that end with \\ (two backslashes).
  • Arguments are referenced by surrounding them with $’s (i.e. $arg_name1$ ), and can be embedded inside of other words.
  • To use the macro, type $macroname and the next N tokens will be taken as arguments.

Examples

$definemacro testmacro seqname filename endframe \\
$sequence $seqname$01 $filename$ { \\
    frames 0 $endframe$ \\
    subtract $seqname$ 0 delta \\
    weightlist justbody \\
}

Then, to use the macro, do:

$testmacro small_flinch "npc flinch 01" 20

Another example:

$definemacro makeidlenoise idleNoiseName fileName \\
$sequence $idleNoiseName$ {\\
     $fileName$ \\
     subtract $idleNoiseName$ 0 \\
     iklock lfoot 1 0 iklock rfoot 1 0 \\
     delta \\
     hidden \\
     realtime \\
}

$makeidlenoise idleNoise03 "Idle03"
$makeidlenoise idleNoise04 "Idle04_v32"

See also