Call of Duty 5: Animation Overview

From COD Modding & Mapping Wiki
Revision as of 15:24, 10 November 2008 by Zeroy (talk | contribs) (→‎Animation Reference Names)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The Animation system in Call of Duty is entirely scripted in GSCs, from body animations to facial animations to interactive animations.

Using animations requires simple script calls to functions in _anim.gsc

This page covers a basic overview and introduction to the animation system, for a more in-depth overview on how to use the animation system and how it works, visit the Body, Facial or Interactive animation pages.


Utility Inclusion

We need to include the _anim.gsc so we can make our script calls without always having to write out the path for every script call. At the top of your script you will need to add:

#include maps\_anim;

If you don't include it, you will always needs to add maps\_anim::someFunction() to every function you want to use from the utility.

AI Animation Reference Names

Every AI that is going to play an animation needs to have an animation reference name. The reference name is tied into the _anim.gsc scripts handling the animation.

You assign an animation name to an AI via script.

myAi = getEnt( "joe", "targetname" ); // Get our AI inside the map
myAI.animName = "My_Name_Is_Joe"; // Assign him an Anim Name

Animation Reference Names

Just like every AI that is going to play an animation, every animation needs a reference name.

These are typically assigned in level script animation files (ie. mak_anim.gsc) to keep a clean file structure with your scripts, but you can also define them in your main level script.

Prefix Type Example
level.scr_anim Body level.scr_anim[ "My_Name_Is_Joe" ][ "Animation_Reference_Name" ] = %ch_oki3_tableguys_guy1;
level.scr_sound Facial Dialogue level.scr_sound[ "My_Name_Is_Joe" ][ "Animation_Reference_Name" ] = "Oki3_IGD_216A_POLO";


scr_sounds DO NOT have a percentage symbol (%), and scr_anims DO NOT have quotations ("").


The layout for the examples are as follows:

Type AI Anim Name Animation Name Animation / SoundAlias
level.scr_anim [ "My_Name_Is_Joe" ] [ "Animation_Reference_Name" ] = %ch_oki3_tableguys_guy1;
level.scr_sound [ "My_Name_Is_Joe" ] [ "Animation_Reference_Name" ] = "Oki3_IGD_216A_POLO";


scr_anim is referencing an animation, scr_sound is referencing a sound alias.

Playing An Animation

Now that we have our AI and animations set up and ready to use, we can make a simple script call to _anim in just one line.

myAi thread anim_single_solo( myAI, "Animation_Reference_Name" );

Battle Chatter

While playing an animation, there is a small chance the AI may call out a battle chatter line, especially if you want the animation to take place during a big fire fight. You can avoid this by various different means such as turning off Battle Chatter, checking if they're speaking, etc...

We will use an if statement to check if they are speaking:

if( ( ( !isDefined(self.isspeaking ) && ( !self.isspeaking ) ) &&
    ( ( !isDefined(self.istalking ) ) && ( !self.istalking ) )
  )
{
  myAi thread anim_single_solo( myAI, "Animation_Reference_Name" );
}

This isn't necessary every time an AI is speaking or playing a physical animation, but something to keep in mind incase you notice your AI are shouting out Battle Chatter commands when you want them to do a scripted animation.

Zone Source

Body animations will need to be included in your Zone Source and compiled into your maps FastFile.

When you try to run your map playing the animations the first time, your AI may not doing anything at all or just play a funky default animation. After you exit the game, you should have a missingAssets.csv generated with the animations listed, just copy and paste those into your Zone Source.


Sources: Treyarch's Wiki