//
// DP (and eventually RMQ Engine) extensions used by RMQ
//

//checkextension function
//idea: expected by almost everyone
//darkplaces implementation: LordHavoc
float(string s) checkextension = #99;
//description:
//check if (cvar("pr_checkextension")) before calling this, this is the only
//guaranteed extension to be present in the extension system, it allows you
//to check if an extension is available, by name, to check for an extension
//use code like this:
//// (it is recommended this code be placed in worldspawn or a worldspawn called function somewhere)
//if (cvar("pr_checkextension"))
//if (checkextension("DP_SV_SETCOLOR"))
//	ext_setcolor = TRUE;
//from then on you can check ext_setcolor to know if that extension is available

//RMQ_TE_EXTENSIONS
//idea: RMQ Project
//builtin definitions:
float() getrmqeffectsversion	= #666;	// returns the available TE_RMQ_* container version
//network messages:
float	TE_RMQ_EFFECT			= 255;	// invokes the TE_RMQ_* container, you must follow this with a WriteByte of one of the following effects:
// version one effects
float	TE_RMQ_RAILTRAIL		= 0;	// Q2 style spiral railtrail, [vector] start [vector] end [byte] corecolour [byte] spiralcolour
// version two effects
float	TE_RMQ_EXPLOSION		= 1;	// TE_EXPLOSION without a sound, [vector] origin
float	TE_RMQ_DLIGHT			= 2;	// Custom fixed-in-place light, [vector] origin [short] radius [float] lifetime [short] decay [short] red [short] green [short] blue
//description:
//expandable TE_ container message, use getrmqeffectsversion to find what effects are available - each version is a superset of the previous versions, so version two is expected to support version one effects as well
//to use, start a manual network message with TE_RMQ_EFFECT and continue the message with a WriteByte of an available TE_RMQ_* message, each TE_RMQ_* effect will also require additional Write* calls to complete the message like with any other manual TE_ message
/*
	Usage examples:
	
	TE_RMQ_RAILTRAIL:
	
	WriteByte	(MSG_BROADCAST, SVC_TEMPENTITY		);
	WriteByte	(MSG_BROADCAST, TE_RMQ_EFFECT		);
	WriteByte	(MSG_BROADCAST, TE_RMQ_RAILTRAIL	);
	WriteCoord	(MSG_BROADCAST, start_x				);
	WriteCoord	(MSG_BROADCAST, start_y				);
	WriteCoord	(MSG_BROADCAST, start_z				);
	WriteCoord	(MSG_BROADCAST, end_x				);
	WriteCoord	(MSG_BROADCAST, end_y				);
	WriteCoord	(MSG_BROADCAST, end_z				);
	WriteByte	(MSG_BROADCAST, corecolor			);
	WriteByte	(MSG_BROADCAST, spiralcolor			);
	
	TE_RMQ_DLIGHT:
		
	WriteByte	(MSG_BROADCAST, SVC_TEMPENTITY		);
	WriteByte	(MSG_BROADCAST, TE_RMQ_EFFECT		);
	WriteByte	(MSG_BROADCAST, TE_RMQ_DLIGHT		);
	WriteCoord	(MSG_BROADCAST, self.origin_x		);
	WriteCoord	(MSG_BROADCAST, self.origin_y		);
	WriteCoord	(MSG_BROADCAST, self.origin_z		);
	WriteShort	(MSG_BROADCAST, radius				); // e.g. 350
	WriteFloat	(MSG_BROADCAST, die					); // e.g. 0.5, time from now when the dl dies
	WriteShort	(MSG_BROADCAST, decay				); // e.g. 300
	WriteShort	(MSG_BROADCAST, red					); // 0-255 scale, can go over 255 if you like
	WriteShort	(MSG_BROADCAST, green				); // 0-255 scale, can go over 255 if you like
	WriteShort	(MSG_BROADCAST, blue				); // 0-255 scale, can go over 255 if you like
*/

//DP_ENT_ALPHA
//idea: Nehahra
//darkplaces implementation: LordHavoc
//fields:
.float alpha;
//description:
//controls opacity of the entity, 0.0 is forced to be 1.0 (otherwise everything would be invisible), use -1 if you want to make something invisible, 1.0 is solid (like normal).

//DP_ENT_SCALE
//idea: LordHavoc
//darkplaces implementation: LordHavoc
//field definitions:
.float scale;
//description:
//controls rendering scale of the object, 0 is forced to be 1, darkplaces uses 1/16th accuracy and a limit of 15.9375, can be used to make an object larger or smaller.

//DP_QC_RANDOMVEC
//idea: LordHavoc
//darkplaces implementation: LordHavoc
//builtin definitions (actual declarations are in mathlib.qc):
//vector() randomvec = #91;
//description:
//returns a vector of length < 1, much quicker version of this QC: do {v_x = random()*2-1;v_y = random()*2-1;v_z = random()*2-1;} while(vlen(v) > 1)

