Skip to content

Call of Duty scripting language syntax

Indrek Ardel edited this page Jun 22, 2015 · 3 revisions

This document describes the Call of Duty scripting language syntax.

Comments

There are two types of comments. Comments work anywhere except inside strings. Block comment will separate two elements in a similar manner to a whitespace (meaning that the safe substitution for a comment is a whitespace).

Single line comment

// this is a single line comment

Block comment

/* this comment
   can span
   across
   multiple lines
*/

File structure

A file can contain in any order function definitions, #using_animtree statements and function definitions inside a developer comment block (each function has to be inside its own developer comment block).

Function definition

Functions can be defined in following way.

myfun()
{
   // your code here
}

myfun2(arg1, arg2, arg3)
{

}

myfun3 ( arg1 , arg2 , arg3 ) { }

Function name and argument names must follow the basic identifier format.

Third example demonstrates possible positions where whitespace may be included.

Identifiers

Identifiers are sequences of ASCII code points 65-90 (A-Z), 97-122 (a-z), 48-57 (0-9) and 95 (_). Identifiers can not be equal to reserved keywords and may not start with a number.

Reserved keywords

Following keywords are reserved and may not be used as identifiers (case sensitive)

  • break
  • case
  • continue
  • default
  • else
  • endon
  • false
  • for
  • game
  • if
  • level
  • notify
  • return
  • self
  • switch
  • thread
  • true
  • undefined
  • wait
  • waittill
  • while

Call of Duty 2

Additional keywords were added

  • breakpoint
  • waittillframeend

Developer comments

Developer comments use syntax /# ... #/ and the code is being used from those if the developer cvar has a nonzero value. The comments can be wrapped around single function definitions or code inside function definitions. Developer comments may not contain a wait statement. Functions that have been defined inside developer comments cannot be referenced in code that is not inside a developer comment.

Call of Duty 2

Since Call of Duty 2 function definitions can be wrapped around multiple function definitions.