3 #include "cl_collision.h"
5 //============================================================================
7 //[515]: unsolved PROBLEMS
8 //- finish player physics code (cs_runplayerphysics)
9 //- fix R_AddDynamicLight
11 //- RF_DEPTHHACK is not like it should be
12 //- add builtin that sets cl.viewangles instead of reading "input_angles" global
13 //- finish lines support for R_Polygon***
14 //- insert selecttraceline into traceline somehow
16 //4 feature darkplaces csqc: add builtin to clientside qc for reading triangles of model meshes (useful to orient a ui along a triangle of a model mesh)
17 //4 feature darkplaces csqc: add builtins to clientside qc for gl calls
19 //[515]: really need new list ?
20 char *vm_cl_extensions =
35 "DP_ENT_CUSTOMCOLORMAP "
38 "DP_GFX_EXTERNALTEXTURES "
39 "DP_GFX_EXTERNALTEXTURES_PERMAP "
41 "DP_GFX_QUAKE3MODELTAGS "
45 "DP_HALFLIFE_MAP_CVAR "
51 "DP_MOVETYPEBOUNCEMISSILE "
53 "DP_QC_ASINACOSATANATAN2TAN "
59 "DP_QC_FINDCHAINFLAGS "
60 "DP_QC_FINDCHAINFLOAT "
63 "DP_QC_FS_SEARCH " // Black: same as in the menu qc
68 "DP_QC_MULTIPLETEMPSTRINGS "
70 "DP_QC_SINCOSSQRTPOW "
71 //"DP_QC_STRINGBUFFERS " //[515]: not needed ?
73 "DP_QC_STRINGCOLORFUNCTIONS "
76 "DP_QC_TRACE_MOVETYPE_HITMODEL "
77 "DP_QC_TRACE_MOVETYPE_WORLDONLY "
78 "DP_QC_UNLIMITEDTEMPSTRINGS "
79 "DP_QC_VECTORVECTORS "
85 "DP_SND_DIRECTIONLESSATTNNONE "
92 "DP_SV_ROTATINGBMODEL "
100 "DP_TE_PARTICLERAIN "
101 "DP_TE_PARTICLESNOW "
103 "DP_TE_QUADEFFECTS1 "
106 "DP_TE_STANDARDEFFECTBUILTINS "
110 "KRIMZON_SV_PARSECLIENTCOMMAND "
113 "PRYDON_CLIENTCURSOR "
114 "TENEBRAE_GFX_DLIGHTS "
116 "NEXUIZ_PLAYERMODEL "
120 sfx_t *S_FindName(const char *name);
121 void PF_registercvar (void);
122 int Sbar_GetPlayer (int index);
123 void Sbar_SortFrags (void);
124 void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius);
125 void CSQC_RelinkAllEntities (int drawmask);
126 void CSQC_RelinkCSQCEntities (void);
127 char *Key_GetBind (int key);
128 model_t *CSQC_GetModelByIndex(int modelindex);
129 model_t *CSQC_GetModelFromEntity(prvm_edict_t *ed);
136 // #1 void(vector ang) makevectors
137 void VM_CL_makevectors (void)
139 VM_SAFEPARMCOUNT(1, VM_CL_makevectors);
140 AngleVectors (PRVM_G_VECTOR(OFS_PARM0), prog->globals.client->v_forward, prog->globals.client->v_right, prog->globals.client->v_up);
143 // #2 void(entity e, vector o) setorigin
144 void VM_CL_setorigin (void)
149 e = PRVM_G_EDICT(OFS_PARM0);
150 if (e == prog->edicts)
152 VM_Warning("setorigin: can not modify world entity\n");
155 if (e->priv.required->free)
157 VM_Warning("setorigin: can not modify free entity\n");
160 org = PRVM_G_VECTOR(OFS_PARM1);
161 VectorCopy (org, e->fields.client->origin);
164 // #3 void(entity e, string m) setmodel
165 void VM_CL_setmodel (void)
172 VM_SAFEPARMCOUNT(2, VM_CL_setmodel);
174 e = PRVM_G_EDICT(OFS_PARM0);
175 m = PRVM_G_STRING(OFS_PARM1);
176 for (i = 0;i < MAX_MODELS && cl.csqc_model_precache[i];i++)
178 if (!strcmp(cl.csqc_model_precache[i]->name, m))
180 e->fields.client->model = PRVM_SetEngineString(cl.csqc_model_precache[i]->name);
181 e->fields.client->modelindex = -(i+1);
186 for (i = 0;i < MAX_MODELS;i++)
188 mod = cl.model_precache[i];
189 if (mod && !strcmp(mod->name, m))
191 e->fields.client->model = PRVM_SetEngineString(mod->name);
192 e->fields.client->modelindex = i;
197 e->fields.client->modelindex = 0;
198 e->fields.client->model = 0;
201 // #4 void(entity e, vector min, vector max) setsize
202 void VM_CL_setsize (void)
206 VM_SAFEPARMCOUNT(3, VM_CL_setsize);
208 e = PRVM_G_EDICT(OFS_PARM0);
209 if (e == prog->edicts)
211 VM_Warning("setsize: can not modify world entity\n");
214 if (e->priv.server->free)
216 VM_Warning("setsize: can not modify free entity\n");
219 min = PRVM_G_VECTOR(OFS_PARM1);
220 max = PRVM_G_VECTOR(OFS_PARM2);
222 VectorCopy (min, e->fields.client->mins);
223 VectorCopy (max, e->fields.client->maxs);
224 VectorSubtract (max, min, e->fields.client->size);
227 // #8 void(entity e, float chan, string samp) sound
228 void VM_CL_sound (void)
232 prvm_edict_t *entity;
236 VM_SAFEPARMCOUNT(5, VM_CL_sound);
238 entity = PRVM_G_EDICT(OFS_PARM0);
239 channel = (int)PRVM_G_FLOAT(OFS_PARM1);
240 sample = PRVM_G_STRING(OFS_PARM2);
241 volume = (int)(PRVM_G_FLOAT(OFS_PARM3)*255.0f);
242 attenuation = PRVM_G_FLOAT(OFS_PARM4);
244 if (volume < 0 || volume > 255)
246 VM_Warning("VM_CL_sound: volume must be in range 0-1\n");
250 if (attenuation < 0 || attenuation > 4)
252 VM_Warning("VM_CL_sound: attenuation must be in range 0-4\n");
256 if (channel < 0 || channel > 7)
258 VM_Warning("VM_CL_sound: channel must be in range 0-7\n");
262 S_StartSound(32768 + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), entity->fields.client->origin, volume, attenuation);
265 // #14 entity() spawn
266 void VM_CL_spawn (void)
269 ed = PRVM_ED_Alloc();
270 ed->fields.client->entnum = PRVM_NUM_FOR_EDICT(ed); //[515]: not needed any more ?
274 // #16 float(vector v1, vector v2, float tryents) traceline
275 void VM_CL_traceline (void)
281 v1 = PRVM_G_VECTOR(OFS_PARM0);
282 v2 = PRVM_G_VECTOR(OFS_PARM1);
284 trace = CL_TraceBox(v1, vec3_origin, vec3_origin, v2, 1, &ent, 1, false);
286 prog->globals.client->trace_allsolid = trace.allsolid;
287 prog->globals.client->trace_startsolid = trace.startsolid;
288 prog->globals.client->trace_fraction = trace.fraction;
289 prog->globals.client->trace_inwater = trace.inwater;
290 prog->globals.client->trace_inopen = trace.inopen;
291 VectorCopy (trace.endpos, prog->globals.client->trace_endpos);
292 VectorCopy (trace.plane.normal, prog->globals.client->trace_plane_normal);
293 prog->globals.client->trace_plane_dist = trace.plane.dist;
295 prog->globals.client->trace_ent = ent;
297 prog->globals.client->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts);
300 // #19 void(string s) precache_sound
301 void VM_CL_precache_sound (void)
303 VM_SAFEPARMCOUNT(1, VM_CL_precache_sound);
304 S_PrecacheSound(PRVM_G_STRING(OFS_PARM0), true, false);
307 // #20 void(string s) precache_model
308 void VM_CL_precache_model (void)
314 VM_SAFEPARMCOUNT(1, VM_CL_precache_model);
316 name = PRVM_G_STRING(OFS_PARM0);
317 for (i = 1;i < MAX_MODELS && cl.csqc_model_precache[i];i++)
319 if(!strcmp(cl.csqc_model_precache[i]->name, name))
321 PRVM_G_FLOAT(OFS_RETURN) = -(i+1);
325 PRVM_G_FLOAT(OFS_RETURN) = 0;
326 m = Mod_ForName(name, false, false, false);
329 for (i = 1;i < MAX_MODELS;i++)
331 if (!cl.csqc_model_precache[i])
333 cl.csqc_model_precache[i] = (model_t*)m;
334 PRVM_G_FLOAT(OFS_RETURN) = -(i+1);
338 VM_Warning("VM_CL_precache_model: no free models\n");
341 VM_Warning("VM_CL_precache_model: model \"%s\" not found\n", name);
344 int CSQC_EntitiesInBox (vec3_t mins, vec3_t maxs, int maxlist, prvm_edict_t **list)
349 ent = PRVM_NEXT_EDICT(prog->edicts);
350 for(k=0,i=1; i<prog->num_edicts ;i++, ent = PRVM_NEXT_EDICT(ent))
352 if (ent->priv.required->free)
354 // VectorAdd(ent->fields.client->origin, ent->fields.client->mins, ent->fields.client->absmin);
355 // VectorAdd(ent->fields.client->origin, ent->fields.client->maxs, ent->fields.client->absmax);
356 if(BoxesOverlap(mins, maxs, ent->fields.client->absmin, ent->fields.client->absmax))
362 // #22 entity(vector org, float rad) findradius
363 void VM_CL_findradius (void)
365 prvm_edict_t *ent, *chain;
366 vec_t radius, radius2;
367 vec3_t org, eorg, mins, maxs;
368 int i, numtouchedicts;
369 prvm_edict_t *touchedicts[MAX_EDICTS];
371 chain = (prvm_edict_t *)prog->edicts;
373 VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
374 radius = PRVM_G_FLOAT(OFS_PARM1);
375 radius2 = radius * radius;
377 mins[0] = org[0] - (radius + 1);
378 mins[1] = org[1] - (radius + 1);
379 mins[2] = org[2] - (radius + 1);
380 maxs[0] = org[0] + (radius + 1);
381 maxs[1] = org[1] + (radius + 1);
382 maxs[2] = org[2] + (radius + 1);
383 numtouchedicts = CSQC_EntitiesInBox(mins, maxs, MAX_EDICTS, touchedicts);
384 if (numtouchedicts > MAX_EDICTS)
386 // this never happens //[515]: for what then ?
387 Con_Printf("CSQC_EntitiesInBox returned %i edicts, max was %i\n", numtouchedicts, MAX_EDICTS);
388 numtouchedicts = MAX_EDICTS;
390 for (i = 0;i < numtouchedicts;i++)
392 ent = touchedicts[i];
393 // Quake did not return non-solid entities but darkplaces does
394 // (note: this is the reason you can't blow up fallen zombies)
395 if (ent->fields.client->solid == SOLID_NOT && !sv_gameplayfix_blowupfallenzombies.integer)
397 // LordHavoc: compare against bounding box rather than center so it
398 // doesn't miss large objects, and use DotProduct instead of Length
399 // for a major speedup
400 VectorSubtract(org, ent->fields.client->origin, eorg);
401 if (sv_gameplayfix_findradiusdistancetobox.integer)
403 eorg[0] -= bound(ent->fields.client->mins[0], eorg[0], ent->fields.client->maxs[0]);
404 eorg[1] -= bound(ent->fields.client->mins[1], eorg[1], ent->fields.client->maxs[1]);
405 eorg[2] -= bound(ent->fields.client->mins[2], eorg[2], ent->fields.client->maxs[2]);
408 VectorMAMAM(1, eorg, 0.5f, ent->fields.client->mins, 0.5f, ent->fields.client->maxs, eorg);
409 if (DotProduct(eorg, eorg) < radius2)
411 ent->fields.client->chain = PRVM_EDICT_TO_PROG(chain);
416 VM_RETURN_EDICT(chain);
419 // #34 float() droptofloor
420 void VM_CL_droptofloor (void)
427 // assume failure if it returns early
428 PRVM_G_FLOAT(OFS_RETURN) = 0;
430 ent = PRVM_PROG_TO_EDICT(prog->globals.client->self);
431 if (ent == prog->edicts)
433 VM_Warning("droptofloor: can not modify world entity\n");
436 if (ent->priv.server->free)
438 VM_Warning("droptofloor: can not modify free entity\n");
442 VectorCopy (ent->fields.client->origin, end);
445 trace = CL_TraceBox(ent->fields.client->origin, ent->fields.client->mins, ent->fields.client->maxs, end, 1, &i, 1, false);
447 if (trace.fraction != 1)
449 VectorCopy (trace.endpos, ent->fields.client->origin);
450 ent->fields.client->flags = (int)ent->fields.client->flags | FL_ONGROUND;
451 // ent->fields.client->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
452 PRVM_G_FLOAT(OFS_RETURN) = 1;
453 // if support is destroyed, keep suspended (gross hack for floating items in various maps)
454 // ent->priv.server->suspendedinairflag = true;
458 // #35 void(float style, string value) lightstyle
459 void VM_CL_lightstyle (void)
464 VM_SAFEPARMCOUNT(2, VM_CL_lightstyle);
466 i = (int)PRVM_G_FLOAT(OFS_PARM0);
467 c = PRVM_G_STRING(OFS_PARM1);
468 if (i >= cl.max_lightstyle)
470 VM_Warning("VM_CL_lightstyle >= MAX_LIGHTSTYLES\n");
473 strlcpy (cl.lightstyle[i].map, MSG_ReadString(), sizeof (cl.lightstyle[i].map));
474 cl.lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
475 cl.lightstyle[i].length = (int)strlen(cl.lightstyle[i].map);
478 // #40 float(entity e) checkbottom
479 void VM_CL_checkbottom (void)
481 static int cs_yes, cs_no;
483 vec3_t mins, maxs, start, stop;
488 VM_SAFEPARMCOUNT(1, VM_CL_checkbottom);
489 ent = PRVM_G_EDICT(OFS_PARM0);
490 PRVM_G_FLOAT(OFS_RETURN) = 0;
492 VectorAdd (ent->fields.client->origin, ent->fields.client->mins, mins);
493 VectorAdd (ent->fields.client->origin, ent->fields.client->maxs, maxs);
495 // if all of the points under the corners are solid world, don't bother
496 // with the tougher checks
497 // the corners must be within 16 of the midpoint
498 start[2] = mins[2] - 1;
499 for (x=0 ; x<=1 ; x++)
500 for (y=0 ; y<=1 ; y++)
502 start[0] = x ? maxs[0] : mins[0];
503 start[1] = y ? maxs[1] : mins[1];
504 if (!(CL_PointSuperContents(start) & (SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY)))
509 PRVM_G_FLOAT(OFS_RETURN) = true;
510 return; // we got out easy
515 // check it for real...
519 // the midpoint must be within 16 of the bottom
520 start[0] = stop[0] = (mins[0] + maxs[0])*0.5;
521 start[1] = stop[1] = (mins[1] + maxs[1])*0.5;
522 stop[2] = start[2] - 2*sv_stepheight.value;
523 trace = CL_TraceBox (start, vec3_origin, vec3_origin, stop, 1, &hit, 1, true);
525 if (trace.fraction == 1.0)
528 mid = bottom = trace.endpos[2];
530 // the corners must be within 16 of the midpoint
531 for (x=0 ; x<=1 ; x++)
532 for (y=0 ; y<=1 ; y++)
534 start[0] = stop[0] = x ? maxs[0] : mins[0];
535 start[1] = stop[1] = y ? maxs[1] : mins[1];
537 trace = CL_TraceBox (start, vec3_origin, vec3_origin, stop, 1, &hit, 1, true);
539 if (trace.fraction != 1.0 && trace.endpos[2] > bottom)
540 bottom = trace.endpos[2];
541 if (trace.fraction == 1.0 || mid - trace.endpos[2] > sv_stepheight.value)
546 PRVM_G_FLOAT(OFS_RETURN) = true;
549 // #41 float(vector v) pointcontents
550 void VM_CL_pointcontents (void)
552 VM_SAFEPARMCOUNT(1, VM_CL_pointcontents);
553 PRVM_G_FLOAT(OFS_RETURN) = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, CL_PointSuperContents(PRVM_G_VECTOR(OFS_PARM0)));
556 // #48 void(vector o, vector d, float color, float count) particle
557 void VM_CL_particle (void)
562 VM_SAFEPARMCOUNT(4, VM_CL_particle);
564 org = PRVM_G_VECTOR(OFS_PARM0);
565 dir = PRVM_G_VECTOR(OFS_PARM1);
566 color = (int)PRVM_G_FLOAT(OFS_PARM2);
567 count = (int)PRVM_G_FLOAT(OFS_PARM3);
568 CL_ParticleEffect(EFFECT_SVC_PARTICLE, count, org, org, dir, dir, NULL, color);
571 // #49 void(entity ent, float ideal_yaw, float speed_yaw) ChangeYaw
572 void VM_CL_changeyaw (void)
575 float ideal, current, move, speed;
576 VM_SAFEPARMCOUNT(3, VM_CL_changeyaw);
578 ent = PRVM_G_EDICT(OFS_PARM0);
579 if (ent == prog->edicts)
581 VM_Warning("changeyaw: can not modify world entity\n");
584 if (ent->priv.server->free)
586 VM_Warning("changeyaw: can not modify free entity\n");
589 current = ANGLEMOD(ent->fields.client->angles[1]);
590 ideal = PRVM_G_FLOAT(OFS_PARM1);
591 speed = PRVM_G_FLOAT(OFS_PARM2);
593 if (current == ideal)
595 move = ideal - current;
617 ent->fields.client->angles[1] = ANGLEMOD (current + move);
620 // #63 void(entity ent, float ideal_pitch, float speed_pitch) changepitch (DP_QC_CHANGEPITCH)
621 void VM_CL_changepitch (void)
624 float ideal, current, move, speed;
625 VM_SAFEPARMCOUNT(3, VM_CL_changepitch);
627 ent = PRVM_G_EDICT(OFS_PARM0);
628 if (ent == prog->edicts)
630 VM_Warning("changepitch: can not modify world entity\n");
633 if (ent->priv.server->free)
635 VM_Warning("changepitch: can not modify free entity\n");
638 current = ANGLEMOD( ent->fields.client->angles[0] );
639 ideal = PRVM_G_FLOAT(OFS_PARM1);
640 speed = PRVM_G_FLOAT(OFS_PARM2);
642 if (current == ideal)
644 move = ideal - current;
666 ent->fields.client->angles[0] = ANGLEMOD (current + move);
669 // #64 void(entity e, entity ignore) tracetoss (DP_QC_TRACETOSS)
670 void VM_CL_tracetoss (void)
674 prvm_edict_t *ignore;
676 ent = PRVM_G_EDICT(OFS_PARM0);
677 if (ent == prog->edicts)
679 VM_Warning("tracetoss: can not use world entity\n");
682 ignore = PRVM_G_EDICT(OFS_PARM1);
685 trace = SV_Trace_Toss (ent, ignore);
687 prog->globals.server->trace_allsolid = trace.allsolid;
688 prog->globals.server->trace_startsolid = trace.startsolid;
689 prog->globals.server->trace_fraction = trace.fraction;
690 prog->globals.server->trace_inwater = trace.inwater;
691 prog->globals.server->trace_inopen = trace.inopen;
692 VectorCopy (trace.endpos, prog->globals.server->trace_endpos);
693 VectorCopy (trace.plane.normal, prog->globals.server->trace_plane_normal);
694 prog->globals.server->trace_plane_dist = trace.plane.dist;
696 prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(trace.ent);
698 prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts);
702 // #74 void(vector pos, string samp, float vol, float atten) ambientsound
703 void VM_CL_ambientsound (void)
707 VM_SAFEPARMCOUNT(4, VM_CL_ambientsound);
708 s = S_FindName(PRVM_G_STRING(OFS_PARM0));
709 f = PRVM_G_VECTOR(OFS_PARM1);
710 S_StaticSound (s, f, PRVM_G_FLOAT(OFS_PARM2), PRVM_G_FLOAT(OFS_PARM3)*64);
713 // #90 void(vector v1, vector min, vector max, vector v2, float nomonsters, entity forent) tracebox (DP_QC_TRACEBOX)
714 void VM_CL_tracebox (void)
716 float *v1, *v2, *m1, *m2;
720 v1 = PRVM_G_VECTOR(OFS_PARM0);
721 m1 = PRVM_G_VECTOR(OFS_PARM1);
722 m2 = PRVM_G_VECTOR(OFS_PARM2);
723 v2 = PRVM_G_VECTOR(OFS_PARM3);
725 trace = CL_TraceBox(v1, m1, m2, v2, 1, &ent, 1, false);
727 prog->globals.client->trace_allsolid = trace.allsolid;
728 prog->globals.client->trace_startsolid = trace.startsolid;
729 prog->globals.client->trace_fraction = trace.fraction;
730 prog->globals.client->trace_inwater = trace.inwater;
731 prog->globals.client->trace_inopen = trace.inopen;
732 VectorCopy (trace.endpos, prog->globals.client->trace_endpos);
733 VectorCopy (trace.plane.normal, prog->globals.client->trace_plane_normal);
734 prog->globals.client->trace_plane_dist = trace.plane.dist;
736 prog->globals.client->trace_ent = ent;
738 prog->globals.client->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts);
741 // #92 vector(vector org) getlight (DP_QC_GETLIGHT)
742 void VM_CL_getlight (void)
744 vec3_t ambientcolor, diffusecolor, diffusenormal;
747 VM_SAFEPARMCOUNT(1, VM_CL_getlight);
749 p = PRVM_G_VECTOR(OFS_PARM0);
750 VectorClear(ambientcolor);
751 VectorClear(diffusecolor);
752 VectorClear(diffusenormal);
753 if (cl.worldmodel && cl.worldmodel->brush.LightPoint)
754 cl.worldmodel->brush.LightPoint(cl.worldmodel, p, ambientcolor, diffusecolor, diffusenormal);
755 VectorMA(ambientcolor, 0.5, diffusecolor, PRVM_G_VECTOR(OFS_RETURN));
759 //============================================================================
760 //[515]: SCENE MANAGER builtins
761 extern qboolean CSQC_AddRenderEdict (prvm_edict_t *ed);//csprogs.c
763 matrix4x4_t csqc_listenermatrix;
764 qboolean csqc_usecsqclistener = false;//[515]: per-frame
766 static void CSQC_R_RecalcView (void)
768 extern matrix4x4_t viewmodelmatrix;
769 viewmodelmatrix = identitymatrix;
770 r_view.matrix = identitymatrix;
771 Matrix4x4_CreateFromQuakeEntity(&r_view.matrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], 1);
772 Matrix4x4_CreateFromQuakeEntity(&viewmodelmatrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], cl_viewmodel_scale.value);
775 //#300 void() clearscene (EXT_CSQC)
776 void VM_R_ClearScene (void)
778 VM_SAFEPARMCOUNT(0, VM_R_ClearScene);
779 r_refdef.numentities = 0;
782 //#301 void(float mask) addentities (EXT_CSQC)
783 extern void CSQC_Predraw (prvm_edict_t *ed);//csprogs.c
784 extern void CSQC_Think (prvm_edict_t *ed);//csprogs.c
785 void VM_R_AddEntities (void)
789 VM_SAFEPARMCOUNT(1, VM_R_AddEntities);
790 drawmask = (int)PRVM_G_FLOAT(OFS_PARM0);
791 CSQC_RelinkAllEntities(drawmask);
793 *prog->time = cl.time;
794 for(i=1;i<prog->num_edicts;i++)
796 ed = &prog->edicts[i];
797 if(ed->priv.required->free)
799 VectorAdd(ed->fields.client->origin, ed->fields.client->mins, ed->fields.client->absmin);
800 VectorAdd(ed->fields.client->origin, ed->fields.client->maxs, ed->fields.client->absmax);
802 if(ed->priv.required->free)
804 // note that for RF_USEAXIS entities, Predraw sets v_forward/v_right/v_up globals that are read by CSQC_AddRenderEdict
806 if(ed->priv.required->free)
808 if(!((int)ed->fields.client->drawmask & drawmask))
810 CSQC_AddRenderEdict(ed);
814 //#302 void(entity ent) addentity (EXT_CSQC)
815 void VM_R_AddEntity (void)
817 VM_SAFEPARMCOUNT(1, VM_R_AddEntity);
818 CSQC_AddRenderEdict(PRVM_G_EDICT(OFS_PARM0));
821 //#303 float(float property, ...) setproperty (EXT_CSQC)
822 void VM_R_SetView (void)
829 VM_SAFEPARMCOUNT(2, VM_R_SetView);
831 c = (int)PRVM_G_FLOAT(OFS_PARM0);
832 f = PRVM_G_VECTOR(OFS_PARM1);
833 k = PRVM_G_FLOAT(OFS_PARM1);
837 case VF_MIN: r_view.x = (int)f[0];
838 r_view.y = (int)f[1];
840 case VF_MIN_X: r_view.x = (int)k;
842 case VF_MIN_Y: r_view.y = (int)k;
844 case VF_SIZE: r_view.width = (int)f[0];
845 r_view.height = (int)f[1];
847 case VF_SIZE_Y: r_view.width = (int)k;
849 case VF_SIZE_X: r_view.height = (int)k;
851 case VF_VIEWPORT: r_view.x = (int)f[0];
852 r_view.y = (int)f[1];
854 // TODO: make sure that view_z and view_depth are set properly even if csqc does not set them!
855 f = PRVM_G_VECTOR(OFS_PARM2);
856 r_view.width = (int)f[0];
857 r_view.height = (int)f[1];
860 case VF_FOV: //r_refdef.fov_x = f[0]; // FIXME!
861 //r_refdef.fov_y = f[1]; // FIXME!
863 case VF_FOVX: //r_refdef.fov_x = k; // FIXME!
865 case VF_FOVY: //r_refdef.fov_y = k; // FIXME!
867 case VF_ORIGIN: VectorCopy(f, csqc_origin);
870 case VF_ORIGIN_X: csqc_origin[0] = k;
873 case VF_ORIGIN_Y: csqc_origin[1] = k;
876 case VF_ORIGIN_Z: csqc_origin[2] = k;
879 case VF_ANGLES: VectorCopy(f, csqc_angles);
882 case VF_ANGLES_X: csqc_angles[0] = k;
885 case VF_ANGLES_Y: csqc_angles[1] = k;
888 case VF_ANGLES_Z: csqc_angles[2] = k;
891 case VF_DRAWWORLD: cl.csqc_vidvars.drawworld = k;
893 case VF_DRAWENGINESBAR: cl.csqc_vidvars.drawenginesbar = k;
895 case VF_DRAWCROSSHAIR: cl.csqc_vidvars.drawcrosshair = k;
898 case VF_CL_VIEWANGLES: VectorCopy(f, cl.viewangles);
900 case VF_CL_VIEWANGLES_X:cl.viewangles[0] = k;
902 case VF_CL_VIEWANGLES_Y:cl.viewangles[1] = k;
904 case VF_CL_VIEWANGLES_Z:cl.viewangles[2] = k;
907 default: PRVM_G_FLOAT(OFS_RETURN) = 0;
908 VM_Warning("VM_R_SetView : unknown parm %i\n", c);
911 PRVM_G_FLOAT(OFS_RETURN) = 1;
914 //#304 void() renderscene (EXT_CSQC)
915 void VM_R_RenderScene (void) //#134
917 VM_SAFEPARMCOUNT(0, VM_R_RenderScene);
918 // update all renderable network entities
923 //#305 void(vector org, float radius, vector lightcolours) adddynamiclight (EXT_CSQC)
924 void VM_R_AddDynamicLight (void)
927 matrix4x4_t tempmatrix;
928 VM_SAFEPARMCOUNT(3, VM_R_AddDynamicLight);
930 pos = PRVM_G_VECTOR(OFS_PARM0);
931 col = PRVM_G_VECTOR(OFS_PARM2);
932 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
933 CL_AllocDlight(NULL, &tempmatrix, PRVM_G_FLOAT(OFS_PARM1), col[0], col[1], col[2], 500, 0, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
934 //CL_AllocDlight(NULL, &tempmatrix, PRVM_G_FLOAT(OFS_PARM1), col[0], col[1], col[2], 500, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
937 //============================================================================
939 //#310 vector (vector v) cs_unproject (EXT_CSQC)
940 void VM_CL_unproject (void)
945 VM_SAFEPARMCOUNT(1, VM_CL_unproject);
946 f = PRVM_G_VECTOR(OFS_PARM0);
947 VectorSet(temp, f[2], f[0] * f[2] * -r_view.frustum_x * 2.0 / r_view.width, f[1] * f[2] * -r_view.frustum_y * 2.0 / r_view.height);
948 Matrix4x4_Transform(&r_view.matrix, temp, PRVM_G_VECTOR(OFS_RETURN));
951 //#311 vector (vector v) cs_project (EXT_CSQC)
952 void VM_CL_project (void)
958 VM_SAFEPARMCOUNT(1, VM_CL_project);
959 f = PRVM_G_VECTOR(OFS_PARM0);
960 Matrix4x4_Invert_Simple(&m, &r_view.matrix);
961 Matrix4x4_Transform(&m, f, v);
962 VectorSet(PRVM_G_VECTOR(OFS_RETURN), v[1]/v[0]/-r_view.frustum_x*0.5*r_view.width, v[2]/v[0]/-r_view.frustum_y*r_view.height*0.5, v[0]);
965 //#330 float(float stnum) getstatf (EXT_CSQC)
966 void VM_CL_getstatf (void)
974 VM_SAFEPARMCOUNT(1, VM_CL_getstatf);
975 i = (int)PRVM_G_FLOAT(OFS_PARM0);
976 if(i < 0 || i >= MAX_CL_STATS)
978 VM_Warning("VM_CL_getstatf: index>=MAX_CL_STATS or index<0\n");
982 PRVM_G_FLOAT(OFS_RETURN) = dat.f;
985 //#331 float(float stnum) getstati (EXT_CSQC)
986 void VM_CL_getstati (void)
989 VM_SAFEPARMCOUNT(1, VM_CL_getstati);
990 index = (int)PRVM_G_FLOAT(OFS_PARM0);
992 if(index < 0 || index >= MAX_CL_STATS)
994 VM_Warning("VM_CL_getstati: index>=MAX_CL_STATS or index<0\n");
998 PRVM_G_FLOAT(OFS_RETURN) = i;
1001 //#332 string(float firststnum) getstats (EXT_CSQC)
1002 void VM_CL_getstats (void)
1006 VM_SAFEPARMCOUNT(1, VM_CL_getstats);
1007 i = (int)PRVM_G_FLOAT(OFS_PARM0);
1008 if(i < 0 || i > MAX_CL_STATS-4)
1010 PRVM_G_INT(OFS_RETURN) = OFS_NULL;
1011 VM_Warning("VM_CL_getstats: index>MAX_CL_STATS-4 or index<0\n");
1014 strlcpy(t, (char*)&cl.stats[i], sizeof(t));
1015 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(t);
1018 //#333 void(entity e, float mdlindex) setmodelindex (EXT_CSQC)
1019 void VM_CL_setmodelindex (void)
1023 struct model_s *model;
1025 VM_SAFEPARMCOUNT(2, VM_CL_setmodelindex);
1027 t = PRVM_G_EDICT(OFS_PARM0);
1029 i = (int)PRVM_G_FLOAT(OFS_PARM1);
1031 t->fields.client->model = 0;
1032 t->fields.client->modelindex = 0;
1037 model = CSQC_GetModelByIndex(i);
1040 VM_Warning("VM_CL_setmodelindex: null model\n");
1043 t->fields.client->model = PRVM_SetEngineString(model->name);
1044 t->fields.client->modelindex = i;
1047 //#334 string(float mdlindex) modelnameforindex (EXT_CSQC)
1048 void VM_CL_modelnameforindex (void)
1052 VM_SAFEPARMCOUNT(1, VM_CL_modelnameforindex);
1054 PRVM_G_INT(OFS_RETURN) = OFS_NULL;
1055 model = CSQC_GetModelByIndex((int)PRVM_G_FLOAT(OFS_PARM0));
1056 PRVM_G_INT(OFS_RETURN) = model ? PRVM_SetEngineString(model->name) : 0;
1059 //#335 float(string effectname) particleeffectnum (EXT_CSQC)
1060 void VM_CL_particleeffectnum (void)
1063 VM_SAFEPARMCOUNT(1, VM_CL_particleeffectnum);
1064 i = CL_ParticleEffectIndexForName(PRVM_G_STRING(OFS_PARM0));
1067 PRVM_G_FLOAT(OFS_RETURN) = i;
1070 // #336 void(entity ent, float effectnum, vector start, vector end[, float color]) trailparticles (EXT_CSQC)
1071 void VM_CL_trailparticles (void)
1076 VM_SAFEPARMCOUNT(4, VM_CL_trailparticles);
1078 t = PRVM_G_EDICT(OFS_PARM0);
1079 i = (int)PRVM_G_FLOAT(OFS_PARM1);
1080 start = PRVM_G_VECTOR(OFS_PARM2);
1081 end = PRVM_G_VECTOR(OFS_PARM3);
1083 CL_ParticleEffect(i, VectorDistance(start, end), start, end, t->fields.client->velocity, t->fields.client->velocity, NULL, (int)PRVM_G_FLOAT(OFS_PARM4));
1086 //#337 void(float effectnum, vector origin, vector dir, float count) pointparticles (EXT_CSQC)
1087 void VM_CL_pointparticles (void)
1091 VM_SAFEPARMCOUNT(4, VM_CL_pointparticles);
1092 i = (int)PRVM_G_FLOAT(OFS_PARM0);
1093 f = PRVM_G_VECTOR(OFS_PARM1);
1094 v = PRVM_G_VECTOR(OFS_PARM2);
1095 n = (int)PRVM_G_FLOAT(OFS_PARM3);
1096 CL_ParticleEffect(i, n, f, f, v, v, NULL, 0);
1099 //#338 void(string s) cprint (EXT_CSQC)
1100 void VM_CL_centerprint (void)
1102 char s[VM_STRINGTEMP_LENGTH];
1104 VM_SAFEPARMCOUNT(1, VM_CL_centerprint);
1105 VM_VarString(0, s, sizeof(s));
1109 //#342 string(float keynum) getkeybind (EXT_CSQC)
1110 void VM_CL_getkeybind (void)
1112 VM_SAFEPARMCOUNT(1, VM_CL_getkeybind);
1113 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(Key_GetBind((int)PRVM_G_FLOAT(OFS_PARM0)));
1116 //#343 void(float usecursor) setcursormode (EXT_CSQC)
1117 void VM_CL_setcursormode (void)
1119 VM_SAFEPARMCOUNT(1, VM_CL_setcursormode);
1120 cl.csqc_wantsmousemove = PRVM_G_FLOAT(OFS_PARM0);
1121 cl_ignoremousemove = true;
1124 //#345 float(float framenum) getinputstate (EXT_CSQC)
1125 void VM_CL_getinputstate (void)
1128 VM_SAFEPARMCOUNT(1, VM_CL_getinputstate);
1129 frame = (int)PRVM_G_FLOAT(OFS_PARM0);
1130 for (i = 0;i < cl.movement_numqueue;i++)
1131 if (cl.movement_queue[i].sequence == frame)
1133 VectorCopy(cl.movement_queue[i].viewangles, prog->globals.client->input_angles);
1134 //prog->globals.client->input_buttons = cl.movement_queue[i].//FIXME
1135 VectorCopy(cl.movement_queue[i].move, prog->globals.client->input_movevalues);
1136 prog->globals.client->input_timelength = cl.movement_queue[i].frametime;
1137 if(cl.movement_queue[i].crouch)
1139 VectorCopy(cl.playercrouchmins, prog->globals.client->pmove_mins);
1140 VectorCopy(cl.playercrouchmaxs, prog->globals.client->pmove_maxs);
1144 VectorCopy(cl.playerstandmins, prog->globals.client->pmove_mins);
1145 VectorCopy(cl.playerstandmaxs, prog->globals.client->pmove_maxs);
1150 //#346 void(float sens) setsensitivityscaler (EXT_CSQC)
1151 void VM_CL_setsensitivityscale (void)
1153 VM_SAFEPARMCOUNT(1, VM_CL_setsensitivityscale);
1154 cl.sensitivityscale = PRVM_G_FLOAT(OFS_PARM0);
1157 //#347 void() runstandardplayerphysics (EXT_CSQC)
1158 void VM_CL_runplayerphysics (void)
1162 //#348 string(float playernum, string keyname) getplayerkeyvalue (EXT_CSQC)
1163 void VM_CL_getplayerkey (void)
1169 VM_SAFEPARMCOUNT(2, VM_CL_getplayerkey);
1171 i = (int)PRVM_G_FLOAT(OFS_PARM0);
1172 c = PRVM_G_STRING(OFS_PARM1);
1173 PRVM_G_INT(OFS_RETURN) = OFS_NULL;
1176 i = Sbar_GetPlayer(i);
1182 if(!strcasecmp(c, "name"))
1183 strlcpy(t, cl.scores[i].name, sizeof(t));
1185 if(!strcasecmp(c, "frags"))
1186 sprintf(t, "%i", cl.scores[i].frags);
1188 if(!strcasecmp(c, "ping"))
1189 sprintf(t, "%i", cl.scores[i].qw_ping);
1191 if(!strcasecmp(c, "entertime"))
1192 sprintf(t, "%f", cl.scores[i].qw_entertime);
1194 if(!strcasecmp(c, "colors"))
1195 sprintf(t, "%i", cl.scores[i].colors);
1197 if(!strcasecmp(c, "topcolor"))
1198 sprintf(t, "%i", cl.scores[i].colors & 0xf0);
1200 if(!strcasecmp(c, "bottomcolor"))
1201 sprintf(t, "%i", (cl.scores[i].colors &15)<<4);
1203 if(!strcasecmp(c, "viewentity"))
1204 sprintf(t, "%i", i+1);
1207 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(t);
1210 //#349 float() isdemo (EXT_CSQC)
1211 void VM_CL_isdemo (void)
1213 PRVM_G_FLOAT(OFS_RETURN) = cls.demoplayback;
1216 //#351 void(vector origin, vector forward, vector right, vector up) SetListener (EXT_CSQC)
1217 void VM_CL_setlistener (void)
1219 VM_SAFEPARMCOUNT(4, VM_CL_setlistener);
1220 Matrix4x4_FromVectors(&csqc_listenermatrix, PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), PRVM_G_VECTOR(OFS_PARM3), PRVM_G_VECTOR(OFS_PARM0));
1221 csqc_usecsqclistener = true; //use csqc listener at this frame
1224 //#352 void(string cmdname) registercommand (EXT_CSQC)
1225 void VM_CL_registercmd (void)
1228 VM_SAFEPARMCOUNT(1, VM_CL_registercmd);
1229 if(!Cmd_Exists(PRVM_G_STRING(OFS_PARM0)))
1233 alloclen = strlen(PRVM_G_STRING(OFS_PARM0)) + 1;
1234 t = (char *)Z_Malloc(alloclen);
1235 memcpy(t, PRVM_G_STRING(OFS_PARM0), alloclen);
1236 Cmd_AddCommand(t, NULL, "console command created by QuakeC");
1239 Cmd_AddCommand(PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC");
1243 //#354 float() playernum (EXT_CSQC)
1244 void VM_CL_playernum (void)
1248 VM_SAFEPARMCOUNT(0, VM_CL_playernum);
1250 for(i=k=0 ; i<cl.maxclients ; i++)
1251 if(cl.scores[i].name[0])
1253 PRVM_G_FLOAT(OFS_RETURN) = k;
1256 //#355 float() cl_onground (EXT_CSQC)
1257 void VM_CL_onground (void)
1259 PRVM_G_FLOAT(OFS_RETURN) = cl.onground;
1262 //#360 float() readbyte (EXT_CSQC)
1263 void VM_CL_ReadByte (void)
1265 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadByte();
1268 //#361 float() readchar (EXT_CSQC)
1269 void VM_CL_ReadChar (void)
1271 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadChar();
1274 //#362 float() readshort (EXT_CSQC)
1275 void VM_CL_ReadShort (void)
1277 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadShort();
1280 //#363 float() readlong (EXT_CSQC)
1281 void VM_CL_ReadLong (void)
1283 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadLong();
1286 //#364 float() readcoord (EXT_CSQC)
1287 void VM_CL_ReadCoord (void)
1289 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadCoord(cls.protocol);
1292 //#365 float() readangle (EXT_CSQC)
1293 void VM_CL_ReadAngle (void)
1295 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadAngle(cls.protocol);
1298 //#366 string() readstring (EXT_CSQC)
1299 void VM_CL_ReadString (void)
1301 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(MSG_ReadString());
1304 //#367 float() readfloat (EXT_CSQC)
1305 void VM_CL_ReadFloat (void)
1307 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadFloat();
1310 //=================================================================//
1312 // #404 void(vector org, string modelname, float startframe, float endframe, float framerate) effect (DP_SV_EFFECT)
1313 void VM_CL_effect (void)
1315 VM_SAFEPARMCOUNT(5, VM_CL_effect);
1316 CL_Effect(PRVM_G_VECTOR(OFS_PARM0), (int)PRVM_G_FLOAT(OFS_PARM1), (int)PRVM_G_FLOAT(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), PRVM_G_FLOAT(OFS_PARM4));
1319 // #405 void(vector org, vector velocity, float howmany) te_blood (DP_TE_BLOOD)
1320 void VM_CL_te_blood (void)
1324 VM_SAFEPARMCOUNT(3, VM_CL_te_blood);
1325 if (PRVM_G_FLOAT(OFS_PARM2) < 1)
1327 pos = PRVM_G_VECTOR(OFS_PARM0);
1328 CL_FindNonSolidLocation(pos, pos2, 4);
1329 CL_ParticleEffect(EFFECT_TE_BLOOD, PRVM_G_FLOAT(OFS_PARM2), pos2, pos2, PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM1), NULL, 0);
1332 // #406 void(vector mincorner, vector maxcorner, float explosionspeed, float howmany) te_bloodshower (DP_TE_BLOODSHOWER)
1333 void VM_CL_te_bloodshower (void)
1337 VM_SAFEPARMCOUNT(4, VM_CL_te_bloodshower);
1338 if (PRVM_G_FLOAT(OFS_PARM3) < 1)
1340 speed = PRVM_G_FLOAT(OFS_PARM2);
1347 CL_ParticleEffect(EFFECT_TE_BLOOD, PRVM_G_FLOAT(OFS_PARM3), PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), vel1, vel2, NULL, 0);
1350 // #407 void(vector org, vector color) te_explosionrgb (DP_TE_EXPLOSIONRGB)
1351 void VM_CL_te_explosionrgb (void)
1355 matrix4x4_t tempmatrix;
1356 VM_SAFEPARMCOUNT(2, VM_CL_te_explosionrgb);
1357 pos = PRVM_G_VECTOR(OFS_PARM0);
1358 CL_FindNonSolidLocation(pos, pos2, 10);
1359 CL_ParticleExplosion(pos2);
1360 Matrix4x4_CreateTranslate(&tempmatrix, pos2[0], pos2[1], pos2[2]);
1361 CL_AllocDlight(NULL, &tempmatrix, 350, PRVM_G_VECTOR(OFS_PARM1)[0], PRVM_G_VECTOR(OFS_PARM1)[1], PRVM_G_VECTOR(OFS_PARM1)[2], 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1364 // #408 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color, float gravityflag, float randomveljitter) te_particlecube (DP_TE_PARTICLECUBE)
1365 void VM_CL_te_particlecube (void)
1367 VM_SAFEPARMCOUNT(7, VM_CL_te_particlecube);
1368 CL_ParticleCube(PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4), PRVM_G_FLOAT(OFS_PARM5), PRVM_G_FLOAT(OFS_PARM6));
1371 // #409 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlerain (DP_TE_PARTICLERAIN)
1372 void VM_CL_te_particlerain (void)
1374 VM_SAFEPARMCOUNT(5, VM_CL_te_particlerain);
1375 CL_ParticleRain(PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4), 0);
1378 // #410 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlesnow (DP_TE_PARTICLESNOW)
1379 void VM_CL_te_particlesnow (void)
1381 VM_SAFEPARMCOUNT(5, VM_CL_te_particlesnow);
1382 CL_ParticleRain(PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4), 1);
1385 // #411 void(vector org, vector vel, float howmany) te_spark
1386 void VM_CL_te_spark (void)
1390 VM_SAFEPARMCOUNT(3, VM_CL_te_spark);
1392 pos = PRVM_G_VECTOR(OFS_PARM0);
1393 CL_FindNonSolidLocation(pos, pos2, 4);
1394 CL_ParticleEffect(EFFECT_TE_SPARK, PRVM_G_FLOAT(OFS_PARM2), pos2, pos2, PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM1), NULL, 0);
1397 // #412 void(vector org) te_gunshotquad (DP_QUADEFFECTS1)
1398 void VM_CL_te_gunshotquad (void)
1402 VM_SAFEPARMCOUNT(1, VM_CL_te_gunshotquad);
1404 pos = PRVM_G_VECTOR(OFS_PARM0);
1405 CL_FindNonSolidLocation(pos, pos2, 4);
1406 CL_ParticleEffect(EFFECT_TE_GUNSHOTQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1409 // #413 void(vector org) te_spikequad (DP_QUADEFFECTS1)
1410 void VM_CL_te_spikequad (void)
1415 VM_SAFEPARMCOUNT(1, VM_CL_te_spikequad);
1417 pos = PRVM_G_VECTOR(OFS_PARM0);
1418 CL_FindNonSolidLocation(pos, pos2, 4);
1419 CL_ParticleEffect(EFFECT_TE_SPIKEQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1420 if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos2, 1, 1);
1424 if (rnd == 1) S_StartSound(-1, 0, cl.sfx_ric1, pos2, 1, 1);
1425 else if (rnd == 2) S_StartSound(-1, 0, cl.sfx_ric2, pos2, 1, 1);
1426 else S_StartSound(-1, 0, cl.sfx_ric3, pos2, 1, 1);
1430 // #414 void(vector org) te_superspikequad (DP_QUADEFFECTS1)
1431 void VM_CL_te_superspikequad (void)
1436 VM_SAFEPARMCOUNT(1, VM_CL_te_superspikequad);
1438 pos = PRVM_G_VECTOR(OFS_PARM0);
1439 CL_FindNonSolidLocation(pos, pos2, 4);
1440 CL_ParticleEffect(EFFECT_TE_SUPERSPIKEQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1441 if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1445 if (rnd == 1) S_StartSound(-1, 0, cl.sfx_ric1, pos2, 1, 1);
1446 else if (rnd == 2) S_StartSound(-1, 0, cl.sfx_ric2, pos2, 1, 1);
1447 else S_StartSound(-1, 0, cl.sfx_ric3, pos2, 1, 1);
1451 // #415 void(vector org) te_explosionquad (DP_QUADEFFECTS1)
1452 void VM_CL_te_explosionquad (void)
1456 VM_SAFEPARMCOUNT(1, VM_CL_te_explosionquad);
1458 pos = PRVM_G_VECTOR(OFS_PARM0);
1459 CL_FindNonSolidLocation(pos, pos2, 10);
1460 CL_ParticleEffect(EFFECT_TE_EXPLOSIONQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1461 S_StartSound(-1, 0, cl.sfx_r_exp3, pos2, 1, 1);
1464 // #416 void(vector org) te_smallflash (DP_TE_SMALLFLASH)
1465 void VM_CL_te_smallflash (void)
1469 VM_SAFEPARMCOUNT(1, VM_CL_te_smallflash);
1471 pos = PRVM_G_VECTOR(OFS_PARM0);
1472 CL_FindNonSolidLocation(pos, pos2, 10);
1473 CL_ParticleEffect(EFFECT_TE_SMALLFLASH, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1476 // #417 void(vector org, float radius, float lifetime, vector color) te_customflash (DP_TE_CUSTOMFLASH)
1477 void VM_CL_te_customflash (void)
1481 matrix4x4_t tempmatrix;
1482 VM_SAFEPARMCOUNT(4, VM_CL_te_customflash);
1484 pos = PRVM_G_VECTOR(OFS_PARM0);
1485 CL_FindNonSolidLocation(pos, pos2, 4);
1486 Matrix4x4_CreateTranslate(&tempmatrix, pos2[0], pos2[1], pos2[2]);
1487 CL_AllocDlight(NULL, &tempmatrix, PRVM_G_FLOAT(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM3)[0], PRVM_G_VECTOR(OFS_PARM3)[1], PRVM_G_VECTOR(OFS_PARM3)[2], PRVM_G_FLOAT(OFS_PARM1) / PRVM_G_FLOAT(OFS_PARM2), PRVM_G_FLOAT(OFS_PARM2), 0, -1, true, 1, 0.25, 1, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1490 // #418 void(vector org) te_gunshot (DP_TE_STANDARDEFFECTBUILTINS)
1491 void VM_CL_te_gunshot (void)
1495 VM_SAFEPARMCOUNT(1, VM_CL_te_gunshot);
1497 pos = PRVM_G_VECTOR(OFS_PARM0);
1498 CL_FindNonSolidLocation(pos, pos2, 4);
1499 CL_ParticleEffect(EFFECT_TE_GUNSHOT, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1502 // #419 void(vector org) te_spike (DP_TE_STANDARDEFFECTBUILTINS)
1503 void VM_CL_te_spike (void)
1508 VM_SAFEPARMCOUNT(1, VM_CL_te_spike);
1510 pos = PRVM_G_VECTOR(OFS_PARM0);
1511 CL_FindNonSolidLocation(pos, pos2, 4);
1512 CL_ParticleEffect(EFFECT_TE_SPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1513 if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos2, 1, 1);
1517 if (rnd == 1) S_StartSound(-1, 0, cl.sfx_ric1, pos2, 1, 1);
1518 else if (rnd == 2) S_StartSound(-1, 0, cl.sfx_ric2, pos2, 1, 1);
1519 else S_StartSound(-1, 0, cl.sfx_ric3, pos2, 1, 1);
1523 // #420 void(vector org) te_superspike (DP_TE_STANDARDEFFECTBUILTINS)
1524 void VM_CL_te_superspike (void)
1529 VM_SAFEPARMCOUNT(1, VM_CL_te_superspike);
1531 pos = PRVM_G_VECTOR(OFS_PARM0);
1532 CL_FindNonSolidLocation(pos, pos2, 4);
1533 CL_ParticleEffect(EFFECT_TE_SUPERSPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1534 if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos2, 1, 1);
1538 if (rnd == 1) S_StartSound(-1, 0, cl.sfx_ric1, pos2, 1, 1);
1539 else if (rnd == 2) S_StartSound(-1, 0, cl.sfx_ric2, pos2, 1, 1);
1540 else S_StartSound(-1, 0, cl.sfx_ric3, pos2, 1, 1);
1544 // #421 void(vector org) te_explosion (DP_TE_STANDARDEFFECTBUILTINS)
1545 void VM_CL_te_explosion (void)
1549 VM_SAFEPARMCOUNT(1, VM_CL_te_explosion);
1551 pos = PRVM_G_VECTOR(OFS_PARM0);
1552 CL_FindNonSolidLocation(pos, pos2, 10);
1553 CL_ParticleEffect(EFFECT_TE_EXPLOSION, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1554 S_StartSound(-1, 0, cl.sfx_r_exp3, pos2, 1, 1);
1557 // #422 void(vector org) te_tarexplosion (DP_TE_STANDARDEFFECTBUILTINS)
1558 void VM_CL_te_tarexplosion (void)
1562 VM_SAFEPARMCOUNT(1, VM_CL_te_tarexplosion);
1564 pos = PRVM_G_VECTOR(OFS_PARM0);
1565 CL_FindNonSolidLocation(pos, pos2, 10);
1566 CL_ParticleEffect(EFFECT_TE_TAREXPLOSION, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1567 S_StartSound(-1, 0, cl.sfx_r_exp3, pos2, 1, 1);
1570 // #423 void(vector org) te_wizspike (DP_TE_STANDARDEFFECTBUILTINS)
1571 void VM_CL_te_wizspike (void)
1575 VM_SAFEPARMCOUNT(1, VM_CL_te_wizspike);
1577 pos = PRVM_G_VECTOR(OFS_PARM0);
1578 CL_FindNonSolidLocation(pos, pos2, 4);
1579 CL_ParticleEffect(EFFECT_TE_WIZSPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1580 S_StartSound(-1, 0, cl.sfx_wizhit, pos2, 1, 1);
1583 // #424 void(vector org) te_knightspike (DP_TE_STANDARDEFFECTBUILTINS)
1584 void VM_CL_te_knightspike (void)
1588 VM_SAFEPARMCOUNT(1, VM_CL_te_knightspike);
1590 pos = PRVM_G_VECTOR(OFS_PARM0);
1591 CL_FindNonSolidLocation(pos, pos2, 4);
1592 CL_ParticleEffect(EFFECT_TE_KNIGHTSPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1593 S_StartSound(-1, 0, cl.sfx_knighthit, pos2, 1, 1);
1596 // #425 void(vector org) te_lavasplash (DP_TE_STANDARDEFFECTBUILTINS)
1597 void VM_CL_te_lavasplash (void)
1599 VM_SAFEPARMCOUNT(1, VM_CL_te_lavasplash);
1600 CL_ParticleEffect(EFFECT_TE_LAVASPLASH, 1, PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM0), vec3_origin, vec3_origin, NULL, 0);
1603 // #426 void(vector org) te_teleport (DP_TE_STANDARDEFFECTBUILTINS)
1604 void VM_CL_te_teleport (void)
1606 VM_SAFEPARMCOUNT(1, VM_CL_te_teleport);
1607 CL_ParticleEffect(EFFECT_TE_TELEPORT, 1, PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM0), vec3_origin, vec3_origin, NULL, 0);
1610 // #427 void(vector org, float colorstart, float colorlength) te_explosion2 (DP_TE_STANDARDEFFECTBUILTINS)
1611 void VM_CL_te_explosion2 (void)
1615 matrix4x4_t tempmatrix;
1616 int colorStart, colorLength;
1617 unsigned char *tempcolor;
1618 VM_SAFEPARMCOUNT(3, VM_CL_te_explosion2);
1620 pos = PRVM_G_VECTOR(OFS_PARM0);
1621 colorStart = (int)PRVM_G_FLOAT(OFS_PARM1);
1622 colorLength = (int)PRVM_G_FLOAT(OFS_PARM2);
1623 CL_FindNonSolidLocation(pos, pos2, 10);
1624 CL_ParticleExplosion2(pos2, colorStart, colorLength);
1625 tempcolor = (unsigned char *)&palette_complete[(rand()%colorLength) + colorStart];
1626 color[0] = tempcolor[0] * (2.0f / 255.0f);
1627 color[1] = tempcolor[1] * (2.0f / 255.0f);
1628 color[2] = tempcolor[2] * (2.0f / 255.0f);
1629 Matrix4x4_CreateTranslate(&tempmatrix, pos2[0], pos2[1], pos2[2]);
1630 CL_AllocDlight(NULL, &tempmatrix, 350, color[0], color[1], color[2], 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1631 S_StartSound(-1, 0, cl.sfx_r_exp3, pos2, 1, 1);
1635 // #428 void(entity own, vector start, vector end) te_lightning1 (DP_TE_STANDARDEFFECTBUILTINS)
1636 void VM_CL_te_lightning1 (void)
1638 VM_SAFEPARMCOUNT(3, VM_CL_te_lightning1);
1639 CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt, true);
1642 // #429 void(entity own, vector start, vector end) te_lightning2 (DP_TE_STANDARDEFFECTBUILTINS)
1643 void VM_CL_te_lightning2 (void)
1645 VM_SAFEPARMCOUNT(3, VM_CL_te_lightning2);
1646 CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt2, true);
1649 // #430 void(entity own, vector start, vector end) te_lightning3 (DP_TE_STANDARDEFFECTBUILTINS)
1650 void VM_CL_te_lightning3 (void)
1652 VM_SAFEPARMCOUNT(3, VM_CL_te_lightning3);
1653 CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt3, false);
1656 // #431 void(entity own, vector start, vector end) te_beam (DP_TE_STANDARDEFFECTBUILTINS)
1657 void VM_CL_te_beam (void)
1659 VM_SAFEPARMCOUNT(3, VM_CL_te_beam);
1660 CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_beam, false);
1663 // #433 void(vector org) te_plasmaburn (DP_TE_PLASMABURN)
1664 void VM_CL_te_plasmaburn (void)
1668 VM_SAFEPARMCOUNT(1, VM_CL_te_plasmaburn);
1670 pos = PRVM_G_VECTOR(OFS_PARM0);
1671 CL_FindNonSolidLocation(pos, pos2, 4);
1672 CL_ParticleEffect(EFFECT_TE_PLASMABURN, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1676 //====================================================================
1679 extern void clippointtosurface(model_t *model, msurface_t *surface, vec3_t p, vec3_t out);
1681 static msurface_t *cl_getsurface(model_t *model, int surfacenum)
1683 if (surfacenum < 0 || surfacenum >= model->nummodelsurfaces)
1685 return model->data_surfaces + surfacenum + model->firstmodelsurface;
1688 // #434 float(entity e, float s) getsurfacenumpoints
1689 void VM_CL_getsurfacenumpoints(void)
1691 model_t *model = CSQC_GetModelFromEntity(PRVM_G_EDICT(OFS_PARM0));
1692 msurface_t *surface;
1693 // return 0 if no such surface
1694 if (!model || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
1696 PRVM_G_FLOAT(OFS_RETURN) = 0;
1700 // note: this (incorrectly) assumes it is a simple polygon
1701 PRVM_G_FLOAT(OFS_RETURN) = surface->num_vertices;
1704 // #435 vector(entity e, float s, float n) getsurfacepoint
1705 void VM_CL_getsurfacepoint(void)
1709 msurface_t *surface;
1711 VectorClear(PRVM_G_VECTOR(OFS_RETURN));
1712 ed = PRVM_G_EDICT(OFS_PARM0);
1713 if (!(model = CSQC_GetModelFromEntity(ed)) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
1715 // note: this (incorrectly) assumes it is a simple polygon
1716 pointnum = (int)PRVM_G_FLOAT(OFS_PARM2);
1717 if (pointnum < 0 || pointnum >= surface->num_vertices)
1719 // FIXME: implement rotation/scaling
1720 VectorAdd(&(model->surfmesh.data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed->fields.client->origin, PRVM_G_VECTOR(OFS_RETURN));
1723 // #436 vector(entity e, float s) getsurfacenormal
1724 void VM_CL_getsurfacenormal(void)
1727 msurface_t *surface;
1729 VectorClear(PRVM_G_VECTOR(OFS_RETURN));
1730 if (!(model = CSQC_GetModelFromEntity(PRVM_G_EDICT(OFS_PARM0))) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
1732 // FIXME: implement rotation/scaling
1733 // note: this (incorrectly) assumes it is a simple polygon
1734 // note: this only returns the first triangle, so it doesn't work very
1735 // well for curved surfaces or arbitrary meshes
1736 TriangleNormal((model->surfmesh.data_vertex3f + 3 * surface->num_firstvertex), (model->surfmesh.data_vertex3f + 3 * surface->num_firstvertex) + 3, (model->surfmesh.data_vertex3f + 3 * surface->num_firstvertex) + 6, normal);
1737 VectorNormalize(normal);
1738 VectorCopy(normal, PRVM_G_VECTOR(OFS_RETURN));
1741 // #437 string(entity e, float s) getsurfacetexture
1742 void VM_CL_getsurfacetexture(void)
1745 msurface_t *surface;
1746 PRVM_G_INT(OFS_RETURN) = OFS_NULL;
1747 if (!(model = CSQC_GetModelFromEntity(PRVM_G_EDICT(OFS_PARM0))) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
1749 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(surface->texture->name);
1752 // #438 float(entity e, vector p) getsurfacenearpoint
1753 void VM_CL_getsurfacenearpoint(void)
1755 int surfacenum, best;
1757 vec_t dist, bestdist;
1759 model_t *model = NULL;
1760 msurface_t *surface;
1762 PRVM_G_FLOAT(OFS_RETURN) = -1;
1763 ed = PRVM_G_EDICT(OFS_PARM0);
1764 if(!(model = CSQC_GetModelFromEntity(ed)) || !model->num_surfaces)
1767 // FIXME: implement rotation/scaling
1768 point = PRVM_G_VECTOR(OFS_PARM1);
1769 VectorSubtract(point, ed->fields.client->origin, p);
1771 bestdist = 1000000000;
1772 for (surfacenum = 0;surfacenum < model->nummodelsurfaces;surfacenum++)
1774 surface = model->data_surfaces + surfacenum + model->firstmodelsurface;
1775 // first see if the nearest point on the surface's box is closer than the previous match
1776 clipped[0] = bound(surface->mins[0], p[0], surface->maxs[0]) - p[0];
1777 clipped[1] = bound(surface->mins[1], p[1], surface->maxs[1]) - p[1];
1778 clipped[2] = bound(surface->mins[2], p[2], surface->maxs[2]) - p[2];
1779 dist = VectorLength2(clipped);
1780 if (dist < bestdist)
1782 // it is, check the nearest point on the actual geometry
1783 clippointtosurface(model, surface, p, clipped);
1784 VectorSubtract(clipped, p, clipped);
1785 dist += VectorLength2(clipped);
1786 if (dist < bestdist)
1788 // that's closer too, store it as the best match
1794 PRVM_G_FLOAT(OFS_RETURN) = best;
1797 // #439 vector(entity e, float s, vector p) getsurfaceclippedpoint
1798 void VM_CL_getsurfaceclippedpoint(void)
1802 msurface_t *surface;
1804 VectorClear(PRVM_G_VECTOR(OFS_RETURN));
1805 ed = PRVM_G_EDICT(OFS_PARM0);
1806 if (!(model = CSQC_GetModelFromEntity(ed)) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
1808 // FIXME: implement rotation/scaling
1809 VectorSubtract(PRVM_G_VECTOR(OFS_PARM2), ed->fields.client->origin, p);
1810 clippointtosurface(model, surface, p, out);
1811 // FIXME: implement rotation/scaling
1812 VectorAdd(out, ed->fields.client->origin, PRVM_G_VECTOR(OFS_RETURN));
1815 // #443 void(entity e, entity tagentity, string tagname) setattachment
1816 void VM_CL_setattachment (void)
1818 prvm_edict_t *e = PRVM_G_EDICT(OFS_PARM0);
1819 prvm_edict_t *tagentity = PRVM_G_EDICT(OFS_PARM1);
1820 const char *tagname = PRVM_G_STRING(OFS_PARM2);
1825 if (e == prog->edicts)
1827 VM_Warning("setattachment: can not modify world entity\n");
1830 if (e->priv.server->free)
1832 VM_Warning("setattachment: can not modify free entity\n");
1836 if (tagentity == NULL)
1837 tagentity = prog->edicts;
1839 v = PRVM_GETEDICTFIELDVALUE(e, csqc_fieldoff_tag_entity);
1841 v->edict = PRVM_EDICT_TO_PROG(tagentity);
1843 v = PRVM_GETEDICTFIELDVALUE(e, csqc_fieldoff_tag_index);
1846 if (tagentity != NULL && tagentity != prog->edicts && tagname && tagname[0])
1848 modelindex = (int)tagentity->fields.client->modelindex;
1849 model = CSQC_GetModelByIndex(modelindex);
1852 v->_float = Mod_Alias_GetTagIndexForName(model, (int)tagentity->fields.client->skin, tagname);
1854 Con_DPrintf("setattachment(edict %i, edict %i, string \"%s\"): tried to find tag named \"%s\" on entity %i (model \"%s\") but could not find it\n", PRVM_NUM_FOR_EDICT(e), PRVM_NUM_FOR_EDICT(tagentity), tagname, tagname, PRVM_NUM_FOR_EDICT(tagentity), model->name);
1857 Con_DPrintf("setattachment(edict %i, edict %i, string \"%s\"): tried to find tag named \"%s\" on entity %i but it has no model\n", PRVM_NUM_FOR_EDICT(e), PRVM_NUM_FOR_EDICT(tagentity), tagname, tagname, PRVM_NUM_FOR_EDICT(tagentity));
1861 /////////////////////////////////////////
1862 // DP_MD3_TAGINFO extension coded by VorteX
1864 int CL_GetTagIndex (prvm_edict_t *e, const char *tagname)
1866 model_t *model = CSQC_GetModelFromEntity(e);
1868 return Mod_Alias_GetTagIndexForName(model, (int)e->fields.client->skin, tagname);
1873 // Warnings/errors code:
1874 // 0 - normal (everything all-right)
1877 // 3 - null or non-precached model
1878 // 4 - no tags with requested index
1879 // 5 - runaway loop at attachment chain
1880 extern cvar_t cl_bob;
1881 extern cvar_t cl_bobcycle;
1882 extern cvar_t cl_bobup;
1883 int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
1886 int reqframe, attachloop;
1887 matrix4x4_t entitymatrix, tagmatrix, attachmatrix;
1888 prvm_edict_t *attachent;
1891 *out = identitymatrix; // warnings and errors return identical matrix
1893 if (ent == prog->edicts)
1895 if (ent->priv.server->free)
1898 model = CSQC_GetModelFromEntity(ent);
1903 if (ent->fields.client->frame >= 0 && ent->fields.client->frame < model->numframes && model->animscenes)
1904 reqframe = model->animscenes[(int)ent->fields.client->frame].firstframe;
1906 reqframe = 0; // if model has wrong frame, engine automatically switches to model first frame
1908 // get initial tag matrix
1911 int ret = Mod_Alias_GetTagMatrix(model, reqframe, tagindex - 1, &tagmatrix);
1916 tagmatrix = identitymatrix;
1918 if ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_tag_entity)) && val->edict)
1919 { // DP_GFX_QUAKE3MODELTAGS, scan all chain and stop on unattached entity
1923 attachent = PRVM_EDICT_NUM(val->edict); // to this it entity our entity is attached
1924 val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_tag_index);
1926 model = CSQC_GetModelFromEntity(attachent);
1928 if (model && val->_float >= 1 && model->animscenes && attachent->fields.client->frame >= 0 && attachent->fields.client->frame < model->numframes)
1929 Mod_Alias_GetTagMatrix(model, model->animscenes[(int)attachent->fields.client->frame].firstframe, (int)val->_float - 1, &attachmatrix);
1931 attachmatrix = identitymatrix;
1933 // apply transformation by child entity matrix
1934 val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_scale);
1935 if (val->_float == 0)
1937 Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], val->_float);
1938 Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
1939 Matrix4x4_Copy(&tagmatrix, out);
1941 // finally transformate by matrix of tag on parent entity
1942 Matrix4x4_Concat(out, &attachmatrix, &tagmatrix);
1943 Matrix4x4_Copy(&tagmatrix, out);
1947 if (attachloop > 255) // prevent runaway looping
1950 while ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_tag_entity)) && val->edict);
1953 // normal or RENDER_VIEWMODEL entity (or main parent entity on attach chain)
1954 val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_scale);
1955 if (val->_float == 0)
1957 // Alias models have inverse pitch, bmodels can't have tags, so don't check for modeltype...
1958 Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], val->_float);
1959 Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
1961 if ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_renderflags)) && (RF_VIEWMODEL & (int)val->_float))
1962 {// RENDER_VIEWMODEL magic
1963 Matrix4x4_Copy(&tagmatrix, out);
1965 val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_scale);
1966 if (val->_float == 0)
1969 Matrix4x4_CreateFromQuakeEntity(&entitymatrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], val->_float);
1970 Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
1973 // Cl_bob, ported from rendering code
1974 if (ent->fields.client->health > 0 && cl_bob.value && cl_bobcycle.value)
1977 // LordHavoc: this code is *weird*, but not replacable (I think it
1978 // should be done in QC on the server, but oh well, quake is quake)
1979 // LordHavoc: figured out bobup: the time at which the sin is at 180
1980 // degrees (which allows lengthening or squishing the peak or valley)
1981 cycle = sv.time/cl_bobcycle.value;
1982 cycle -= (int)cycle;
1983 if (cycle < cl_bobup.value)
1984 cycle = sin(M_PI * cycle / cl_bobup.value);
1986 cycle = sin(M_PI + M_PI * (cycle-cl_bobup.value)/(1.0 - cl_bobup.value));
1987 // bob is proportional to velocity in the xy plane
1988 // (don't count Z, or jumping messes it up)
1989 bob = sqrt(ent->fields.client->velocity[0]*ent->fields.client->velocity[0] + ent->fields.client->velocity[1]*ent->fields.client->velocity[1])*cl_bob.value;
1990 bob = bob*0.3 + bob*0.7*cycle;
1991 Matrix4x4_AdjustOrigin(out, 0, 0, bound(-7, bob, 4));
1998 // #451 float(entity ent, string tagname) gettagindex (DP_QC_GETTAGINFO)
1999 void VM_CL_gettagindex (void)
2001 prvm_edict_t *ent = PRVM_G_EDICT(OFS_PARM0);
2002 const char *tag_name = PRVM_G_STRING(OFS_PARM1);
2003 int modelindex, tag_index;
2005 if (ent == prog->edicts)
2007 VM_Warning("gettagindex: can't affect world entity\n");
2010 if (ent->priv.server->free)
2012 VM_Warning("gettagindex: can't affect free entity\n");
2016 modelindex = (int)ent->fields.client->modelindex;
2018 modelindex = -(modelindex+1);
2020 if (modelindex <= 0 || modelindex >= MAX_MODELS)
2021 Con_DPrintf("gettagindex(entity #%i): null or non-precached model\n", PRVM_NUM_FOR_EDICT(ent));
2024 tag_index = CL_GetTagIndex(ent, tag_name);
2026 Con_DPrintf("gettagindex(entity #%i): tag \"%s\" not found\n", PRVM_NUM_FOR_EDICT(ent), tag_name);
2028 PRVM_G_FLOAT(OFS_RETURN) = tag_index;
2031 // #452 vector(entity ent, float tagindex) gettaginfo (DP_QC_GETTAGINFO)
2032 void VM_CL_gettaginfo (void)
2034 prvm_edict_t *e = PRVM_G_EDICT(OFS_PARM0);
2035 int tagindex = (int)PRVM_G_FLOAT(OFS_PARM1);
2036 matrix4x4_t tag_matrix;
2039 returncode = CL_GetTagMatrix(&tag_matrix, e, tagindex);
2040 Matrix4x4_ToVectors(&tag_matrix, prog->globals.client->v_forward, prog->globals.client->v_right, prog->globals.client->v_up, PRVM_G_VECTOR(OFS_RETURN));
2045 VM_Warning("gettagindex: can't affect world entity\n");
2048 VM_Warning("gettagindex: can't affect free entity\n");
2051 Con_DPrintf("CL_GetTagMatrix(entity #%i): null or non-precached model\n", PRVM_NUM_FOR_EDICT(e));
2054 Con_DPrintf("CL_GetTagMatrix(entity #%i): model has no tag with requested index %i\n", PRVM_NUM_FOR_EDICT(e), tagindex);
2057 Con_DPrintf("CL_GetTagMatrix(entity #%i): runaway loop at attachment chain\n", PRVM_NUM_FOR_EDICT(e));
2062 //=================================================
2063 //[515]: here goes test/unfinished/etc.
2065 //[515]: check if it is what it should be
2066 void VM_WasFreed (void)
2069 VM_SAFEPARMCOUNT(1, VM_WasFreed);
2071 e = PRVM_G_EDICT(OFS_PARM0);
2072 if (!e->priv.required->free || (e->priv.required->free && (e->priv.required->freetime < 2 || (*prog->time - e->priv.required->freetime) > 0.5 )))
2073 PRVM_G_FLOAT(OFS_RETURN) = false;
2075 PRVM_G_FLOAT(OFS_RETURN) = true;
2078 void VM_CL_select_cube (void)
2082 float *mins2, *maxs2;
2083 prvm_edict_t *ent, *chain;
2084 vec3_t mins1, maxs1;
2086 VM_SAFEPARMCOUNT(2, VM_CL_select_cube);
2088 // is the same like !(prog->flag & PRVM_FE_CHAIN) - even if the operator precedence is another
2089 if(!prog->flag & PRVM_FE_CHAIN)
2090 PRVM_ERROR("VM_findchain: %s doesnt have a chain field !\n", PRVM_NAME);
2092 chain_of = PRVM_ED_FindField("chain")->ofs;
2093 chain = prog->edicts;
2095 mins2 = PRVM_G_VECTOR(OFS_PARM0);
2096 maxs2 = PRVM_G_VECTOR(OFS_PARM1);
2098 ent = PRVM_NEXT_EDICT(prog->edicts);
2099 for (i = 1;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
2101 if (ent->priv.required->free)
2103 VectorCopy(ent->fields.client->origin, mins1);
2104 VectorAdd(mins1, ent->fields.client->maxs, maxs1);
2105 VectorAdd(mins1, ent->fields.client->mins, mins1);
2106 if (mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2])
2108 if (maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
2110 PRVM_E_INT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
2114 VM_RETURN_EDICT(chain);
2117 void VM_CL_select_super (void)
2122 prvm_edict_t *ent, *chain;
2123 vec3_t mins1, maxs1;
2125 VM_SAFEPARMCOUNT(8, VM_findchain);
2127 v[i] = PRVM_G_VECTOR(OFS_PARM0+i*3);
2129 // is the same like !(prog->flag & PRVM_FE_CHAIN) - even if the operator precedence is another
2130 if(!prog->flag & PRVM_FE_CHAIN)
2131 PRVM_ERROR("VM_findchain: %s doesnt have a chain field !\n", PRVM_NAME);
2133 chain_of = PRVM_ED_FindField("chain")->ofs;
2134 chain = prog->edicts;
2136 mins2 = PRVM_G_VECTOR(OFS_PARM0);
2137 maxs2 = PRVM_G_VECTOR(OFS_PARM1);
2139 ent = PRVM_NEXT_EDICT(prog->edicts);
2140 for (i = 1;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
2142 if (ent->priv.required->free)
2144 VectorCopy(ent->fields.client->origin, mins1);
2145 VectorAdd(mins1, ent->fields.client->maxs, maxs1);
2146 VectorAdd(mins1, ent->fields.client->mins, mins1);
2147 if (mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2])
2149 if (maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
2151 PRVM_E_INT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
2155 VM_RETURN_EDICT(chain);*/
2158 static int Is_Text_Color (char c, char t)
2161 char c2 = c - (c & 128);
2162 char t2 = t - (t & 128);
2164 if(c != STRING_COLOR_TAG && c2 != STRING_COLOR_TAG) return 0;
2165 if(t >= '0' && t <= '9') a = 1;
2166 if(t2 >= '0' && t2 <= '9') a = 1;
2167 /* if(t >= 'A' && t <= 'Z') a = 2;
2168 if(t2 >= 'A' && t2 <= 'Z') a = 2;
2170 if(a == 1 && scr_colortext.integer > 0)
2172 if(a == 2 && scr_multifonts.integer > 0)
2178 void VM_uncolorstring (void) //#170
2181 char out[VM_STRINGTEMP_LENGTH];
2184 VM_SAFEPARMCOUNT(1, VM_uncolorstring);
2185 in = PRVM_G_STRING(OFS_PARM0);
2186 VM_CheckEmptyString (in);
2191 if(Is_Text_Color(in[k], in[k+1]) == 1/* || (in[k] == '&' && in[k+1] == 'r')*/)
2200 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(out);
2203 void VM_CL_selecttraceline (void)
2206 int ent, ignore, csqcents;
2208 v1 = PRVM_G_VECTOR(OFS_PARM0);
2209 v2 = PRVM_G_VECTOR(OFS_PARM1);
2210 ignore = (int)PRVM_G_FLOAT(OFS_PARM2);
2211 csqcents = (int)PRVM_G_FLOAT(OFS_PARM3);
2216 VM_Warning("VM_CL_selecttraceline: csqcents flag not supported anymore, and this function is deprecated\n");
2219 prog->globals.client->trace_fraction = CL_SelectTraceLine(v1, v2, prog->globals.client->trace_endpos, prog->globals.client->trace_plane_normal, &ent, &cl.entities[ignore].render);
2220 PRVM_G_FLOAT(OFS_RETURN) = ent;
2223 void VM_charindex (void)
2226 s = PRVM_G_STRING(OFS_PARM0);
2227 if((unsigned)PRVM_G_FLOAT(OFS_PARM1) > strlen(s))
2229 PRVM_G_FLOAT(OFS_RETURN) = (unsigned char)s[(int)PRVM_G_FLOAT(OFS_PARM1)];
2232 //#223 string(float c, ...) chr2str (FTE_STRINGS)
2233 void VM_chr2str (void)
2237 for(i = 0;i < prog->argc && i < (int)sizeof(t) - 1;i++)
2238 t[i] = (unsigned char)PRVM_G_FLOAT(OFS_PARM0+i*3);
2240 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(t);
2243 //#228 float(string s1, string s2, float len) strncmp (FTE_STRINGS)
2244 void VM_strncmp (void)
2246 const char *s1, *s2;
2247 VM_SAFEPARMCOUNT(1, VM_strncmp);
2248 s1 = PRVM_G_STRING(OFS_PARM0);
2249 s2 = PRVM_G_STRING(OFS_PARM1);
2250 PRVM_G_FLOAT(OFS_RETURN) = strncmp(s1, s2, (size_t)PRVM_G_FLOAT(OFS_PARM2));
2253 //============================================================================
2254 //============================================================================
2256 prvm_builtin_t vm_cl_builtins[] = {
2257 0, // to be consistent with the old vm
2258 VM_CL_makevectors, // #1 void(vector ang) makevectors
2259 VM_CL_setorigin, // #2 void(entity e, vector o) setorigin
2260 VM_CL_setmodel, // #3 void(entity e, string m) setmodel
2261 VM_CL_setsize, // #4 void(entity e, vector min, vector max) setsize
2263 VM_break, // #6 void() break
2264 VM_random, // #7 float() random
2265 VM_CL_sound, // #8 void(entity e, float chan, string samp) sound
2266 VM_normalize, // #9 vector(vector v) normalize
2267 VM_error, // #10 void(string e) error
2268 VM_objerror, // #11 void(string e) objerror
2269 VM_vlen, // #12 float(vector v) vlen
2270 VM_vectoyaw, // #13 float(vector v) vectoyaw
2271 VM_CL_spawn, // #14 entity() spawn
2272 VM_remove, // #15 void(entity e) remove
2273 VM_CL_traceline, // #16 float(vector v1, vector v2, float tryents) traceline
2275 VM_find, // #18 entity(entity start, .string fld, string match) find
2276 VM_CL_precache_sound, // #19 void(string s) precache_sound
2277 VM_CL_precache_model, // #20 void(string s) precache_model
2279 VM_CL_findradius, // #22 entity(vector org, float rad) findradius
2282 VM_dprint, // #25 void(string s) dprint
2283 VM_ftos, // #26 void(string s) ftos
2284 VM_vtos, // #27 void(string s) vtos
2285 VM_coredump, // #28 void() coredump
2286 VM_traceon, // #29 void() traceon
2287 VM_traceoff, // #30 void() traceoff
2288 VM_eprint, // #31 void(entity e) eprint
2291 VM_CL_droptofloor, // #34 float() droptofloor
2292 VM_CL_lightstyle, // #35 void(float style, string value) lightstyle
2293 VM_rint, // #36 float(float v) rint
2294 VM_floor, // #37 float(float v) floor
2295 VM_ceil, // #38 float(float v) ceil
2297 VM_CL_checkbottom, // #40 float(entity e) checkbottom
2298 VM_CL_pointcontents, // #41 float(vector v) pointcontents
2300 VM_fabs, // #43 float(float f) fabs
2302 VM_cvar, // #45 float(string s) cvar
2303 VM_localcmd, // #46 void(string s) localcmd
2304 VM_nextent, // #47 entity(entity e) nextent
2305 VM_CL_particle, // #48 void(vector o, vector d, float color, float count) particle
2306 VM_CL_changeyaw, // #49 void(entity ent, float ideal_yaw, float speed_yaw) ChangeYaw
2308 VM_vectoangles, // #51 vector(vector v) vectoangles
2309 0, // #52 void(float to, float f) WriteByte
2310 0, // #53 void(float to, float f) WriteChar
2311 0, // #54 void(float to, float f) WriteShort
2312 0, // #55 void(float to, float f) WriteLong
2313 0, // #56 void(float to, float f) WriteCoord
2314 0, // #57 void(float to, float f) WriteAngle
2315 0, // #58 void(float to, string s) WriteString
2317 VM_sin, // #60 float(float f) sin (DP_QC_SINCOSSQRTPOW)
2318 VM_cos, // #61 float(float f) cos (DP_QC_SINCOSSQRTPOW)
2319 VM_sqrt, // #62 float(float f) sqrt (DP_QC_SINCOSSQRTPOW)
2320 VM_CL_changepitch, // #63 void(entity ent, float ideal_pitch, float speed_pitch) changepitch (DP_QC_CHANGEPITCH)
2321 VM_CL_tracetoss, // #64 void(entity e, entity ignore) tracetoss (DP_QC_TRACETOSS)
2322 VM_etos, // #65 string(entity ent) etos (DP_QC_ETOS)
2329 VM_cvar_set, // #72 void(string var, string val) cvar_set
2331 VM_CL_ambientsound, // #74 void(vector pos, string samp, float vol, float atten) ambientsound
2332 VM_CL_precache_model, // #75 string(string s) precache_model2
2333 VM_CL_precache_sound, // #76 string(string s) precache_sound2
2338 VM_stof, // #81 float(string s) stof (FRIK_FILE)
2347 VM_CL_tracebox, // #90 void(vector v1, vector min, vector max, vector v2, float nomonsters, entity forent) tracebox (DP_QC_TRACEBOX)
2348 VM_randomvec, // #91 vector() randomvec (DP_QC_RANDOMVEC)
2349 VM_CL_getlight, // #92 vector(vector org) getlight (DP_QC_GETLIGHT)
2350 PF_registercvar, // #93 float(string name, string value) registercvar (DP_REGISTERCVAR)
2351 VM_min, // #94 float(float a, floats) min (DP_QC_MINMAXBOUND)
2352 VM_max, // #95 float(float a, floats) max (DP_QC_MINMAXBOUND)
2353 VM_bound, // #96 float(float minimum, float val, float maximum) bound (DP_QC_MINMAXBOUND)
2354 VM_pow, // #97 float(float f, float f) pow (DP_QC_SINCOSSQRTPOW)
2355 VM_findfloat, // #98 entity(entity start, .float fld, float match) findfloat (DP_QC_FINDFLOAT)
2356 VM_checkextension, // #99 float(string s) checkextension (the basis of the extension system)
2367 VM_fopen, // #110 float(string filename, float mode) fopen (FRIK_FILE)
2368 VM_fclose, // #111 void(float fhandle) fclose (FRIK_FILE)
2369 VM_fgets, // #112 string(float fhandle) fgets (FRIK_FILE)
2370 VM_fputs, // #113 void(float fhandle, string s) fputs (FRIK_FILE)
2371 VM_strlen, // #114 float(string s) strlen (FRIK_FILE)
2372 VM_strcat, // #115 string(string s1, string s2) strcat (FRIK_FILE)
2373 VM_substring, // #116 string(string s, float start, float length) substring (FRIK_FILE)
2374 VM_stov, // #117 vector(string) stov (FRIK_FILE)
2375 VM_strzone, // #118 string(string s) strzone (FRIK_FILE)
2376 VM_strunzone, // #119 void(string s) strunzone (FRIK_FILE)
2378 e10, e10, e10, e10, e10, e10, e10, e10, // #120-199
2388 VM_bitshift, //#218 float(float number, float quantity) bitshift (EXT_BITSHIFT)
2392 VM_charindex, //#222 float(string str, float ofs) str2chr (FTE_STRINGS)
2393 VM_chr2str, //#223 string(float c, ...) chr2str (FTE_STRINGS)
2398 VM_strncmp, //#228 float(string s1, string s2, float len) strncmp (FTE_STRINGS)
2400 e10, e10, e10, e10, e10, e10, e10, // #230-299
2402 //======CSQC start=======//
2403 //3d world (buffer/buffering) operations
2404 VM_R_ClearScene, //#300 void() clearscene (EXT_CSQC)
2405 VM_R_AddEntities, //#301 void(float mask) addentities (EXT_CSQC)
2406 VM_R_AddEntity, //#302 void(entity ent) addentity (EXT_CSQC)
2407 VM_R_SetView, //#303 float(float property, ...) setproperty (EXT_CSQC)
2408 VM_R_RenderScene, //#304 void() renderscene (EXT_CSQC)
2409 VM_R_AddDynamicLight, //#305 void(vector org, float radius, vector lightcolours) adddynamiclight (EXT_CSQC)
2410 VM_R_PolygonBegin, //#306 void(string texturename, float flag[, float is2d, float lines]) R_BeginPolygon
2411 VM_R_PolygonVertex, //#307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
2412 VM_R_PolygonEnd, //#308 void() R_EndPolygon
2415 //maths stuff that uses the current view settings
2416 VM_CL_unproject, //#310 vector (vector v) cs_unproject (EXT_CSQC)
2417 VM_CL_project, //#311 vector (vector v) cs_project (EXT_CSQC)
2422 //2d (immediate) operations
2423 VM_drawline, //#315 void(float width, vector pos1, vector pos2, float flag) drawline (EXT_CSQC)
2424 VM_iscachedpic, //#316 float(string name) iscachedpic (EXT_CSQC)
2425 VM_precache_pic, //#317 string(string name, float trywad) precache_pic (EXT_CSQC)
2426 VM_getimagesize, //#318 vector(string picname) draw_getimagesize (EXT_CSQC)
2427 VM_freepic, //#319 void(string name) freepic (EXT_CSQC)
2428 VM_drawcharacter, //#320 float(vector position, float character, vector scale, vector rgb, float alpha, float flag) drawcharacter (EXT_CSQC)
2429 VM_drawstring, //#321 float(vector position, string text, vector scale, vector rgb, float alpha, float flag) drawstring (EXT_CSQC)
2430 VM_drawpic, //#322 float(vector position, string pic, vector size, vector rgb, float alpha, float flag) drawpic (EXT_CSQC)
2431 VM_drawfill, //#323 float(vector position, vector size, vector rgb, float alpha, float flag) drawfill (EXT_CSQC)
2432 VM_drawsetcliparea, //#324 void(float x, float y, float width, float height) drawsetcliparea
2433 VM_drawresetcliparea, //#325 void(void) drawresetcliparea
2439 VM_CL_getstatf, //#330 float(float stnum) getstatf (EXT_CSQC)
2440 VM_CL_getstati, //#331 float(float stnum) getstati (EXT_CSQC)
2441 VM_CL_getstats, //#332 string(float firststnum) getstats (EXT_CSQC)
2442 VM_CL_setmodelindex, //#333 void(entity e, float mdlindex) setmodelindex (EXT_CSQC)
2443 VM_CL_modelnameforindex, //#334 string(float mdlindex) modelnameforindex (EXT_CSQC)
2444 VM_CL_particleeffectnum, //#335 float(string effectname) particleeffectnum (EXT_CSQC)
2445 VM_CL_trailparticles, //#336 void(entity ent, float effectnum, vector start, vector end) trailparticles (EXT_CSQC)
2446 VM_CL_pointparticles, //#337 void(float effectnum, vector origin [, vector dir, float count]) pointparticles (EXT_CSQC)
2447 VM_CL_centerprint, //#338 void(string s) cprint (EXT_CSQC)
2448 VM_print, //#339 void(string s) print (EXT_CSQC)
2449 VM_keynumtostring, //#340 string(float keynum) keynumtostring (EXT_CSQC)
2450 VM_stringtokeynum, //#341 float(string keyname) stringtokeynum (EXT_CSQC)
2451 VM_CL_getkeybind, //#342 string(float keynum) getkeybind (EXT_CSQC)
2452 VM_CL_setcursormode, //#343 void(float usecursor) setcursormode (EXT_CSQC)
2453 VM_getmousepos, //#344 vector() getmousepos (EXT_CSQC)
2454 VM_CL_getinputstate, //#345 float(float framenum) getinputstate (EXT_CSQC)
2455 VM_CL_setsensitivityscale, //#346 void(float sens) setsensitivityscaler (EXT_CSQC)
2456 VM_CL_runplayerphysics, //#347 void() runstandardplayerphysics (EXT_CSQC)
2457 VM_CL_getplayerkey, //#348 string(float playernum, string keyname) getplayerkeyvalue (EXT_CSQC)
2458 VM_CL_isdemo, //#349 float() isdemo (EXT_CSQC)
2459 VM_isserver, //#350 float() isserver (EXT_CSQC)
2460 VM_CL_setlistener, //#351 void(vector origin, vector forward, vector right, vector up) SetListener (EXT_CSQC)
2461 VM_CL_registercmd, //#352 void(string cmdname) registercommand (EXT_CSQC)
2462 VM_WasFreed, //#353 float(entity ent) wasfreed (EXT_CSQC) (should be availabe on server too)
2463 VM_CL_playernum, //#354 float() playernum
2464 VM_CL_onground, //#355 float() cl_onground (EXT_CSQC)
2465 VM_charindex, //#356 float(string s, float num) charindex
2466 VM_CL_selecttraceline, //#357 float(vector start, vector end, float ignore, float csqcents) selecttraceline
2469 VM_CL_ReadByte, //#360 float() readbyte (EXT_CSQC)
2470 VM_CL_ReadChar, //#361 float() readchar (EXT_CSQC)
2471 VM_CL_ReadShort, //#362 float() readshort (EXT_CSQC)
2472 VM_CL_ReadLong, //#363 float() readlong (EXT_CSQC)
2473 VM_CL_ReadCoord, //#364 float() readcoord (EXT_CSQC)
2474 VM_CL_ReadAngle, //#365 float() readangle (EXT_CSQC)
2475 VM_CL_ReadString, //#366 string() readstring (EXT_CSQC)
2476 VM_CL_ReadFloat, //#367 float() readfloat (EXT_CSQC)
2509 //=========CSQC end========//
2511 VM_copyentity, // #400 void(entity from, entity to) copyentity (DP_QC_COPYENTITY)
2513 VM_findchain, // #402 entity(.string fld, string match) findchain (DP_QC_FINDCHAIN)
2514 VM_findchainfloat, // #403 entity(.float fld, float match) findchainfloat (DP_QC_FINDCHAINFLOAT)
2515 VM_CL_effect, // #404 void(vector org, string modelname, float startframe, float endframe, float framerate) effect (DP_SV_EFFECT)
2516 VM_CL_te_blood, // #405 void(vector org, vector velocity, float howmany) te_blood (DP_TE_BLOOD)
2517 VM_CL_te_bloodshower, // #406 void(vector mincorner, vector maxcorner, float explosionspeed, float howmany) te_bloodshower (DP_TE_BLOODSHOWER)
2518 VM_CL_te_explosionrgb, // #407 void(vector org, vector color) te_explosionrgb (DP_TE_EXPLOSIONRGB)
2519 VM_CL_te_particlecube, // #408 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color, float gravityflag, float randomveljitter) te_particlecube (DP_TE_PARTICLECUBE)
2520 VM_CL_te_particlerain, // #409 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlerain (DP_TE_PARTICLERAIN)
2521 VM_CL_te_particlesnow, // #410 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlesnow (DP_TE_PARTICLESNOW)
2522 VM_CL_te_spark, // #411 void(vector org, vector vel, float howmany) te_spark (DP_TE_SPARK)
2523 VM_CL_te_gunshotquad, // #412 void(vector org) te_gunshotquad (DP_QUADEFFECTS1)
2524 VM_CL_te_spikequad, // #413 void(vector org) te_spikequad (DP_QUADEFFECTS1)
2525 VM_CL_te_superspikequad, // #414 void(vector org) te_superspikequad (DP_QUADEFFECTS1)
2526 VM_CL_te_explosionquad, // #415 void(vector org) te_explosionquad (DP_QUADEFFECTS1)
2527 VM_CL_te_smallflash, // #416 void(vector org) te_smallflash (DP_TE_SMALLFLASH)
2528 VM_CL_te_customflash, // #417 void(vector org, float radius, float lifetime, vector color) te_customflash (DP_TE_CUSTOMFLASH)
2529 VM_CL_te_gunshot, // #418 void(vector org) te_gunshot (DP_TE_STANDARDEFFECTBUILTINS)
2530 VM_CL_te_spike, // #419 void(vector org) te_spike (DP_TE_STANDARDEFFECTBUILTINS)
2531 VM_CL_te_superspike, // #420 void(vector org) te_superspike (DP_TE_STANDARDEFFECTBUILTINS)
2532 VM_CL_te_explosion, // #421 void(vector org) te_explosion (DP_TE_STANDARDEFFECTBUILTINS)
2533 VM_CL_te_tarexplosion, // #422 void(vector org) te_tarexplosion (DP_TE_STANDARDEFFECTBUILTINS)
2534 VM_CL_te_wizspike, // #423 void(vector org) te_wizspike (DP_TE_STANDARDEFFECTBUILTINS)
2535 VM_CL_te_knightspike, // #424 void(vector org) te_knightspike (DP_TE_STANDARDEFFECTBUILTINS)
2536 VM_CL_te_lavasplash, // #425 void(vector org) te_lavasplash (DP_TE_STANDARDEFFECTBUILTINS)
2537 VM_CL_te_teleport, // #426 void(vector org) te_teleport (DP_TE_STANDARDEFFECTBUILTINS)
2538 VM_CL_te_explosion2, // #427 void(vector org, float colorstart, float colorlength) te_explosion2 (DP_TE_STANDARDEFFECTBUILTINS)
2539 VM_CL_te_lightning1, // #428 void(entity own, vector start, vector end) te_lightning1 (DP_TE_STANDARDEFFECTBUILTINS)
2540 VM_CL_te_lightning2, // #429 void(entity own, vector start, vector end) te_lightning2 (DP_TE_STANDARDEFFECTBUILTINS)
2541 VM_CL_te_lightning3, // #430 void(entity own, vector start, vector end) te_lightning3 (DP_TE_STANDARDEFFECTBUILTINS)
2542 VM_CL_te_beam, // #431 void(entity own, vector start, vector end) te_beam (DP_TE_STANDARDEFFECTBUILTINS)
2543 VM_vectorvectors, // #432 void(vector dir) vectorvectors (DP_QC_VECTORVECTORS)
2544 VM_CL_te_plasmaburn, // #433 void(vector org) te_plasmaburn (DP_TE_PLASMABURN)
2545 VM_CL_getsurfacenumpoints, // #434 float(entity e, float s) getsurfacenumpoints (DP_QC_GETSURFACE)
2546 VM_CL_getsurfacepoint, // #435 vector(entity e, float s, float n) getsurfacepoint (DP_QC_GETSURFACE)
2547 VM_CL_getsurfacenormal, // #436 vector(entity e, float s) getsurfacenormal (DP_QC_GETSURFACE)
2548 VM_CL_getsurfacetexture, // #437 string(entity e, float s) getsurfacetexture (DP_QC_GETSURFACE)
2549 VM_CL_getsurfacenearpoint, // #438 float(entity e, vector p) getsurfacenearpoint (DP_QC_GETSURFACE)
2550 VM_CL_getsurfaceclippedpoint, // #439 vector(entity e, float s, vector p) getsurfaceclippedpoint (DP_QC_GETSURFACE)
2552 VM_tokenize, // #441 float(string s) tokenize (KRIMZON_SV_PARSECLIENTCOMMAND)
2553 VM_argv, // #442 string(float n) argv (KRIMZON_SV_PARSECLIENTCOMMAND)
2554 VM_CL_setattachment, // #443 void(entity e, entity tagentity, string tagname) setattachment (DP_GFX_QUAKE3MODELTAGS)
2555 VM_search_begin, // #444 float(string pattern, float caseinsensitive, float quiet) search_begin (DP_FS_SEARCH)
2556 VM_search_end, // #445 void(float handle) search_end (DP_FS_SEARCH)
2557 VM_search_getsize, // #446 float(float handle) search_getsize (DP_FS_SEARCH)
2558 VM_search_getfilename, // #447 string(float handle, float num) search_getfilename (DP_FS_SEARCH)
2559 VM_cvar_string, // #448 string(string s) cvar_string (DP_QC_CVAR_STRING)
2560 VM_findflags, // #449 entity(entity start, .float fld, float match) findflags (DP_QC_FINDFLAGS)
2561 VM_findchainflags, // #450 entity(.float fld, float match) findchainflags (DP_QC_FINDCHAINFLAGS)
2562 VM_CL_gettagindex, // #451 float(entity ent, string tagname) gettagindex (DP_QC_GETTAGINFO)
2563 VM_CL_gettaginfo, // #452 vector(entity ent, float tagindex) gettaginfo (DP_QC_GETTAGINFO)
2571 VM_buf_create, // #460 float() buf_create (DP_QC_STRINGBUFFERS)
2572 VM_buf_del, // #461 void(float bufhandle) buf_del (DP_QC_STRINGBUFFERS)
2573 VM_buf_getsize, // #462 float(float bufhandle) buf_getsize (DP_QC_STRINGBUFFERS)
2574 VM_buf_copy, // #463 void(float bufhandle_from, float bufhandle_to) buf_copy (DP_QC_STRINGBUFFERS)
2575 VM_buf_sort, // #464 void(float bufhandle, float sortpower, float backward) buf_sort (DP_QC_STRINGBUFFERS)
2576 VM_buf_implode, // #465 string(float bufhandle, string glue) buf_implode (DP_QC_STRINGBUFFERS)
2577 VM_bufstr_get, // #466 string(float bufhandle, float string_index) bufstr_get (DP_QC_STRINGBUFFERS)
2578 VM_bufstr_set, // #467 void(float bufhandle, float string_index, string str) bufstr_set (DP_QC_STRINGBUFFERS)
2579 VM_bufstr_add, // #468 float(float bufhandle, string str, float order) bufstr_add (DP_QC_STRINGBUFFERS)
2580 VM_bufstr_free, // #469 void(float bufhandle, float string_index) bufstr_free (DP_QC_STRINGBUFFERS)
2582 VM_asin, // #471 float(float s) VM_asin (DP_QC_ASINACOSATANATAN2TAN)
2583 VM_acos, // #472 float(float c) VM_acos (DP_QC_ASINACOSATANATAN2TAN)
2584 VM_atan, // #473 float(float t) VM_atan (DP_QC_ASINACOSATANATAN2TAN)
2585 VM_atan2, // #474 float(float c, float s) VM_atan2 (DP_QC_ASINACOSATANATAN2TAN)
2586 VM_tan, // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
2587 VM_strlennocol, // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
2588 VM_strdecolorize, // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS)
2589 VM_strftime, // #478 string(float uselocaltime, string format, ...) (DP_QC_STRFTIME)
2591 e10, e10 // #480-499 (LordHavoc)
2594 const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t);
2596 void VM_CL_Cmd_Init(void)
2600 void VM_CL_Cmd_Reset(void)