Quake-C Model definitions

(Derived from information published by Steve Tietze)

Here are a few definitions that are commonly found in the Quake-C code defining the behavior of animated models (monsters, players, etc...).

Most of this information is not interpreted by the Quake-C compiler, but it's useful for the program modelgen that generates the models.

Model name

$modelname name
name is the name of the model file defining the object.
ex: $name armor

directory

$cd dir
Specify the directory where your model file (.MDL) is located.
ex: $cd /evil/models/armor

Special animation flags

$flags  rotation
This field is not interpreted by Quake-C, but it's useful for the program modelgen that generates the models.
Rotation of the object.
ex: $flags 8
Possible values for the flags:

Origin

$origin x y z
This field is not interpreted by Quake-C, but it's useful for the program modelgen that generates the models.
Location of the object within the bounding box, in the quake editor.
ex: $origin 0 0 8

Scale factor

$scale number
This field is not interpreted by Quake-C, but it's useful for the program modelgen that generates the models.
number comes from the texmake number that is generated.
You can use different values if you want.
ex: $scale 4

Base

$base  object
This field is not interpreted by Quake-C, but it's useful for the program modelgen that generates the models.
object is the name of a model file, that will be used as a kind of starting position, for animation.

Skin file

$skin  skinfile
This field is not interpreted by Quake-C, but it's useful for the program modelgen that generates the models.
skinfile is the name (without extension) of the .lbm file that defines the skin of the object, as generated by the program texmake.

Frame definitions

$frame  frame1 frame2 ...
This defines several animation frames of the object.
For every animation frame defined, you must also define a Quake-C function, that will be called during this animation frame. For instance:
$frame walk1 walk2 walk3 walk4
void() man_walk1 = [ $walk1, man_walk2 ] { ... some code ... };
void() man_walk2 = [ $walk2, man_walk3 ] { ... some code ... };
void() man_walk3 = [ $walk3, man_walk4 ] { ... some code ... };
void() man_walk4 = [ $walk4, man_walk1 ] { ... some code ... };

In the brackets, the first parameter defines the name of the frame (as found in the model file), and the second parameter defined the function that is to be executed in the next frame (by setting the value of self.nextthink).

Most of these functions do nothing special, but some can be very complex (for instance, the functions that are called when the monster tries to see a player).