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 ?
72 "DP_QC_STRINGCOLORFUNCTIONS "
75 "DP_QC_TRACE_MOVETYPE_HITMODEL "
76 "DP_QC_TRACE_MOVETYPE_WORLDONLY "
77 "DP_QC_UNLIMITEDTEMPSTRINGS "
78 "DP_QC_VECTORVECTORS "
84 "DP_SND_DIRECTIONLESSATTNNONE "
91 "DP_SV_ROTATINGBMODEL "
100 "DP_TE_PARTICLESNOW "
102 "DP_TE_QUADEFFECTS1 "
105 "DP_TE_STANDARDEFFECTBUILTINS "
109 "KRIMZON_SV_PARSECLIENTCOMMAND "
112 "PRYDON_CLIENTCURSOR "
113 "TENEBRAE_GFX_DLIGHTS "
115 "NEXUIZ_PLAYERMODEL "
119 sfx_t *S_FindName(const char *name);
120 void PF_registercvar (void);
121 int Sbar_GetPlayer (int index);
122 void Sbar_SortFrags (void);
123 void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius);
124 void CSQC_RelinkAllEntities (int drawmask);
125 void CSQC_RelinkCSQCEntities (void);
126 char *Key_GetBind (int key);
127 model_t *CSQC_GetModelByIndex(int modelindex);
128 model_t *CSQC_GetModelFromEntity(prvm_edict_t *ed);
135 // #1 void(vector ang) makevectors
136 void VM_CL_makevectors (void)
138 VM_SAFEPARMCOUNT(1, VM_CL_makevectors);
139 AngleVectors (PRVM_G_VECTOR(OFS_PARM0), prog->globals.client->v_forward, prog->globals.client->v_right, prog->globals.client->v_up);
142 // #2 void(entity e, vector o) setorigin
143 void VM_CL_setorigin (void)
148 e = PRVM_G_EDICT(OFS_PARM0);
149 if (e == prog->edicts)
151 VM_Warning("setorigin: can not modify world entity\n");
154 if (e->priv.required->free)
156 VM_Warning("setorigin: can not modify free entity\n");
159 org = PRVM_G_VECTOR(OFS_PARM1);
160 VectorCopy (org, e->fields.client->origin);
163 // #3 void(entity e, string m) setmodel
164 void VM_CL_setmodel (void)
171 VM_SAFEPARMCOUNT(2, VM_CL_setmodel);
173 e = PRVM_G_EDICT(OFS_PARM0);
174 m = PRVM_G_STRING(OFS_PARM1);
175 for (i = 0;i < MAX_MODELS && cl.csqc_model_precache[i];i++)
177 if (!strcmp(cl.csqc_model_precache[i]->name, m))
179 e->fields.client->model = PRVM_SetEngineString(cl.csqc_model_precache[i]->name);
180 e->fields.client->modelindex = -(i+1);
185 for (i = 0;i < MAX_MODELS;i++)
187 mod = cl.model_precache[i];
188 if (mod && !strcmp(mod->name, m))
190 e->fields.client->model = PRVM_SetEngineString(mod->name);
191 e->fields.client->modelindex = i;
196 e->fields.client->modelindex = 0;
197 e->fields.client->model = 0;
200 // #4 void(entity e, vector min, vector max) setsize
201 void VM_CL_setsize (void)
205 VM_SAFEPARMCOUNT(3, VM_CL_setsize);
207 e = PRVM_G_EDICT(OFS_PARM0);
208 if (e == prog->edicts)
210 VM_Warning("setsize: can not modify world entity\n");
213 if (e->priv.server->free)
215 VM_Warning("setsize: can not modify free entity\n");
218 min = PRVM_G_VECTOR(OFS_PARM1);
219 max = PRVM_G_VECTOR(OFS_PARM2);
221 VectorCopy (min, e->fields.client->mins);
222 VectorCopy (max, e->fields.client->maxs);
223 VectorSubtract (max, min, e->fields.client->size);
226 // #8 void(entity e, float chan, string samp) sound
227 void VM_CL_sound (void)
231 prvm_edict_t *entity;
235 VM_SAFEPARMCOUNT(5, VM_CL_sound);
237 entity = PRVM_G_EDICT(OFS_PARM0);
238 channel = (int)PRVM_G_FLOAT(OFS_PARM1);
239 sample = PRVM_G_STRING(OFS_PARM2);
240 volume = (int)(PRVM_G_FLOAT(OFS_PARM3)*255.0f);
241 attenuation = PRVM_G_FLOAT(OFS_PARM4);
243 if (volume < 0 || volume > 255)
245 VM_Warning("VM_CL_sound: volume must be in range 0-1\n");
249 if (attenuation < 0 || attenuation > 4)
251 VM_Warning("VM_CL_sound: attenuation must be in range 0-4\n");
255 if (channel < 0 || channel > 7)
257 VM_Warning("VM_CL_sound: channel must be in range 0-7\n");
261 S_StartSound(32768 + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), entity->fields.client->origin, volume, attenuation);
264 // #14 entity() spawn
265 void VM_CL_spawn (void)
268 ed = PRVM_ED_Alloc();
269 ed->fields.client->entnum = PRVM_NUM_FOR_EDICT(ed); //[515]: not needed any more ?
273 // #16 float(vector v1, vector v2, float tryents) traceline
274 void VM_CL_traceline (void)
280 v1 = PRVM_G_VECTOR(OFS_PARM0);
281 v2 = PRVM_G_VECTOR(OFS_PARM1);
283 trace = CL_TraceBox(v1, vec3_origin, vec3_origin, v2, 1, &ent, 1, false);
285 prog->globals.client->trace_allsolid = trace.allsolid;
286 prog->globals.client->trace_startsolid = trace.startsolid;
287 prog->globals.client->trace_fraction = trace.fraction;
288 prog->globals.client->trace_inwater = trace.inwater;
289 prog->globals.client->trace_inopen = trace.inopen;
290 VectorCopy (trace.endpos, prog->globals.client->trace_endpos);
291 VectorCopy (trace.plane.normal, prog->globals.client->trace_plane_normal);
292 prog->globals.client->trace_plane_dist = trace.plane.dist;
294 prog->globals.client->trace_ent = ent;
296 prog->globals.client->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts);
299 // #19 void(string s) precache_sound
300 void VM_CL_precache_sound (void)
302 VM_SAFEPARMCOUNT(1, VM_CL_precache_sound);
303 S_PrecacheSound(PRVM_G_STRING(OFS_PARM0), true, false);
306 // #20 void(string s) precache_model
307 void VM_CL_precache_model (void)
313 VM_SAFEPARMCOUNT(1, VM_CL_precache_model);
315 name = PRVM_G_STRING(OFS_PARM0);
316 for (i = 1;i < MAX_MODELS && cl.csqc_model_precache[i];i++)
318 if(!strcmp(cl.csqc_model_precache[i]->name, name))
320 PRVM_G_FLOAT(OFS_RETURN) = -(i+1);
324 PRVM_G_FLOAT(OFS_RETURN) = 0;
325 m = Mod_ForName(name, false, false, false);
328 for (i = 1;i < MAX_MODELS;i++)
330 if (!cl.csqc_model_precache[i])
332 cl.csqc_model_precache[i] = (model_t*)m;
333 PRVM_G_FLOAT(OFS_RETURN) = -(i+1);
337 VM_Warning("VM_CL_precache_model: no free models\n");
340 VM_Warning("VM_CL_precache_model: model \"%s\" not found\n", name);
343 int CSQC_EntitiesInBox (vec3_t mins, vec3_t maxs, int maxlist, prvm_edict_t **list)
348 ent = PRVM_NEXT_EDICT(prog->edicts);
349 for(k=0,i=1; i<prog->num_edicts ;i++, ent = PRVM_NEXT_EDICT(ent))
351 if (ent->priv.required->free)
353 // VectorAdd(ent->fields.client->origin, ent->fields.client->mins, ent->fields.client->absmin);
354 // VectorAdd(ent->fields.client->origin, ent->fields.client->maxs, ent->fields.client->absmax);
355 if(BoxesOverlap(mins, maxs, ent->fields.client->absmin, ent->fields.client->absmax))
361 // #22 entity(vector org, float rad) findradius
362 void VM_CL_findradius (void)
364 prvm_edict_t *ent, *chain;
365 vec_t radius, radius2;
366 vec3_t org, eorg, mins, maxs;
367 int i, numtouchedicts;
368 prvm_edict_t *touchedicts[MAX_EDICTS];
370 chain = (prvm_edict_t *)prog->edicts;
372 VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
373 radius = PRVM_G_FLOAT(OFS_PARM1);
374 radius2 = radius * radius;
376 mins[0] = org[0] - (radius + 1);
377 mins[1] = org[1] - (radius + 1);
378 mins[2] = org[2] - (radius + 1);
379 maxs[0] = org[0] + (radius + 1);
380 maxs[1] = org[1] + (radius + 1);
381 maxs[2] = org[2] + (radius + 1);
382 numtouchedicts = CSQC_EntitiesInBox(mins, maxs, MAX_EDICTS, touchedicts);
383 if (numtouchedicts > MAX_EDICTS)
385 // this never happens //[515]: for what then ?
386 Con_Printf("CSQC_EntitiesInBox returned %i edicts, max was %i\n", numtouchedicts, MAX_EDICTS);
387 numtouchedicts = MAX_EDICTS;
389 for (i = 0;i < numtouchedicts;i++)
391 ent = touchedicts[i];
392 // Quake did not return non-solid entities but darkplaces does
393 // (note: this is the reason you can't blow up fallen zombies)
394 if (ent->fields.client->solid == SOLID_NOT && !sv_gameplayfix_blowupfallenzombies.integer)
396 // LordHavoc: compare against bounding box rather than center so it
397 // doesn't miss large objects, and use DotProduct instead of Length
398 // for a major speedup
399 VectorSubtract(org, ent->fields.client->origin, eorg);
400 if (sv_gameplayfix_findradiusdistancetobox.integer)
402 eorg[0] -= bound(ent->fields.client->mins[0], eorg[0], ent->fields.client->maxs[0]);
403 eorg[1] -= bound(ent->fields.client->mins[1], eorg[1], ent->fields.client->maxs[1]);
404 eorg[2] -= bound(ent->fields.client->mins[2], eorg[2], ent->fields.client->maxs[2]);
407 VectorMAMAM(1, eorg, 0.5f, ent->fields.client->mins, 0.5f, ent->fields.client->maxs, eorg);
408 if (DotProduct(eorg, eorg) < radius2)
410 ent->fields.client->chain = PRVM_EDICT_TO_PROG(chain);
415 VM_RETURN_EDICT(chain);
418 // #34 float() droptofloor
419 void VM_CL_droptofloor (void)
426 // assume failure if it returns early
427 PRVM_G_FLOAT(OFS_RETURN) = 0;
429 ent = PRVM_PROG_TO_EDICT(prog->globals.client->self);
430 if (ent == prog->edicts)
432 VM_Warning("droptofloor: can not modify world entity\n");
435 if (ent->priv.server->free)
437 VM_Warning("droptofloor: can not modify free entity\n");
441 VectorCopy (ent->fields.client->origin, end);
444 trace = CL_TraceBox(ent->fields.client->origin, ent->fields.client->mins, ent->fields.client->maxs, end, 1, &i, 1, false);
446 if (trace.fraction != 1)
448 VectorCopy (trace.endpos, ent->fields.client->origin);
449 ent->fields.client->flags = (int)ent->fields.client->flags | FL_ONGROUND;
450 // ent->fields.client->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
451 PRVM_G_FLOAT(OFS_RETURN) = 1;
452 // if support is destroyed, keep suspended (gross hack for floating items in various maps)
453 // ent->priv.server->suspendedinairflag = true;
457 // #35 void(float style, string value) lightstyle
458 void VM_CL_lightstyle (void)
463 VM_SAFEPARMCOUNT(2, VM_CL_lightstyle);
465 i = (int)PRVM_G_FLOAT(OFS_PARM0);
466 c = PRVM_G_STRING(OFS_PARM1);
467 if (i >= cl.max_lightstyle)
469 VM_Warning("VM_CL_lightstyle >= MAX_LIGHTSTYLES\n");
472 strlcpy (cl.lightstyle[i].map, MSG_ReadString(), sizeof (cl.lightstyle[i].map));
473 cl.lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
474 cl.lightstyle[i].length = (int)strlen(cl.lightstyle[i].map);
477 // #40 float(entity e) checkbottom
478 void VM_CL_checkbottom (void)
480 static int cs_yes, cs_no;
482 vec3_t mins, maxs, start, stop;
487 VM_SAFEPARMCOUNT(1, VM_CL_checkbottom);
488 ent = PRVM_G_EDICT(OFS_PARM0);
489 PRVM_G_FLOAT(OFS_RETURN) = 0;
491 VectorAdd (ent->fields.client->origin, ent->fields.client->mins, mins);
492 VectorAdd (ent->fields.client->origin, ent->fields.client->maxs, maxs);
494 // if all of the points under the corners are solid world, don't bother
495 // with the tougher checks
496 // the corners must be within 16 of the midpoint
497 start[2] = mins[2] - 1;
498 for (x=0 ; x<=1 ; x++)
499 for (y=0 ; y<=1 ; y++)
501 start[0] = x ? maxs[0] : mins[0];
502 start[1] = y ? maxs[1] : mins[1];
503 if (!(CL_PointSuperContents(start) & (SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY)))
508 PRVM_G_FLOAT(OFS_RETURN) = true;
509 return; // we got out easy
514 // check it for real...
518 // the midpoint must be within 16 of the bottom
519 start[0] = stop[0] = (mins[0] + maxs[0])*0.5;
520 start[1] = stop[1] = (mins[1] + maxs[1])*0.5;
521 stop[2] = start[2] - 2*sv_stepheight.value;
522 trace = CL_TraceBox (start, vec3_origin, vec3_origin, stop, 1, &hit, 1, true);
524 if (trace.fraction == 1.0)
527 mid = bottom = trace.endpos[2];
529 // the corners must be within 16 of the midpoint
530 for (x=0 ; x<=1 ; x++)
531 for (y=0 ; y<=1 ; y++)
533 start[0] = stop[0] = x ? maxs[0] : mins[0];
534 start[1] = stop[1] = y ? maxs[1] : mins[1];
536 trace = CL_TraceBox (start, vec3_origin, vec3_origin, stop, 1, &hit, 1, true);
538 if (trace.fraction != 1.0 && trace.endpos[2] > bottom)
539 bottom = trace.endpos[2];
540 if (trace.fraction == 1.0 || mid - trace.endpos[2] > sv_stepheight.value)
545 PRVM_G_FLOAT(OFS_RETURN) = true;
548 // #41 float(vector v) pointcontents
549 void VM_CL_pointcontents (void)
551 VM_SAFEPARMCOUNT(1, VM_CL_pointcontents);
552 PRVM_G_FLOAT(OFS_RETURN) = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, CL_PointSuperContents(PRVM_G_VECTOR(OFS_PARM0)));
555 // #48 void(vector o, vector d, float color, float count) particle
556 void VM_CL_particle (void)
561 VM_SAFEPARMCOUNT(4, VM_CL_particle);
563 org = PRVM_G_VECTOR(OFS_PARM0);
564 dir = PRVM_G_VECTOR(OFS_PARM1);
565 color = (int)PRVM_G_FLOAT(OFS_PARM2);
566 count = (int)PRVM_G_FLOAT(OFS_PARM3);
567 CL_ParticleEffect(EFFECT_SVC_PARTICLE, count, org, org, dir, dir, NULL, color);
570 // #49 void(entity ent, float ideal_yaw, float speed_yaw) ChangeYaw
571 void VM_CL_changeyaw (void)
574 float ideal, current, move, speed;
575 VM_SAFEPARMCOUNT(3, VM_CL_changeyaw);
577 ent = PRVM_G_EDICT(OFS_PARM0);
578 if (ent == prog->edicts)
580 VM_Warning("changeyaw: can not modify world entity\n");
583 if (ent->priv.server->free)
585 VM_Warning("changeyaw: can not modify free entity\n");
588 current = ANGLEMOD(ent->fields.client->angles[1]);
589 ideal = PRVM_G_FLOAT(OFS_PARM1);
590 speed = PRVM_G_FLOAT(OFS_PARM2);
592 if (current == ideal)
594 move = ideal - current;
616 ent->fields.client->angles[1] = ANGLEMOD (current + move);
619 // #63 void(entity ent, float ideal_pitch, float speed_pitch) changepitch (DP_QC_CHANGEPITCH)
620 void VM_CL_changepitch (void)
623 float ideal, current, move, speed;
624 VM_SAFEPARMCOUNT(3, VM_CL_changepitch);
626 ent = PRVM_G_EDICT(OFS_PARM0);
627 if (ent == prog->edicts)
629 VM_Warning("changepitch: can not modify world entity\n");
632 if (ent->priv.server->free)
634 VM_Warning("changepitch: can not modify free entity\n");
637 current = ANGLEMOD( ent->fields.client->angles[0] );
638 ideal = PRVM_G_FLOAT(OFS_PARM1);
639 speed = PRVM_G_FLOAT(OFS_PARM2);
641 if (current == ideal)
643 move = ideal - current;
665 ent->fields.client->angles[0] = ANGLEMOD (current + move);
668 // #64 void(entity e, entity ignore) tracetoss (DP_QC_TRACETOSS)
669 void VM_CL_tracetoss (void)
673 prvm_edict_t *ignore;
675 ent = PRVM_G_EDICT(OFS_PARM0);
676 if (ent == prog->edicts)
678 VM_Warning("tracetoss: can not use world entity\n");
681 ignore = PRVM_G_EDICT(OFS_PARM1);
684 trace = SV_Trace_Toss (ent, ignore);
686 prog->globals.server->trace_allsolid = trace.allsolid;
687 prog->globals.server->trace_startsolid = trace.startsolid;
688 prog->globals.server->trace_fraction = trace.fraction;
689 prog->globals.server->trace_inwater = trace.inwater;
690 prog->globals.server->trace_inopen = trace.inopen;
691 VectorCopy (trace.endpos, prog->globals.server->trace_endpos);
692 VectorCopy (trace.plane.normal, prog->globals.server->trace_plane_normal);
693 prog->globals.server->trace_plane_dist = trace.plane.dist;
695 prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(trace.ent);
697 prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts);
701 // #74 void(vector pos, string samp, float vol, float atten) ambientsound
702 void VM_CL_ambientsound (void)
706 VM_SAFEPARMCOUNT(4, VM_CL_ambientsound);
707 s = S_FindName(PRVM_G_STRING(OFS_PARM0));
708 f = PRVM_G_VECTOR(OFS_PARM1);
709 S_StaticSound (s, f, PRVM_G_FLOAT(OFS_PARM2), PRVM_G_FLOAT(OFS_PARM3)*64);
712 // #90 void(vector v1, vector min, vector max, vector v2, float nomonsters, entity forent) tracebox (DP_QC_TRACEBOX)
713 void VM_CL_tracebox (void)
715 float *v1, *v2, *m1, *m2;
719 v1 = PRVM_G_VECTOR(OFS_PARM0);
720 m1 = PRVM_G_VECTOR(OFS_PARM1);
721 m2 = PRVM_G_VECTOR(OFS_PARM2);
722 v2 = PRVM_G_VECTOR(OFS_PARM3);
724 trace = CL_TraceBox(v1, m1, m2, v2, 1, &ent, 1, false);
726 prog->globals.client->trace_allsolid = trace.allsolid;
727 prog->globals.client->trace_startsolid = trace.startsolid;
728 prog->globals.client->trace_fraction = trace.fraction;
729 prog->globals.client->trace_inwater = trace.inwater;
730 prog->globals.client->trace_inopen = trace.inopen;
731 VectorCopy (trace.endpos, prog->globals.client->trace_endpos);
732 VectorCopy (trace.plane.normal, prog->globals.client->trace_plane_normal);
733 prog->globals.client->trace_plane_dist = trace.plane.dist;
735 prog->globals.client->trace_ent = ent;
737 prog->globals.client->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts);
740 // #92 vector(vector org) getlight (DP_QC_GETLIGHT)
741 void VM_CL_getlight (void)
743 vec3_t ambientcolor, diffusecolor, diffusenormal;
746 VM_SAFEPARMCOUNT(1, VM_CL_getlight);
748 p = PRVM_G_VECTOR(OFS_PARM0);
749 VectorClear(ambientcolor);
750 VectorClear(diffusecolor);
751 VectorClear(diffusenormal);
752 if (cl.worldmodel && cl.worldmodel->brush.LightPoint)
753 cl.worldmodel->brush.LightPoint(cl.worldmodel, p, ambientcolor, diffusecolor, diffusenormal);
754 VectorMA(ambientcolor, 0.5, diffusecolor, PRVM_G_VECTOR(OFS_RETURN));
758 //============================================================================
759 //[515]: SCENE MANAGER builtins
760 extern qboolean CSQC_AddRenderEdict (prvm_edict_t *ed);//csprogs.c
762 matrix4x4_t csqc_listenermatrix;
763 qboolean csqc_usecsqclistener = false;//[515]: per-frame
765 static void CSQC_R_RecalcView (void)
767 extern matrix4x4_t viewmodelmatrix;
768 viewmodelmatrix = identitymatrix;
769 r_view.matrix = identitymatrix;
770 Matrix4x4_CreateFromQuakeEntity(&r_view.matrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], 1);
771 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);
774 //#300 void() clearscene (EXT_CSQC)
775 void VM_R_ClearScene (void)
777 VM_SAFEPARMCOUNT(0, VM_R_ClearScene);
778 r_refdef.numentities = 0;
781 //#301 void(float mask) addentities (EXT_CSQC)
782 extern void CSQC_Predraw (prvm_edict_t *ed);//csprogs.c
783 extern void CSQC_Think (prvm_edict_t *ed);//csprogs.c
784 void VM_R_AddEntities (void)
788 VM_SAFEPARMCOUNT(1, VM_R_AddEntities);
789 drawmask = (int)PRVM_G_FLOAT(OFS_PARM0);
790 CSQC_RelinkAllEntities(drawmask);
792 *prog->time = cl.time;
793 for(i=1;i<prog->num_edicts;i++)
795 ed = &prog->edicts[i];
796 if(ed->priv.required->free)
798 VectorAdd(ed->fields.client->origin, ed->fields.client->mins, ed->fields.client->absmin);
799 VectorAdd(ed->fields.client->origin, ed->fields.client->maxs, ed->fields.client->absmax);
801 if(ed->priv.required->free)
803 // note that for RF_USEAXIS entities, Predraw sets v_forward/v_right/v_up globals that are read by CSQC_AddRenderEdict
805 if(ed->priv.required->free)
807 if(!((int)ed->fields.client->drawmask & drawmask))
809 CSQC_AddRenderEdict(ed);
813 //#302 void(entity ent) addentity (EXT_CSQC)
814 void VM_R_AddEntity (void)
816 VM_SAFEPARMCOUNT(1, VM_R_AddEntity);
817 CSQC_AddRenderEdict(PRVM_G_EDICT(OFS_PARM0));
820 //#303 float(float property, ...) setproperty (EXT_CSQC)
821 void VM_R_SetView (void)
828 VM_SAFEPARMCOUNT(2, VM_R_SetView);
830 c = (int)PRVM_G_FLOAT(OFS_PARM0);
831 f = PRVM_G_VECTOR(OFS_PARM1);
832 k = PRVM_G_FLOAT(OFS_PARM1);
836 case VF_MIN: r_view.x = (int)f[0];
837 r_view.y = (int)f[1];
839 case VF_MIN_X: r_view.x = (int)k;
841 case VF_MIN_Y: r_view.y = (int)k;
843 case VF_SIZE: r_view.width = (int)f[0];
844 r_view.height = (int)f[1];
846 case VF_SIZE_Y: r_view.width = (int)k;
848 case VF_SIZE_X: r_view.height = (int)k;
850 case VF_VIEWPORT: r_view.x = (int)f[0];
851 r_view.y = (int)f[1];
853 // TODO: make sure that view_z and view_depth are set properly even if csqc does not set them!
854 f = PRVM_G_VECTOR(OFS_PARM2);
855 r_view.width = (int)f[0];
856 r_view.height = (int)f[1];
859 case VF_FOV: //r_refdef.fov_x = f[0]; // FIXME!
860 //r_refdef.fov_y = f[1]; // FIXME!
862 case VF_FOVX: //r_refdef.fov_x = k; // FIXME!
864 case VF_FOVY: //r_refdef.fov_y = k; // FIXME!
866 case VF_ORIGIN: VectorCopy(f, csqc_origin);
869 case VF_ORIGIN_X: csqc_origin[0] = k;
872 case VF_ORIGIN_Y: csqc_origin[1] = k;
875 case VF_ORIGIN_Z: csqc_origin[2] = k;
878 case VF_ANGLES: VectorCopy(f, csqc_angles);
881 case VF_ANGLES_X: csqc_angles[0] = k;
884 case VF_ANGLES_Y: csqc_angles[1] = k;
887 case VF_ANGLES_Z: csqc_angles[2] = k;
890 case VF_DRAWWORLD: cl.csqc_vidvars.drawworld = k;
892 case VF_DRAWENGINESBAR: cl.csqc_vidvars.drawenginesbar = k;
894 case VF_DRAWCROSSHAIR: cl.csqc_vidvars.drawcrosshair = k;
897 case VF_CL_VIEWANGLES: VectorCopy(f, cl.viewangles);
899 case VF_CL_VIEWANGLES_X:cl.viewangles[0] = k;
901 case VF_CL_VIEWANGLES_Y:cl.viewangles[1] = k;
903 case VF_CL_VIEWANGLES_Z:cl.viewangles[2] = k;
906 default: PRVM_G_FLOAT(OFS_RETURN) = 0;
907 VM_Warning("VM_R_SetView : unknown parm %i\n", c);
910 PRVM_G_FLOAT(OFS_RETURN) = 1;
913 //#304 void() renderscene (EXT_CSQC)
914 void VM_R_RenderScene (void) //#134
916 VM_SAFEPARMCOUNT(0, VM_R_RenderScene);
917 // update all renderable network entities
922 //#305 void(vector org, float radius, vector lightcolours) adddynamiclight (EXT_CSQC)
923 void VM_R_AddDynamicLight (void)
926 matrix4x4_t tempmatrix;
927 VM_SAFEPARMCOUNT(3, VM_R_AddDynamicLight);
929 pos = PRVM_G_VECTOR(OFS_PARM0);
930 col = PRVM_G_VECTOR(OFS_PARM2);
931 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
932 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);
933 //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);
936 //============================================================================
938 //#310 vector (vector v) cs_unproject (EXT_CSQC)
939 void VM_CL_unproject (void)
944 VM_SAFEPARMCOUNT(1, VM_CL_unproject);
945 f = PRVM_G_VECTOR(OFS_PARM0);
946 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);
947 Matrix4x4_Transform(&r_view.matrix, temp, PRVM_G_VECTOR(OFS_RETURN));
950 //#311 vector (vector v) cs_project (EXT_CSQC)
951 void VM_CL_project (void)
957 VM_SAFEPARMCOUNT(1, VM_CL_project);
958 f = PRVM_G_VECTOR(OFS_PARM0);
959 Matrix4x4_Invert_Simple(&m, &r_view.matrix);
960 Matrix4x4_Transform(&m, f, v);
961 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]);
964 //#330 float(float stnum) getstatf (EXT_CSQC)
965 void VM_CL_getstatf (void)
973 VM_SAFEPARMCOUNT(1, VM_CL_getstatf);
974 i = (int)PRVM_G_FLOAT(OFS_PARM0);
975 if(i < 0 || i >= MAX_CL_STATS)
977 VM_Warning("VM_CL_getstatf: index>=MAX_CL_STATS or index<0\n");
981 PRVM_G_FLOAT(OFS_RETURN) = dat.f;
984 //#331 float(float stnum) getstati (EXT_CSQC)
985 void VM_CL_getstati (void)
988 VM_SAFEPARMCOUNT(1, VM_CL_getstati);
989 index = (int)PRVM_G_FLOAT(OFS_PARM0);
991 if(index < 0 || index >= MAX_CL_STATS)
993 VM_Warning("VM_CL_getstati: index>=MAX_CL_STATS or index<0\n");
997 PRVM_G_FLOAT(OFS_RETURN) = i;
1000 //#332 string(float firststnum) getstats (EXT_CSQC)
1001 void VM_CL_getstats (void)
1005 VM_SAFEPARMCOUNT(1, VM_CL_getstats);
1006 i = (int)PRVM_G_FLOAT(OFS_PARM0);
1007 if(i < 0 || i > MAX_CL_STATS-4)
1009 PRVM_G_INT(OFS_RETURN) = OFS_NULL;
1010 VM_Warning("VM_CL_getstats: index>MAX_CL_STATS-4 or index<0\n");
1013 strlcpy(t, (char*)&cl.stats[i], sizeof(t));
1014 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(t);
1017 //#333 void(entity e, float mdlindex) setmodelindex (EXT_CSQC)
1018 void VM_CL_setmodelindex (void)
1022 struct model_s *model;
1024 VM_SAFEPARMCOUNT(2, VM_CL_setmodelindex);
1026 t = PRVM_G_EDICT(OFS_PARM0);
1028 i = (int)PRVM_G_FLOAT(OFS_PARM1);
1030 t->fields.client->model = 0;
1031 t->fields.client->modelindex = 0;
1036 model = CSQC_GetModelByIndex(i);
1039 VM_Warning("VM_CL_setmodelindex: null model\n");
1042 t->fields.client->model = PRVM_SetEngineString(model->name);
1043 t->fields.client->modelindex = i;
1046 //#334 string(float mdlindex) modelnameforindex (EXT_CSQC)
1047 void VM_CL_modelnameforindex (void)
1051 VM_SAFEPARMCOUNT(1, VM_CL_modelnameforindex);
1053 PRVM_G_INT(OFS_RETURN) = OFS_NULL;
1054 model = CSQC_GetModelByIndex((int)PRVM_G_FLOAT(OFS_PARM0));
1055 PRVM_G_INT(OFS_RETURN) = model ? PRVM_SetEngineString(model->name) : 0;
1058 //#335 float(string effectname) particleeffectnum (EXT_CSQC)
1059 void VM_CL_particleeffectnum (void)
1062 VM_SAFEPARMCOUNT(1, VM_CL_particleeffectnum);
1063 i = CL_ParticleEffectIndexForName(PRVM_G_STRING(OFS_PARM0));
1066 PRVM_G_FLOAT(OFS_RETURN) = i;
1069 // #336 void(entity ent, float effectnum, vector start, vector end[, float color]) trailparticles (EXT_CSQC)
1070 void VM_CL_trailparticles (void)
1075 VM_SAFEPARMCOUNT(4, VM_CL_trailparticles);
1077 t = PRVM_G_EDICT(OFS_PARM0);
1078 i = (int)PRVM_G_FLOAT(OFS_PARM1);
1079 start = PRVM_G_VECTOR(OFS_PARM2);
1080 end = PRVM_G_VECTOR(OFS_PARM3);
1082 CL_ParticleEffect(i, VectorDistance(start, end), start, end, t->fields.client->velocity, t->fields.client->velocity, NULL, (int)PRVM_G_FLOAT(OFS_PARM4));
1085 //#337 void(float effectnum, vector origin, vector dir, float count) pointparticles (EXT_CSQC)
1086 void VM_CL_pointparticles (void)
1090 VM_SAFEPARMCOUNT(4, VM_CL_pointparticles);
1091 i = (int)PRVM_G_FLOAT(OFS_PARM0);
1092 f = PRVM_G_VECTOR(OFS_PARM1);
1093 v = PRVM_G_VECTOR(OFS_PARM2);
1094 n = (int)PRVM_G_FLOAT(OFS_PARM3);
1095 CL_ParticleEffect(i, n, f, f, v, v, NULL, 0);
1098 //#338 void(string s) cprint (EXT_CSQC)
1099 void VM_CL_centerprint (void)
1101 char s[VM_STRINGTEMP_LENGTH];
1103 VM_SAFEPARMCOUNT(1, VM_CL_centerprint);
1104 VM_VarString(0, s, sizeof(s));
1108 //#342 string(float keynum) getkeybind (EXT_CSQC)
1109 void VM_CL_getkeybind (void)
1111 VM_SAFEPARMCOUNT(1, VM_CL_getkeybind);
1112 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(Key_GetBind((int)PRVM_G_FLOAT(OFS_PARM0)));
1115 //#343 void(float usecursor) setcursormode (EXT_CSQC)
1116 void VM_CL_setcursormode (void)
1118 VM_SAFEPARMCOUNT(1, VM_CL_setcursormode);
1119 cl.csqc_wantsmousemove = PRVM_G_FLOAT(OFS_PARM0);
1120 cl_ignoremousemove = true;
1123 //#345 float(float framenum) getinputstate (EXT_CSQC)
1124 void VM_CL_getinputstate (void)
1127 VM_SAFEPARMCOUNT(1, VM_CL_getinputstate);
1128 frame = (int)PRVM_G_FLOAT(OFS_PARM0);
1129 for (i = 0;i < cl.movement_numqueue;i++)
1130 if (cl.movement_queue[i].sequence == frame)
1132 VectorCopy(cl.movement_queue[i].viewangles, prog->globals.client->input_angles);
1133 //prog->globals.client->input_buttons = cl.movement_queue[i].//FIXME
1134 VectorCopy(cl.movement_queue[i].move, prog->globals.client->input_movevalues);
1135 prog->globals.client->input_timelength = cl.movement_queue[i].frametime;
1136 if(cl.movement_queue[i].crouch)
1138 VectorCopy(cl.playercrouchmins, prog->globals.client->pmove_mins);
1139 VectorCopy(cl.playercrouchmaxs, prog->globals.client->pmove_maxs);
1143 VectorCopy(cl.playerstandmins, prog->globals.client->pmove_mins);
1144 VectorCopy(cl.playerstandmaxs, prog->globals.client->pmove_maxs);
1149 //#346 void(float sens) setsensitivityscaler (EXT_CSQC)
1150 void VM_CL_setsensitivityscale (void)
1152 VM_SAFEPARMCOUNT(1, VM_CL_setsensitivityscale);
1153 cl.sensitivityscale = PRVM_G_FLOAT(OFS_PARM0);
1156 //#347 void() runstandardplayerphysics (EXT_CSQC)
1157 void VM_CL_runplayerphysics (void)
1161 //#348 string(float playernum, string keyname) getplayerkeyvalue (EXT_CSQC)
1162 void VM_CL_getplayerkey (void)
1168 VM_SAFEPARMCOUNT(2, VM_CL_getplayerkey);
1170 i = (int)PRVM_G_FLOAT(OFS_PARM0);
1171 c = PRVM_G_STRING(OFS_PARM1);
1172 PRVM_G_INT(OFS_RETURN) = OFS_NULL;
1175 i = Sbar_GetPlayer(i);
1181 if(!strcasecmp(c, "name"))
1182 strlcpy(t, cl.scores[i].name, sizeof(t));
1184 if(!strcasecmp(c, "frags"))
1185 sprintf(t, "%i", cl.scores[i].frags);
1187 if(!strcasecmp(c, "ping"))
1188 sprintf(t, "%i", cl.scores[i].qw_ping);
1190 if(!strcasecmp(c, "entertime"))
1191 sprintf(t, "%f", cl.scores[i].qw_entertime);
1193 if(!strcasecmp(c, "colors"))
1194 sprintf(t, "%i", cl.scores[i].colors);
1196 if(!strcasecmp(c, "topcolor"))
1197 sprintf(t, "%i", cl.scores[i].colors & 0xf0);
1199 if(!strcasecmp(c, "bottomcolor"))
1200 sprintf(t, "%i", (cl.scores[i].colors &15)<<4);
1202 if(!strcasecmp(c, "viewentity"))
1203 sprintf(t, "%i", i+1);
1206 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(t);
1209 //#349 float() isdemo (EXT_CSQC)
1210 void VM_CL_isdemo (void)
1212 PRVM_G_FLOAT(OFS_RETURN) = cls.demoplayback;
1215 //#351 void(vector origin, vector forward, vector right, vector up) SetListener (EXT_CSQC)
1216 void VM_CL_setlistener (void)
1218 VM_SAFEPARMCOUNT(4, VM_CL_setlistener);
1219 Matrix4x4_FromVectors(&csqc_listenermatrix, PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), PRVM_G_VECTOR(OFS_PARM3), PRVM_G_VECTOR(OFS_PARM0));
1220 csqc_usecsqclistener = true; //use csqc listener at this frame
1223 //#352 void(string cmdname) registercommand (EXT_CSQC)
1224 void VM_CL_registercmd (void)
1227 VM_SAFEPARMCOUNT(1, VM_CL_registercmd);
1228 if(!Cmd_Exists(PRVM_G_STRING(OFS_PARM0)))
1232 alloclen = strlen(PRVM_G_STRING(OFS_PARM0)) + 1;
1233 t = (char *)Z_Malloc(alloclen);
1234 memcpy(t, PRVM_G_STRING(OFS_PARM0), alloclen);
1235 Cmd_AddCommand(t, NULL, "console command created by QuakeC");
1238 Cmd_AddCommand(PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC");
1242 //#354 float() playernum (EXT_CSQC)
1243 void VM_CL_playernum (void)
1247 VM_SAFEPARMCOUNT(0, VM_CL_playernum);
1249 for(i=k=0 ; i<cl.maxclients ; i++)
1250 if(cl.scores[i].name[0])
1252 PRVM_G_FLOAT(OFS_RETURN) = k;
1255 //#355 float() cl_onground (EXT_CSQC)
1256 void VM_CL_onground (void)
1258 PRVM_G_FLOAT(OFS_RETURN) = cl.onground;
1261 //#360 float() readbyte (EXT_CSQC)
1262 void VM_CL_ReadByte (void)
1264 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadByte();
1267 //#361 float() readchar (EXT_CSQC)
1268 void VM_CL_ReadChar (void)
1270 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadChar();
1273 //#362 float() readshort (EXT_CSQC)
1274 void VM_CL_ReadShort (void)
1276 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadShort();
1279 //#363 float() readlong (EXT_CSQC)
1280 void VM_CL_ReadLong (void)
1282 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadLong();
1285 //#364 float() readcoord (EXT_CSQC)
1286 void VM_CL_ReadCoord (void)
1288 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadCoord(cls.protocol);
1291 //#365 float() readangle (EXT_CSQC)
1292 void VM_CL_ReadAngle (void)
1294 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadAngle(cls.protocol);
1297 //#366 string() readstring (EXT_CSQC)
1298 void VM_CL_ReadString (void)
1300 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(MSG_ReadString());
1303 //#367 float() readfloat (EXT_CSQC)
1304 void VM_CL_ReadFloat (void)
1306 PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadFloat();
1309 //=================================================================//
1311 // #404 void(vector org, string modelname, float startframe, float endframe, float framerate) effect (DP_SV_EFFECT)
1312 void VM_CL_effect (void)
1314 VM_SAFEPARMCOUNT(5, VM_CL_effect);
1315 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));
1318 // #405 void(vector org, vector velocity, float howmany) te_blood (DP_TE_BLOOD)
1319 void VM_CL_te_blood (void)
1323 VM_SAFEPARMCOUNT(3, VM_CL_te_blood);
1324 if (PRVM_G_FLOAT(OFS_PARM2) < 1)
1326 pos = PRVM_G_VECTOR(OFS_PARM0);
1327 CL_FindNonSolidLocation(pos, pos2, 4);
1328 CL_ParticleEffect(EFFECT_TE_BLOOD, PRVM_G_FLOAT(OFS_PARM2), pos2, pos2, PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM1), NULL, 0);
1331 // #406 void(vector mincorner, vector maxcorner, float explosionspeed, float howmany) te_bloodshower (DP_TE_BLOODSHOWER)
1332 void VM_CL_te_bloodshower (void)
1336 VM_SAFEPARMCOUNT(4, VM_CL_te_bloodshower);
1337 if (PRVM_G_FLOAT(OFS_PARM3) < 1)
1339 speed = PRVM_G_FLOAT(OFS_PARM2);
1346 CL_ParticleEffect(EFFECT_TE_BLOOD, PRVM_G_FLOAT(OFS_PARM3), PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), vel1, vel2, NULL, 0);
1349 // #407 void(vector org, vector color) te_explosionrgb (DP_TE_EXPLOSIONRGB)
1350 void VM_CL_te_explosionrgb (void)
1354 matrix4x4_t tempmatrix;
1355 VM_SAFEPARMCOUNT(2, VM_CL_te_explosionrgb);
1356 pos = PRVM_G_VECTOR(OFS_PARM0);
1357 CL_FindNonSolidLocation(pos, pos2, 10);
1358 CL_ParticleExplosion(pos2);
1359 Matrix4x4_CreateTranslate(&tempmatrix, pos2[0], pos2[1], pos2[2]);
1360 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);
1363 // #408 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color, float gravityflag, float randomveljitter) te_particlecube (DP_TE_PARTICLECUBE)
1364 void VM_CL_te_particlecube (void)
1366 VM_SAFEPARMCOUNT(7, VM_CL_te_particlecube);
1367 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));
1370 // #409 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlerain (DP_TE_PARTICLERAIN)
1371 void VM_CL_te_particlerain (void)
1373 VM_SAFEPARMCOUNT(5, VM_CL_te_particlerain);
1374 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);
1377 // #410 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlesnow (DP_TE_PARTICLESNOW)
1378 void VM_CL_te_particlesnow (void)
1380 VM_SAFEPARMCOUNT(5, VM_CL_te_particlesnow);
1381 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);
1384 // #411 void(vector org, vector vel, float howmany) te_spark
1385 void VM_CL_te_spark (void)
1389 VM_SAFEPARMCOUNT(3, VM_CL_te_spark);
1391 pos = PRVM_G_VECTOR(OFS_PARM0);
1392 CL_FindNonSolidLocation(pos, pos2, 4);
1393 CL_ParticleEffect(EFFECT_TE_SPARK, PRVM_G_FLOAT(OFS_PARM2), pos2, pos2, PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM1), NULL, 0);
1396 // #412 void(vector org) te_gunshotquad (DP_QUADEFFECTS1)
1397 void VM_CL_te_gunshotquad (void)
1401 VM_SAFEPARMCOUNT(1, VM_CL_te_gunshotquad);
1403 pos = PRVM_G_VECTOR(OFS_PARM0);
1404 CL_FindNonSolidLocation(pos, pos2, 4);
1405 CL_ParticleEffect(EFFECT_TE_GUNSHOTQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1408 // #413 void(vector org) te_spikequad (DP_QUADEFFECTS1)
1409 void VM_CL_te_spikequad (void)
1414 VM_SAFEPARMCOUNT(1, VM_CL_te_spikequad);
1416 pos = PRVM_G_VECTOR(OFS_PARM0);
1417 CL_FindNonSolidLocation(pos, pos2, 4);
1418 CL_ParticleEffect(EFFECT_TE_SPIKEQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1419 if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos2, 1, 1);
1423 if (rnd == 1) S_StartSound(-1, 0, cl.sfx_ric1, pos2, 1, 1);
1424 else if (rnd == 2) S_StartSound(-1, 0, cl.sfx_ric2, pos2, 1, 1);
1425 else S_StartSound(-1, 0, cl.sfx_ric3, pos2, 1, 1);
1429 // #414 void(vector org) te_superspikequad (DP_QUADEFFECTS1)
1430 void VM_CL_te_superspikequad (void)
1435 VM_SAFEPARMCOUNT(1, VM_CL_te_superspikequad);
1437 pos = PRVM_G_VECTOR(OFS_PARM0);
1438 CL_FindNonSolidLocation(pos, pos2, 4);
1439 CL_ParticleEffect(EFFECT_TE_SUPERSPIKEQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1440 if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1444 if (rnd == 1) S_StartSound(-1, 0, cl.sfx_ric1, pos2, 1, 1);
1445 else if (rnd == 2) S_StartSound(-1, 0, cl.sfx_ric2, pos2, 1, 1);
1446 else S_StartSound(-1, 0, cl.sfx_ric3, pos2, 1, 1);
1450 // #415 void(vector org) te_explosionquad (DP_QUADEFFECTS1)
1451 void VM_CL_te_explosionquad (void)
1455 VM_SAFEPARMCOUNT(1, VM_CL_te_explosionquad);
1457 pos = PRVM_G_VECTOR(OFS_PARM0);
1458 CL_FindNonSolidLocation(pos, pos2, 10);
1459 CL_ParticleEffect(EFFECT_TE_EXPLOSIONQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1460 S_StartSound(-1, 0, cl.sfx_r_exp3, pos2, 1, 1);
1463 // #416 void(vector org) te_smallflash (DP_TE_SMALLFLASH)
1464 void VM_CL_te_smallflash (void)
1468 VM_SAFEPARMCOUNT(1, VM_CL_te_smallflash);
1470 pos = PRVM_G_VECTOR(OFS_PARM0);
1471 CL_FindNonSolidLocation(pos, pos2, 10);
1472 CL_ParticleEffect(EFFECT_TE_SMALLFLASH, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1475 // #417 void(vector org, float radius, float lifetime, vector color) te_customflash (DP_TE_CUSTOMFLASH)
1476 void VM_CL_te_customflash (void)
1480 matrix4x4_t tempmatrix;
1481 VM_SAFEPARMCOUNT(4, VM_CL_te_customflash);
1483 pos = PRVM_G_VECTOR(OFS_PARM0);
1484 CL_FindNonSolidLocation(pos, pos2, 4);
1485 Matrix4x4_CreateTranslate(&tempmatrix, pos2[0], pos2[1], pos2[2]);
1486 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);
1489 // #418 void(vector org) te_gunshot (DP_TE_STANDARDEFFECTBUILTINS)
1490 void VM_CL_te_gunshot (void)
1494 VM_SAFEPARMCOUNT(1, VM_CL_te_gunshot);
1496 pos = PRVM_G_VECTOR(OFS_PARM0);
1497 CL_FindNonSolidLocation(pos, pos2, 4);
1498 CL_ParticleEffect(EFFECT_TE_GUNSHOT, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1501 // #419 void(vector org) te_spike (DP_TE_STANDARDEFFECTBUILTINS)
1502 void VM_CL_te_spike (void)
1507 VM_SAFEPARMCOUNT(1, VM_CL_te_spike);
1509 pos = PRVM_G_VECTOR(OFS_PARM0);
1510 CL_FindNonSolidLocation(pos, pos2, 4);
1511 CL_ParticleEffect(EFFECT_TE_SPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1512 if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos2, 1, 1);
1516 if (rnd == 1) S_StartSound(-1, 0, cl.sfx_ric1, pos2, 1, 1);
1517 else if (rnd == 2) S_StartSound(-1, 0, cl.sfx_ric2, pos2, 1, 1);
1518 else S_StartSound(-1, 0, cl.sfx_ric3, pos2, 1, 1);
1522 // #420 void(vector org) te_superspike (DP_TE_STANDARDEFFECTBUILTINS)
1523 void VM_CL_te_superspike (void)
1528 VM_SAFEPARMCOUNT(1, VM_CL_te_superspike);
1530 pos = PRVM_G_VECTOR(OFS_PARM0);
1531 CL_FindNonSolidLocation(pos, pos2, 4);
1532 CL_ParticleEffect(EFFECT_TE_SUPERSPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1533 if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos2, 1, 1);
1537 if (rnd == 1) S_StartSound(-1, 0, cl.sfx_ric1, pos2, 1, 1);
1538 else if (rnd == 2) S_StartSound(-1, 0, cl.sfx_ric2, pos2, 1, 1);
1539 else S_StartSound(-1, 0, cl.sfx_ric3, pos2, 1, 1);
1543 // #421 void(vector org) te_explosion (DP_TE_STANDARDEFFECTBUILTINS)
1544 void VM_CL_te_explosion (void)
1548 VM_SAFEPARMCOUNT(1, VM_CL_te_explosion);
1550 pos = PRVM_G_VECTOR(OFS_PARM0);
1551 CL_FindNonSolidLocation(pos, pos2, 10);
1552 CL_ParticleEffect(EFFECT_TE_EXPLOSION, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1553 S_StartSound(-1, 0, cl.sfx_r_exp3, pos2, 1, 1);
1556 // #422 void(vector org) te_tarexplosion (DP_TE_STANDARDEFFECTBUILTINS)
1557 void VM_CL_te_tarexplosion (void)
1561 VM_SAFEPARMCOUNT(1, VM_CL_te_tarexplosion);
1563 pos = PRVM_G_VECTOR(OFS_PARM0);
1564 CL_FindNonSolidLocation(pos, pos2, 10);
1565 CL_ParticleEffect(EFFECT_TE_TAREXPLOSION, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1566 S_StartSound(-1, 0, cl.sfx_r_exp3, pos2, 1, 1);
1569 // #423 void(vector org) te_wizspike (DP_TE_STANDARDEFFECTBUILTINS)
1570 void VM_CL_te_wizspike (void)
1574 VM_SAFEPARMCOUNT(1, VM_CL_te_wizspike);
1576 pos = PRVM_G_VECTOR(OFS_PARM0);
1577 CL_FindNonSolidLocation(pos, pos2, 4);
1578 CL_ParticleEffect(EFFECT_TE_WIZSPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1579 S_StartSound(-1, 0, cl.sfx_wizhit, pos2, 1, 1);
1582 // #424 void(vector org) te_knightspike (DP_TE_STANDARDEFFECTBUILTINS)
1583 void VM_CL_te_knightspike (void)
1587 VM_SAFEPARMCOUNT(1, VM_CL_te_knightspike);
1589 pos = PRVM_G_VECTOR(OFS_PARM0);
1590 CL_FindNonSolidLocation(pos, pos2, 4);
1591 CL_ParticleEffect(EFFECT_TE_KNIGHTSPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1592 S_StartSound(-1, 0, cl.sfx_knighthit, pos2, 1, 1);
1595 // #425 void(vector org) te_lavasplash (DP_TE_STANDARDEFFECTBUILTINS)
1596 void VM_CL_te_lavasplash (void)
1598 VM_SAFEPARMCOUNT(1, VM_CL_te_lavasplash);
1599 CL_ParticleEffect(EFFECT_TE_LAVASPLASH, 1, PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM0), vec3_origin, vec3_origin, NULL, 0);
1602 // #426 void(vector org) te_teleport (DP_TE_STANDARDEFFECTBUILTINS)
1603 void VM_CL_te_teleport (void)
1605 VM_SAFEPARMCOUNT(1, VM_CL_te_teleport);
1606 CL_ParticleEffect(EFFECT_TE_TELEPORT, 1, PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM0), vec3_origin, vec3_origin, NULL, 0);
1609 // #427 void(vector org, float colorstart, float colorlength) te_explosion2 (DP_TE_STANDARDEFFECTBUILTINS)
1610 void VM_CL_te_explosion2 (void)
1614 matrix4x4_t tempmatrix;
1615 int colorStart, colorLength;
1616 unsigned char *tempcolor;
1617 VM_SAFEPARMCOUNT(3, VM_CL_te_explosion2);
1619 pos = PRVM_G_VECTOR(OFS_PARM0);
1620 colorStart = (int)PRVM_G_FLOAT(OFS_PARM1);
1621 colorLength = (int)PRVM_G_FLOAT(OFS_PARM2);
1622 CL_FindNonSolidLocation(pos, pos2, 10);
1623 CL_ParticleExplosion2(pos2, colorStart, colorLength);
1624 tempcolor = (unsigned char *)&palette_complete[(rand()%colorLength) + colorStart];
1625 color[0] = tempcolor[0] * (2.0f / 255.0f);
1626 color[1] = tempcolor[1] * (2.0f / 255.0f);
1627 color[2] = tempcolor[2] * (2.0f / 255.0f);
1628 Matrix4x4_CreateTranslate(&tempmatrix, pos2[0], pos2[1], pos2[2]);
1629 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);
1630 S_StartSound(-1, 0, cl.sfx_r_exp3, pos2, 1, 1);
1634 // #428 void(entity own, vector start, vector end) te_lightning1 (DP_TE_STANDARDEFFECTBUILTINS)
1635 void VM_CL_te_lightning1 (void)
1637 VM_SAFEPARMCOUNT(3, VM_CL_te_lightning1);
1638 CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt, true);
1641 // #429 void(entity own, vector start, vector end) te_lightning2 (DP_TE_STANDARDEFFECTBUILTINS)
1642 void VM_CL_te_lightning2 (void)
1644 VM_SAFEPARMCOUNT(3, VM_CL_te_lightning2);
1645 CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt2, true);
1648 // #430 void(entity own, vector start, vector end) te_lightning3 (DP_TE_STANDARDEFFECTBUILTINS)
1649 void VM_CL_te_lightning3 (void)
1651 VM_SAFEPARMCOUNT(3, VM_CL_te_lightning3);
1652 CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt3, false);
1655 // #431 void(entity own, vector start, vector end) te_beam (DP_TE_STANDARDEFFECTBUILTINS)
1656 void VM_CL_te_beam (void)
1658 VM_SAFEPARMCOUNT(3, VM_CL_te_beam);
1659 CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_beam, false);
1662 // #433 void(vector org) te_plasmaburn (DP_TE_PLASMABURN)
1663 void VM_CL_te_plasmaburn (void)
1667 VM_SAFEPARMCOUNT(1, VM_CL_te_plasmaburn);
1669 pos = PRVM_G_VECTOR(OFS_PARM0);
1670 CL_FindNonSolidLocation(pos, pos2, 4);
1671 CL_ParticleEffect(EFFECT_TE_PLASMABURN, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
1675 //====================================================================
1678 extern void clippointtosurface(model_t *model, msurface_t *surface, vec3_t p, vec3_t out);
1680 static msurface_t *cl_getsurface(model_t *model, int surfacenum)
1682 if (surfacenum < 0 || surfacenum >= model->nummodelsurfaces)
1684 return model->data_surfaces + surfacenum + model->firstmodelsurface;
1687 // #434 float(entity e, float s) getsurfacenumpoints
1688 void VM_CL_getsurfacenumpoints(void)
1690 model_t *model = CSQC_GetModelFromEntity(PRVM_G_EDICT(OFS_PARM0));
1691 msurface_t *surface;
1692 // return 0 if no such surface
1693 if (!model || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
1695 PRVM_G_FLOAT(OFS_RETURN) = 0;
1699 // note: this (incorrectly) assumes it is a simple polygon
1700 PRVM_G_FLOAT(OFS_RETURN) = surface->num_vertices;
1703 // #435 vector(entity e, float s, float n) getsurfacepoint
1704 void VM_CL_getsurfacepoint(void)
1708 msurface_t *surface;
1710 VectorClear(PRVM_G_VECTOR(OFS_RETURN));
1711 ed = PRVM_G_EDICT(OFS_PARM0);
1712 if (!(model = CSQC_GetModelFromEntity(ed)) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
1714 // note: this (incorrectly) assumes it is a simple polygon
1715 pointnum = (int)PRVM_G_FLOAT(OFS_PARM2);
1716 if (pointnum < 0 || pointnum >= surface->num_vertices)
1718 // FIXME: implement rotation/scaling
1719 VectorAdd(&(model->surfmesh.data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed->fields.client->origin, PRVM_G_VECTOR(OFS_RETURN));
1722 // #436 vector(entity e, float s) getsurfacenormal
1723 void VM_CL_getsurfacenormal(void)
1726 msurface_t *surface;
1728 VectorClear(PRVM_G_VECTOR(OFS_RETURN));
1729 if (!(model = CSQC_GetModelFromEntity(PRVM_G_EDICT(OFS_PARM0))) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
1731 // FIXME: implement rotation/scaling
1732 // note: this (incorrectly) assumes it is a simple polygon
1733 // note: this only returns the first triangle, so it doesn't work very
1734 // well for curved surfaces or arbitrary meshes
1735 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);
1736 VectorNormalize(normal);
1737 VectorCopy(normal, PRVM_G_VECTOR(OFS_RETURN));
1740 // #437 string(entity e, float s) getsurfacetexture
1741 void VM_CL_getsurfacetexture(void)
1744 msurface_t *surface;
1745 PRVM_G_INT(OFS_RETURN) = OFS_NULL;
1746 if (!(model = CSQC_GetModelFromEntity(PRVM_G_EDICT(OFS_PARM0))) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
1748 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(surface->texture->name);
1751 // #438 float(entity e, vector p) getsurfacenearpoint
1752 void VM_CL_getsurfacenearpoint(void)
1754 int surfacenum, best;
1756 vec_t dist, bestdist;
1758 model_t *model = NULL;
1759 msurface_t *surface;
1761 PRVM_G_FLOAT(OFS_RETURN) = -1;
1762 ed = PRVM_G_EDICT(OFS_PARM0);
1763 if(!(model = CSQC_GetModelFromEntity(ed)) || !model->num_surfaces)
1766 // FIXME: implement rotation/scaling
1767 point = PRVM_G_VECTOR(OFS_PARM1);
1768 VectorSubtract(point, ed->fields.client->origin, p);
1770 bestdist = 1000000000;
1771 for (surfacenum = 0;surfacenum < model->nummodelsurfaces;surfacenum++)
1773 surface = model->data_surfaces + surfacenum + model->firstmodelsurface;
1774 // first see if the nearest point on the surface's box is closer than the previous match
1775 clipped[0] = bound(surface->mins[0], p[0], surface->maxs[0]) - p[0];
1776 clipped[1] = bound(surface->mins[1], p[1], surface->maxs[1]) - p[1];
1777 clipped[2] = bound(surface->mins[2], p[2], surface->maxs[2]) - p[2];
1778 dist = VectorLength2(clipped);
1779 if (dist < bestdist)
1781 // it is, check the nearest point on the actual geometry
1782 clippointtosurface(model, surface, p, clipped);
1783 VectorSubtract(clipped, p, clipped);
1784 dist += VectorLength2(clipped);
1785 if (dist < bestdist)
1787 // that's closer too, store it as the best match
1793 PRVM_G_FLOAT(OFS_RETURN) = best;
1796 // #439 vector(entity e, float s, vector p) getsurfaceclippedpoint
1797 void VM_CL_getsurfaceclippedpoint(void)
1801 msurface_t *surface;
1803 VectorClear(PRVM_G_VECTOR(OFS_RETURN));
1804 ed = PRVM_G_EDICT(OFS_PARM0);
1805 if (!(model = CSQC_GetModelFromEntity(ed)) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
1807 // FIXME: implement rotation/scaling
1808 VectorSubtract(PRVM_G_VECTOR(OFS_PARM2), ed->fields.client->origin, p);
1809 clippointtosurface(model, surface, p, out);
1810 // FIXME: implement rotation/scaling
1811 VectorAdd(out, ed->fields.client->origin, PRVM_G_VECTOR(OFS_RETURN));
1814 // #443 void(entity e, entity tagentity, string tagname) setattachment
1815 void VM_CL_setattachment (void)
1817 prvm_edict_t *e = PRVM_G_EDICT(OFS_PARM0);
1818 prvm_edict_t *tagentity = PRVM_G_EDICT(OFS_PARM1);
1819 const char *tagname = PRVM_G_STRING(OFS_PARM2);
1824 if (e == prog->edicts)
1826 VM_Warning("setattachment: can not modify world entity\n");
1829 if (e->priv.server->free)
1831 VM_Warning("setattachment: can not modify free entity\n");
1835 if (tagentity == NULL)
1836 tagentity = prog->edicts;
1838 v = PRVM_GETEDICTFIELDVALUE(e, csqc_fieldoff_tag_entity);
1840 v->edict = PRVM_EDICT_TO_PROG(tagentity);
1842 v = PRVM_GETEDICTFIELDVALUE(e, csqc_fieldoff_tag_index);
1845 if (tagentity != NULL && tagentity != prog->edicts && tagname && tagname[0])
1847 modelindex = (int)tagentity->fields.client->modelindex;
1848 model = CSQC_GetModelByIndex(modelindex);
1851 v->_float = Mod_Alias_GetTagIndexForName(model, (int)tagentity->fields.client->skin, tagname);
1853 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);
1856 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));
1860 /////////////////////////////////////////
1861 // DP_MD3_TAGINFO extension coded by VorteX
1863 int CL_GetTagIndex (prvm_edict_t *e, const char *tagname)
1865 model_t *model = CSQC_GetModelFromEntity(e);
1867 return Mod_Alias_GetTagIndexForName(model, (int)e->fields.client->skin, tagname);
1872 // Warnings/errors code:
1873 // 0 - normal (everything all-right)
1876 // 3 - null or non-precached model
1877 // 4 - no tags with requested index
1878 // 5 - runaway loop at attachment chain
1879 extern cvar_t cl_bob;
1880 extern cvar_t cl_bobcycle;
1881 extern cvar_t cl_bobup;
1882 int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
1885 int reqframe, attachloop;
1886 matrix4x4_t entitymatrix, tagmatrix, attachmatrix;
1887 prvm_edict_t *attachent;
1890 *out = identitymatrix; // warnings and errors return identical matrix
1892 if (ent == prog->edicts)
1894 if (ent->priv.server->free)
1897 model = CSQC_GetModelFromEntity(ent);
1902 if (ent->fields.client->frame >= 0 && ent->fields.client->frame < model->numframes && model->animscenes)
1903 reqframe = model->animscenes[(int)ent->fields.client->frame].firstframe;
1905 reqframe = 0; // if model has wrong frame, engine automatically switches to model first frame
1907 // get initial tag matrix
1910 int ret = Mod_Alias_GetTagMatrix(model, reqframe, tagindex - 1, &tagmatrix);
1915 tagmatrix = identitymatrix;
1917 if ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_tag_entity)) && val->edict)
1918 { // DP_GFX_QUAKE3MODELTAGS, scan all chain and stop on unattached entity
1922 attachent = PRVM_EDICT_NUM(val->edict); // to this it entity our entity is attached
1923 val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_tag_index);
1925 model = CSQC_GetModelFromEntity(attachent);
1927 if (model && val->_float >= 1 && model->animscenes && attachent->fields.client->frame >= 0 && attachent->fields.client->frame < model->numframes)
1928 Mod_Alias_GetTagMatrix(model, model->animscenes[(int)attachent->fields.client->frame].firstframe, (int)val->_float - 1, &attachmatrix);
1930 attachmatrix = identitymatrix;
1932 // apply transformation by child entity matrix
1933 val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_scale);
1934 if (val->_float == 0)
1936 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);
1937 Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
1938 Matrix4x4_Copy(&tagmatrix, out);
1940 // finally transformate by matrix of tag on parent entity
1941 Matrix4x4_Concat(out, &attachmatrix, &tagmatrix);
1942 Matrix4x4_Copy(&tagmatrix, out);
1946 if (attachloop > 255) // prevent runaway looping
1949 while ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_tag_entity)) && val->edict);
1952 // normal or RENDER_VIEWMODEL entity (or main parent entity on attach chain)
1953 val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_scale);
1954 if (val->_float == 0)
1956 // Alias models have inverse pitch, bmodels can't have tags, so don't check for modeltype...
1957 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);
1958 Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
1960 if ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_renderflags)) && (RF_VIEWMODEL & (int)val->_float))
1961 {// RENDER_VIEWMODEL magic
1962 Matrix4x4_Copy(&tagmatrix, out);
1964 val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_scale);
1965 if (val->_float == 0)
1968 Matrix4x4_CreateFromQuakeEntity(&entitymatrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], val->_float);
1969 Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
1972 // Cl_bob, ported from rendering code
1973 if (ent->fields.client->health > 0 && cl_bob.value && cl_bobcycle.value)
1976 // LordHavoc: this code is *weird*, but not replacable (I think it
1977 // should be done in QC on the server, but oh well, quake is quake)
1978 // LordHavoc: figured out bobup: the time at which the sin is at 180
1979 // degrees (which allows lengthening or squishing the peak or valley)
1980 cycle = sv.time/cl_bobcycle.value;
1981 cycle -= (int)cycle;
1982 if (cycle < cl_bobup.value)
1983 cycle = sin(M_PI * cycle / cl_bobup.value);
1985 cycle = sin(M_PI + M_PI * (cycle-cl_bobup.value)/(1.0 - cl_bobup.value));
1986 // bob is proportional to velocity in the xy plane
1987 // (don't count Z, or jumping messes it up)
1988 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;
1989 bob = bob*0.3 + bob*0.7*cycle;
1990 Matrix4x4_AdjustOrigin(out, 0, 0, bound(-7, bob, 4));
1997 // #451 float(entity ent, string tagname) gettagindex (DP_QC_GETTAGINFO)
1998 void VM_CL_gettagindex (void)
2000 prvm_edict_t *ent = PRVM_G_EDICT(OFS_PARM0);
2001 const char *tag_name = PRVM_G_STRING(OFS_PARM1);
2002 int modelindex, tag_index;
2004 if (ent == prog->edicts)
2006 VM_Warning("gettagindex: can't affect world entity\n");
2009 if (ent->priv.server->free)
2011 VM_Warning("gettagindex: can't affect free entity\n");
2015 modelindex = (int)ent->fields.client->modelindex;
2017 modelindex = -(modelindex+1);
2019 if (modelindex <= 0 || modelindex >= MAX_MODELS)
2020 Con_DPrintf("gettagindex(entity #%i): null or non-precached model\n", PRVM_NUM_FOR_EDICT(ent));
2023 tag_index = CL_GetTagIndex(ent, tag_name);
2025 Con_DPrintf("gettagindex(entity #%i): tag \"%s\" not found\n", PRVM_NUM_FOR_EDICT(ent), tag_name);
2027 PRVM_G_FLOAT(OFS_RETURN) = tag_index;
2030 // #452 vector(entity ent, float tagindex) gettaginfo (DP_QC_GETTAGINFO)
2031 void VM_CL_gettaginfo (void)
2033 prvm_edict_t *e = PRVM_G_EDICT(OFS_PARM0);
2034 int tagindex = (int)PRVM_G_FLOAT(OFS_PARM1);
2035 matrix4x4_t tag_matrix;
2038 returncode = CL_GetTagMatrix(&tag_matrix, e, tagindex);
2039 Matrix4x4_ToVectors(&tag_matrix, prog->globals.client->v_forward, prog->globals.client->v_right, prog->globals.client->v_up, PRVM_G_VECTOR(OFS_RETURN));
2044 VM_Warning("gettagindex: can't affect world entity\n");
2047 VM_Warning("gettagindex: can't affect free entity\n");
2050 Con_DPrintf("CL_GetTagMatrix(entity #%i): null or non-precached model\n", PRVM_NUM_FOR_EDICT(e));
2053 Con_DPrintf("CL_GetTagMatrix(entity #%i): model has no tag with requested index %i\n", PRVM_NUM_FOR_EDICT(e), tagindex);
2056 Con_DPrintf("CL_GetTagMatrix(entity #%i): runaway loop at attachment chain\n", PRVM_NUM_FOR_EDICT(e));
2061 //=================================================
2062 //[515]: here goes test/unfinished/etc.
2064 //[515]: check if it is what it should be
2065 void VM_WasFreed (void)
2068 VM_SAFEPARMCOUNT(1, VM_WasFreed);
2070 e = PRVM_G_EDICT(OFS_PARM0);
2071 if (!e->priv.required->free || (e->priv.required->free && (e->priv.required->freetime < 2 || (*prog->time - e->priv.required->freetime) > 0.5 )))
2072 PRVM_G_FLOAT(OFS_RETURN) = false;
2074 PRVM_G_FLOAT(OFS_RETURN) = true;
2077 void VM_CL_select_cube (void)
2081 float *mins2, *maxs2;
2082 prvm_edict_t *ent, *chain;
2083 vec3_t mins1, maxs1;
2085 VM_SAFEPARMCOUNT(2, VM_CL_select_cube);
2087 // is the same like !(prog->flag & PRVM_FE_CHAIN) - even if the operator precedence is another
2088 if(!prog->flag & PRVM_FE_CHAIN)
2089 PRVM_ERROR("VM_findchain: %s doesnt have a chain field !\n", PRVM_NAME);
2091 chain_of = PRVM_ED_FindField("chain")->ofs;
2092 chain = prog->edicts;
2094 mins2 = PRVM_G_VECTOR(OFS_PARM0);
2095 maxs2 = PRVM_G_VECTOR(OFS_PARM1);
2097 ent = PRVM_NEXT_EDICT(prog->edicts);
2098 for (i = 1;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
2100 if (ent->priv.required->free)
2102 VectorCopy(ent->fields.client->origin, mins1);
2103 VectorAdd(mins1, ent->fields.client->maxs, maxs1);
2104 VectorAdd(mins1, ent->fields.client->mins, mins1);
2105 if (mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2])
2107 if (maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
2109 PRVM_E_INT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
2113 VM_RETURN_EDICT(chain);
2116 void VM_CL_select_super (void)
2121 prvm_edict_t *ent, *chain;
2122 vec3_t mins1, maxs1;
2124 VM_SAFEPARMCOUNT(8, VM_findchain);
2126 v[i] = PRVM_G_VECTOR(OFS_PARM0+i*3);
2128 // is the same like !(prog->flag & PRVM_FE_CHAIN) - even if the operator precedence is another
2129 if(!prog->flag & PRVM_FE_CHAIN)
2130 PRVM_ERROR("VM_findchain: %s doesnt have a chain field !\n", PRVM_NAME);
2132 chain_of = PRVM_ED_FindField("chain")->ofs;
2133 chain = prog->edicts;
2135 mins2 = PRVM_G_VECTOR(OFS_PARM0);
2136 maxs2 = PRVM_G_VECTOR(OFS_PARM1);
2138 ent = PRVM_NEXT_EDICT(prog->edicts);
2139 for (i = 1;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
2141 if (ent->priv.required->free)
2143 VectorCopy(ent->fields.client->origin, mins1);
2144 VectorAdd(mins1, ent->fields.client->maxs, maxs1);
2145 VectorAdd(mins1, ent->fields.client->mins, mins1);
2146 if (mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2])
2148 if (maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
2150 PRVM_E_INT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
2154 VM_RETURN_EDICT(chain);*/
2157 static int Is_Text_Color (char c, char t)
2160 char c2 = c - (c & 128);
2161 char t2 = t - (t & 128);
2163 if(c != STRING_COLOR_TAG && c2 != STRING_COLOR_TAG) return 0;
2164 if(t >= '0' && t <= '9') a = 1;
2165 if(t2 >= '0' && t2 <= '9') a = 1;
2166 /* if(t >= 'A' && t <= 'Z') a = 2;
2167 if(t2 >= 'A' && t2 <= 'Z') a = 2;
2169 if(a == 1 && scr_colortext.integer > 0)
2171 if(a == 2 && scr_multifonts.integer > 0)
2177 void VM_uncolorstring (void) //#170
2180 char out[VM_STRINGTEMP_LENGTH];
2183 VM_SAFEPARMCOUNT(1, VM_uncolorstring);
2184 in = PRVM_G_STRING(OFS_PARM0);
2185 VM_CheckEmptyString (in);
2190 if(Is_Text_Color(in[k], in[k+1]) == 1/* || (in[k] == '&' && in[k+1] == 'r')*/)
2199 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(out);
2202 void VM_CL_selecttraceline (void)
2205 int ent, ignore, csqcents;
2207 v1 = PRVM_G_VECTOR(OFS_PARM0);
2208 v2 = PRVM_G_VECTOR(OFS_PARM1);
2209 ignore = (int)PRVM_G_FLOAT(OFS_PARM2);
2210 csqcents = (int)PRVM_G_FLOAT(OFS_PARM3);
2215 VM_Warning("VM_CL_selecttraceline: csqcents flag not supported anymore, and this function is deprecated\n");
2218 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);
2219 PRVM_G_FLOAT(OFS_RETURN) = ent;
2222 void VM_charindex (void)
2225 s = PRVM_G_STRING(OFS_PARM0);
2226 if((unsigned)PRVM_G_FLOAT(OFS_PARM1) > strlen(s))
2228 PRVM_G_FLOAT(OFS_RETURN) = (unsigned char)s[(int)PRVM_G_FLOAT(OFS_PARM1)];
2231 //#223 string(float c, ...) chr2str (FTE_STRINGS)
2232 void VM_chr2str (void)
2236 for(i = 0;i < prog->argc && i < (int)sizeof(t) - 1;i++)
2237 t[i] = (unsigned char)PRVM_G_FLOAT(OFS_PARM0+i*3);
2239 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(t);
2242 //#228 float(string s1, string s2, float len) strncmp (FTE_STRINGS)
2243 void VM_strncmp (void)
2245 const char *s1, *s2;
2246 VM_SAFEPARMCOUNT(1, VM_strncmp);
2247 s1 = PRVM_G_STRING(OFS_PARM0);
2248 s2 = PRVM_G_STRING(OFS_PARM1);
2249 PRVM_G_FLOAT(OFS_RETURN) = strncmp(s1, s2, (size_t)PRVM_G_FLOAT(OFS_PARM2));
2252 //============================================================================
2253 //============================================================================
2255 prvm_builtin_t vm_cl_builtins[] = {
2256 0, // to be consistent with the old vm
2257 VM_CL_makevectors, // #1 void(vector ang) makevectors
2258 VM_CL_setorigin, // #2 void(entity e, vector o) setorigin
2259 VM_CL_setmodel, // #3 void(entity e, string m) setmodel
2260 VM_CL_setsize, // #4 void(entity e, vector min, vector max) setsize
2262 VM_break, // #6 void() break
2263 VM_random, // #7 float() random
2264 VM_CL_sound, // #8 void(entity e, float chan, string samp) sound
2265 VM_normalize, // #9 vector(vector v) normalize
2266 VM_error, // #10 void(string e) error
2267 VM_objerror, // #11 void(string e) objerror
2268 VM_vlen, // #12 float(vector v) vlen
2269 VM_vectoyaw, // #13 float(vector v) vectoyaw
2270 VM_CL_spawn, // #14 entity() spawn
2271 VM_remove, // #15 void(entity e) remove
2272 VM_CL_traceline, // #16 float(vector v1, vector v2, float tryents) traceline
2274 VM_find, // #18 entity(entity start, .string fld, string match) find
2275 VM_CL_precache_sound, // #19 void(string s) precache_sound
2276 VM_CL_precache_model, // #20 void(string s) precache_model
2278 VM_CL_findradius, // #22 entity(vector org, float rad) findradius
2281 VM_dprint, // #25 void(string s) dprint
2282 VM_ftos, // #26 void(string s) ftos
2283 VM_vtos, // #27 void(string s) vtos
2284 VM_coredump, // #28 void() coredump
2285 VM_traceon, // #29 void() traceon
2286 VM_traceoff, // #30 void() traceoff
2287 VM_eprint, // #31 void(entity e) eprint
2290 VM_CL_droptofloor, // #34 float() droptofloor
2291 VM_CL_lightstyle, // #35 void(float style, string value) lightstyle
2292 VM_rint, // #36 float(float v) rint
2293 VM_floor, // #37 float(float v) floor
2294 VM_ceil, // #38 float(float v) ceil
2296 VM_CL_checkbottom, // #40 float(entity e) checkbottom
2297 VM_CL_pointcontents, // #41 float(vector v) pointcontents
2299 VM_fabs, // #43 float(float f) fabs
2301 VM_cvar, // #45 float(string s) cvar
2302 VM_localcmd, // #46 void(string s) localcmd
2303 VM_nextent, // #47 entity(entity e) nextent
2304 VM_CL_particle, // #48 void(vector o, vector d, float color, float count) particle
2305 VM_CL_changeyaw, // #49 void(entity ent, float ideal_yaw, float speed_yaw) ChangeYaw
2307 VM_vectoangles, // #51 vector(vector v) vectoangles
2308 0, // #52 void(float to, float f) WriteByte
2309 0, // #53 void(float to, float f) WriteChar
2310 0, // #54 void(float to, float f) WriteShort
2311 0, // #55 void(float to, float f) WriteLong
2312 0, // #56 void(float to, float f) WriteCoord
2313 0, // #57 void(float to, float f) WriteAngle
2314 0, // #58 void(float to, string s) WriteString
2316 VM_sin, // #60 float(float f) sin (DP_QC_SINCOSSQRTPOW)
2317 VM_cos, // #61 float(float f) cos (DP_QC_SINCOSSQRTPOW)
2318 VM_sqrt, // #62 float(float f) sqrt (DP_QC_SINCOSSQRTPOW)
2319 VM_CL_changepitch, // #63 void(entity ent, float ideal_pitch, float speed_pitch) changepitch (DP_QC_CHANGEPITCH)
2320 VM_CL_tracetoss, // #64 void(entity e, entity ignore) tracetoss (DP_QC_TRACETOSS)
2321 VM_etos, // #65 string(entity ent) etos (DP_QC_ETOS)
2328 VM_cvar_set, // #72 void(string var, string val) cvar_set
2330 VM_CL_ambientsound, // #74 void(vector pos, string samp, float vol, float atten) ambientsound
2331 VM_CL_precache_model, // #75 string(string s) precache_model2
2332 VM_CL_precache_sound, // #76 string(string s) precache_sound2
2337 VM_stof, // #81 float(string s) stof (FRIK_FILE)
2346 VM_CL_tracebox, // #90 void(vector v1, vector min, vector max, vector v2, float nomonsters, entity forent) tracebox (DP_QC_TRACEBOX)
2347 VM_randomvec, // #91 vector() randomvec (DP_QC_RANDOMVEC)
2348 VM_CL_getlight, // #92 vector(vector org) getlight (DP_QC_GETLIGHT)
2349 PF_registercvar, // #93 float(string name, string value) registercvar (DP_REGISTERCVAR)
2350 VM_min, // #94 float(float a, floats) min (DP_QC_MINMAXBOUND)
2351 VM_max, // #95 float(float a, floats) max (DP_QC_MINMAXBOUND)
2352 VM_bound, // #96 float(float minimum, float val, float maximum) bound (DP_QC_MINMAXBOUND)
2353 VM_pow, // #97 float(float f, float f) pow (DP_QC_SINCOSSQRTPOW)
2354 VM_findfloat, // #98 entity(entity start, .float fld, float match) findfloat (DP_QC_FINDFLOAT)
2355 VM_checkextension, // #99 float(string s) checkextension (the basis of the extension system)
2366 VM_fopen, // #110 float(string filename, float mode) fopen (FRIK_FILE)
2367 VM_fclose, // #111 void(float fhandle) fclose (FRIK_FILE)
2368 VM_fgets, // #112 string(float fhandle) fgets (FRIK_FILE)
2369 VM_fputs, // #113 void(float fhandle, string s) fputs (FRIK_FILE)
2370 VM_strlen, // #114 float(string s) strlen (FRIK_FILE)
2371 VM_strcat, // #115 string(string s1, string s2) strcat (FRIK_FILE)
2372 VM_substring, // #116 string(string s, float start, float length) substring (FRIK_FILE)
2373 VM_stov, // #117 vector(string) stov (FRIK_FILE)
2374 VM_strzone, // #118 string(string s) strzone (FRIK_FILE)
2375 VM_strunzone, // #119 void(string s) strunzone (FRIK_FILE)
2377 e10, e10, e10, e10, e10, e10, e10, e10, // #120-199
2387 VM_bitshift, //#218 float(float number, float quantity) bitshift (EXT_BITSHIFT)
2391 VM_charindex, //#222 float(string str, float ofs) str2chr (FTE_STRINGS)
2392 VM_chr2str, //#223 string(float c, ...) chr2str (FTE_STRINGS)
2397 VM_strncmp, //#228 float(string s1, string s2, float len) strncmp (FTE_STRINGS)
2399 e10, e10, e10, e10, e10, e10, e10, // #230-299
2401 //======CSQC start=======//
2402 //3d world (buffer/buffering) operations
2403 VM_R_ClearScene, //#300 void() clearscene (EXT_CSQC)
2404 VM_R_AddEntities, //#301 void(float mask) addentities (EXT_CSQC)
2405 VM_R_AddEntity, //#302 void(entity ent) addentity (EXT_CSQC)
2406 VM_R_SetView, //#303 float(float property, ...) setproperty (EXT_CSQC)
2407 VM_R_RenderScene, //#304 void() renderscene (EXT_CSQC)
2408 VM_R_AddDynamicLight, //#305 void(vector org, float radius, vector lightcolours) adddynamiclight (EXT_CSQC)
2409 VM_R_PolygonBegin, //#306 void(string texturename, float flag[, float is2d, float lines]) R_BeginPolygon
2410 VM_R_PolygonVertex, //#307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
2411 VM_R_PolygonEnd, //#308 void() R_EndPolygon
2414 //maths stuff that uses the current view settings
2415 VM_CL_unproject, //#310 vector (vector v) cs_unproject (EXT_CSQC)
2416 VM_CL_project, //#311 vector (vector v) cs_project (EXT_CSQC)
2421 //2d (immediate) operations
2422 VM_drawline, //#315 void(float width, vector pos1, vector pos2, float flag) drawline (EXT_CSQC)
2423 VM_iscachedpic, //#316 float(string name) iscachedpic (EXT_CSQC)
2424 VM_precache_pic, //#317 string(string name, float trywad) precache_pic (EXT_CSQC)
2425 VM_getimagesize, //#318 vector(string picname) draw_getimagesize (EXT_CSQC)
2426 VM_freepic, //#319 void(string name) freepic (EXT_CSQC)
2427 VM_drawcharacter, //#320 float(vector position, float character, vector scale, vector rgb, float alpha, float flag) drawcharacter (EXT_CSQC)
2428 VM_drawstring, //#321 float(vector position, string text, vector scale, vector rgb, float alpha, float flag) drawstring (EXT_CSQC)
2429 VM_drawpic, //#322 float(vector position, string pic, vector size, vector rgb, float alpha, float flag) drawpic (EXT_CSQC)
2430 VM_drawfill, //#323 float(vector position, vector size, vector rgb, float alpha, float flag) drawfill (EXT_CSQC)
2431 VM_drawsetcliparea, //#324 void(float x, float y, float width, float height) drawsetcliparea
2432 VM_drawresetcliparea, //#325 void(void) drawresetcliparea
2438 VM_CL_getstatf, //#330 float(float stnum) getstatf (EXT_CSQC)
2439 VM_CL_getstati, //#331 float(float stnum) getstati (EXT_CSQC)
2440 VM_CL_getstats, //#332 string(float firststnum) getstats (EXT_CSQC)
2441 VM_CL_setmodelindex, //#333 void(entity e, float mdlindex) setmodelindex (EXT_CSQC)
2442 VM_CL_modelnameforindex, //#334 string(float mdlindex) modelnameforindex (EXT_CSQC)
2443 VM_CL_particleeffectnum, //#335 float(string effectname) particleeffectnum (EXT_CSQC)
2444 VM_CL_trailparticles, //#336 void(entity ent, float effectnum, vector start, vector end) trailparticles (EXT_CSQC)
2445 VM_CL_pointparticles, //#337 void(float effectnum, vector origin [, vector dir, float count]) pointparticles (EXT_CSQC)
2446 VM_CL_centerprint, //#338 void(string s) cprint (EXT_CSQC)
2447 VM_print, //#339 void(string s) print (EXT_CSQC)
2448 VM_keynumtostring, //#340 string(float keynum) keynumtostring (EXT_CSQC)
2449 VM_stringtokeynum, //#341 float(string keyname) stringtokeynum (EXT_CSQC)
2450 VM_CL_getkeybind, //#342 string(float keynum) getkeybind (EXT_CSQC)
2451 VM_CL_setcursormode, //#343 void(float usecursor) setcursormode (EXT_CSQC)
2452 VM_getmousepos, //#344 vector() getmousepos (EXT_CSQC)
2453 VM_CL_getinputstate, //#345 float(float framenum) getinputstate (EXT_CSQC)
2454 VM_CL_setsensitivityscale, //#346 void(float sens) setsensitivityscaler (EXT_CSQC)
2455 VM_CL_runplayerphysics, //#347 void() runstandardplayerphysics (EXT_CSQC)
2456 VM_CL_getplayerkey, //#348 string(float playernum, string keyname) getplayerkeyvalue (EXT_CSQC)
2457 VM_CL_isdemo, //#349 float() isdemo (EXT_CSQC)
2458 VM_isserver, //#350 float() isserver (EXT_CSQC)
2459 VM_CL_setlistener, //#351 void(vector origin, vector forward, vector right, vector up) SetListener (EXT_CSQC)
2460 VM_CL_registercmd, //#352 void(string cmdname) registercommand (EXT_CSQC)
2461 VM_WasFreed, //#353 float(entity ent) wasfreed (EXT_CSQC) (should be availabe on server too)
2462 VM_CL_playernum, //#354 float() playernum
2463 VM_CL_onground, //#355 float() cl_onground (EXT_CSQC)
2464 VM_charindex, //#356 float(string s, float num) charindex
2465 VM_CL_selecttraceline, //#357 float(vector start, vector end, float ignore, float csqcents) selecttraceline
2468 VM_CL_ReadByte, //#360 float() readbyte (EXT_CSQC)
2469 VM_CL_ReadChar, //#361 float() readchar (EXT_CSQC)
2470 VM_CL_ReadShort, //#362 float() readshort (EXT_CSQC)
2471 VM_CL_ReadLong, //#363 float() readlong (EXT_CSQC)
2472 VM_CL_ReadCoord, //#364 float() readcoord (EXT_CSQC)
2473 VM_CL_ReadAngle, //#365 float() readangle (EXT_CSQC)
2474 VM_CL_ReadString, //#366 string() readstring (EXT_CSQC)
2475 VM_CL_ReadFloat, //#367 float() readfloat (EXT_CSQC)
2508 //=========CSQC end========//
2510 VM_copyentity, // #400 void(entity from, entity to) copyentity (DP_QC_COPYENTITY)
2512 VM_findchain, // #402 entity(.string fld, string match) findchain (DP_QC_FINDCHAIN)
2513 VM_findchainfloat, // #403 entity(.float fld, float match) findchainfloat (DP_QC_FINDCHAINFLOAT)
2514 VM_CL_effect, // #404 void(vector org, string modelname, float startframe, float endframe, float framerate) effect (DP_SV_EFFECT)
2515 VM_CL_te_blood, // #405 void(vector org, vector velocity, float howmany) te_blood (DP_TE_BLOOD)
2516 VM_CL_te_bloodshower, // #406 void(vector mincorner, vector maxcorner, float explosionspeed, float howmany) te_bloodshower (DP_TE_BLOODSHOWER)
2517 VM_CL_te_explosionrgb, // #407 void(vector org, vector color) te_explosionrgb (DP_TE_EXPLOSIONRGB)
2518 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)
2519 VM_CL_te_particlerain, // #409 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlerain (DP_TE_PARTICLERAIN)
2520 VM_CL_te_particlesnow, // #410 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlesnow (DP_TE_PARTICLESNOW)
2521 VM_CL_te_spark, // #411 void(vector org, vector vel, float howmany) te_spark (DP_TE_SPARK)
2522 VM_CL_te_gunshotquad, // #412 void(vector org) te_gunshotquad (DP_QUADEFFECTS1)
2523 VM_CL_te_spikequad, // #413 void(vector org) te_spikequad (DP_QUADEFFECTS1)
2524 VM_CL_te_superspikequad, // #414 void(vector org) te_superspikequad (DP_QUADEFFECTS1)
2525 VM_CL_te_explosionquad, // #415 void(vector org) te_explosionquad (DP_QUADEFFECTS1)
2526 VM_CL_te_smallflash, // #416 void(vector org) te_smallflash (DP_TE_SMALLFLASH)
2527 VM_CL_te_customflash, // #417 void(vector org, float radius, float lifetime, vector color) te_customflash (DP_TE_CUSTOMFLASH)
2528 VM_CL_te_gunshot, // #418 void(vector org) te_gunshot (DP_TE_STANDARDEFFECTBUILTINS)
2529 VM_CL_te_spike, // #419 void(vector org) te_spike (DP_TE_STANDARDEFFECTBUILTINS)
2530 VM_CL_te_superspike, // #420 void(vector org) te_superspike (DP_TE_STANDARDEFFECTBUILTINS)
2531 VM_CL_te_explosion, // #421 void(vector org) te_explosion (DP_TE_STANDARDEFFECTBUILTINS)
2532 VM_CL_te_tarexplosion, // #422 void(vector org) te_tarexplosion (DP_TE_STANDARDEFFECTBUILTINS)
2533 VM_CL_te_wizspike, // #423 void(vector org) te_wizspike (DP_TE_STANDARDEFFECTBUILTINS)
2534 VM_CL_te_knightspike, // #424 void(vector org) te_knightspike (DP_TE_STANDARDEFFECTBUILTINS)
2535 VM_CL_te_lavasplash, // #425 void(vector org) te_lavasplash (DP_TE_STANDARDEFFECTBUILTINS)
2536 VM_CL_te_teleport, // #426 void(vector org) te_teleport (DP_TE_STANDARDEFFECTBUILTINS)
2537 VM_CL_te_explosion2, // #427 void(vector org, float colorstart, float colorlength) te_explosion2 (DP_TE_STANDARDEFFECTBUILTINS)
2538 VM_CL_te_lightning1, // #428 void(entity own, vector start, vector end) te_lightning1 (DP_TE_STANDARDEFFECTBUILTINS)
2539 VM_CL_te_lightning2, // #429 void(entity own, vector start, vector end) te_lightning2 (DP_TE_STANDARDEFFECTBUILTINS)
2540 VM_CL_te_lightning3, // #430 void(entity own, vector start, vector end) te_lightning3 (DP_TE_STANDARDEFFECTBUILTINS)
2541 VM_CL_te_beam, // #431 void(entity own, vector start, vector end) te_beam (DP_TE_STANDARDEFFECTBUILTINS)
2542 VM_vectorvectors, // #432 void(vector dir) vectorvectors (DP_QC_VECTORVECTORS)
2543 VM_CL_te_plasmaburn, // #433 void(vector org) te_plasmaburn (DP_TE_PLASMABURN)
2544 VM_CL_getsurfacenumpoints, // #434 float(entity e, float s) getsurfacenumpoints (DP_QC_GETSURFACE)
2545 VM_CL_getsurfacepoint, // #435 vector(entity e, float s, float n) getsurfacepoint (DP_QC_GETSURFACE)
2546 VM_CL_getsurfacenormal, // #436 vector(entity e, float s) getsurfacenormal (DP_QC_GETSURFACE)
2547 VM_CL_getsurfacetexture, // #437 string(entity e, float s) getsurfacetexture (DP_QC_GETSURFACE)
2548 VM_CL_getsurfacenearpoint, // #438 float(entity e, vector p) getsurfacenearpoint (DP_QC_GETSURFACE)
2549 VM_CL_getsurfaceclippedpoint, // #439 vector(entity e, float s, vector p) getsurfaceclippedpoint (DP_QC_GETSURFACE)
2551 VM_tokenize, // #441 float(string s) tokenize (KRIMZON_SV_PARSECLIENTCOMMAND)
2552 VM_argv, // #442 string(float n) argv (KRIMZON_SV_PARSECLIENTCOMMAND)
2553 VM_CL_setattachment, // #443 void(entity e, entity tagentity, string tagname) setattachment (DP_GFX_QUAKE3MODELTAGS)
2554 VM_search_begin, // #444 float(string pattern, float caseinsensitive, float quiet) search_begin (DP_FS_SEARCH)
2555 VM_search_end, // #445 void(float handle) search_end (DP_FS_SEARCH)
2556 VM_search_getsize, // #446 float(float handle) search_getsize (DP_FS_SEARCH)
2557 VM_search_getfilename, // #447 string(float handle, float num) search_getfilename (DP_FS_SEARCH)
2558 VM_cvar_string, // #448 string(string s) cvar_string (DP_QC_CVAR_STRING)
2559 VM_findflags, // #449 entity(entity start, .float fld, float match) findflags (DP_QC_FINDFLAGS)
2560 VM_findchainflags, // #450 entity(.float fld, float match) findchainflags (DP_QC_FINDCHAINFLAGS)
2561 VM_CL_gettagindex, // #451 float(entity ent, string tagname) gettagindex (DP_QC_GETTAGINFO)
2562 VM_CL_gettaginfo, // #452 vector(entity ent, float tagindex) gettaginfo (DP_QC_GETTAGINFO)
2570 VM_buf_create, // #460 float() buf_create (DP_QC_STRINGBUFFERS)
2571 VM_buf_del, // #461 void(float bufhandle) buf_del (DP_QC_STRINGBUFFERS)
2572 VM_buf_getsize, // #462 float(float bufhandle) buf_getsize (DP_QC_STRINGBUFFERS)
2573 VM_buf_copy, // #463 void(float bufhandle_from, float bufhandle_to) buf_copy (DP_QC_STRINGBUFFERS)
2574 VM_buf_sort, // #464 void(float bufhandle, float sortpower, float backward) buf_sort (DP_QC_STRINGBUFFERS)
2575 VM_buf_implode, // #465 string(float bufhandle, string glue) buf_implode (DP_QC_STRINGBUFFERS)
2576 VM_bufstr_get, // #466 string(float bufhandle, float string_index) bufstr_get (DP_QC_STRINGBUFFERS)
2577 VM_bufstr_set, // #467 void(float bufhandle, float string_index, string str) bufstr_set (DP_QC_STRINGBUFFERS)
2578 VM_bufstr_add, // #468 float(float bufhandle, string str, float order) bufstr_add (DP_QC_STRINGBUFFERS)
2579 VM_bufstr_free, // #469 void(float bufhandle, float string_index) bufstr_free (DP_QC_STRINGBUFFERS)
2581 VM_asin, // #471 float(float s) VM_asin (DP_QC_ASINACOSATANATAN2TAN)
2582 VM_acos, // #472 float(float c) VM_acos (DP_QC_ASINACOSATANATAN2TAN)
2583 VM_atan, // #473 float(float t) VM_atan (DP_QC_ASINACOSATANATAN2TAN)
2584 VM_atan2, // #474 float(float c, float s) VM_atan2 (DP_QC_ASINACOSATANATAN2TAN)
2585 VM_tan, // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
2586 VM_strlennocol, // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
2587 VM_strdecolorize, // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS)
2590 e10, e10 // #480-499 (LordHavoc)
2593 const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t);
2595 void VM_CL_Cmd_Init(void)
2599 void VM_CL_Cmd_Reset(void)