-prvm_builtin_t vm_cl_builtins[] = {
-0, // to be consistent with the old vm
-VM_CL_makevectors, // #1 void(vector ang) makevectors
-VM_CL_setorigin, // #2 void(entity e, vector o) setorigin
-VM_CL_setmodel, // #3 void(entity e, string m) setmodel
-VM_CL_setsize, // #4 void(entity e, vector min, vector max) setsize
-0,
-VM_break, // #6 void() break
-VM_random, // #7 float() random
-VM_CL_sound, // #8 void(entity e, float chan, string samp) sound
-VM_normalize, // #9 vector(vector v) normalize
-VM_error, // #10 void(string e) error
-VM_objerror, // #11 void(string e) objerror
-VM_vlen, // #12 float(vector v) vlen
-VM_vectoyaw, // #13 float(vector v) vectoyaw
-VM_CL_spawn, // #14 entity() spawn
-VM_remove, // #15 void(entity e) remove
-VM_CL_traceline, // #16 float(vector v1, vector v2, float tryents) traceline
-0,
-VM_find, // #18 entity(entity start, .string fld, string match) find
-VM_CL_precache_sound, // #19 void(string s) precache_sound
-VM_CL_precache_model, // #20 void(string s) precache_model
-0,
-VM_CL_findradius, // #22 entity(vector org, float rad) findradius
-0,
-0,
-VM_dprint, // #25 void(string s) dprint
-VM_ftos, // #26 void(string s) ftos
-VM_vtos, // #27 void(string s) vtos
-VM_coredump, // #28 void() coredump
-VM_traceon, // #29 void() traceon
-VM_traceoff, // #30 void() traceoff
-VM_eprint, // #31 void(entity e) eprint
-0,
-NULL, // #33
-VM_CL_droptofloor, // #34 float() droptofloor
-VM_CL_lightstyle, // #35 void(float style, string value) lightstyle
-VM_rint, // #36 float(float v) rint
-VM_floor, // #37 float(float v) floor
-VM_ceil, // #38 float(float v) ceil
-NULL, // #39
-VM_CL_checkbottom, // #40 float(entity e) checkbottom
-VM_CL_pointcontents, // #41 float(vector v) pointcontents
-NULL, // #42
-VM_fabs, // #43 float(float f) fabs
-0,
-VM_cvar, // #45 float(string s) cvar
-VM_localcmd, // #46 void(string s) localcmd
-VM_nextent, // #47 entity(entity e) nextent
-VM_CL_particle, // #48 void(vector o, vector d, float color, float count) particle
-VM_CL_changeyaw, // #49 void(entity ent, float ideal_yaw, float speed_yaw) ChangeYaw
-NULL, // #50
-VM_vectoangles, // #51 vector(vector v) vectoangles
-0, // #52 void(float to, float f) WriteByte
-0, // #53 void(float to, float f) WriteChar
-0, // #54 void(float to, float f) WriteShort
-0, // #55 void(float to, float f) WriteLong
-0, // #56 void(float to, float f) WriteCoord
-0, // #57 void(float to, float f) WriteAngle
-0, // #58 void(float to, string s) WriteString
-0,
-VM_sin, // #60 float(float f) sin (DP_QC_SINCOSSQRTPOW)
-VM_cos, // #61 float(float f) cos (DP_QC_SINCOSSQRTPOW)
-VM_sqrt, // #62 float(float f) sqrt (DP_QC_SINCOSSQRTPOW)
-VM_CL_changepitch, // #63 void(entity ent, float ideal_pitch, float speed_pitch) changepitch (DP_QC_CHANGEPITCH)
-VM_CL_tracetoss, // #64 void(entity e, entity ignore) tracetoss (DP_QC_TRACETOSS)
-VM_etos, // #65 string(entity ent) etos (DP_QC_ETOS)
-NULL, // #66
-0, // #67
-0, // #68
-0, // #69
-0, // #70
-NULL, // #71
-VM_cvar_set, // #72 void(string var, string val) cvar_set
-0, // #73
-VM_CL_ambientsound, // #74 void(vector pos, string samp, float vol, float atten) ambientsound
-VM_CL_precache_model, // #75 string(string s) precache_model2
-VM_CL_precache_sound, // #76 string(string s) precache_sound2
-0, // #77
-VM_chr, // #78
-NULL, // #79
-NULL, // #80
-VM_stof, // #81 float(string s) stof (FRIK_FILE)
-NULL, // #82
-NULL, // #83
-NULL, // #84
-NULL, // #85
-NULL, // #86
-NULL, // #87
-NULL, // #88
-NULL, // #89
-VM_CL_tracebox, // #90 void(vector v1, vector min, vector max, vector v2, float nomonsters, entity forent) tracebox (DP_QC_TRACEBOX)
-VM_randomvec, // #91 vector() randomvec (DP_QC_RANDOMVEC)
-VM_CL_getlight, // #92 vector(vector org) getlight (DP_QC_GETLIGHT)
-PF_registercvar, // #93 float(string name, string value) registercvar (DP_REGISTERCVAR)
-VM_min, // #94 float(float a, floats) min (DP_QC_MINMAXBOUND)
-VM_max, // #95 float(float a, floats) max (DP_QC_MINMAXBOUND)
-VM_bound, // #96 float(float minimum, float val, float maximum) bound (DP_QC_MINMAXBOUND)
-VM_pow, // #97 float(float f, float f) pow (DP_QC_SINCOSSQRTPOW)
-VM_findfloat, // #98 entity(entity start, .float fld, float match) findfloat (DP_QC_FINDFLOAT)
-VM_checkextension, // #99 float(string s) checkextension (the basis of the extension system)
-NULL, // #100
-NULL, // #101
-NULL, // #102
-NULL, // #103
-NULL, // #104
-NULL, // #105
-NULL, // #106
-NULL, // #107
-NULL, // #108
-NULL, // #109
-VM_fopen, // #110 float(string filename, float mode) fopen (FRIK_FILE)
-VM_fclose, // #111 void(float fhandle) fclose (FRIK_FILE)
-VM_fgets, // #112 string(float fhandle) fgets (FRIK_FILE)
-VM_fputs, // #113 void(float fhandle, string s) fputs (FRIK_FILE)
-VM_strlen, // #114 float(string s) strlen (FRIK_FILE)
-VM_strcat, // #115 string(string s1, string s2) strcat (FRIK_FILE)
-VM_substring, // #116 string(string s, float start, float length) substring (FRIK_FILE)
-VM_stov, // #117 vector(string) stov (FRIK_FILE)
-VM_strzone, // #118 string(string s) strzone (FRIK_FILE)
-VM_strunzone, // #119 void(string s) strunzone (FRIK_FILE)
-
-e10, e10, e10, e10, e10, e10, e10, e10, // #120-199
-e10, //#200-209
-0, //#210
-0, //#211
-0, //#212
-0, //#213
-0, //#214
-0, //#215
-0, //#216
-0, //#217
-VM_bitshift, //#218 float(float number, float quantity) bitshift (EXT_BITSHIFT)
-0, //#219
-0, //#220
-0, //#221
-VM_charindex, //#222 float(string str, float ofs) str2chr (FTE_STRINGS)
-VM_chr2str, //#223 string(float c, ...) chr2str (FTE_STRINGS)
-0, //#224
-0, //#225
-0, //#226
-0, //#227
-VM_strncmp, //#228 float(string s1, string s2, float len) strncmp (FTE_STRINGS)
-0,
-e10, e10, e10, e10, e10, e10, e10, // #230-299
-
-//======CSQC start=======//
-//3d world (buffer/buffering) operations
-VM_R_ClearScene, //#300 void() clearscene (EXT_CSQC)
-VM_R_AddEntities, //#301 void(float mask) addentities (EXT_CSQC)
-VM_R_AddEntity, //#302 void(entity ent) addentity (EXT_CSQC)
-VM_R_SetView, //#303 float(float property, ...) setproperty (EXT_CSQC)
-VM_R_RenderScene, //#304 void() renderscene (EXT_CSQC)
-VM_R_AddDynamicLight, //#305 void(vector org, float radius, vector lightcolours) adddynamiclight (EXT_CSQC)
-VM_R_PolygonBegin, //#306 void(string texturename, float flag[, float is2d, float lines]) R_BeginPolygon
-VM_R_PolygonVertex, //#307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
-VM_R_PolygonEnd, //#308 void() R_EndPolygon
-0, //#309
-
-//maths stuff that uses the current view settings
-VM_CL_unproject, //#310 vector (vector v) cs_unproject (EXT_CSQC)
-VM_CL_project, //#311 vector (vector v) cs_project (EXT_CSQC)
-0, //#312
-0, //#313
-0, //#314
-
-//2d (immediate) operations
-VM_drawline, //#315 void(float width, vector pos1, vector pos2, float flag) drawline (EXT_CSQC)
-VM_iscachedpic, //#316 float(string name) iscachedpic (EXT_CSQC)
-VM_precache_pic, //#317 string(string name, float trywad) precache_pic (EXT_CSQC)
-VM_getimagesize, //#318 vector(string picname) draw_getimagesize (EXT_CSQC)
-VM_freepic, //#319 void(string name) freepic (EXT_CSQC)
-VM_drawcharacter, //#320 float(vector position, float character, vector scale, vector rgb, float alpha, float flag) drawcharacter (EXT_CSQC)
-VM_drawstring, //#321 float(vector position, string text, vector scale, vector rgb, float alpha, float flag) drawstring (EXT_CSQC)
-VM_drawpic, //#322 float(vector position, string pic, vector size, vector rgb, float alpha, float flag) drawpic (EXT_CSQC)
-VM_drawfill, //#323 float(vector position, vector size, vector rgb, float alpha, float flag) drawfill (EXT_CSQC)
-VM_drawsetcliparea, //#324 void(float x, float y, float width, float height) drawsetcliparea
-VM_drawresetcliparea, //#325 void(void) drawresetcliparea
-0, //#326
-0, //#327
-0, //#328
-0, //#329
-
-VM_CL_getstatf, //#330 float(float stnum) getstatf (EXT_CSQC)
-VM_CL_getstati, //#331 float(float stnum) getstati (EXT_CSQC)
-VM_CL_getstats, //#332 string(float firststnum) getstats (EXT_CSQC)
-VM_CL_setmodelindex, //#333 void(entity e, float mdlindex) setmodelindex (EXT_CSQC)
-VM_CL_modelnameforindex, //#334 string(float mdlindex) modelnameforindex (EXT_CSQC)
-VM_CL_particleeffectnum, //#335 float(string effectname) particleeffectnum (EXT_CSQC)
-VM_CL_trailparticles, //#336 void(entity ent, float effectnum, vector start, vector end) trailparticles (EXT_CSQC)
-VM_CL_pointparticles, //#337 void(float effectnum, vector origin [, vector dir, float count]) pointparticles (EXT_CSQC)
-VM_CL_centerprint, //#338 void(string s) cprint (EXT_CSQC)
-VM_print, //#339 void(string s) print (EXT_CSQC)
-VM_keynumtostring, //#340 string(float keynum) keynumtostring (EXT_CSQC)
-VM_stringtokeynum, //#341 float(string keyname) stringtokeynum (EXT_CSQC)
-VM_CL_getkeybind, //#342 string(float keynum) getkeybind (EXT_CSQC)
-VM_CL_setcursormode, //#343 void(float usecursor) setcursormode (EXT_CSQC)
-VM_getmousepos, //#344 vector() getmousepos (EXT_CSQC)
-VM_CL_getinputstate, //#345 float(float framenum) getinputstate (EXT_CSQC)
-VM_CL_setsensitivityscale, //#346 void(float sens) setsensitivityscaler (EXT_CSQC)
-VM_CL_runplayerphysics, //#347 void() runstandardplayerphysics (EXT_CSQC)
-VM_CL_getplayerkey, //#348 string(float playernum, string keyname) getplayerkeyvalue (EXT_CSQC)
-VM_CL_isdemo, //#349 float() isdemo (EXT_CSQC)
-VM_isserver, //#350 float() isserver (EXT_CSQC)
-VM_CL_setlistener, //#351 void(vector origin, vector forward, vector right, vector up) SetListener (EXT_CSQC)
-VM_CL_registercmd, //#352 void(string cmdname) registercommand (EXT_CSQC)
-VM_WasFreed, //#353 float(entity ent) wasfreed (EXT_CSQC) (should be availabe on server too)
-VM_CL_playernum, //#354 float() playernum
-VM_CL_onground, //#355 float() cl_onground (EXT_CSQC)
-VM_charindex, //#356 float(string s, float num) charindex
-VM_CL_selecttraceline, //#357 float(vector start, vector end, float ignore, float csqcents) selecttraceline
-0, //#358
-0, //#359
-VM_CL_ReadByte, //#360 float() readbyte (EXT_CSQC)
-VM_CL_ReadChar, //#361 float() readchar (EXT_CSQC)
-VM_CL_ReadShort, //#362 float() readshort (EXT_CSQC)
-VM_CL_ReadLong, //#363 float() readlong (EXT_CSQC)
-VM_CL_ReadCoord, //#364 float() readcoord (EXT_CSQC)
-VM_CL_ReadAngle, //#365 float() readangle (EXT_CSQC)
-VM_CL_ReadString, //#366 string() readstring (EXT_CSQC)
-VM_CL_ReadFloat, //#367 float() readfloat (EXT_CSQC)
-0, //#368
-0, //#369
-0, //#370
-0, //#371
-0, //#372
-0, //#373
-0, //#374
-0, //#375
-0, //#376
-0, //#377
-0, //#378
-0, //#379
-0, //#380
-0, //#381
-0, //#382
-0, //#383
-0, //#384
-0, //#385
-0, //#386
-0, //#387
-0, //#388
-0, //#389
-0, //#390
-0, //#391
-0, //#392
-0, //#393
-0, //#394
-0, //#395
-0, //#396
-0, //#397
-0, //#398
-0, //#399
-//=========CSQC end========//
-
-VM_copyentity, // #400 void(entity from, entity to) copyentity (DP_QC_COPYENTITY)
-0,
-VM_findchain, // #402 entity(.string fld, string match) findchain (DP_QC_FINDCHAIN)
-VM_findchainfloat, // #403 entity(.float fld, float match) findchainfloat (DP_QC_FINDCHAINFLOAT)
-VM_CL_effect, // #404 void(vector org, string modelname, float startframe, float endframe, float framerate) effect (DP_SV_EFFECT)
-VM_CL_te_blood, // #405 void(vector org, vector velocity, float howmany) te_blood (DP_TE_BLOOD)
-VM_CL_te_bloodshower, // #406 void(vector mincorner, vector maxcorner, float explosionspeed, float howmany) te_bloodshower (DP_TE_BLOODSHOWER)
-VM_CL_te_explosionrgb, // #407 void(vector org, vector color) te_explosionrgb (DP_TE_EXPLOSIONRGB)
+ if (!polys->begin_active)
+ {
+ VM_Warning("VM_CL_R_PolygonVertex: VM_CL_R_PolygonBegin wasn't called\n");
+ return;
+ }
+
+ if (polys->begin_vertices >= VMPOLYGONS_MAXPOINTS)
+ {
+ VM_Warning("VM_CL_R_PolygonVertex: may have %i vertices max\n", VMPOLYGONS_MAXPOINTS);
+ return;
+ }
+
+ polys->begin_vertex[polys->begin_vertices][0] = PRVM_G_VECTOR(OFS_PARM0)[0];
+ polys->begin_vertex[polys->begin_vertices][1] = PRVM_G_VECTOR(OFS_PARM0)[1];
+ polys->begin_vertex[polys->begin_vertices][2] = PRVM_G_VECTOR(OFS_PARM0)[2];
+ polys->begin_texcoord[polys->begin_vertices][0] = PRVM_G_VECTOR(OFS_PARM1)[0];
+ polys->begin_texcoord[polys->begin_vertices][1] = PRVM_G_VECTOR(OFS_PARM1)[1];
+ polys->begin_color[polys->begin_vertices][0] = PRVM_G_VECTOR(OFS_PARM2)[0];
+ polys->begin_color[polys->begin_vertices][1] = PRVM_G_VECTOR(OFS_PARM2)[1];
+ polys->begin_color[polys->begin_vertices][2] = PRVM_G_VECTOR(OFS_PARM2)[2];
+ polys->begin_color[polys->begin_vertices][3] = PRVM_G_FLOAT(OFS_PARM3);
+ polys->begin_vertices++;
+}
+
+//void() R_EndPolygon
+void VM_CL_R_PolygonEnd (void)
+{
+ vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
+
+ VM_SAFEPARMCOUNT(0, VM_CL_R_PolygonEnd);
+ if (!polys->begin_active)
+ {
+ VM_Warning("VM_CL_R_PolygonEnd: VM_CL_R_PolygonBegin wasn't called\n");
+ return;
+ }
+ polys->begin_active = false;
+ if (polys->begin_vertices >= 3)
+ VMPolygons_Store(polys);
+ else
+ VM_Warning("VM_CL_R_PolygonEnd: %i vertices isn't a good choice\n", polys->begin_vertices);
+}
+
+static vmpolygons_t debugPolys;
+
+void Debug_PolygonBegin(const char *picname, int drawflag)
+{
+ if(!debugPolys.initialized)
+ VM_InitPolygons(&debugPolys);
+ if(debugPolys.begin_active)
+ {
+ Con_Printf("Debug_PolygonBegin: called twice without Debug_PolygonEnd after first\n");
+ return;
+ }
+ debugPolys.begin_texture = picname[0] ? Draw_CachePic_Flags (picname, CACHEPICFLAG_NOTPERSISTENT)->tex : r_texture_white;
+ debugPolys.begin_drawflag = drawflag;
+ debugPolys.begin_vertices = 0;
+ debugPolys.begin_active = true;
+}
+
+void Debug_PolygonVertex(float x, float y, float z, float s, float t, float r, float g, float b, float a)
+{
+ if(!debugPolys.begin_active)
+ {
+ Con_Printf("Debug_PolygonVertex: Debug_PolygonBegin wasn't called\n");
+ return;
+ }
+
+ if(debugPolys.begin_vertices > VMPOLYGONS_MAXPOINTS)
+ {
+ Con_Printf("Debug_PolygonVertex: may have %i vertices max\n", VMPOLYGONS_MAXPOINTS);
+ return;
+ }
+
+ debugPolys.begin_vertex[debugPolys.begin_vertices][0] = x;
+ debugPolys.begin_vertex[debugPolys.begin_vertices][1] = y;
+ debugPolys.begin_vertex[debugPolys.begin_vertices][2] = z;
+ debugPolys.begin_texcoord[debugPolys.begin_vertices][0] = s;
+ debugPolys.begin_texcoord[debugPolys.begin_vertices][1] = t;
+ debugPolys.begin_color[debugPolys.begin_vertices][0] = r;
+ debugPolys.begin_color[debugPolys.begin_vertices][1] = g;
+ debugPolys.begin_color[debugPolys.begin_vertices][2] = b;
+ debugPolys.begin_color[debugPolys.begin_vertices][3] = a;
+ debugPolys.begin_vertices++;
+}
+
+void Debug_PolygonEnd(void)
+{
+ if (!debugPolys.begin_active)
+ {
+ Con_Printf("Debug_PolygonEnd: Debug_PolygonBegin wasn't called\n");
+ return;
+ }
+ debugPolys.begin_active = false;
+ if (debugPolys.begin_vertices >= 3)
+ VMPolygons_Store(&debugPolys);
+ else
+ Con_Printf("Debug_PolygonEnd: %i vertices isn't a good choice\n", debugPolys.begin_vertices);
+}
+
+/*
+=============
+CL_CheckBottom
+
+Returns false if any part of the bottom of the entity is off an edge that
+is not a staircase.
+
+=============
+*/
+qboolean CL_CheckBottom (prvm_edict_t *ent)
+{
+ vec3_t mins, maxs, start, stop;
+ trace_t trace;
+ int x, y;
+ float mid, bottom;
+
+ VectorAdd (ent->fields.client->origin, ent->fields.client->mins, mins);
+ VectorAdd (ent->fields.client->origin, ent->fields.client->maxs, maxs);
+
+// if all of the points under the corners are solid world, don't bother
+// with the tougher checks
+// the corners must be within 16 of the midpoint
+ start[2] = mins[2] - 1;
+ for (x=0 ; x<=1 ; x++)
+ for (y=0 ; y<=1 ; y++)
+ {
+ start[0] = x ? maxs[0] : mins[0];
+ start[1] = y ? maxs[1] : mins[1];
+ if (!(CL_PointSuperContents(start) & (SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY)))
+ goto realcheck;
+ }
+
+ return true; // we got out easy
+
+realcheck:
+//
+// check it for real...
+//
+ start[2] = mins[2];
+
+// the midpoint must be within 16 of the bottom
+ start[0] = stop[0] = (mins[0] + maxs[0])*0.5;
+ start[1] = stop[1] = (mins[1] + maxs[1])*0.5;
+ stop[2] = start[2] - 2*sv_stepheight.value;
+ trace = CL_TraceLine(start, stop, MOVE_NOMONSTERS, ent, CL_GenericHitSuperContentsMask(ent), true, false, NULL, true, false);
+
+ if (trace.fraction == 1.0)
+ return false;
+ mid = bottom = trace.endpos[2];
+
+// the corners must be within 16 of the midpoint
+ for (x=0 ; x<=1 ; x++)
+ for (y=0 ; y<=1 ; y++)
+ {
+ start[0] = stop[0] = x ? maxs[0] : mins[0];
+ start[1] = stop[1] = y ? maxs[1] : mins[1];
+
+ trace = CL_TraceLine(start, stop, MOVE_NOMONSTERS, ent, CL_GenericHitSuperContentsMask(ent), true, false, NULL, true, false);
+
+ if (trace.fraction != 1.0 && trace.endpos[2] > bottom)
+ bottom = trace.endpos[2];
+ if (trace.fraction == 1.0 || mid - trace.endpos[2] > sv_stepheight.value)
+ return false;
+ }
+
+ return true;
+}
+
+/*
+=============
+CL_movestep
+
+Called by monster program code.
+The move will be adjusted for slopes and stairs, but if the move isn't
+possible, no move is done and false is returned
+=============
+*/
+qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean noenemy, qboolean settrace)
+{
+ float dz;
+ vec3_t oldorg, neworg, end, traceendpos;
+ trace_t trace;
+ int i, svent;
+ prvm_edict_t *enemy;
+ prvm_eval_t *val;
+
+// try the move
+ VectorCopy (ent->fields.client->origin, oldorg);
+ VectorAdd (ent->fields.client->origin, move, neworg);
+
+// flying monsters don't step up
+ if ( (int)ent->fields.client->flags & (FL_SWIM | FL_FLY) )
+ {
+ // try one move with vertical motion, then one without
+ for (i=0 ; i<2 ; i++)
+ {
+ VectorAdd (ent->fields.client->origin, move, neworg);
+ enemy = PRVM_PROG_TO_EDICT(ent->fields.client->enemy);
+ if (i == 0 && enemy != prog->edicts)
+ {
+ dz = ent->fields.client->origin[2] - PRVM_PROG_TO_EDICT(ent->fields.client->enemy)->fields.client->origin[2];
+ if (dz > 40)
+ neworg[2] -= 8;
+ if (dz < 30)
+ neworg[2] += 8;
+ }
+ trace = CL_TraceBox(ent->fields.client->origin, ent->fields.client->mins, ent->fields.client->maxs, neworg, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
+ if (settrace)
+ CL_VM_SetTraceGlobals(&trace, svent);
+
+ if (trace.fraction == 1)
+ {
+ VectorCopy(trace.endpos, traceendpos);
+ if (((int)ent->fields.client->flags & FL_SWIM) && !(CL_PointSuperContents(traceendpos) & SUPERCONTENTS_LIQUIDSMASK))
+ return false; // swim monster left water
+
+ VectorCopy (traceendpos, ent->fields.client->origin);
+ if (relink)
+ CL_LinkEdict(ent);
+ return true;
+ }
+
+ if (enemy == prog->edicts)
+ break;
+ }
+
+ return false;
+ }
+
+// push down from a step height above the wished position
+ neworg[2] += sv_stepheight.value;
+ VectorCopy (neworg, end);
+ end[2] -= sv_stepheight.value*2;
+
+ trace = CL_TraceBox(neworg, ent->fields.client->mins, ent->fields.client->maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
+ if (settrace)
+ CL_VM_SetTraceGlobals(&trace, svent);
+
+ if (trace.startsolid)
+ {
+ neworg[2] -= sv_stepheight.value;
+ trace = CL_TraceBox(neworg, ent->fields.client->mins, ent->fields.client->maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
+ if (settrace)
+ CL_VM_SetTraceGlobals(&trace, svent);
+ if (trace.startsolid)
+ return false;
+ }
+ if (trace.fraction == 1)
+ {
+ // if monster had the ground pulled out, go ahead and fall
+ if ( (int)ent->fields.client->flags & FL_PARTIALGROUND )
+ {
+ VectorAdd (ent->fields.client->origin, move, ent->fields.client->origin);
+ if (relink)
+ CL_LinkEdict(ent);
+ ent->fields.client->flags = (int)ent->fields.client->flags & ~FL_ONGROUND;
+ return true;
+ }
+
+ return false; // walked off an edge
+ }
+
+// check point traces down for dangling corners
+ VectorCopy (trace.endpos, ent->fields.client->origin);
+
+ if (!CL_CheckBottom (ent))
+ {
+ if ( (int)ent->fields.client->flags & FL_PARTIALGROUND )
+ { // entity had floor mostly pulled out from underneath it
+ // and is trying to correct
+ if (relink)
+ CL_LinkEdict(ent);
+ return true;
+ }
+ VectorCopy (oldorg, ent->fields.client->origin);
+ return false;
+ }
+
+ if ( (int)ent->fields.client->flags & FL_PARTIALGROUND )
+ ent->fields.client->flags = (int)ent->fields.client->flags & ~FL_PARTIALGROUND;
+
+ if ((val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.groundentity)))
+ val->edict = PRVM_EDICT_TO_PROG(trace.ent);
+
+// the move is ok
+ if (relink)
+ CL_LinkEdict(ent);
+ return true;
+}
+
+/*
+===============
+VM_CL_walkmove
+
+float(float yaw, float dist[, settrace]) walkmove
+===============
+*/
+static void VM_CL_walkmove (void)
+{
+ prvm_edict_t *ent;
+ float yaw, dist;
+ vec3_t move;
+ mfunction_t *oldf;
+ int oldself;
+ qboolean settrace;
+
+ VM_SAFEPARMCOUNTRANGE(2, 3, VM_CL_walkmove);
+
+ // assume failure if it returns early
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+
+ ent = PRVM_PROG_TO_EDICT(prog->globals.client->self);
+ if (ent == prog->edicts)
+ {
+ VM_Warning("walkmove: can not modify world entity\n");
+ return;
+ }
+ if (ent->priv.server->free)
+ {
+ VM_Warning("walkmove: can not modify free entity\n");
+ return;
+ }
+ yaw = PRVM_G_FLOAT(OFS_PARM0);
+ dist = PRVM_G_FLOAT(OFS_PARM1);
+ settrace = prog->argc >= 3 && PRVM_G_FLOAT(OFS_PARM2);
+
+ if ( !( (int)ent->fields.client->flags & (FL_ONGROUND|FL_FLY|FL_SWIM) ) )
+ return;
+
+ yaw = yaw*M_PI*2 / 360;
+
+ move[0] = cos(yaw)*dist;
+ move[1] = sin(yaw)*dist;
+ move[2] = 0;
+
+// save program state, because CL_movestep may call other progs
+ oldf = prog->xfunction;
+ oldself = prog->globals.client->self;
+
+ PRVM_G_FLOAT(OFS_RETURN) = CL_movestep(ent, move, true, false, settrace);
+
+
+// restore program state
+ prog->xfunction = oldf;
+ prog->globals.client->self = oldself;
+}
+
+/*
+===============
+VM_CL_serverkey
+
+string(string key) serverkey
+===============
+*/
+void VM_CL_serverkey(void)
+{
+ char string[VM_STRINGTEMP_LENGTH];
+ VM_SAFEPARMCOUNT(1, VM_CL_serverkey);
+ InfoString_GetValue(cl.qw_serverinfo, PRVM_G_STRING(OFS_PARM0), string, sizeof(string));
+ PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(string);
+}
+
+/*
+=================
+VM_CL_checkpvs
+
+Checks if an entity is in a point's PVS.
+Should be fast but can be inexact.
+
+float checkpvs(vector viewpos, entity viewee) = #240;
+=================
+*/
+static void VM_CL_checkpvs (void)
+{
+ vec3_t viewpos;
+ prvm_edict_t *viewee;
+ vec3_t mi, ma;
+#if 1
+ unsigned char *pvs;
+#else
+ int fatpvsbytes;
+ unsigned char fatpvs[MAX_MAP_LEAFS/8];
+#endif
+
+ VM_SAFEPARMCOUNT(2, VM_SV_checkpvs);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), viewpos);
+ viewee = PRVM_G_EDICT(OFS_PARM1);
+
+ if(viewee->priv.required->free)
+ {
+ VM_Warning("checkpvs: can not check free entity\n");
+ PRVM_G_FLOAT(OFS_RETURN) = 4;
+ return;
+ }
+
+ VectorAdd(viewee->fields.server->origin, viewee->fields.server->mins, mi);
+ VectorAdd(viewee->fields.server->origin, viewee->fields.server->maxs, ma);
+
+#if 1
+ if(!sv.worldmodel->brush.GetPVS || !sv.worldmodel->brush.BoxTouchingPVS)
+ {
+ // no PVS support on this worldmodel... darn
+ PRVM_G_FLOAT(OFS_RETURN) = 3;
+ return;
+ }
+ pvs = sv.worldmodel->brush.GetPVS(sv.worldmodel, viewpos);
+ if(!pvs)
+ {
+ // viewpos isn't in any PVS... darn
+ PRVM_G_FLOAT(OFS_RETURN) = 2;
+ return;
+ }
+ PRVM_G_FLOAT(OFS_RETURN) = sv.worldmodel->brush.BoxTouchingPVS(sv.worldmodel, pvs, mi, ma);
+#else
+ // using fat PVS like FTEQW does (slow)
+ if(!sv.worldmodel->brush.FatPVS || !sv.worldmodel->brush.BoxTouchingPVS)
+ {
+ // no PVS support on this worldmodel... darn
+ PRVM_G_FLOAT(OFS_RETURN) = 3;
+ return;
+ }
+ fatpvsbytes = sv.worldmodel->brush.FatPVS(sv.worldmodel, viewpos, 8, fatpvs, sizeof(fatpvs), false);
+ if(!fatpvsbytes)
+ {
+ // viewpos isn't in any PVS... darn
+ PRVM_G_FLOAT(OFS_RETURN) = 2;
+ return;
+ }
+ PRVM_G_FLOAT(OFS_RETURN) = sv.worldmodel->brush.BoxTouchingPVS(sv.worldmodel, fatpvs, mi, ma);
+#endif
+}
+
+// #263 float(float modlindex) skel_create = #263; // (FTE_CSQC_SKELETONOBJECTS) create a skeleton (be sure to assign this value into .skeletonindex for use), returns skeleton index (1 or higher) on success, returns 0 on failure (for example if the modelindex is not skeletal), it is recommended that you create a new skeleton if you change modelindex.
+static void VM_CL_skel_create(void)
+{
+ int modelindex = (int)PRVM_G_FLOAT(OFS_PARM0);
+ dp_model_t *model = CL_GetModelByIndex(modelindex);
+ skeleton_t *skeleton;
+ int i;
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ if (!model || !model->num_bones)
+ return;
+ for (i = 0;i < MAX_EDICTS;i++)
+ if (!prog->skeletons[i])
+ break;
+ if (i == MAX_EDICTS)
+ return;
+ prog->skeletons[i] = skeleton = (skeleton_t *)Mem_Alloc(cls.levelmempool, sizeof(skeleton_t) + model->num_bones * sizeof(matrix4x4_t));
+ PRVM_G_FLOAT(OFS_RETURN) = i + 1;
+ skeleton->model = model;
+ skeleton->relativetransforms = (matrix4x4_t *)(skeleton+1);
+ // initialize to identity matrices
+ for (i = 0;i < skeleton->model->num_bones;i++)
+ skeleton->relativetransforms[i] = identitymatrix;
+}
+
+// #264 float(float skel, entity ent, float modlindex, float retainfrac, float firstbone, float lastbone) skel_build = #264; // (FTE_CSQC_SKELETONOBJECTS) blend in a percentage of standard animation, 0 replaces entirely, 1 does nothing, 0.5 blends half, etc, and this only alters the bones in the specified range for which out of bounds values like 0,100000 are safe (uses .frame, .frame2, .frame3, .frame4, .lerpfrac, .lerpfrac3, .lerpfrac4, .frame1time, .frame2time, .frame3time, .frame4time), returns skel on success, 0 on failure
+static void VM_CL_skel_build(void)
+{
+ int skeletonindex = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ skeleton_t *skeleton;
+ prvm_edict_t *ed = PRVM_G_EDICT(OFS_PARM1);
+ int modelindex = (int)PRVM_G_FLOAT(OFS_PARM2);
+ float retainfrac = PRVM_G_FLOAT(OFS_PARM3);
+ int firstbone = PRVM_G_FLOAT(OFS_PARM4) - 1;
+ int lastbone = PRVM_G_FLOAT(OFS_PARM5) - 1;
+ dp_model_t *model = CL_GetModelByIndex(modelindex);
+ float blendfrac;
+ int numblends;
+ int bonenum;
+ int blendindex;
+ framegroupblend_t framegroupblend[MAX_FRAMEGROUPBLENDS];
+ frameblend_t frameblend[MAX_FRAMEBLENDS];
+ matrix4x4_t blendedmatrix;
+ matrix4x4_t matrix;
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
+ return;
+ firstbone = max(0, firstbone);
+ lastbone = min(lastbone, model->num_bones - 1);
+ lastbone = min(lastbone, skeleton->model->num_bones - 1);
+ VM_GenerateFrameGroupBlend(framegroupblend, ed);
+ VM_FrameBlendFromFrameGroupBlend(frameblend, framegroupblend, model);
+ blendfrac = 1.0f - retainfrac;
+ for (numblends = 0;numblends < MAX_FRAMEBLENDS && frameblend[numblends].lerp;numblends++)
+ frameblend[numblends].lerp *= blendfrac;
+ for (bonenum = firstbone;bonenum <= lastbone;bonenum++)
+ {
+ memset(&blendedmatrix, 0, sizeof(blendedmatrix));
+ Matrix4x4_Accumulate(&blendedmatrix, &skeleton->relativetransforms[bonenum], retainfrac);
+ for (blendindex = 0;blendindex < numblends;blendindex++)
+ {
+ Matrix4x4_FromBonePose6s(&matrix, model->num_posescale, model->data_poses6s + 6 * (frameblend[blendindex].subframe * model->num_bones + bonenum));
+ Matrix4x4_Accumulate(&blendedmatrix, &matrix, frameblend[blendindex].lerp);
+ }
+ skeleton->relativetransforms[bonenum] = blendedmatrix;
+ }
+ PRVM_G_FLOAT(OFS_RETURN) = skeletonindex + 1;
+}
+
+// #265 float(float skel) skel_get_numbones = #265; // (FTE_CSQC_SKELETONOBJECTS) returns how many bones exist in the created skeleton
+static void VM_CL_skel_get_numbones(void)
+{
+ int skeletonindex = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ skeleton_t *skeleton;
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
+ return;
+ PRVM_G_FLOAT(OFS_RETURN) = skeleton->model->num_bones;
+}
+
+// #266 string(float skel, float bonenum) skel_get_bonename = #266; // (FTE_CSQC_SKELETONOBJECTS) returns name of bone (as a tempstring)
+static void VM_CL_skel_get_bonename(void)
+{
+ int skeletonindex = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ int bonenum = (int)PRVM_G_FLOAT(OFS_PARM1) - 1;
+ skeleton_t *skeleton;
+ PRVM_G_INT(OFS_RETURN) = 0;
+ if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
+ return;
+ if (bonenum < 0 || bonenum >= skeleton->model->num_bones)
+ return;
+ PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(skeleton->model->data_bones[bonenum].name);
+}
+
+// #267 float(float skel, float bonenum) skel_get_boneparent = #267; // (FTE_CSQC_SKELETONOBJECTS) returns parent num for supplied bonenum, 0 if bonenum has no parent or bone does not exist (returned value is always less than bonenum, you can loop on this)
+static void VM_CL_skel_get_boneparent(void)
+{
+ int skeletonindex = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ int bonenum = (int)PRVM_G_FLOAT(OFS_PARM1) - 1;
+ skeleton_t *skeleton;
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
+ return;
+ if (bonenum < 0 || bonenum >= skeleton->model->num_bones)
+ return;
+ PRVM_G_FLOAT(OFS_RETURN) = skeleton->model->data_bones[bonenum].parent + 1;
+}
+
+// #268 float(float skel, string tagname) skel_find_bone = #268; // (FTE_CSQC_SKELETONOBJECTS) get number of bone with specified name, 0 on failure, tagindex (bonenum+1) on success, same as using gettagindex on the modelindex
+static void VM_CL_skel_find_bone(void)
+{
+ int skeletonindex = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ const char *tagname = PRVM_G_STRING(OFS_PARM1);
+ skeleton_t *skeleton;
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
+ return;
+ PRVM_G_FLOAT(OFS_RETURN) = Mod_Alias_GetTagIndexForName(skeleton->model, 0, tagname);
+}
+
+// #269 vector(float skel, float bonenum) skel_get_bonerel = #269; // (FTE_CSQC_SKELETONOBJECTS) get matrix of bone in skeleton relative to its parent - sets v_forward, v_right, v_up, returns origin (relative to parent bone)
+static void VM_CL_skel_get_bonerel(void)
+{
+ int skeletonindex = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ int bonenum = (int)PRVM_G_FLOAT(OFS_PARM1) - 1;
+ skeleton_t *skeleton;
+ matrix4x4_t matrix;
+ vec3_t forward, left, up, origin;
+ VectorClear(PRVM_G_VECTOR(OFS_RETURN));
+ VectorClear(prog->globals.client->v_forward);
+ VectorClear(prog->globals.client->v_right);
+ VectorClear(prog->globals.client->v_up);
+ if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
+ return;
+ if (bonenum < 0 || bonenum >= skeleton->model->num_bones)
+ return;
+ matrix = skeleton->relativetransforms[bonenum];
+ Matrix4x4_ToVectors(&matrix, forward, left, up, origin);
+ VectorCopy(forward, prog->globals.client->v_forward);
+ VectorNegate(left, prog->globals.client->v_right);
+ VectorCopy(up, prog->globals.client->v_up);
+ VectorCopy(origin, PRVM_G_VECTOR(OFS_RETURN));
+}
+
+// #270 vector(float skel, float bonenum) skel_get_boneabs = #270; // (FTE_CSQC_SKELETONOBJECTS) get matrix of bone in skeleton in model space - sets v_forward, v_right, v_up, returns origin (relative to entity)
+static void VM_CL_skel_get_boneabs(void)
+{
+ int skeletonindex = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ int bonenum = (int)PRVM_G_FLOAT(OFS_PARM1) - 1;
+ skeleton_t *skeleton;
+ matrix4x4_t matrix;
+ matrix4x4_t temp;
+ vec3_t forward, left, up, origin;
+ VectorClear(PRVM_G_VECTOR(OFS_RETURN));
+ VectorClear(prog->globals.client->v_forward);
+ VectorClear(prog->globals.client->v_right);
+ VectorClear(prog->globals.client->v_up);
+ if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
+ return;
+ if (bonenum < 0 || bonenum >= skeleton->model->num_bones)
+ return;
+ matrix = skeleton->relativetransforms[bonenum];
+ // convert to absolute
+ while ((bonenum = skeleton->model->data_bones[bonenum].parent) >= 0)
+ {
+ temp = matrix;
+ Matrix4x4_Concat(&matrix, &skeleton->relativetransforms[bonenum], &temp);
+ }
+ Matrix4x4_ToVectors(&matrix, forward, left, up, origin);
+ VectorCopy(forward, prog->globals.client->v_forward);
+ VectorNegate(left, prog->globals.client->v_right);
+ VectorCopy(up, prog->globals.client->v_up);
+ VectorCopy(origin, PRVM_G_VECTOR(OFS_RETURN));
+}
+
+// #271 void(float skel, float bonenum, vector org) skel_set_bone = #271; // (FTE_CSQC_SKELETONOBJECTS) set matrix of bone relative to its parent, reads v_forward, v_right, v_up, takes origin as parameter (relative to parent bone)
+static void VM_CL_skel_set_bone(void)
+{
+ int skeletonindex = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ int bonenum = (int)PRVM_G_FLOAT(OFS_PARM1) - 1;
+ vec3_t forward, left, up, origin;
+ skeleton_t *skeleton;
+ matrix4x4_t matrix;
+ if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
+ return;
+ if (bonenum < 0 || bonenum >= skeleton->model->num_bones)
+ return;
+ VectorCopy(prog->globals.client->v_forward, forward);
+ VectorNegate(prog->globals.client->v_right, left);
+ VectorCopy(prog->globals.client->v_up, up);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), origin);
+ Matrix4x4_FromVectors(&matrix, forward, left, up, origin);
+ skeleton->relativetransforms[bonenum] = matrix;
+}
+
+// #272 void(float skel, float bonenum, vector org) skel_mul_bone = #272; // (FTE_CSQC_SKELETONOBJECTS) transform bone matrix (relative to its parent) by the supplied matrix in v_forward, v_right, v_up, takes origin as parameter (relative to parent bone)
+static void VM_CL_skel_mul_bone(void)
+{
+ int skeletonindex = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ int bonenum = (int)PRVM_G_FLOAT(OFS_PARM1) - 1;
+ vec3_t forward, left, up, origin;
+ skeleton_t *skeleton;
+ matrix4x4_t matrix;
+ matrix4x4_t temp;
+ if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
+ return;
+ if (bonenum < 0 || bonenum >= skeleton->model->num_bones)
+ return;
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), origin);
+ VectorCopy(prog->globals.client->v_forward, forward);
+ VectorNegate(prog->globals.client->v_right, left);
+ VectorCopy(prog->globals.client->v_up, up);
+ Matrix4x4_FromVectors(&matrix, forward, left, up, origin);
+ temp = skeleton->relativetransforms[bonenum];
+ Matrix4x4_Concat(&skeleton->relativetransforms[bonenum], &matrix, &temp);
+}
+
+// #273 void(float skel, float startbone, float endbone, vector org) skel_mul_bones = #273; // (FTE_CSQC_SKELETONOBJECTS) transform bone matrices (relative to their parents) by the supplied matrix in v_forward, v_right, v_up, takes origin as parameter (relative to parent bones)
+static void VM_CL_skel_mul_bones(void)
+{
+ int skeletonindex = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ int firstbone = PRVM_G_FLOAT(OFS_PARM1) - 1;
+ int lastbone = PRVM_G_FLOAT(OFS_PARM2) - 1;
+ int bonenum;
+ vec3_t forward, left, up, origin;
+ skeleton_t *skeleton;
+ matrix4x4_t matrix;
+ matrix4x4_t temp;
+ if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
+ return;
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM3), origin);
+ VectorCopy(prog->globals.client->v_forward, forward);
+ VectorNegate(prog->globals.client->v_right, left);
+ VectorCopy(prog->globals.client->v_up, up);
+ Matrix4x4_FromVectors(&matrix, forward, left, up, origin);
+ firstbone = max(0, firstbone);
+ lastbone = min(lastbone, skeleton->model->num_bones - 1);
+ for (bonenum = firstbone;bonenum <= lastbone;bonenum++)
+ {
+ temp = skeleton->relativetransforms[bonenum];
+ Matrix4x4_Concat(&skeleton->relativetransforms[bonenum], &matrix, &temp);
+ }
+}
+
+// #274 void(float skeldst, float skelsrc, float startbone, float endbone) skel_copybones = #274; // (FTE_CSQC_SKELETONOBJECTS) copy bone matrices (relative to their parents) from one skeleton to another, useful for copying a skeleton to a corpse
+static void VM_CL_skel_copybones(void)
+{
+ int skeletonindexdst = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ int skeletonindexsrc = (int)PRVM_G_FLOAT(OFS_PARM1) - 1;
+ int firstbone = PRVM_G_FLOAT(OFS_PARM2) - 1;
+ int lastbone = PRVM_G_FLOAT(OFS_PARM3) - 1;
+ int bonenum;
+ skeleton_t *skeletondst;
+ skeleton_t *skeletonsrc;
+ if (skeletonindexdst < 0 || skeletonindexdst >= MAX_EDICTS || !(skeletondst = prog->skeletons[skeletonindexdst]))
+ return;
+ if (skeletonindexsrc < 0 || skeletonindexsrc >= MAX_EDICTS || !(skeletonsrc = prog->skeletons[skeletonindexsrc]))
+ return;
+ firstbone = max(0, firstbone);
+ lastbone = min(lastbone, skeletondst->model->num_bones - 1);
+ lastbone = min(lastbone, skeletonsrc->model->num_bones - 1);
+ for (bonenum = firstbone;bonenum <= lastbone;bonenum++)
+ skeletondst->relativetransforms[bonenum] = skeletonsrc->relativetransforms[bonenum];
+}
+
+// #275 void(float skel) skel_delete = #275; // (FTE_CSQC_SKELETONOBJECTS) deletes skeleton at the beginning of the next frame (you can add the entity, delete the skeleton, renderscene, and it will still work)
+static void VM_CL_skel_delete(void)
+{
+ int skeletonindex = (int)PRVM_G_FLOAT(OFS_PARM0) - 1;
+ skeleton_t *skeleton;
+ if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
+ return;
+ Mem_Free(skeleton);
+ prog->skeletons[skeletonindex] = NULL;
+}
+
+// #276 float(float modlindex, string framename) frameforname = #276; // (FTE_CSQC_SKELETONOBJECTS) finds number of a specified frame in the animation, returns -1 if no match found
+static void VM_CL_frameforname(void)
+{
+ int modelindex = (int)PRVM_G_FLOAT(OFS_PARM0);
+ dp_model_t *model = CL_GetModelByIndex(modelindex);
+ const char *name = PRVM_G_STRING(OFS_PARM1);
+ int i;
+ PRVM_G_FLOAT(OFS_RETURN) = -1;
+ if (!model || !model->animscenes)
+ return;
+ for (i = 0;i < model->numframes;i++)
+ {
+ if (!strcasecmp(model->animscenes[i].name, name))
+ {
+ PRVM_G_FLOAT(OFS_RETURN) = i;
+ break;
+ }
+ }
+}
+
+// #277 float(float modlindex, float framenum) frameduration = #277; // (FTE_CSQC_SKELETONOBJECTS) returns the intended play time (in seconds) of the specified framegroup, if it does not exist the result is 0, if it is a single frame it may be a small value around 0.1 or 0.
+static void VM_CL_frameduration(void)
+{
+ int modelindex = (int)PRVM_G_FLOAT(OFS_PARM0);
+ dp_model_t *model = CL_GetModelByIndex(modelindex);
+ int framenum = (int)PRVM_G_FLOAT(OFS_PARM1);
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ if (!model || !model->animscenes || framenum < 0 || framenum >= model->numframes)
+ return;
+ if (model->animscenes[framenum].framerate)
+ PRVM_G_FLOAT(OFS_RETURN) = model->animscenes[framenum].framecount / model->animscenes[framenum].framerate;
+}
+
+//============================================================================
+
+// To create a almost working builtin file from this replace:
+// "^NULL.*" with ""
+// "^{.*//.*}:Wh\(.*\)" with "\1"
+// "\:" with "//"
+// "^.*//:Wh{\#:d*}:Wh{.*}" with "\2 = \1;"
+// "\n\n+" with "\n\n"
+
+prvm_builtin_t vm_cl_builtins[] = {
+NULL, // #0 NULL function (not callable) (QUAKE)
+VM_CL_makevectors, // #1 void(vector ang) makevectors (QUAKE)
+VM_CL_setorigin, // #2 void(entity e, vector o) setorigin (QUAKE)
+VM_CL_setmodel, // #3 void(entity e, string m) setmodel (QUAKE)
+VM_CL_setsize, // #4 void(entity e, vector min, vector max) setsize (QUAKE)
+NULL, // #5 void(entity e, vector min, vector max) setabssize (QUAKE)
+VM_break, // #6 void() break (QUAKE)
+VM_random, // #7 float() random (QUAKE)
+VM_CL_sound, // #8 void(entity e, float chan, string samp) sound (QUAKE)
+VM_normalize, // #9 vector(vector v) normalize (QUAKE)
+VM_error, // #10 void(string e) error (QUAKE)
+VM_objerror, // #11 void(string e) objerror (QUAKE)
+VM_vlen, // #12 float(vector v) vlen (QUAKE)
+VM_vectoyaw, // #13 float(vector v) vectoyaw (QUAKE)
+VM_CL_spawn, // #14 entity() spawn (QUAKE)
+VM_remove, // #15 void(entity e) remove (QUAKE)
+VM_CL_traceline, // #16 void(vector v1, vector v2, float tryents, entity ignoreentity) traceline (QUAKE)
+NULL, // #17 entity() checkclient (QUAKE)
+VM_find, // #18 entity(entity start, .string fld, string match) find (QUAKE)
+VM_precache_sound, // #19 void(string s) precache_sound (QUAKE)
+VM_CL_precache_model, // #20 void(string s) precache_model (QUAKE)
+NULL, // #21 void(entity client, string s, ...) stuffcmd (QUAKE)
+VM_CL_findradius, // #22 entity(vector org, float rad) findradius (QUAKE)
+NULL, // #23 void(string s, ...) bprint (QUAKE)
+NULL, // #24 void(entity client, string s, ...) sprint (QUAKE)
+VM_dprint, // #25 void(string s, ...) dprint (QUAKE)
+VM_ftos, // #26 string(float f) ftos (QUAKE)
+VM_vtos, // #27 string(vector v) vtos (QUAKE)
+VM_coredump, // #28 void() coredump (QUAKE)
+VM_traceon, // #29 void() traceon (QUAKE)
+VM_traceoff, // #30 void() traceoff (QUAKE)
+VM_eprint, // #31 void(entity e) eprint (QUAKE)
+VM_CL_walkmove, // #32 float(float yaw, float dist[, float settrace]) walkmove (QUAKE)
+NULL, // #33 (QUAKE)
+VM_CL_droptofloor, // #34 float() droptofloor (QUAKE)
+VM_CL_lightstyle, // #35 void(float style, string value) lightstyle (QUAKE)
+VM_rint, // #36 float(float v) rint (QUAKE)
+VM_floor, // #37 float(float v) floor (QUAKE)
+VM_ceil, // #38 float(float v) ceil (QUAKE)
+NULL, // #39 (QUAKE)
+VM_CL_checkbottom, // #40 float(entity e) checkbottom (QUAKE)
+VM_CL_pointcontents, // #41 float(vector v) pointcontents (QUAKE)
+NULL, // #42 (QUAKE)
+VM_fabs, // #43 float(float f) fabs (QUAKE)
+NULL, // #44 vector(entity e, float speed) aim (QUAKE)
+VM_cvar, // #45 float(string s) cvar (QUAKE)
+VM_localcmd, // #46 void(string s) localcmd (QUAKE)
+VM_nextent, // #47 entity(entity e) nextent (QUAKE)
+VM_CL_particle, // #48 void(vector o, vector d, float color, float count) particle (QUAKE)
+VM_changeyaw, // #49 void() ChangeYaw (QUAKE)
+NULL, // #50 (QUAKE)
+VM_vectoangles, // #51 vector(vector v) vectoangles (QUAKE)
+NULL, // #52 void(float to, float f) WriteByte (QUAKE)
+NULL, // #53 void(float to, float f) WriteChar (QUAKE)
+NULL, // #54 void(float to, float f) WriteShort (QUAKE)
+NULL, // #55 void(float to, float f) WriteLong (QUAKE)
+NULL, // #56 void(float to, float f) WriteCoord (QUAKE)
+NULL, // #57 void(float to, float f) WriteAngle (QUAKE)
+NULL, // #58 void(float to, string s) WriteString (QUAKE)
+NULL, // #59 (QUAKE)
+VM_sin, // #60 float(float f) sin (DP_QC_SINCOSSQRTPOW)
+VM_cos, // #61 float(float f) cos (DP_QC_SINCOSSQRTPOW)
+VM_sqrt, // #62 float(float f) sqrt (DP_QC_SINCOSSQRTPOW)
+VM_changepitch, // #63 void(entity ent) changepitch (DP_QC_CHANGEPITCH)
+VM_CL_tracetoss, // #64 void(entity e, entity ignore) tracetoss (DP_QC_TRACETOSS)
+VM_etos, // #65 string(entity ent) etos (DP_QC_ETOS)
+NULL, // #66 (QUAKE)
+NULL, // #67 void(float step) movetogoal (QUAKE)
+VM_precache_file, // #68 string(string s) precache_file (QUAKE)
+VM_CL_makestatic, // #69 void(entity e) makestatic (QUAKE)
+NULL, // #70 void(string s) changelevel (QUAKE)
+NULL, // #71 (QUAKE)
+VM_cvar_set, // #72 void(string var, string val) cvar_set (QUAKE)
+NULL, // #73 void(entity client, strings) centerprint (QUAKE)
+VM_CL_ambientsound, // #74 void(vector pos, string samp, float vol, float atten) ambientsound (QUAKE)
+VM_CL_precache_model, // #75 string(string s) precache_model2 (QUAKE)
+VM_precache_sound, // #76 string(string s) precache_sound2 (QUAKE)
+VM_precache_file, // #77 string(string s) precache_file2 (QUAKE)
+NULL, // #78 void(entity e) setspawnparms (QUAKE)
+NULL, // #79 void(entity killer, entity killee) logfrag (QUAKEWORLD)
+NULL, // #80 string(entity e, string keyname) infokey (QUAKEWORLD)
+VM_stof, // #81 float(string s) stof (FRIK_FILE)
+NULL, // #82 void(vector where, float set) multicast (QUAKEWORLD)
+NULL, // #83 (QUAKE)
+NULL, // #84 (QUAKE)
+NULL, // #85 (QUAKE)
+NULL, // #86 (QUAKE)
+NULL, // #87 (QUAKE)
+NULL, // #88 (QUAKE)
+NULL, // #89 (QUAKE)
+VM_CL_tracebox, // #90 void(vector v1, vector min, vector max, vector v2, float nomonsters, entity forent) tracebox (DP_QC_TRACEBOX)
+VM_randomvec, // #91 vector() randomvec (DP_QC_RANDOMVEC)
+VM_CL_getlight, // #92 vector(vector org) getlight (DP_QC_GETLIGHT)
+VM_registercvar, // #93 float(string name, string value) registercvar (DP_REGISTERCVAR)
+VM_min, // #94 float(float a, floats) min (DP_QC_MINMAXBOUND)
+VM_max, // #95 float(float a, floats) max (DP_QC_MINMAXBOUND)
+VM_bound, // #96 float(float minimum, float val, float maximum) bound (DP_QC_MINMAXBOUND)
+VM_pow, // #97 float(float f, float f) pow (DP_QC_SINCOSSQRTPOW)
+VM_findfloat, // #98 entity(entity start, .float fld, float match) findfloat (DP_QC_FINDFLOAT)
+VM_checkextension, // #99 float(string s) checkextension (the basis of the extension system)
+// FrikaC and Telejano range #100-#199
+NULL, // #100
+NULL, // #101
+NULL, // #102
+NULL, // #103
+NULL, // #104
+NULL, // #105
+NULL, // #106
+NULL, // #107
+NULL, // #108
+NULL, // #109
+VM_fopen, // #110 float(string filename, float mode) fopen (FRIK_FILE)
+VM_fclose, // #111 void(float fhandle) fclose (FRIK_FILE)
+VM_fgets, // #112 string(float fhandle) fgets (FRIK_FILE)
+VM_fputs, // #113 void(float fhandle, string s) fputs (FRIK_FILE)
+VM_strlen, // #114 float(string s) strlen (FRIK_FILE)
+VM_strcat, // #115 string(string s1, string s2, ...) strcat (FRIK_FILE)
+VM_substring, // #116 string(string s, float start, float length) substring (FRIK_FILE)
+VM_stov, // #117 vector(string) stov (FRIK_FILE)
+VM_strzone, // #118 string(string s) strzone (FRIK_FILE)
+VM_strunzone, // #119 void(string s) strunzone (FRIK_FILE)
+NULL, // #120
+NULL, // #121
+NULL, // #122
+NULL, // #123
+NULL, // #124
+NULL, // #125
+NULL, // #126
+NULL, // #127
+NULL, // #128
+NULL, // #129
+NULL, // #130
+NULL, // #131
+NULL, // #132
+NULL, // #133
+NULL, // #134
+NULL, // #135
+NULL, // #136
+NULL, // #137
+NULL, // #138
+NULL, // #139
+NULL, // #140
+NULL, // #141
+NULL, // #142
+NULL, // #143
+NULL, // #144
+NULL, // #145
+NULL, // #146
+NULL, // #147
+NULL, // #148
+NULL, // #149
+NULL, // #150
+NULL, // #151
+NULL, // #152
+NULL, // #153
+NULL, // #154
+NULL, // #155
+NULL, // #156
+NULL, // #157
+NULL, // #158
+NULL, // #159
+NULL, // #160
+NULL, // #161
+NULL, // #162
+NULL, // #163
+NULL, // #164
+NULL, // #165
+NULL, // #166
+NULL, // #167
+NULL, // #168
+NULL, // #169
+NULL, // #170
+NULL, // #171
+NULL, // #172
+NULL, // #173
+NULL, // #174
+NULL, // #175
+NULL, // #176
+NULL, // #177
+NULL, // #178
+NULL, // #179
+NULL, // #180
+NULL, // #181
+NULL, // #182
+NULL, // #183
+NULL, // #184
+NULL, // #185
+NULL, // #186
+NULL, // #187
+NULL, // #188
+NULL, // #189
+NULL, // #190
+NULL, // #191
+NULL, // #192
+NULL, // #193
+NULL, // #194
+NULL, // #195
+NULL, // #196
+NULL, // #197
+NULL, // #198
+NULL, // #199
+// FTEQW range #200-#299
+NULL, // #200
+NULL, // #201
+NULL, // #202
+NULL, // #203
+NULL, // #204
+NULL, // #205
+NULL, // #206
+NULL, // #207
+NULL, // #208
+NULL, // #209
+NULL, // #210
+NULL, // #211
+NULL, // #212
+NULL, // #213
+NULL, // #214
+NULL, // #215
+NULL, // #216
+NULL, // #217
+VM_bitshift, // #218 float(float number, float quantity) bitshift (EXT_BITSHIFT)
+NULL, // #219
+NULL, // #220
+VM_strstrofs, // #221 float(string str, string sub[, float startpos]) strstrofs (FTE_STRINGS)
+VM_str2chr, // #222 float(string str, float ofs) str2chr (FTE_STRINGS)
+VM_chr2str, // #223 string(float c, ...) chr2str (FTE_STRINGS)
+VM_strconv, // #224 string(float ccase, float calpha, float cnum, string s, ...) strconv (FTE_STRINGS)
+VM_strpad, // #225 string(float chars, string s, ...) strpad (FTE_STRINGS)
+VM_infoadd, // #226 string(string info, string key, string value, ...) infoadd (FTE_STRINGS)
+VM_infoget, // #227 string(string info, string key) infoget (FTE_STRINGS)
+VM_strncmp, // #228 float(string s1, string s2, float len) strncmp (FTE_STRINGS)
+VM_strncasecmp, // #229 float(string s1, string s2) strcasecmp (FTE_STRINGS)
+VM_strncasecmp, // #230 float(string s1, string s2, float len) strncasecmp (FTE_STRINGS)
+NULL, // #231
+NULL, // #232 void(float index, float type, .void field) SV_AddStat (EXT_CSQC)
+NULL, // #233
+NULL, // #234
+NULL, // #235
+NULL, // #236
+NULL, // #237
+NULL, // #238
+NULL, // #239
+VM_CL_checkpvs, // #240
+NULL, // #241
+NULL, // #242
+NULL, // #243
+NULL, // #244
+NULL, // #245
+NULL, // #246
+NULL, // #247
+NULL, // #248
+NULL, // #249
+NULL, // #250
+NULL, // #251
+NULL, // #252
+NULL, // #253
+NULL, // #254
+NULL, // #255
+NULL, // #256
+NULL, // #257
+NULL, // #258
+NULL, // #259
+NULL, // #260
+NULL, // #261
+NULL, // #262
+VM_CL_skel_create, // #263 float(float modlindex) skel_create = #263; // (FTE_CSQC_SKELETONOBJECTS) create a skeleton (be sure to assign this value into .skeletonindex for use), returns skeleton index (1 or higher) on success, returns 0 on failure (for example if the modelindex is not skeletal), it is recommended that you create a new skeleton if you change modelindex.
+VM_CL_skel_build, // #264 float(float skel, entity ent, float modlindex, float retainfrac, float firstbone, float lastbone) skel_build = #264; // (FTE_CSQC_SKELETONOBJECTS) blend in a percentage of standard animation, 0 replaces entirely, 1 does nothing, 0.5 blends half, etc, and this only alters the bones in the specified range for which out of bounds values like 0,100000 are safe (uses .frame, .frame2, .frame3, .frame4, .lerpfrac, .lerpfrac3, .lerpfrac4, .frame1time, .frame2time, .frame3time, .frame4time), returns skel on success, 0 on failure
+VM_CL_skel_get_numbones, // #265 float(float skel) skel_get_numbones = #265; // (FTE_CSQC_SKELETONOBJECTS) returns how many bones exist in the created skeleton
+VM_CL_skel_get_bonename, // #266 string(float skel, float bonenum) skel_get_bonename = #266; // (FTE_CSQC_SKELETONOBJECTS) returns name of bone (as a tempstring)
+VM_CL_skel_get_boneparent, // #267 float(float skel, float bonenum) skel_get_boneparent = #267; // (FTE_CSQC_SKELETONOBJECTS) returns parent num for supplied bonenum, -1 if bonenum has no parent or bone does not exist (returned value is always less than bonenum, you can loop on this)
+VM_CL_skel_find_bone, // #268 float(float skel, string tagname) skel_find_bone = #268; // (FTE_CSQC_SKELETONOBJECTS) get number of bone with specified name, 0 on failure, tagindex (bonenum+1) on success, same as using gettagindex on the modelindex
+VM_CL_skel_get_bonerel, // #269 vector(float skel, float bonenum) skel_get_bonerel = #269; // (FTE_CSQC_SKELETONOBJECTS) get matrix of bone in skeleton relative to its parent - sets v_forward, v_right, v_up, returns origin (relative to parent bone)
+VM_CL_skel_get_boneabs, // #270 vector(float skel, float bonenum) skel_get_boneabs = #270; // (FTE_CSQC_SKELETONOBJECTS) get matrix of bone in skeleton in model space - sets v_forward, v_right, v_up, returns origin (relative to entity)
+VM_CL_skel_set_bone, // #271 void(float skel, float bonenum, vector org) skel_set_bone = #271; // (FTE_CSQC_SKELETONOBJECTS) set matrix of bone relative to its parent, reads v_forward, v_right, v_up, takes origin as parameter (relative to parent bone)
+VM_CL_skel_mul_bone, // #272 void(float skel, float bonenum, vector org) skel_mul_bone = #272; // (FTE_CSQC_SKELETONOBJECTS) transform bone matrix (relative to its parent) by the supplied matrix in v_forward, v_right, v_up, takes origin as parameter (relative to parent bone)
+VM_CL_skel_mul_bones, // #273 void(float skel, float startbone, float endbone, vector org) skel_mul_bones = #273; // (FTE_CSQC_SKELETONOBJECTS) transform bone matrices (relative to their parents) by the supplied matrix in v_forward, v_right, v_up, takes origin as parameter (relative to parent bones)
+VM_CL_skel_copybones, // #274 void(float skeldst, float skelsrc, float startbone, float endbone) skel_copybones = #274; // (FTE_CSQC_SKELETONOBJECTS) copy bone matrices (relative to their parents) from one skeleton to another, useful for copying a skeleton to a corpse
+VM_CL_skel_delete, // #275 void(float skel) skel_delete = #275; // (FTE_CSQC_SKELETONOBJECTS) deletes skeleton at the beginning of the next frame (you can add the entity, delete the skeleton, renderscene, and it will still work)
+VM_CL_frameforname, // #276 float(float modlindex, string framename) frameforname = #276; // (FTE_CSQC_SKELETONOBJECTS) finds number of a specified frame in the animation, returns -1 if no match found
+VM_CL_frameduration, // #277 float(float modlindex, float framenum) frameduration = #277; // (FTE_CSQC_SKELETONOBJECTS) returns the intended play time (in seconds) of the specified framegroup, if it does not exist the result is 0, if it is a single frame it may be a small value around 0.1 or 0.
+NULL, // #278
+NULL, // #279
+NULL, // #280
+NULL, // #281
+NULL, // #282
+NULL, // #283
+NULL, // #284
+NULL, // #285
+NULL, // #286
+NULL, // #287
+NULL, // #288
+NULL, // #289
+NULL, // #290
+NULL, // #291
+NULL, // #292
+NULL, // #293
+NULL, // #294
+NULL, // #295
+NULL, // #296
+NULL, // #297
+NULL, // #298
+NULL, // #299
+// CSQC range #300-#399
+VM_CL_R_ClearScene, // #300 void() clearscene (EXT_CSQC)
+VM_CL_R_AddEntities, // #301 void(float mask) addentities (EXT_CSQC)
+VM_CL_R_AddEntity, // #302 void(entity ent) addentity (EXT_CSQC)
+VM_CL_R_SetView, // #303 float(float property, ...) setproperty (EXT_CSQC)
+VM_CL_R_RenderScene, // #304 void() renderscene (EXT_CSQC)
+VM_CL_R_AddDynamicLight, // #305 void(vector org, float radius, vector lightcolours) adddynamiclight (EXT_CSQC)
+VM_CL_R_PolygonBegin, // #306 void(string texturename, float flag, float is2d[NYI: , float lines]) R_BeginPolygon
+VM_CL_R_PolygonVertex, // #307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
+VM_CL_R_PolygonEnd, // #308 void() R_EndPolygon
+NULL /* R_LoadWorldModel in menu VM, should stay unassigned in client*/, // #309
+VM_CL_unproject, // #310 vector (vector v) cs_unproject (EXT_CSQC)
+VM_CL_project, // #311 vector (vector v) cs_project (EXT_CSQC)
+NULL, // #312
+NULL, // #313
+NULL, // #314
+VM_drawline, // #315 void(float width, vector pos1, vector pos2, float flag) drawline (EXT_CSQC)
+VM_iscachedpic, // #316 float(string name) iscachedpic (EXT_CSQC)
+VM_precache_pic, // #317 string(string name, float trywad) precache_pic (EXT_CSQC)
+VM_getimagesize, // #318 vector(string picname) draw_getimagesize (EXT_CSQC)
+VM_freepic, // #319 void(string name) freepic (EXT_CSQC)
+VM_drawcharacter, // #320 float(vector position, float character, vector scale, vector rgb, float alpha, float flag) drawcharacter (EXT_CSQC)
+VM_drawstring, // #321 float(vector position, string text, vector scale, vector rgb, float alpha, float flag) drawstring (EXT_CSQC)
+VM_drawpic, // #322 float(vector position, string pic, vector size, vector rgb, float alpha, float flag) drawpic (EXT_CSQC)
+VM_drawfill, // #323 float(vector position, vector size, vector rgb, float alpha, float flag) drawfill (EXT_CSQC)
+VM_drawsetcliparea, // #324 void(float x, float y, float width, float height) drawsetcliparea
+VM_drawresetcliparea, // #325 void(void) drawresetcliparea
+VM_drawcolorcodedstring, // #326 float drawcolorcodedstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) (EXT_CSQC)
+VM_stringwidth, // #327 // FIXME is this okay?
+VM_drawsubpic, // #328 // FIXME is this okay?
+VM_drawrotpic, // #329 // FIXME is this okay?
+VM_CL_getstatf, // #330 float(float stnum) getstatf (EXT_CSQC)
+VM_CL_getstati, // #331 float(float stnum) getstati (EXT_CSQC)
+VM_CL_getstats, // #332 string(float firststnum) getstats (EXT_CSQC)
+VM_CL_setmodelindex, // #333 void(entity e, float mdlindex) setmodelindex (EXT_CSQC)
+VM_CL_modelnameforindex, // #334 string(float mdlindex) modelnameforindex (EXT_CSQC)
+VM_CL_particleeffectnum, // #335 float(string effectname) particleeffectnum (EXT_CSQC)
+VM_CL_trailparticles, // #336 void(entity ent, float effectnum, vector start, vector end) trailparticles (EXT_CSQC)
+VM_CL_pointparticles, // #337 void(float effectnum, vector origin [, vector dir, float count]) pointparticles (EXT_CSQC)
+VM_centerprint, // #338 void(string s, ...) centerprint (EXT_CSQC)
+VM_print, // #339 void(string s, ...) print (EXT_CSQC, DP_SV_PRINT)
+VM_keynumtostring, // #340 string(float keynum) keynumtostring (EXT_CSQC)
+VM_stringtokeynum, // #341 float(string keyname) stringtokeynum (EXT_CSQC)
+VM_getkeybind, // #342 string(float keynum[, float bindmap]) getkeybind (EXT_CSQC)
+VM_CL_setcursormode, // #343 void(float usecursor) setcursormode (EXT_CSQC)
+VM_CL_getmousepos, // #344 vector() getmousepos (EXT_CSQC)
+VM_CL_getinputstate, // #345 float(float framenum) getinputstate (EXT_CSQC)
+VM_CL_setsensitivityscale, // #346 void(float sens) setsensitivityscale (EXT_CSQC)
+VM_CL_runplayerphysics, // #347 void() runstandardplayerphysics (EXT_CSQC)
+VM_CL_getplayerkey, // #348 string(float playernum, string keyname) getplayerkeyvalue (EXT_CSQC)
+VM_CL_isdemo, // #349 float() isdemo (EXT_CSQC)
+VM_isserver, // #350 float() isserver (EXT_CSQC)
+VM_CL_setlistener, // #351 void(vector origin, vector forward, vector right, vector up) SetListener (EXT_CSQC)
+VM_CL_registercmd, // #352 void(string cmdname) registercommand (EXT_CSQC)
+VM_wasfreed, // #353 float(entity ent) wasfreed (EXT_CSQC) (should be availabe on server too)
+VM_CL_serverkey, // #354 string(string key) serverkey (EXT_CSQC)
+VM_CL_videoplaying, // #355
+VM_findfont, // #356 float(string fontname) loadfont (DP_GFX_FONTS)
+VM_loadfont, // #357 float(string fontname, string fontmaps, string sizes, float slot) loadfont (DP_GFX_FONTS)
+NULL, // #358
+NULL, // #359
+VM_CL_ReadByte, // #360 float() readbyte (EXT_CSQC)
+VM_CL_ReadChar, // #361 float() readchar (EXT_CSQC)
+VM_CL_ReadShort, // #362 float() readshort (EXT_CSQC)
+VM_CL_ReadLong, // #363 float() readlong (EXT_CSQC)
+VM_CL_ReadCoord, // #364 float() readcoord (EXT_CSQC)
+VM_CL_ReadAngle, // #365 float() readangle (EXT_CSQC)
+VM_CL_ReadString, // #366 string() readstring (EXT_CSQC)
+VM_CL_ReadFloat, // #367 float() readfloat (EXT_CSQC)
+NULL, // #368
+NULL, // #369
+NULL, // #370
+NULL, // #371
+NULL, // #372
+NULL, // #373
+NULL, // #374
+NULL, // #375
+NULL, // #376
+NULL, // #377
+NULL, // #378
+NULL, // #379
+NULL, // #380
+NULL, // #381
+NULL, // #382
+NULL, // #383
+NULL, // #384
+NULL, // #385
+NULL, // #386
+NULL, // #387
+NULL, // #388
+NULL, // #389
+NULL, // #390
+NULL, // #391
+NULL, // #392
+NULL, // #393
+NULL, // #394
+NULL, // #395
+NULL, // #396
+NULL, // #397
+NULL, // #398
+NULL, // #399
+// LordHavoc's range #400-#499
+VM_CL_copyentity, // #400 void(entity from, entity to) copyentity (DP_QC_COPYENTITY)
+NULL, // #401 void(entity ent, float colors) setcolor (DP_QC_SETCOLOR)
+VM_findchain, // #402 entity(.string fld, string match) findchain (DP_QC_FINDCHAIN)
+VM_findchainfloat, // #403 entity(.float fld, float match) findchainfloat (DP_QC_FINDCHAINFLOAT)
+VM_CL_effect, // #404 void(vector org, string modelname, float startframe, float endframe, float framerate) effect (DP_SV_EFFECT)
+VM_CL_te_blood, // #405 void(vector org, vector velocity, float howmany) te_blood (DP_TE_BLOOD)
+VM_CL_te_bloodshower, // #406 void(vector mincorner, vector maxcorner, float explosionspeed, float howmany) te_bloodshower (DP_TE_BLOODSHOWER)
+VM_CL_te_explosionrgb, // #407 void(vector org, vector color) te_explosionrgb (DP_TE_EXPLOSIONRGB)