The following is a list of the Quake2 engine internal commands which can be referenced by the
Text output Commands

gi.bprintf (print_level, text, variables)

sends message to all players
print_level gives the message priority, and can be :
PRINT_LOW pickup items
PRINT_HIGH important stuff
PRINT_CHAT chat messages

gi.dprintf (text, variables)

debug message (Debug cvar allows you to view these) //kami0

gi.cprintf (entity, print_level, text, variables)

sends message to only one entity
print_level sets message priority (see gi.bprintf for values)

gi.centerprintf (entity, text, variables)

sends message to one entity and displays message in centre of screen

Audio Commands

gi.soundindex (sound_filename)

during spawning it caches the sound, after that it simply returns the index which
refers to that sound

gi.sound (entity, channel, sound_index, volume, attenuation, time_ofs)
generates sound centered on given entity
channel specifies the sort of sound - a second sound of the same sort will overwrite the first
sound to play is given by sound_index, which is given by gi.soundindex
volume is between 0 and 1
attenuation gives how far away sound can be heard
time_ofs is time before playing sound? (not yet found anything other than 0)
channel can be :
CHAN_AUTO new sound - doesn't overwrite any others
CHAN_WEAPON weapon sound
CHAN_VOICE sound made by entities vocal chords :)
CHAN_ITEM invulnerability, quad damage, etc
CHAN_BODY footsteps, stomache rumblings :)
plus optional flags :
CHAN_NO_PHS_ADD everyone hears this (same as ATTN_NONE)
CHAN_RELIABLE important sound - make sure it gets there safetly
attenuation can be :
ATTN_NONE heard everywhere
ATTN_NORM carries a long way
ATTN_IDLE doesn't carry as far?
ATTN_STATIC doesn't go very far at all

gi.positioned_sound (origin, entity, sound_index, volume, attenuation, time_ofs)

similar to sound (see above for most of settings)
origin sets position for sound to come from realative to level origin (NOT entity origin)

Model Stuff

gi.modelindex (model_filename)

during spawning it caches the model, after that it simply returns the index which
refers to that model

gi.setmodel (entity, model_filename)

sets the entitie's model to model_filename
Icon Stuff
gi.imageindex (image_filename)

used to precache the icon during initialisation, and reference it thereafter

Detection functions

gi.trace (point1, vector1, vector2, point2, ignore, mask)
Traces a box from point1 to point2, ignoring entity ignore, stoping if it hits an object of
type specified in mask.
Vector1 and vector2 set the box which will do the tracing - if NULL, then a line is used instead
returns value of type trace_t with attributes :
.allsolid boolean - if true, entire trace was in a wall
.startsolid boolean - if true, trace started in a wall
.fraction fraction of trace completed (1.0 if totally completed)
.endpos point where trace ended
.plane surface normal at hitpoint (type cplane_t)
.surface surface hit (type csurface_t)
.contents contents of point at end of trace (see gi.pointcontents for values)
.ent entity hit by trace
Mask can be one (or more) of contents values (see gi.pointcontents) or can be one of :
MASK_ALL stop on anything
MASK_SOLID solid wall
MASK_PLAYERSOLID solid wall or player or non-solid monster?
MASK_DEADSOLID solid wall or player
MASK_MONSTERSOLID solid wall or monster
MASK_WATER any liquid
MASK_OPAQUE walls and liquid except water (see thru)
MASK_SHOT anything hit by weapons
MASK_CURRENT current contents?
gi.AreasConnected (int areanum1, int areanum2)

checks if two areas are connected - used to check whether a monster can hear a sound or not
returns 1 or 0? (some sort of boolean value)

gi.pointcontents (point)

returns the content of the given point, will be one of :
CONTENTS_SOLID solid wall (not windows)
CONTENTS_LAVA err.. lava
CONTENTS_AREAPORTAL portals to conserve memory used in map designing, also dont allow sounds to pass //kami0
CONTENTS_PLAYERCLIP brush which player may not pass through //kami0
CONTENTS_MONSTERCLIP brush where monsters may not pass through //kami0
CONTENTS_CURRENT_0 flowing current moving at angle 0 //kami0
CONTENTS_CURRENT_90 flowing current moving at angle 90 //kami0
CONTENTS_CURRENT_180 flowing current moving at angle 180 //kami0
CONTENTS_CURRENT_270 flowing current moving at angle 270 //kami0
CONTENTS_CURRENT_UP flowing current moving up //kami0
CONTENTS_CURRENT_DOWN flowing current moving down //kami0
CONTENTS_ORIGIN used for rotation, invisible //kami0
CONTENTS_MONSTER non-solid monster?
CONTENTS_DETAIL brush that is not passed to vis - not in final BSP ?