//DP_QC_SINCOSSQRTPOW
//idea: id Software, LordHavoc
//darkplaces implementation: id Software, LordHavoc
//builtin definitions (actual declarations are in mathlib.qc):
//float(float val) sin = #60;
//float(float val) cos = #61;
//float(float val) sqrt = #62;
//float(float a, float b) pow = #97;
//description:
//useful math functions, sine of val, cosine of val, square root of val, and raise a to power b, respectively.
//Additional notes by LA:
//Note that the builtins of sin and cos expect the angle to be in radians, not degrees.
//mathlib.qc uses a wrapper function to make these functions expect degrees (as most mortals here would expect).

//DP_QC_COPYENTITY
//idea: LordHavoc
//darkplaces implementation: LordHavoc
//builtin definitions:
void(entity from, entity to) copyentity = #400;
//description:
//copies all data in the entity to another entity.

//DP_QC_TRACEBOX
//idea: id Software
//darkplaces implementation: id Software
//builtin definitions:
void(vector v1, vector min, vector max, vector v2, float nomonsters, entity forent) tracebox = #90;
//description:
//similar to traceline but much more useful, traces a box of the size specified (technical note: in quake1 and halflife bsp maps the mins and maxs will be rounded up to one of the hull sizes, quake3 bsp does not have this problem, this is the case with normal moving entities as well).

// gb, the following just copied from dpmod so far, see func_rain in misc.qc

//DP_TE_PARTICLERAIN
//idea: LordHavoc
//darkplaces implementation: LordHavoc
//builtin definitions:
void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlerain = #409;
//temp entity definitions:
//float TE_PARTICLERAIN = 55;
//protocol:
//vector mins (minimum corner of the cube)
//vector maxs (maximum corner of the cube)
//vector velocity (velocity of particles)
//short count (number of particles)
//byte color (8bit palette color)
//description:
//creates a shower of rain, the rain will appear either at the top (if falling down) or bottom (if falling up) of the cube.

//DP_TE_PARTICLESNOW
//idea: LordHavoc
//darkplaces implementation: LordHavoc
//builtin definitions:
void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlesnow = #410;
//temp entity definitions:
//float TE_PARTICLERAIN = 56;
//protocol:
//vector mins (minimum corner of the cube)
//vector maxs (maximum corner of the cube)
//vector velocity (velocity of particles)
//short count (number of particles)
//byte color (8bit palette color)
//description:
//creates a shower of snow, the snow will appear either at the top (if falling down) or bottom (if falling up) of the cube, low velocities are advisable for convincing snow.



//DP_QC_STRFTIME
//idea: LordHavoc
//darkplaces implementation: LordHavoc
//builtin definitions:
string(float uselocaltime, string format, ...) strftime = #478;
//description:
//provides the ability to get the local (in your timezone) or world (Universal Coordinated Time) time as a string using the formatting of your choice:
//example: "%Y-%m-%d %H:%M:%S"   (result looks like: 2007-02-08 01:03:15)
//note: "%F %T" gives the same result as "%Y-%m-%d %H:%M:%S" (ISO 8601 date format and 24-hour time)
//for more format codes please do a web search for strftime 3 and you should find the man(3) pages for this standard C function.
//
//practical uses:
//changing day/night cycle (shops closing, monsters going on the prowl) in an RPG, for this you probably want to use s = strftime(TRUE, "%H");hour = stof(s);
//printing current date/time for competitive multiplayer games, such as the beginning/end of each round in real world time.
//activating eastereggs in singleplayer games on certain dates.
//
//note: some codes such as %x and %X use your locale settings and thus may not make sense to international users, it is not advisable to use these as the server and clients may be in different countries.
//note: if you display local time to a player, it would be a good idea to note whether it is local time using a string like "%F %T (local)", and otherwise use "%F %T (UTC)".
//note: be aware that if the game is saved and reloaded a week later the date and time will be different, so if activating eastereggs in a singleplayer game or something you may want to only check when a level is loaded and then keep the same easteregg state throughout the level so that the easteregg does not deactivate when reloading from a savegame (also be aware that precaches should not depend on such date/time code because reloading a savegame often scrambles the precaches if so!).
//note: this function can return a NULL string (you can check for it with if (!s)) if the localtime/gmtime functions returned NULL in the engine code, such as if those functions don't work on this platform (consoles perhaps?), so be aware that this may return nothing.

//DP_SV_CLIENTCAMERA
//idea: LordHavoc, others
//darkplaces implementation: Black
//field definitions:
.entity clientcamera; // override camera entity
//description:
//allows another entity to be the camera for a client, for example a remote camera, this is similar to sending svc_setview manually except that it also changes the network culling appropriately.
