11. Implementation

The original Quake game library source code is divided in 31 QuakeC modules. A lot of the original modules were slightly modified for the Omicron bot. All changes made are marked in the code with conditional compilation directives. For the Omicron bot also 21 additional modules were created.

11.1 Modules

 
Module Description
 
b_defs.c All definitions (entity fields, constants, global variables)
b_func.c All function prototypes (like in C header files)
 
b_frames.c Handling of the animation frames
b_think.c The pre and post AI think
b_aitree.c Artificial Intelligence tree
b_goal.c Goal related code
b_fight.c Fighting related code, aim at enemy, attack and attack movement
b_fuzzy.c All fuzzy logic (decision library)
b_talk.c Chat code
b_char.c Character specific chat lines
b_waypnt.c Waypoint system (waypoint placement, routing)
b_hcwp.c Hard coded waypoints
b_locate.c Locating entities (environment sampling)
b_hear.c Hearing entities (environment sampling)
b_move.c Movement (environment sampling)
 
b_clrank.c Client rankings emulation
b_clskin.c Client skin emulation
b_clphys.c Client physics emulation
 
b_spawn.c Spawning and removing of bots
b_impuls.c User impulse commands and menu
b_observ.c User observer mode (eye and chase camera)
 

11.2 Module dependency

 


 
The client emulation modules are independent from the other bot modules. They are used to make the bots look like real clients. These modules are necessary because the bots aren't real clients of the Quake server.

The first two additional modules are related to the QuakeC language. The others provide the user of the Omicron bot with several options.

11.3 Implementation difficulties

The QuakeC language has several restrictions.

In QuakeC the only data structure is the entity. This means every data object will have to be modeled with an entity. One has to be careful with the number of data objects because there are only around 500 entities available.

It's not possible to use arrays or a the like data structure. When a sequence of elements is needed one has to declare several entity fields or variables and access them with functions.

Because the code in the game library is interpreted by the server process it's a magnitude slower than code executed by the operating system. Often one has to unfold loops or use the like tricks to gain speed.

Every server frame code from the game library is executed. Quake has a maximum of 100000 statements which may be executed each server frame. When there are more statements to execute the Quake server process assumes there's an infinite loop in the game library.

 

11.4 Tools for testing

To be able to test the Omicron bot or parts of it several tools were created.

An observer mode was created to watch the bot without interacting with it. When a client is in observer mode, the client can walk like normal but it is also possible to fly around. For the observer mode an "eyecam" and "chasecam" were created. The "eyecam"  gives the client the possibility to view through the bots eyes. With the "chasecam" the client can watch the bot from a short distance. It is possible to turn around the bot. All the code related to the observer mode can be found in the module "b_observ.c".

To test the waypoint system a waypoint model was created. With this model one has a visual representation of the waypoints in Quake. The different waypoints have different colors. Also a function was created to print the waypoint data structure. A real client can initiate the function and the data of the nearest waypoint is printed on the console. The waypoint system and tools for testing it are implemented in the module "b_waypnt.c".

The movement prediction used in the module "b_move.c" is also tested using a model. This movement prediction, predicts in steps of 0.1 seconds and for every step, a model of an arrow is shown. For instance when a jump is predicted, the jump parabola will be marked with arrows.