gi.BoxEdicts(mins, maxs, entity_list, maxcount, areatype)

generates a list of all the entities in a certain box
mins and maxs define the box (relative to level origin)
entity_list (type edict_t *varname[])
maxcount - number of entities to give
areatype - type of entity, can be :
AREA_SOLID find solids
AREA_TRIGGERS find triggers
returns number of entities found
gi.SetAreaPortalState (poral_num, open)

set when a door opens or closes (to prevent sound detection through closed doors?)
gi.inPVS (point1, point2)

checks to see if point2 is in the Potentially Visible Set of point1. The potentially visible set
(PVS) is a data structure used by Quake II to determine visibility and lines of sight. Note
that if point2 is in the PVS of point1, then point1 will also be in the PVS of point2, hence
the first law of optics: if I can see you, then you can see me.

gi.inPHS (point1, point2)
checks to see if point2 is in the Potentially Hearable Set of point1. The PHS is the same concept
as a PVS, except it tracks sound instead of sight.
Thanks to Anthony Spataro for inPHS and inPVS
Entity Linking

links entity into the world so that it is sent to the client and used for collision detection,
must be re-linked if its size, position or solidity changes


stop entity from interacting with the world
must be done before deleting item

Console Stuff


returns the number of arguments on the console


returns the next entry on the console as a string


returns the argument number index from the console (command is arg 0)


adds a command to the server console, as if it had been typed

gi.cvar(variable_name, value, flags)

declares and sets the variable to the value, and sets flags :
CVAR_ARCHIVE saved to vars.rc
CVAR_USERINFO added to userinfo when changed
CVAR_SERVERINFO added to serverinfo when changed
CVAR_NOSET can only be changed at command line
CVAR_LATCH save changes until server restart
returns the variable just set
NOTE : this is only used during the initialisation function

gi.cvar_set(variable_name, value)

sets the variable to value
returns the variable just set

gi.cvar_forceset(variable_name, value)

sets the variable to value
returns the variable just set
forces the value?
Network Broadcast
There are quite a lot of bits of info that can be sent with network broadcast messages (such
as scores, and temporary entities such as explosions and sparks). I am not going to go into them
gi.unicast(entity, reliable)

send the prepared data to a single entity
set reliable to true for important messages?
 gi.multicast(origin, to)
 send prepared data (including origin) to :
MULTICAST_ALL send message to all
MULTICAST_PHS send message to all nearby?
MULTICAST_PVS send message to all nearby?


various bits of data that can be sent



moves the player, according to information given in varaible pmove

gi.configstring (index, string)

general means of communication from server to all clients
index has values:
CS_NAME level name
CS_CDTRACK cd sound track
CS_SKY sky picture
CS_SKYAXIS line around which sky wraps?
CS_SKYROTATE where to start sky picture?
CS_STATUSBAR either 'dm_statusbar' or 'single_statusbar'
CS_MAPCHECKSUM appears to be unused (for detecting 'cheater' maps, apparently)
CS_MODELS info on models in level? (unused)
CS_SOUNDS info on level sounds? (unused)
CS_IMAGES info on level images? (unused)
CS_LIGHTS send message giving change in light level of a light
CS_ITEMS used when sending a list of items on the level
CS_PLAYERSKINS used to send name and skin of player to all
MAX_CONFIGSTRINGS maximum configsting number ?! (unused)

gi.DebugGraph (value, colour)

draws a graph? doesn't seem to do anything try turning debug mode on, a cvar //kami0

gi.error (text, variables)

Shuts down the game and displays the error message

gi.TagMalloc(size, tag)

allocate 'size' bytes of memory, referenced by tag


free memory referenced by tag

something to do with memory (de)allocation
not used anywhere in code
Sorry for any mistakes/inaccuracies, and if anyone's got any updates to this, please e-mail me.

with various changes by:
Michael 'kami0' DiGiovanni (changes marked with //kami0)