MDS - Model Script
Model script is a file describing what skeleton should be used, what body meshes work with this set of animations and how should the animations be named, how fast they run, what animation is supposed to start after the current one is finished and much more.
Info
If you are unfamiliar with the animation naming conventions, please read the naming conventions article first.
Syntax
The MDS file consists of blocks and commands. Blocks are wrapped in curly braces {} and commands are single lines that end with a newline character.
Comments
Comments start with // and continue to the end of the line.
Tip
The MDS syntax is very simple and scripts can be edited in any text editor. It is, however, easier to work in an editor with a proper syntax highlighting. vscode-daedalus extension for Visual Studio Code supports MDS syntax highlighting.
Model
The whole script is wrapped in the Model block. It defines the name of the model this script belongs to.
meshAndTree
This command defines the source file for the model mesh and skeleton in the neutral pose.
ASC_NAME - name of the source file
DONT_USE_MESH - optional parameter, if specified the mesh from the source file is not used, only the skeleton. This is used for humans and creatures, since different meshes could use the same skeleton.
registerMesh
This command registers a body mesh that can be used with this model (e.g armor or clothing).
ASC_NAME - name of the source file
aniEnum
This block contains all the animations for this model.
ani
This is the main command for defining an animation.
Info
Inside the ani command animation events could be used.
Example
Parameters
ANI_NAME    - animation name, used in scripts and code as identifier
There is a naming convention, that is recommended and sometimes required to be used.
- prefix t_- transition animations
- prefix s_- state animations - they usually run in a loop
- prefix c_- animations used for animation combining/interpolation
LAYER       - layer number for multi-layer animations
NEXT_ANI    - name of the next animations
BLEND_IN    - time in seconds describing animation blending at the start
If we set it to 0.5, it takes 0.5 seconds for this animation to take full effect. At 0.0 s the previous animation has full effect on the bones of the skeleton, at 0.1 s it is influenced by 20% by this animation and at 0.5s it is completely influenced by this animation and the previous one has no effect.
BLEND_OUT   - time in seconds describing animation blending at the end
FLAGS       - flags, that describe animation behavior
- M - specifies a movement animation, the animation of the model translates into a changed position in the game world
- R - the same as M but for rotation
- E - this flag makes this animation run only, if the animation in the same layer are finished, this is used in the movement animations. The animation s_walk(walking loop animation) runs, when the player is walking,when he stops the transition animation to standing state is playedt_walk_2_stand. This animation uses the E flag to wait for the walk cycle animation to finish, to smoothly transition into the standing state.
- F - the engine ignores height coordinate - doesn't keep the model "glued" to the ground (falling/flying animation)
- I - specifies idle animation - breathing, standing with a drawn weapon and moving the weapon
ASC_NAME    - name of the source file
ANI_DIR     - direction of the animation
- F - forward
- R - reverse
START_FRAME - on what frame from the source file the animation starts
END_FRAME   - on what frame from the source file the animation ends
Additional parameters
Some additional parameters could be specified at the end of the command, these are optional and not used in all animations.
FPS:XX - sets the frames per second for this animation
SPD:XX - sets the speed multiplier
CVS:XX - sets the collision volume scale
Example
aniAlias
Command to create an alias (hard link for UNIX users) for an already defined animation.
Example
Parameters
ANI_NAME   - name of the new animation
LAYER      - layer the animation is on
NEXT_ANI   - name of the next animations
BLEND_IN   - time in seconds describing animation blending at the start
BLEND_OUT  - time in seconds describing animation blending at the end
FLAGS      - flags, that describe animation behavior
ALIAS_NAME - name of the animation we want to use as a source for the alias
ANI_DIR    - direction of the animation
If we look for the animation in the example we can see that there is a related one just one line above
t_Sneak_2_Run animation and we are specifying that the animation after this one is finished will be s_Run and that it is being made by reversing animation t_Run_2_Sneak by specifying the R flag.
aniBlend
Command to define animations that are a result of blending of two animations. This animation is not animated by hand, but it is dynamically generated by the engine during run-time.
Syntax:
Example
Parameters
ANI_NAME   - name of the new animation
NEXT_ANI   - name of the next animations
BLEND_IN   - time in seconds describing animation blending at the start
BLEND_OUT  - time in seconds describing animation blending at the end
aniComb
Command that defines an animation that is created by interpolating several animations with an equal number of frames.
Example
In this example, aniComb creates the s_bow_aim animation by combining four preceding ani phases (c_bow_1 to c_bow_4). Each phase uses the same source file but different frame ranges.
Parameters
ANI_NAME   - name of the new animation
LAYER      - layer the animation is on
NEXT_ANI   - name of the next animations
BLEND_IN   - time in seconds describing animation blending at the start
BLEND_OUT  - time in seconds describing animation blending at the end
FLAGS      - flags, that describe animation behavior
ANI_PREFIX - prefix of the animations to combine
NUM_ANI – number of previous ani commands to combine
aniMaxFPS
Sets the default maximum frame rate for all animations, if not specified, the default value (25 FPS) is used.
FPS_VALUE - maximum frames per second
aniDisable
Disables an animation, so it is not played by the engine.
Bug
This command is broken and doesn't work as expected
Parameters
ANI_NAME - name of the animation to disable
aniBatch
Command to combine multiple animations into one. When the combined animation is played, all the animations in the batch are played simultaneously. This could be used e.g. to split the upper and lower body animations.
Danger
This command is not used in the game files and might not work as expected.
Example
Parameters
ANI_NAME   - name of the new animation
BATCH_ANI_NAME - name of the animation to be played in the batch, it must be defined previously in the script
aniSync
Unknown command, never used in the game files.
Example ModelScript
For a better understanding of the MDS syntax, here is a simple example of a human model script.
Animation state machine
More complex animations such as MOBSI animations form a state machine - an animation set.
stateDiagram-v2
    s_S0      : Closed chest
    t_S0_2_S1 : Opening the chest
    s_S1      : Opened chest
    t_S1_2_S0 : Closing the chest
    t_S0_Try  : Pick lock broken
    [*] --> s_S0
    s_S0 --> s_S0
    s_S0 --> t_S0_2_S1
    t_S0_2_S1 --> s_S1
    s_S1 --> s_S1
    s_S1 --> t_S1_2_S0
    t_S1_2_S0 --> s_S0
    s_S0 --> t_S0_Try
    t_S0_Try --> s_S0- 
Inspired by the MDS article by VAM. ↩