7. Quake-C Global Variables

7.1 Console Variables

These variables can be read or modified from the console, during game play. The player can change them, to affect the program behavior.

"teamplay"      // boolean, true if playing in teams.
"samelevel"     // boolean, if true, then cannot change level.
"noexit"        // boolean, true if can't exit level in deathmatch.
"timelimit" 	// number of minutes the deathmatch will last.
"fraglimit"     // maximum number of frags before deathmatch ends.
"skill"         // text of skill message (?)
"sv_gravity"    // gravity pull, normal value is 800.
"registered"    // boolean, game is registered (do not change).
"temp1"         // to store custom floating point values

Beware that the variables you can read in Quake-C are those that are defined on the server, not those defined on the client. So if a player sets a value on his console, there is no chance that you can ever get this value (unless his console is also the server console).

Well, at least you can read values set by the server administrator, for what it's worth.

7.2 Global Variables

These variables are accessible in every functions.
Quake C function are not supposed to modify them directly.

Variable: world

the server's world object, which holds all global state for the server, like the deathmatch flags and the body ques.

Variable: time

  float time;               // in seconds
The current game time, a floating point value in seconds. Note that because the entities in the world are simulated sequentially, time is NOT strictly increasing. An impact late in one entity's time slice may set time higher than the think function of the next entity. The difference is limited to 0.1 seconds.

Variable: frametime

  float frametime;           // in seconds
No idea what this can be. Used only when jumping in water.

Variable: self

 entity self;
The entity that is subject to the current function.

Variable: other

 entity other;
The object concerned by an impact, not used for thinks.

Variable: force_retouch

  float force_retouch;  // counter
Force all entities to touch triggers next frame. this is needed because non-moving things don't normally scan for triggers, and when a trigger is created (like a teleport trigger), it needs to catch everything.
It is decremented each frame, so it is usually set to 2 to guarantee everything is touched.

Variable: mapname

  string mapname;
Name of the level map currently being played, like "start".

Variable: deathmatch

  float deathmatch;  // a boolean value, 0 or 1
True if playing deathmatch.

Variable: coop

  float coop;  // a boolean value, 0 or 1
True if playing cooperative.

Variable: teamplay

  float teamplay;  // a boolean value, 0 or 1
True if playing by teams.

Variable: serverflags

  float serverflags;  // bit fields
Propagated from level to level, and used to keep track of the completed episodes.
If serverflag & ( 1 << e)) is true, then episode e was already completed.
Generally equal to player.spawnflags & 15.

Variable: total_secrets

  float total_secrets;  // counter
Number of secrets found by the players. Affected only by trigger_secret.

Variable: found_secrets

  float found_secrets;  // counter
Number of secrets found.

Variable: total_monsters

  float total_monsters;  // counter
Total number of monsters that were spawned, since the begining of the level.

Variable: killed_monsters

  float killed_monsters;  // counter
Store the total number of monsters killed.

Variable: parm1...parm16

  float	parm1; // items bit flag (IT_SHOTGUN | IT_AXE )
  float parm2; // health
  float parm3; // armorvalue
  float parm4, parm5, parm6, parm7; // ammo
  float parm8; // weapon 
  float parm9; // armortype*100
  float parm10, parm11, parm12, parm13, parm14, parm15, parm16;

Those parameters seem to be a bit of hack. They are used when a client connects.
Spawnparms are used to encode information about clients across server level changes


7.3 Mandatory functions

These functions must be defined in Quake C, since they are invoked by Quake under certain conditions.

Misc

void main();
Only used for testing progs.
void StartFrame();
Called at the start of each frame.

Behavior of players

void PlayerPreThink();
Called with self=player, for every frame, before physics are run.
void PlayerPostThink();
Called with self=player, for every frame, after physics are run.

Management of network game clients

void ClientKill();
Called when a player suicides.

void ClientConnect();
Called when a player connects to a server, but also, for every player, when a new level starts.
It is used to announces the new player to every other players.

void PutClientInServer();
Call after setting the parm1... parm16.

void ClientDisconnect();
Called when a player disconnects from a server
Announce that the player has left the game.

void SetNewParms(); 
Called when a client first connects to a server. Sets parm1...parm16 so that they can be saved off for restarts.

void SetChangeParms();
Call to set parms for self so they can?