-
//DarkPlaces supported extension list, draft version 1.04
//things that don't have extensions yet:
//definitions that id Software left out:
//these are passed as the 'nomonsters' parameter to traceline/tracebox (yes really this was supported in all quake engines, nomonsters is misnamed)
-float MOVE_NORMAL = 0; // same as FALSE
-float MOVE_NOMONSTERS = 1; // same as TRUE
+float MOVE_NORMAL = 0; // same as false
+float MOVE_NOMONSTERS = 1; // same as true
float MOVE_MISSILE = 2; // save as movement with .movetype == MOVETYPE_FLYMISSILE
//checkextension function
//// (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;
+// ext_setcolor = true;
//from then on you can check ext_setcolor to know if that extension is available
//BX_WAL_SUPPORT
//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);
+//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.
//
//field definitions:
.float() customizeentityforclient; // self = this entity, other = client entity
//description:
-//allows qc to modify an entity before it is sent to each client, the function returns TRUE if it should send, FALSE if it should not, and is fully capable of editing the entity's fields, this allows cloaked players to appear less transparent to their teammates, navigation markers to only show to their team, etc
+//allows qc to modify an entity before it is sent to each client, the function returns true if it should send, false if it should not, and is fully capable of editing the entity's fields, this allows cloaked players to appear less transparent to their teammates, navigation markers to only show to their team, etc
//tips on writing customize functions:
-//it is a good idea to return FALSE early in the function if possible to reduce cpu usage, because this function may be called many thousands of times per frame if there are many customized entities on a 64+ player server.
+//it is a good idea to return false early in the function if possible to reduce cpu usage, because this function may be called many thousands of times per frame if there are many customized entities on a 64+ player server.
//you are free to change anything in self, but please do not change any other entities (the results may be very inconsistent).
//example ideas for use of this extension:
//making icons over teammates' heads which are only visible to teammates. for exasmple: float() playericon_customizeentityforclient = {return self.owner.team == other.team;};
-//making cloaked players more visible to their teammates than their enemies. for example: float() player_customizeentityforclient = {if (self.items & IT_CLOAKING) {if (self.team == other.team) self.alpha = 0.6;else self.alpha = 0.1;} return TRUE;};
+//making cloaked players more visible to their teammates than their enemies. for example: float() player_customizeentityforclient = {if (self.items & IT_CLOAKING) {if (self.team == other.team) self.alpha = 0.6;else self.alpha = 0.1;} return true;};
//making explosion models that face the viewer (does not work well with chase_active). for example: float() explosion_customizeentityforclient = {self.angles = vectoangles(other.origin + other.view_ofs - self.origin);self.angles_x = 0 - self.angles_x;};
//implementation notes:
//entity customization is done before per-client culling (visibility for instance) because the entity may be doing setorigin to display itself in different locations on different clients, may be altering its .modelindex, .effects and other fields important to culling, so customized entities increase cpu usage (non-customized entities can use all the early culling they want however, as they are not changing on a per client basis).
//vector velocity
//short count
//byte color (palette color)
-//byte gravity (TRUE or FALSE, FIXME should this be a scaler instead?)
+//byte gravity (true or false, FIXME should this be a scaler instead?)
//coord randomvel (how much to jitter the velocity)
//description:
//creates a cloud of particles, useful for forcefields but quite customizable.
//"leftarm" (which is a child of "torso") which would return 2 instead...
float(float skel, float bonenum, string g1, string g2, string g3, string g4, string g5, string g6) example_skel_findbonegroup =
{
- local string bonename;
while (bonenum >= 0)
{
- bonename = skel_get_bonename(skel, bonenum);
+ string bonename = skel_get_bonename(skel, bonenum);
if (bonename == g1) return 1;
if (bonename == g2) return 2;
if (bonename == g3) return 3;
// apply a different framegroup animation to bones with a specified parent
void(float animmodelindex, float framegroup, float framegroupstarttime, float blendalpha, string groupbonename, string excludegroupname1, string excludegroupname2) example_skel_player_update_applyoverride =
{
- local float bonenum;
- local float numbones;
self.frame = framegroup;
self.frame2 = 0;
self.frame3 = 0;
self.lerpfrac = 0;
self.lerpfrac3 = 0;
self.lerpfrac4 = 0;
- bonenum = 0;
- numbones = skel_get_numbones(self.skeletonindex);
+ float bonenum = 0;
+ float numbones = skel_get_numbones(self.skeletonindex);
while (bonenum < numbones)
{
if (example_skel_findbonegroup(self.skeletonindex, bonenum, groupbonename, excludegroupname1, excludegroupname2, "", "", "") == 1)
// make eyes point at a target location, be sure v_forward, v_right, v_up are set correctly before calling
void(vector eyetarget, string bonename) example_skel_player_update_eyetarget =
{
- local float bonenum;
- local vector ang;
- local vector oldforward, oldright, oldup;
- local vector relforward, relright, relup, relorg;
- local vector boneforward, boneright, boneup, boneorg;
- local vector parentforward, parentright, parentup, parentorg;
- local vector u, v;
- local vector modeleyetarget;
- bonenum = skel_find_bone(self.skeletonindex, bonename) - 1;
+ float bonenum = skel_find_bone(self.skeletonindex, bonename) - 1;
if (bonenum < 0)
return;
- oldforward = v_forward;
- oldright = v_right;
- oldup = v_up;
- v = eyetarget - self.origin;
+ vector oldforward = v_forward;
+ vector oldright = v_right;
+ vector oldup = v_up;
+ vector v = eyetarget - self.origin;
+ vector modeleyetarget;
modeleyetarget_x = v * v_forward;
modeleyetarget_y = 0-v * v_right;
modeleyetarget_z = v * v_up;
// this is an eyeball, make it point at the target location
// first get all the data we can...
- relorg = skel_get_bonerel(self.skeletonindex, bonenum);
- relforward = v_forward;
- relright = v_right;
- relup = v_up;
- boneorg = skel_get_boneabs(self.skeletonindex, bonenum);
- boneforward = v_forward;
- boneright = v_right;
- boneup = v_up;
- parentorg = skel_get_boneabs(self.skeletonindex, skel_get_boneparent(self.skeletonindex, bonenum));
- parentforward = v_forward;
- parentright = v_right;
- parentup = v_up;
+ vector relorg = skel_get_bonerel(self.skeletonindex, bonenum);
+ vector relforward = v_forward;
+ vector relright = v_right;
+ vector relup = v_up;
+ vector boneorg = skel_get_boneabs(self.skeletonindex, bonenum);
+ vector boneforward = v_forward;
+ vector boneright = v_right;
+ vector boneup = v_up;
+ vector parentorg = skel_get_boneabs(self.skeletonindex, skel_get_boneparent(self.skeletonindex, bonenum));
+ vector parentforward = v_forward;
+ vector parentright = v_right;
+ vector parentup = v_up;
// get the vector from the eyeball to the target
- u = modeleyetarget - boneorg;
+ vector u = modeleyetarget - boneorg;
// now transform it inversely by the parent matrix to produce new rel vectors
v_x = u * parentforward;
v_y = u * parentright;
v_z = u * parentup;
- ang = vectoangles2(v, relup);
- ang_x = 0 - ang_x;
+ vector ang = vectoangles2(v, relup);
+ ang_x = 0 - ang.x;
makevectors(ang);
// set the relative bone matrix
skel_set_bone(self.skeletonindex, bonenum, relorg);
//idea: many
//darkplaces implementation: KrimZon
//builtin definitions:
-float(string str, string sub, float startpos) strstrofs = #221; // returns the offset into a string of the matching text, or -1 if not found, case sensitive
+int(string str, string sub, float startpos) strstrofs = #221; // returns the offset into a string of the matching text, or -1 if not found, case sensitive
float(string str, float ofs) str2chr = #222; // returns the character at the specified offset as an integer, or 0 if an invalid index, or byte value - 256 if the engine supports UTF8 and the byte is part of an extended character
string(float c, ...) chr2str = #223; // returns a string representing the character given, if the engine supports UTF8 this may be a multi-byte sequence (length may be more than 1) for characters over 127.
string(float ccase, float calpha, float cnum, string s, ...) strconv = #224; // reformat a string with special color characters in the font, DO NOT USE THIS ON UTF8 ENGINES (if you are lucky they will emit ^4 and such color codes instead), the parameter values are 0=same/1=lower/2=upper for ccase, 0=same/1=white/2=red/5=alternate/6=alternate-alternate for redalpha, 0=same/1=white/2=red/3=redspecial/4=whitespecial/5=alternate/6=alternate-alternate for rednum.