0
Posted September 1, 2012 by Spyros in General Programming
 
 

Introduction to Programming for a QuakeC Interpreter

256px-Quake1cover
256px-Quake1cover

“QuakeC” is an interpreted scripting language designed for use with the original “Quake” game engine by iD software. Since its introduction in 1997, it has gone on to form the foundation for a number of game scripting systems. Even games as modern as “Call of Duty: Modern Warfare 3″ use a derivative of this technology to control scripted events, game logic, artificial intelligence and other aspects of the game experience.

QuakeC is written in a syntax that is very similar to C. However, there are some notable deviations. For example, closing curly braces are not followed by a semicolon, function declarations are followed by an equals sign, the –, ++, -=, += and other similar operators are not used and arrays are not supported. Strutures are implemented in an unusual fashion known as “entities” or “edicts”. Entities are one of the few defined types in QuakeC. Once declared, an entity takes on a number of fields that are predefined earlier in the program’s scope. An example of this is the original “defs.qc” file in Quake. If the entity’s name were “test”, for example, it would have fields such as test.health, test.ammo_shells, test.target, test.origin_x, test.velocity_z, et cetera.

Other defined types include:

FLOAT: This variable type stores a floating point numeric value. This is also known as a decimal number. Integers are not implemented and are instead represented by highly precise floating point values.

STRING: Strings are long series of alphanumeric characters. They support the letters A through Z, zero through nine, a limited number of special characters and spaces. In order to instruct the engine to print the following characters on a new line, the \n identifier is used.

VECTOR: A vector stores three floating point values. These are defined as the _x, _y and _z values. They are used for entity locations, abstract locations, angles and movement vectors. They can also be used to store three floating point variables in one place as a space-saving measure. However, if this approach is used, it should be well commented so that other programmers will be able to understand the approach.

QuakeC is designed for machines with a floating point unit, also known as a math coprocessor. For this reason, integer values are not defined. If a floating point variable is assigned an integer value, the integer will be followed by a decimal point and a number of zeroes. QuakeC is compiled into one large file known as a “progs.dat.” This is performed by the QCC compiler or one of its many evolutions. This produces the instructions that a game server will follow. Client-side instructions can be generated using a variation on QuakeC. This is only supported in newer engines. Most of these recognize client-side instructions as the file “csprogs.dat.”

This guest post is contributed by Debra Johnson, blogger and editor of Liveinnanny.com. She welcomes your comments at her email Id: – jdebra84 @ gmail.com.


Spyros