type variable1, variable2; eg: float a,b;Where type is one of the pre-defined simple types.
type variable1 = value; eg: float a = 2;Scoping of variables : There are two levels of scoping. By default all variables are global : they can be accessed by any functions, and they are shared by all the functions (and all the clients of a given network server, of course).
type (type param1, typeparam2, ... ) function = { ... code ... };Don't forget the ";" after the brackets.
void() think = {...}; entity() FindTarget = {...}; void(vector destination, float speed, void() callback) SUB_CalcMove = {...};
type (type param1, typeparam2, ... ) function;
void() framename = [$framenum, nextthink] { ...code...};It is strictly equivalent to :
void() framename = { self.frame= $framenum; // the model frame to displayed self.nextthink = time + 0.1; // next frame happens in 1/10 of second self.think = nextthink; // the function to call at the next frame ...code... };
if( expression ) { statements } else { statements }
while( expression ) { statements }or
do { statements }while( expression )
function_name ( parameter1, parameter2,... )The cannot be more than 8 parameters.
return( expression )
! // logical not && // logical and || // logical orTake care that in if() conditional expressions containing two or more logical clauses, all the clauses will be evaluated before the condition test (like in Basic, and unlike C).
<= < >= > == // equal, beware at the double = like in C. != // not equal, like in C.
* / - +Use parenthesis to remove ambiguities.
& // bitwise and | // bitwise orThese operators treat floats like integers, so they are usually meant to be used with values made of bit masks.
Function: anglemod float anglemod (float angle) |
Returns angle in degree, modulo 360. |
Function: rint float rint(float val) |
Returns val, rounded up to the closest integer value. |
Function: floor float floor(float val) |
Returns val, rounded up to the integer below (like the equivalent function in C). |
Function: ceil float ceil(float val) |
Returns val, rounded up to the integer above (like the equivalent function in C). |
Function: fabs float fabs(float val) |
Returns absolute value of val (like the equivalent function in C). |
Function: random float random() |
Returns a random floating point number between 0.0 and 1.0. |
Function: ftos string ftos(float value) |
Float to string: converts value to string. |
Function: normalize vector normalize(vector v) |
Returns a vector of length 1. Gives the vector colinear to v, but of length 1. This can be useful for calculation of distance along an axis. |
Function: vlen float vlen(vector v) |
Returns the length of vector v (never < 0). |
Function: vectoyaw float vectoyaw(vector v) |
Returns and angle in degree. Vector to yaw : calculates the yaw angle (bearing) corresponding to a given 3D direction v. |
Function: vectoangles vector vectoangles(vector v) |
returns vector 'pitch yaw 0 ' Vector to angles : calculates the pitch angle (aiming) and yaw angle (bearing) corresponding to a given 3D direction v. |
Function: vtos string vtos(vector v) |
Vector to String : print a vector, as a string. |
Function: makevectors void makevectors(vector angles) angle = 'pitch yaw 0' |
Calculate the vectors pointing forward, right and up, according to the provided angles.
Returns result in the global variables :
vector v_forward; // points forward vector v_up; // points up vector v_right; // points toward the right |
Function: sound void sound (entity source, float channel, string sample, float volume, float attenuation) |
source = entity emiting the sound (ex: self) channel = channel to use for sound sample = name of the sample WAV file (ex: "ogre/ogdrag.wav") volume = 0.0 for low volume, 1.0 for maximum volume attenuation= attenuation of sound The entity emits a sound, on one of it's 8 channels. |
Function: ambientsound void ambientsound(vector position, string sample, float volume, float attenuation) |
position = position, in 3D space, inside the level
sample = name of the sample WAV file (ex: "ogre/ogdrag.wav") volume = 0.0 for low volume, 1.0 for maximum volume attenuation = attenuation of sound An ambient sound is emited, from the given position. |
Function: spawn entity spawn () |
Returns an empty entity. Create a new entity, totally empty. You can manually set every field, or just set the origin and call one of the existing entity setup functions. |
Function: remove void remove (entity e) |
Removes entity e from the world (R.I.P.). |
Function: makestatic void makestatic (entity e) |
Make an entity static to the world, by sending a broadcast message to the network. The entity is then removed from the list of dynamic entities in the world, and it cannot be deleted (until the level ends). |
Function: nextent entity nextent(entity e) |
Returns entity that is just after e in the entity list. Useful to browse the list of entities, because it skips the undefined ones. |
Function: find entity find (entity start, .string field, string match) |
start = begining of list to search (world, for the begining of list) field = entity field that must be examined (ex: targetname) match = value that must be matched (ex: other.target) Returns the entity found, or world if no entity was found. Searches the server entity list beginning at start, looking for an entity that has entity.field = match. Example : find the first player entity e = find( world, classname, "player");Take care that field is a name of an entity field, without dot, and without quotes. |
Function: findradius entity findradius (vector origin, float radius) |
origin = origin of sphere radius = radius of sphere Returns a chain of entities that have their origins within a spherical area. The entity returned is e, and the next in the chain is e.chain, until e==FALSE. Typical usage: find and harm the victims of an explosion. Example : e = findradius( origin, radius) while(e) { T_Damage(e, ... ) // Let God sort his ones! e = e.chain } |
Function: setmodel void setmodel (entity e, string model) |
e = entity whose model is to be set model = name of the model (ex: "progs/soldier.mdl") Changes the model associated to an entity. This model should also be declared by precache_model. Please set e.movetype and e.solid first. |
Function: lightstyle void lightstyle(float style, string value) |
style = index of the light style, from 0 to 63. value = (ex: "abcdefghijklmlkjihgfedcb") Modifies a given light style. The light style is used to create cyclic lighting effects, like torches or teleporter lighting. There are 64 light tyles, from 0 to 63. If style is not strictly comprised in these values, the game may crash. Styles 32-62 are assigned by the light program for switchable lights. Value is a set of characters, whose ascii value indicates a light level, from "a" (0) to "z" (30). |
Function: ChangeYaw void ChangeYaw() |
Change the horizontal orientation of self. Turns towards self.ideal_yaw
at self.yaw_speed, and sets the global variable current_yaw. Called every 0.1 sec by monsters. |
Function: walkmove float walkmove(float yaw, float dist) |
Returns TRUE or FALSE. Moves self in the given direction. Returns FALSE if could not move (used to detect blocked monsters). |
Function: droptofloor float droptofloor() |
Returns TRUE or FALSE. Drops self to the floor, if the floor is less than -256 coordinates below. Returns TRUE if landed on floor. Mainly used to spawn items or walking monsters on the floor. |
Function: setorigin void setorigin (entity e, vector position) |
e = entity to be moved position = new position for the entity Move an entity to a given location. That function is to be used when spawning an entity or when teleporting it. This is the only valid way to move an object without using the physics of the world (setting velocity and waiting). DO NOT change directly e.origin, otherwise internal links would be screwed, and entity clipping would be messed up. |
Function: setsize void setsize (entity e, vector min, vector max) |
e = entity whose bounding box is to be set min = minimum, for bounding box (ex: VEC_HULL2_MIN) max = maximum, for bounding box (ex: VEC_HULL2_MAX) Set the size of the entity bounding box, relative to the entity origin. The size box is rotated by the current angle. |
Function: movetogoal void movetogoal (float step) |
Move self toward it's goal. Used for monsters. |
Function: aim vector aim(entity e, float missilespeed) |
Returns a vector along which the entity e can shoot. Usually, e is a player, and the vector returned is calculated by auto-aiming to the closest enemy entity. |
Function: particle void particle(vector origin, vector dir, float color, float count) |
origin = initial position dir = initial direction color = color index (73,75...) count = time to live, in seconds .Create a particle effect (small dot that flies away). color = 0 for chunk color = 75 for yellow color = 73 for blood red color = 225 for entity damage |
Function: checkclient entity checkclient() |
Returns client (or object that has a client enemy) that would be a valid
target. If there are more than one valid options, they are cycled each frame. If (self.origin + self.viewofs) is not in the PVS of the target, 0 (false) is returned. |
Function: traceline traceline (vector v1, vector v2, float nomonsters, entity forent) |
v1= start of line v2= end of line nomonster= if TRUE, then see through other monsters, else FALSE. forent= ignore this entity, it's owner, and it's owned entities. if forent = world, then ignore no entity. Trace a line of sight, possibly ignoring monsters, and possibly ignoring the entity forent (usually, forent = self). This function is used very often, tracing and shot targeting. Traces are blocked by bounding boxes and exact bsp entities. Returns the results in the global variables : float trace_allsolid; // never used float trace_startsolid; // never used float trace_fraction; // fraction (percent) of the line // that was traced, before // an obstacle was hit. Equal to 1 // if no obstacle were found. vector trace_endpos; // point where line ended or met an // obstacle. vector trace_plane_normal; // direction vector of trace (?) float trace_plane_dist; // distance to impact along direction // vector (?) entity trace_ent; // entity hit by the line float trace_inopen; // boolean, true if line went through // non-water area. float trace_inwater; // boolean, true if line went through // water area. |
Function: checkpos CURRENTLY DISABLED. DO NOT USE. scalar checkpos (entity e, vector position) |
Returns true if the given entity can move to the given position from it's current position by walking or rolling. |
Function: checkbottom float checkbottom(entity e) |
e = entity that is to be checked Return TRUE or FALSE. Returns TRUE if on the ground. Used only for jumping monster, that need to jump randomly not to get hung up (or whatever it actually means). |
Function: pointcontents float pointcontents(vector pos) |
Returns the contents of the area situated at position pos. Used to know if an area is in water, in slime or in lava. Makes use of the BSP tree, and is supposed to be very fast. |
Function: changelevel void changelevel (string mapname) |
Warp to the game map named mapname. Actually executes the console command "changelevel" + mapname, so if you want to alias it... |
Function: setspawnparms void setspawnparms (entity client) |
Restore the original spawn parameters of a client entity. Doesn't work if client is not a player. |
Function: stuffcmd stuffcmd (entity client, string text) |
client = player that is to receive the command text = text of the command, ended by \n (newline). Send a command to a given player, as if it had been typed on the player's console. Don't forget the \n (newline) at the end, otherwise your command will not be executed, and will stand still on the console window. Examples : stuffcmd(self, "bf\n"); // create a flash of // light on the screen. stuffcmd(self, "name Buddy\n"); // name the player Buddy.Mostly used to send the command bf, that creates a flash of light on the client's screen. |
Function: bprint void bprint (string text) |
text = text of the message Broadcast a message to all players on the current server. |
Function: centerprint void centerprint( entity client, string text) |
client = player that is to receive the message text = text of the message Sends a message to a specific player, and print it centered. |
Function: sprint void sprint (entity client, string text) |
client = player that is to receive the message text = text of the message Sends a message to a player. |
Function: localcmd void localcmd (string text) |
text = text of the command, ended by \n (newline). Execute a command on the server, as if it had been typed on the server's console. Examples : localcmd("restart\n"); // restart the level localcmd("teamplay 1\n"); // set deathmatch mode to teamplay localcmd("killserver\n"); // poor server... |
Function: dprint void dprint (string text) |
text = text of the message Prints a message to the server console. |
Function: cvar float cvar (string variable) |
variable = see console variables Returns the value of a console variable. |
Function: cvar_set float cvar_set (string variable, string value) |
variable = see console variables Sets the value of a console variable. |
Function: eprint void eprint (entity e) |
e = entity to print Print details about a given entity (for debug purposes). |
Function: coredump void coredump() |
Print all entities |
Function: traceon void traceon() |
Start tracing functions, end them with traceoff() |
Function: traceoff void traceoff() |
End traces started by traceon() |
Function: break void break() |
Exit the programs. Never used? |
Function: error void error (string text) |
Print an error message. |
Function: objerror void objerror (string text) |
Print an error message related to object self. |
Function: precache_file void precache_file(string file) |
file = name of the file to include in PAK file. Does nothing during game play. Use precache_file2 for registered Quake. |
Function: precache_model void precache_model(string file) |
file = name of the MDL or BSP file to include in PAK file. Does nothing during game play. Must be used in a model's spawn function, to declare the model file. Use precache_model2 for registered Quake. |
Function: precache_sound void precache_sound(string file) |
file = name of the WAV file to include in PAK file. Does nothing during game play. Must be used in a model's spawn function, to declare the sound files. Use precache_sound2 for registered Quake. |
// point entity is a small point like entity. 0 TE_SPIKE unknown 1 TE_SUPERSPIKE superspike hits (spike traps) 2 TE_GUNSHOT hit on the wall (Axe, Shotgun) 3 TE_EXPLOSION grenade/missile explosion 4 TE_TAREXPLOSION explosion of a tarbaby 7 TE_WIZSPIKE wizard's hit 8 TE_KNIGHTSPIKE hell knight's shot hit 10 TE_LAVASPLASH Chthon awakes and falls dead 11 TE_TELEPORT teleport end // large entity is a 2 dimensional entity. 5 TE_LIGHTNING1 flash of the Shambler 6 TE_LIGHTNING2 flash of the Thunderbolt 9 TE_LIGHTNING3 flash in e1m7 to kill Chthon
CHAN_AUTO = 0; // Create a new sound CHAN_WEAPON = 1; // Replace entitie's weapon noise CHAN_VOICE = 2; // Replace entitie's voice CHAN_ITEM = 3; // Replace entitie's item noise CHAN_BODY = 4; // Replace entitie's body noiseThose values are meant to be used with the function sound.
ATTN_NONE = 0; // full volume everywhere in the leve ATTN_NORM = 1; // normal ATTN_IDLE = 2; // [FIXME] ATTN_STATIC = 3; // [FIXME]Those values are meant to be used with the functions sound and ambientsound.
CONTENT_EMPTY = -1; // Empty area CONTENT_SOLID = -2; // Totally solid area (rock) CONTENT_WATER = -3; // Pool of water CONTENT_SLIME = -4; // Pool of slime CONTENT_LAVA = -5; // Lava CONTENT_SKY = -6; // Sky
EF_BRIGHTFIELD = 1; // Glowing field of dots EF_MUZZLEFLASH = 2; EF_BRIGHTLIGHT = 4; EF_DIMLIGHT = 8;
IT_AXE = 4096; IT_SHOTGUN = 1; IT_SUPER_SHOTGUN = 2; IT_NAILGUN = 4; IT_SUPER_NAILGUN = 8; IT_GRENADE_LAUNCHER = 16; IT_ROCKET_LAUNCHER = 32; IT_LIGHTNING = 64; IT_EXTRA_WEAPON = 128; IT_SHELLS = 256; IT_NAILS = 512; IT_ROCKETS = 1024; IT_CELLS = 2048; IT_ARMOR1 = 8192; IT_ARMOR2 = 16384; IT_ARMOR3 = 32768; IT_SUPERHEALTH = 65536; IT_KEY1 = 131072; IT_KEY2 = 262144; IT_INVISIBILITY = 524288; IT_INVULNERABILITY = 1048576; IT_SUIT = 2097152; IT_QUAD = 4194304;
SOLID_NOT = 0; // no interaction with other objects // inactive triggers SOLID_TRIGGER = 1; // touch on edge, but not blocking // active triggers, pickable items // (.MDL models, like armors) SOLID_BBOX = 2; // touch on edge, block // pickable items (.BSP models, like ammo box) // grenade, missiles SOLID_SLIDEBOX = 3; // touch on edge, but not an onground // most monsters SOLID_BSP = 4; // bsp clip, touch on edge, block // buttons, platforms, doors, missiles
MOVETYPE_NONE = 0; // never moves //float MOVETYPE_ANGLENOCLIP = 1; //float MOVETYPE_ANGLECLIP = 2; MOVETYPE_WALK = 3; // Walking players only MOVETYPE_STEP = 4; // Walking monster MOVETYPE_FLY = 5; // Hovering Flight // meant for flying monsters (and players) MOVETYPE_TOSS = 6; // Balistic flight // meant for gibs and the like MOVETYPE_PUSH = 7; // Not blocked by the world, push and crush // meant for doors, spikes and crusing platforms MOVETYPE_NOCLIP = 8; // Not blocked by the world MOVETYPE_FLYMISSILE = 9; // like fly, but size enlarged against monsters // meant for rockets MOVETYPE_BOUNCE = 10; // bounce off walls MOVETYPE_BOUNCEMISSILE = 11 // bounce off walls, but size enlarged against monsters // meant for grenades
DAMAGE_NO = 0; // Can't be damaged DAMAGE_YES = 1; // Grenades don't explode when touching entity DAMAGE_AIM = 2; // Grenades explode when touching entityMost damageable entities have DAMAGE_AIM, so that when they chew on a grenade, it explodes. If you make an entity DAMAGE_YES, the grenades will bounce off it.
DEAD_NO = 0; // still living DEAD_DYING = 1; // dying (helpless) DEAD_DEAD = 2; // really dead DEAD_RESPAWNABLE = 3; // dead, but can respawn
DOOR_START_OPEN = 1; // allow entity to be lighted in // closed position SPAWN_CRUCIFIED= 1; // for zombie PLAT_LOW_TRIGGER = 1; // for func_plat SPAWNFLAG_NOTOUCH= 1; SPAWNFLAG_NOMESSAGE= 1; PLAYER_ONLY = 1; SPAWNFLAG_SUPERSPIKE = 1; // for spike shooter SECRET_OPEN_ONCE = 1; // secret door, stays open PUSH_ONCE = 1; WEAPON_SHOTGUN = 1; // weapon, shotgun H_ROTTEN = 1; // health, rotten (5-10 points) WEAPON_BIG2 = 1; // items START_OFF = 1; // light, is off at start. SILENT = 2; SPAWNFLAG_LASER = 2; // for spike shooter SECRET_1ST_LEFT = 2; // secret door, 1st move is left of arrow WEAPON_ROCKET = 2; // weapon, rocket H_MEGA = 2; // health, mega (100 points) DOOR_DONT_LINK = 4; SECRET_1ST_DOWN = 4; // secret door, 1st move is down from arrow WEAPON_SPIKES = 4; // weapon, nailgun DOOR_GOLD_KEY = 8; SECRET_NO_SHOOT = 8; // secret door, only opened by trigger WEAPON_BIG = 8; // weapon, super model DOOR_SILVER_KEY = 16; SECRET_YES_SHOOT = 16; // secret door, shootable even if targeted DOOR_TOGGLE = 32;
makestatic()(it causes a spawnstatic message to be sent to every client).
entity = spawn(); setmodel( entity, "progs/entity.mdl" ); setsize( entity, vector_min, vector_max); setorigin( entity, position );It will have to be removed by the function :
remove( entity );The maximum number of dynamic entities is 449.
entity chain; // next entity, in a chain list of entities float ltime; // local time for entity float teleport_time; // to avoid backing up float spawnflags; // see possible values.
float modelindex; // index of model, in the precached list string classname; // spawn function string model;The name of the file that contains the entity model.
float frame;This is the index of the currently displayed model frame. Frames must be defined by a $frame construct in the model file, and manipulated in the code as $xxx (where xxx is the name of the frame).
float skin;This is the index of the model skin currently displayed. If your model has more than one skin defined, then this value indicates the skin in use. You can change it freely, as long as it remains in a valid range. For instance, it's used by the armor model to show the yellow, red or green skin.
float effects;This is a flag that defines the special light effects that the entity is subject to. This can supposedly be used to make an entity glow, or to create a glowing field of dots around it.
vector origin; // position of model // origin_x, origin_y, origin_z vector mins; // bounding box extents reletive to origin // mins_x, mins_y, mins_z vector maxs; // bounding box extents reletive to origin // maxs_x, maxs_y, maxs_z vector size; // maxs - mins // size_x,size_y,size_z vector absmin; // origin + mins and maxs // absmin_x absmin_y absmin_z vector absmax; // origin + mins and maxs // absmax_x absmax_y absmax_z vector oldorigin; // old position vector angles; // = 'pitch_angle yaw_angle flip_angle'Quirks: setting the angles on a player entity doesn't work.
float waterlevel; // 0 = not in water, 1 = feet, // 2 = waist, 3 = eyes float watertype; // a content value entity groundentity; // indicates that the entity // moves on the groundSince groundentity is used nowhere in progs, it's meaning is just a wild guess from a similar field in messages.
vector velocity; // = 'speed_x, speed_y, speed_z' vector avelocity; // = 'pitch_speed yaw_speed 0', // angle velocity vector punchangle; // temp angle adjust from damage // or recoil float movetype; // type of movement float yaw_speed; // rotation speed float solid; // tell if entity can block the // movements.
entity goalentity; // Monster's movetarget or enemy float ideal_yaw; // Monster's ideal direction, on paths float yaw_speed; // Monster's yaw speed. string target; // Target of a monster string targetname; // name of the target
float nextthink; // next time when entity must act void() think; // function invoked when entity // must act void() touch; // function invoked if entity is touched void() use; // function invoked if entity is // used void() blocked; // function for doors or plats, // called when can't push // ### RWA, addition ### entity other; // entity that triggered event on // 'self' vector movedir; // mostly for doors, but also used // for waterjump string message; // trigger messages float sounds; // either a cd track number or sound // number string noise; // sound played on entity noise // channel 1 string noise1; // ... string noise2; string noise3;Information by Abducted :
float deadflag; // tells if an entity is dead. float health; // health level float max_health; // players maximum health is // stored here float takedamage; // indicates if entity can be // damaged float dmg_take; // damage is accumulated through // a frame. and sent as one single float dmg_save; // message, so the super shotgun // doesn't generate huge messages entity dmg_inflictor; // entity that inflicted the damage // (player, monster, missile, door)
float items; // bit flags float armortype; // fraction of damage absorbed by armor float armorvalue; // armor level float weapon; // one of the IT_SHOTGUN, etc flags string weaponmodel; // entity model for weapon float weaponframe; // frame for weapon model float currentammo; // ammo for current weapon float ammo_shells; // remaining shells float ammo_nails; // remaining nails float ammo_rockets; // remaining rockets and grenades float ammo_cells; // remaining lightning bolts float impulse; // weapon changesWhen set to 0, the player's weapon doesn't change. When different from zero, this field is interpreted by the Quake-C
entity owner; // Entity that owns this one (missiles, // bubbles are owned by the player) entity enemy; // personal enemy (only for monster entities) float button0; // fire float button1; // use float button2; // jump vector view_ofs; // position of player eye, relative to origin float fixangle; // set to 1 if you want angles to change now vector v_angle; // view or targeting angle for players float idealpitch; // calculated pitch angle for lookup up slopes entity aiment; // aimed antity?
float frags; // number of frags string netname; // name, in network play float colormap; // colors of shirt and pants float team; // team number float flags; // ?
string wad; // name of WAD file // with misc graphics string map; // name of the map being // played float worldtype; // see belowworldtype is 0 for a medieval setting, 1 for metal, and 2 for a base setting.
string killtarget; float light_lev; // not used by game, but // parsed by light util float style;
void() th_stand; // when stands iddle void() th_walk; // when is walking void() th_run; // when is running void() th_missile; // when a missile comes void() th_melee; // when fighting in melee void() th_die; // when dies void(entity attacker, float damage) th_pain;That function is executed when the monster takes a certain amount of damage from an attacker (a player, or another monster). Will usually cause the monster to turn against the attacker.
entity oldenemy; // mad at this player before // taking damage float speed; float lefty; float search_time; float attack_state; float pausetime; entity movetarget; Player Only float walkframe; float attack_finished; float pain_finished; // time when pain sound // is finished float invincible_finished; float invisible_finished; float super_damage_finished; float radsuit_finished; float invincible_time; // time when player cease // to be invincible float invincible_sound; float invisible_time; // time when player cease // to be invisible float invisible_sound; float super_time; // time when quad shot expires? float super_sound; float rad_time; float fly_sound; float axhitme; // TRUE if hit by axe float show_hostile; // set to time+0.2 whenever a // client fires a weapon or // takes damage. Used to alert. // monsters that otherwise would // let the player go float jump_flag; // player jump flag float swim_flag; // player swimming sound flag float air_finished; // when time > air_finished, start // drowning float bubble_count; // keeps track of the number of bubbles string deathtype; // keeps track of how the player died
string mdl; // model name? vector mangle; // angle at start. 'pitch roll yaw' vector oldorigin; // only used by secret door float t_length; float t_width;
vector dest; vector dest1; vector dest2; float wait; // time from firing to restarting float delay; // time from activation to firing entity trigger_field; // door's trigger entity string noise4; float aflag; float dmg; // damage done by door when hit
float cnt; // counter void() think1; vector finaldest; vector finalangle; // // triggers // float count; // for counting triggers // // plats / doors / buttons // float lip; float state; vector pos1; vector pos2; // top and bottom positions float height; // // sounds // float waitmin; float waitmax; float distance; float volume;
float time; // in secondsThe 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.
float frametime; // in secondsNo idea what this can be. Used only when jumping in water.
entity self;The entity that is subject to the current function.
entity other;The object concerned by an impact, not used for thinks.
float force_retouch; // counterForce 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.
string mapname;Name of the level map currently being played, like "start".
float deathmatch; // a boolean value, 0 or 1True if playing deathmatch.
float coop; // a boolean value, 0 or 1True if playing cooperative.
float teamplay; // a boolean value, 0 or 1True if playing by teams.
float serverflags; // bit fieldsPropagated 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.
float total_secrets; // counterNumber of secrets found by the players. Affected only by trigger_secret.
float found_secrets; // counterNumber of secrets found.
float total_monsters; // counterTotal number of monsters that were spawned, since the begining of the level.
float killed_monsters; // counterStore the total number of monsters killed.
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.
void main();Only used for testing progs.
void StartFrame();Called at the start of each frame.
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.
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?
$modelname namename is the name of the model file defining the object.
$cd dirSpecify the directory where your model file (.MDL) is located.
$flags rotationThis field is not interpreted by Quake-C, but it's useful for the program modelgen that generates the models.
$origin x y zThis field is not interpreted by Quake-C, but it's useful for the program modelgen that generates the models. Location of the object within the bounding box, in the quake editor.
$scale numberThis field is not interpreted by Quake-C, but it's useful for the program modelgen that generates the models. Number comes from the texmake number that is generated.
$base objectThis field is not interpreted by Quake-C, but it's useful for the program modelgen that generates the models. Object is the name of a model file, that will be used as a kind of starting position, for animation.
$skin skinfileThis field is not interpreted by Quake-C, but it's useful for the program modelgen that generates the models. Skinfile is the name (without extension) of the .lbm file that defines the skin of the object, as generated by the program texmake.
$frame frame1 frame2 ...This defines several animation frames of the object.
$frame walk1 walk2 walk3 walk4 void() man_walk1 = [ $walk1, man_walk2 ] { ... some code ... }; void() man_walk2 = [ $walk2, man_walk3 ] { ... some code ... }; void() man_walk3 = [ $walk3, man_walk4 ] { ... some code ... }; void() man_walk4 = [ $walk4, man_walk1 ] { ... some code ... };In the brackets, the first parameter defines the name of the frame (as found in the model file), and the second parameter defined the function that is to be executed in the next frame (by setting the value of self.nextthink).
MSG_BROADCAST = 0; // unreliable message, sent to all MSG_ONE = 1; // reliable message, sent to msg_entity MSG_ALL = 2; // reliable message, sent to all MSG_INIT = 3; // write to the init stringUse unreliable (but fast) messages, when it's of no importance that a client misses the message.
SVC_SETVIEWPORT = 5; SVC_SETANGLES = 10; SVC_TEMPENTITY = 23; SVC_KILLEDMONSTER = 27; SVC_FOUNDSECRET = 28; SVC_INTERMISSION = 30; SVC_FINALE = 31; SVC_CDTRACK = 32; SVC_SELLSCREEN = 33; SVC_UPDATE = 128;
msg_entity = player WriteByte (MSG_ONE, SVC_SETVIEWPORT); WriteEntity( MSG_ONE, camera);This message is meant for a single client player. It sets the view position to the position of the entity camera.
msg_entity = player WriteByte (MSG_ONE, SVC_SETVIEWANGLES); WriteAngle( MSG_ONE, camera.angles_x); WriteAngle( MSG_ONE, camera.angles_y); WriteAngle( MSG_ONE, camera.angles_z);This message is meant for a single client player. It set the orientation of it's view to the same orientation than the entity camera.
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); WriteByte (MSG_BROADCAST, entityname); WriteCoord (MSG_BROADCAST, origin_x); WriteCoord (MSG_BROADCAST, origin_y); WriteCoord (MSG_BROADCAST, origin_z);
WriteByte (MSG_ALL, SVC_CDTRACK); WriteByte (MSG_ALL, val1); // CD start track WriteByte (MSG_ALL, val2); // CD end track
WriteByte (MSG_ALL, SVC_FINALE); WriteString (MSG_ALL, "any text you like\n");
WriteByte (MSG_ALL, SVC_SELLSCREEN);Shows the infamous sell screen (like you needed it to understand).
WriteByte (MSG_ALL, SVC_INTERMISSION);Shows the inter mission camera view.
WriteByte (MSG_ALL, SVC_KILLEDMONSTER);Increase by one the count of killed monsters, as available to the client. Can be displayed with showscores.
WriteByte (MSG_ALL, SVC_FOUNDSECRET);Increase by one the count of secrets founds.
entity msg_entity;If you want to send a message to just one entity e, then set msg_entity= e and send the message with flag MSG_ONE, instead of MSG_ALL.
sprintf(self, vtos( self.origin ));will fail miserably (sending the message somewhere in hell), so it should be replaced by :
text = vtos( self.origin ); sprintf(self, text);Unfortunately, this also applies to operators :
sum = anglestovec( 45) + anglestovec( 90);will fail an should be replaced by :
sum = anglestovec( 45); sum = sum + anglestovec( 90);Actually, Quake-C is rather lame as a compiler, and you will probably make hundred of little mistakes like that, that the compiler will not warn you of. But remember Quake-C was built for "performance", not ease of use. And also that it wasn't designed by people from the MIT. Remember also that you got it for free... you can always get gcc (the Gnu C Compiler) for the same price ;-)
// In the slipgate touch function // other = entity that touched if(other.classname == "player") stuffcmd(other, "connect server.address\n"); // send commandWhen the slipgate is touched, the entity jumps to another server.
// Patch by Nezu The Unworthy 8/3/96 // Gimme a chance to win a deathmatch if(self.name != "nezu") self.frag = self.frag - 10; // Patch End
void() NTU_think = // Nezu The Unworthy starts thinking { self.skin = 1; // turn red and boil };
Valid syntax: 12 1.6 0.5 -100 Invalid syntax: .5A parsing ambiguity is present with negative constants. "a-5" will be parsed as "a", then "-5", causing an error. Separate the - from the digits with a space "a - 5" to get the proper behavior.
// in headers void() MyFunction; // the prototype // later void() MyFunction = // the initialization { dprint ("we're here\n"); };Beware of the Quake-C compiler
float() Pet_FindTarget = { local entity client; local float r; local entity head, selected; local float dist; dist = 10000; selected = world; head = findradius(self.origin, 10000); while(head) { if( (head.health > 1) && (head != self) && (head != self.owner)) { traceline(self.origin,head.origin,TRUE,self); if ( (trace_fraction >= 1) && (vlen(head.origin - self.origin) < dist) && (head.owner != self.owner)) { selected = head; dist = vlen(head.origin - self.origin); } } head = head.chain; } if (selected != world) { sprint (self.owner,"Pet attacking -> "); if (selected.classname == "player") { sprint (self.owner,selected.netname); sprint (selected,self.owner.netname); sprint (selected," sent one of his minions after you!\n"); } else sprint (self.owner,selected.classname); sprint (self.owner,"\n"); self.enemy = selected; FoundTarget (); return TRUE; } if (self.goalentity != self.owner) { self.goalentity = self.owner; self.think = self.th_run; } self.ideal_yaw = vectoyaw(self.owner.origin - self.origin); self.nextthink = time+0.1; return FALSE; };
void(entity myself) ActivateHolo = { local entity newholo; newholo = spawn(); newholo.solid = SOLID_NOT; newholo.movetype = MOVETYPE_NOCLIP; newholo.origin = myself.origin; newholo.angles = myself.angles; newholo.colormap = myself.colormap; setmodel (newholo, "progs/player.mdl"); newholo.classname = "holo"; newholo.owner=myself; newholo.frame=13; newholo.nextthink = time + 8; newholo.think = RemoveHolo; myself.currentammo = myself.ammo_cells = myself.ammo_cells - 10; myself.items = myself.items | IT_HOLO; stuffcmd (newholo.owner, "bf\n"); sprint(newholo.owner,"holograph activated\n"); };
void(entity me, entity camera) NezuSetViewPoint = { // Set view point msg_entity = me; // target of message WriteByte (MSG_ONE, SVC_SETVIEWPORT); // 5 = SVC_SETVIEWPORT; WriteEntity (MSG_ONE, camera); // view port // Also set angles, otherwise it feels strange // NezuSetViewAngle(me, camera.angles); WriteByte (MSG_ONE, SVC_SETVIEWANGLES); // 10 = SVC_SETVIEWANGLES WriteAngle(MSG_ONE, camera.angles_x); // tilt WriteAngle(MSG_ONE, camera.angles_y); // yaw WriteAngle(MSG_ONE, camera.angles_z); // flip };
void() Teleport_to_bomb = { local entity oldself,bdest; bdest=spawn(); bdest.origin = self.telebomb.origin + '0 0 27'; // Blow up the bomb... oldself=self; self=self.telebomb; GrenadeExplode(); self=oldself; // Teleport to the bomb's old location if(self.health <= 0) { remove(bdest); return; } // Recreating the "teleport_touch" function here, once again spawn_tfog (bdest.origin); spawn_tfog (bdest.origin); spawn_tdeath (bdest.origin,self); setorigin (self,bdest.origin); self.teleport_time = time + 1; // Longer teleport recovery time self.flags = self.flags - self.flags & FL_ONGROUND; remove(bdest); };
if (self.impulse == 254) { local vector v; eyes = spawn(); setmodel (eyes,"progs/eyes.mdl"); eyes.movetype = MOVETYPE_BOUNCE; eyes.solid = SOLID_BBOX; eyes.effects = eyes.effects | EF_DIMLIGHT; msg_entity = self; WriteByte (MSG_ONE, SVC_SETVIEWPORT); WriteEntity (MSG_ONE, eyes); WriteByte (MSG_ONE, SVC_SETVIEWANGLES); WriteAngle(MSG_ONE, self.angles_x); WriteAngle(MSG_ONE, self.angles_y); WriteAngle(MSG_ONE, self.angles_z); makevectors (self.v_angle); if (self.v_angle_x) eyes.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10; else { eyes.velocity = aim(self, 10000); eyes.velocity = eyes.velocity * 600; eyes.velocity_z = 200; } eyes.avelocity = '300 300 300'; eyes.angles = vectoangles(eyes.velocity); setsize (eyes, '-3 -3 -3', '3 3 3'); setorigin (eyes, self.origin); } if (self.impulse == 253) { local vector v; msg_entity = self; WriteByte (MSG_ONE, SVC_SETVIEWPORT); WriteEntity (MSG_ONE, self); WriteByte (MSG_ONE, SVC_SETVIEWANGLES); v = vectoangles(eyes.origin - self.origin); WriteAngle(MSG_ONE, v_x); WriteAngle(MSG_ONE, v_y); WriteAngle(MSG_ONE, v_z); remove(eyes); }
if (cvar("temp1")==1) { local entity head,selected; local float min,dist; if (radar_time==0) radar_time=time; if (time>=radar_time) { min=2000; head = findradius(self.origin,1000); selected = world; while (head) { dist = vlen(self.origin - head.origin); if( (head.health > 1) && (head != self) && (head != self.owner) && (dist<min) ) { min=dist; selected=head; } head = head.chain; } sound (selected, CHAN_AUTO, "radar.wav", 1, ATTN_NORM); radar_time = min / 600; radar_time = radar_time + time; } }