builtin.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619
  1. /* Copyright (C) 1996-1997 Id Software, Inc.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  13. See file, 'COPYING', for details.
  14. */
  15. #include "quakedef.h"
  16. #define RETURN_EDICT(e) (((int *)pr_globals)[OFS_RETURN] = EDICT_TO_PROG(e))
  17. /*
  18. ===============================================================================
  19. BUILT-IN FUNCTIONS
  20. ===============================================================================
  21. */
  22. char *PF_VarString (int first)
  23. {
  24. int i;
  25. static char out[256];
  26. out[0] = 0;
  27. for (i=first ; i<pr_argc ; i++)
  28. {
  29. strcat (out, G_STRING((OFS_PARM0+i*3)));
  30. }
  31. return out;
  32. }
  33. /*
  34. =================
  35. PF_errror
  36. This is a TERMINAL error, which will kill off the entire server.
  37. Dumps self.
  38. error(value)
  39. =================
  40. */
  41. void PF_error (void)
  42. {
  43. char *s;
  44. edict_t *ed;
  45. s = PF_VarString(0);
  46. Con_Printf ("======SERVER ERROR in %s:\n%s\n"
  47. ,pr_strings + pr_xfunction->s_name,s);
  48. ed = PROG_TO_EDICT(pr_global_struct->self);
  49. ED_Print (ed);
  50. Host_Error ("Program error");
  51. }
  52. /*
  53. =================
  54. PF_objerror
  55. Dumps out self, then an error message. The program is aborted and self is
  56. removed, but the level can continue.
  57. objerror(value)
  58. =================
  59. */
  60. void PF_objerror (void)
  61. {
  62. char *s;
  63. edict_t *ed;
  64. s = PF_VarString(0);
  65. Con_Printf ("======OBJECT ERROR in %s:\n%s\n"
  66. ,pr_strings + pr_xfunction->s_name,s);
  67. ed = PROG_TO_EDICT(pr_global_struct->self);
  68. ED_Print (ed);
  69. ED_Free (ed);
  70. Host_Error ("Program error");
  71. }
  72. /*
  73. ==============
  74. PF_makevectors
  75. Writes new values for v_forward, v_up, and v_right based on angles
  76. makevectors(vector)
  77. ==============
  78. */
  79. void PF_makevectors (void)
  80. {
  81. AngleVectors (G_VECTOR(OFS_PARM0), pr_global_struct->v_forward, pr_global_struct->v_right, pr_global_struct->v_up);
  82. }
  83. /*
  84. =================
  85. PF_setorigin
  86. This is the only valid way to move an object without using the physics of the world (setting velocity and waiting). Directly changing origin will not set internal links correctly, so clipping would be messed up. This should be called when an object is spawned, and then only if it is teleported.
  87. setorigin (entity, origin)
  88. =================
  89. */
  90. void PF_setorigin (void)
  91. {
  92. edict_t *e;
  93. float *org;
  94. e = G_EDICT(OFS_PARM0);
  95. org = G_VECTOR(OFS_PARM1);
  96. VectorCopy (org, e->v.origin);
  97. SV_LinkEdict (e, false);
  98. }
  99. void SetMinMaxSize (edict_t *e, float *min, float *max, qboolean rotate)
  100. {
  101. float *angles;
  102. vec3_t rmin, rmax;
  103. float bounds[2][3];
  104. float xvector[2], yvector[2];
  105. float a;
  106. vec3_t base, transformed;
  107. int i, j, k, l;
  108. for (i=0 ; i<3 ; i++)
  109. if (min[i] > max[i])
  110. PR_RunError ("backwards mins/maxs");
  111. rotate = false; // FIXME: implement rotation properly again
  112. if (!rotate)
  113. {
  114. VectorCopy (min, rmin);
  115. VectorCopy (max, rmax);
  116. }
  117. else
  118. {
  119. // find min / max for rotations
  120. angles = e->v.angles;
  121. a = angles[1]/180 * M_PI;
  122. xvector[0] = cos(a);
  123. xvector[1] = sin(a);
  124. yvector[0] = -sin(a);
  125. yvector[1] = cos(a);
  126. VectorCopy (min, bounds[0]);
  127. VectorCopy (max, bounds[1]);
  128. rmin[0] = rmin[1] = rmin[2] = 9999;
  129. rmax[0] = rmax[1] = rmax[2] = -9999;
  130. for (i=0 ; i<= 1 ; i++)
  131. {
  132. base[0] = bounds[i][0];
  133. for (j=0 ; j<= 1 ; j++)
  134. {
  135. base[1] = bounds[j][1];
  136. for (k=0 ; k<= 1 ; k++)
  137. {
  138. base[2] = bounds[k][2];
  139. // transform the point
  140. transformed[0] = xvector[0]*base[0] + yvector[0]*base[1];
  141. transformed[1] = xvector[1]*base[0] + yvector[1]*base[1];
  142. transformed[2] = base[2];
  143. for (l=0 ; l<3 ; l++)
  144. {
  145. if (transformed[l] < rmin[l])
  146. rmin[l] = transformed[l];
  147. if (transformed[l] > rmax[l])
  148. rmax[l] = transformed[l];
  149. }
  150. }
  151. }
  152. }
  153. }
  154. // set derived values
  155. VectorCopy (rmin, e->v.mins);
  156. VectorCopy (rmax, e->v.maxs);
  157. VectorSubtract (max, min, e->v.size);
  158. SV_LinkEdict (e, false);
  159. }
  160. /*
  161. =================
  162. PF_setsize
  163. the size box is rotated by the current angle
  164. setsize (entity, minvector, maxvector)
  165. =================
  166. */
  167. void PF_setsize (void)
  168. {
  169. edict_t *e;
  170. float *min, *max;
  171. e = G_EDICT(OFS_PARM0);
  172. min = G_VECTOR(OFS_PARM1);
  173. max = G_VECTOR(OFS_PARM2);
  174. SetMinMaxSize (e, min, max, false);
  175. }
  176. /*
  177. =================
  178. PF_setmodel
  179. setmodel(entity, model)
  180. =================
  181. */
  182. void PF_setmodel (void)
  183. {
  184. edict_t *e;
  185. char *m, **check;
  186. model_t *mod;
  187. int i;
  188. e = G_EDICT(OFS_PARM0);
  189. m = G_STRING(OFS_PARM1);
  190. // check to see if model was properly precached
  191. for (i=0, check = sv.model_precache ; *check ; i++, check++)
  192. if (!strcmp(*check, m))
  193. break;
  194. if (!*check)
  195. PR_RunError ("no precache: %s\n", m);
  196. e->v.model = m - pr_strings;
  197. e->v.modelindex = i; //SV_ModelIndex (m);
  198. mod = sv.models[ (int)e->v.modelindex]; // Mod_ForName (m, true);
  199. if (mod)
  200. SetMinMaxSize (e, mod->mins, mod->maxs, true);
  201. else
  202. SetMinMaxSize (e, vec3_origin, vec3_origin, true);
  203. }
  204. /*
  205. =================
  206. PF_bprint
  207. broadcast print to everyone on server
  208. bprint(value)
  209. =================
  210. */
  211. void PF_bprint (void)
  212. {
  213. char *s;
  214. s = PF_VarString(0);
  215. SV_BroadcastPrintf (s);
  216. }
  217. /*
  218. =================
  219. PF_sprint
  220. single print to a specific client
  221. sprint(clientent, value)
  222. =================
  223. */
  224. void PF_sprint (void)
  225. {
  226. char *s;
  227. client_t *client;
  228. int entnum;
  229. entnum = G_EDICTNUM(OFS_PARM0);
  230. s = PF_VarString(1);
  231. if (entnum < 1 || entnum > svs.maxclients)
  232. {
  233. Con_Printf ("tried to sprint to a non-client\n");
  234. return;
  235. }
  236. client = &svs.clients[entnum-1];
  237. MSG_WriteChar (&client->message,svc_print);
  238. MSG_WriteString (&client->message, s );
  239. }
  240. /*
  241. =================
  242. PF_centerprint
  243. single print to a specific client
  244. centerprint(clientent, value)
  245. =================
  246. */
  247. void PF_centerprint (void)
  248. {
  249. char *s;
  250. client_t *client;
  251. int entnum;
  252. entnum = G_EDICTNUM(OFS_PARM0);
  253. s = PF_VarString(1);
  254. if (entnum < 1 || entnum > svs.maxclients)
  255. {
  256. Con_Printf ("tried to sprint to a non-client\n");
  257. return;
  258. }
  259. client = &svs.clients[entnum-1];
  260. MSG_WriteChar (&client->message,svc_centerprint);
  261. MSG_WriteString (&client->message, s );
  262. }
  263. /*
  264. =================
  265. PF_normalize
  266. vector normalize(vector)
  267. =================
  268. */
  269. void PF_normalize (void)
  270. {
  271. float *value1;
  272. vec3_t newvalue;
  273. float new;
  274. value1 = G_VECTOR(OFS_PARM0);
  275. new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
  276. new = sqrt(new);
  277. if (new == 0)
  278. newvalue[0] = newvalue[1] = newvalue[2] = 0;
  279. else
  280. {
  281. new = 1/new;
  282. newvalue[0] = value1[0] * new;
  283. newvalue[1] = value1[1] * new;
  284. newvalue[2] = value1[2] * new;
  285. }
  286. VectorCopy (newvalue, G_VECTOR(OFS_RETURN));
  287. }
  288. /*
  289. =================
  290. PF_vlen
  291. scalar vlen(vector)
  292. =================
  293. */
  294. void PF_vlen (void)
  295. {
  296. float *value1;
  297. float new;
  298. value1 = G_VECTOR(OFS_PARM0);
  299. new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
  300. new = sqrt(new);
  301. G_FLOAT(OFS_RETURN) = new;
  302. }
  303. /*
  304. =================
  305. PF_vectoyaw
  306. float vectoyaw(vector)
  307. =================
  308. */
  309. void PF_vectoyaw (void)
  310. {
  311. float *value1;
  312. float yaw;
  313. value1 = G_VECTOR(OFS_PARM0);
  314. if (value1[1] == 0 && value1[0] == 0)
  315. yaw = 0;
  316. else
  317. {
  318. yaw = (int) (atan2(value1[1], value1[0]) * 180 / M_PI);
  319. if (yaw < 0)
  320. yaw += 360;
  321. }
  322. G_FLOAT(OFS_RETURN) = yaw;
  323. }
  324. /*
  325. =================
  326. PF_vectoangles
  327. vector vectoangles(vector)
  328. =================
  329. */
  330. void PF_vectoangles (void)
  331. {
  332. float *value1;
  333. float forward;
  334. float yaw, pitch;
  335. value1 = G_VECTOR(OFS_PARM0);
  336. if (value1[1] == 0 && value1[0] == 0)
  337. {
  338. yaw = 0;
  339. if (value1[2] > 0)
  340. pitch = 90;
  341. else
  342. pitch = 270;
  343. }
  344. else
  345. {
  346. yaw = (int) (atan2(value1[1], value1[0]) * 180 / M_PI);
  347. if (yaw < 0)
  348. yaw += 360;
  349. forward = sqrt (value1[0]*value1[0] + value1[1]*value1[1]);
  350. pitch = (int) (atan2(value1[2], forward) * 180 / M_PI);
  351. if (pitch < 0)
  352. pitch += 360;
  353. }
  354. G_FLOAT(OFS_RETURN+0) = pitch;
  355. G_FLOAT(OFS_RETURN+1) = yaw;
  356. G_FLOAT(OFS_RETURN+2) = 0;
  357. }
  358. /*
  359. =================
  360. PF_Random
  361. Returns a number from 0<= num < 1
  362. random()
  363. =================
  364. */
  365. void PF_random (void)
  366. {
  367. float num;
  368. num = (rand ()&0x7fff) / ((float)0x7fff);
  369. G_FLOAT(OFS_RETURN) = num;
  370. }
  371. /*
  372. =================
  373. PF_particle
  374. particle(origin, color, count)
  375. =================
  376. */
  377. void PF_particle (void)
  378. {
  379. float *org, *dir;
  380. float color;
  381. float count;
  382. org = G_VECTOR(OFS_PARM0);
  383. dir = G_VECTOR(OFS_PARM1);
  384. color = G_FLOAT(OFS_PARM2);
  385. count = G_FLOAT(OFS_PARM3);
  386. SV_StartParticle (org, dir, color, count);
  387. }
  388. /*
  389. =================
  390. PF_ambientsound
  391. =================
  392. */
  393. void PF_ambientsound (void)
  394. {
  395. char **check;
  396. char *samp;
  397. float *pos;
  398. float vol, attenuation;
  399. int i, soundnum;
  400. pos = G_VECTOR (OFS_PARM0);
  401. samp = G_STRING(OFS_PARM1);
  402. vol = G_FLOAT(OFS_PARM2);
  403. attenuation = G_FLOAT(OFS_PARM3);
  404. // check to see if samp was properly precached
  405. for (soundnum=0, check = sv.sound_precache ; *check ; check++, soundnum++)
  406. if (!strcmp(*check,samp))
  407. break;
  408. if (!*check)
  409. {
  410. Con_Printf ("no precache: %s\n", samp);
  411. return;
  412. }
  413. // add an svc_spawnambient command to the level signon packet
  414. MSG_WriteByte (&sv.signon,svc_spawnstaticsound);
  415. for (i=0 ; i<3 ; i++)
  416. MSG_WriteCoord(&sv.signon, pos[i]);
  417. MSG_WriteByte (&sv.signon, soundnum);
  418. MSG_WriteByte (&sv.signon, vol*255);
  419. MSG_WriteByte (&sv.signon, attenuation*64);
  420. }
  421. /*
  422. =================
  423. PF_sound
  424. Each entity can have eight independant sound sources, like voice,
  425. weapon, feet, etc.
  426. Channel 0 is an auto-allocate channel, the others override anything
  427. allready running on that entity/channel pair.
  428. An attenuation of 0 will play full volume everywhere in the level.
  429. Larger attenuations will drop off.
  430. =================
  431. */
  432. void PF_sound (void)
  433. {
  434. char *sample;
  435. int channel;
  436. edict_t *entity;
  437. int volume;
  438. float attenuation;
  439. entity = G_EDICT(OFS_PARM0);
  440. channel = G_FLOAT(OFS_PARM1);
  441. sample = G_STRING(OFS_PARM2);
  442. volume = G_FLOAT(OFS_PARM3) * 255;
  443. attenuation = G_FLOAT(OFS_PARM4);
  444. if (volume < 0 || volume > 255)
  445. Sys_Error ("SV_StartSound: volume = %i", volume);
  446. if (attenuation < 0 || attenuation > 4)
  447. Sys_Error ("SV_StartSound: attenuation = %f", attenuation);
  448. if (channel < 0 || channel > 7)
  449. Sys_Error ("SV_StartSound: channel = %i", channel);
  450. SV_StartSound (entity, channel, sample, volume, attenuation);
  451. }
  452. /*
  453. =================
  454. PF_break
  455. break()
  456. =================
  457. */
  458. void PF_break (void)
  459. {
  460. Con_Printf ("break statement\n");
  461. *(int *)-4 = 0; // dump to debugger
  462. // PR_RunError ("break statement");
  463. }
  464. /*
  465. =================
  466. PF_traceline
  467. Used for use tracing and shot targeting
  468. Traces are blocked by bbox and exact bsp entityes, and also slide box entities
  469. if the tryents flag is set.
  470. traceline (vector1, vector2, tryents)
  471. =================
  472. */
  473. void PF_traceline (void)
  474. {
  475. float *v1, *v2;
  476. trace_t trace;
  477. int nomonsters;
  478. edict_t *ent;
  479. v1 = G_VECTOR(OFS_PARM0);
  480. v2 = G_VECTOR(OFS_PARM1);
  481. nomonsters = G_FLOAT(OFS_PARM2);
  482. ent = G_EDICT(OFS_PARM3);
  483. trace = SV_Move (v1, vec3_origin, vec3_origin, v2, nomonsters, ent);
  484. pr_global_struct->trace_allsolid = trace.allsolid;
  485. pr_global_struct->trace_startsolid = trace.startsolid;
  486. pr_global_struct->trace_fraction = trace.fraction;
  487. pr_global_struct->trace_inwater = trace.inwater;
  488. pr_global_struct->trace_inopen = trace.inopen;
  489. VectorCopy (trace.endpos, pr_global_struct->trace_endpos);
  490. VectorCopy (trace.plane.normal, pr_global_struct->trace_plane_normal);
  491. pr_global_struct->trace_plane_dist = trace.plane.dist;
  492. if (trace.ent)
  493. pr_global_struct->trace_ent = EDICT_TO_PROG(trace.ent);
  494. else
  495. pr_global_struct->trace_ent = EDICT_TO_PROG(sv.edicts);
  496. }
  497. /*
  498. =================
  499. PF_checkpos
  500. Returns true if the given entity can move to the given position from it's
  501. current position by walking or rolling.
  502. FIXME: make work...
  503. scalar checkpos (entity, vector)
  504. =================
  505. */
  506. void PF_checkpos (void)
  507. {
  508. }
  509. //============================================================================
  510. byte checkpvs[MAX_MAP_LEAFS/8];
  511. int PF_newcheckclient (int check)
  512. {
  513. int i;
  514. byte *pvs;
  515. edict_t *ent;
  516. mleaf_t *leaf;
  517. vec3_t org;
  518. // cycle to the next one
  519. if (check < 1)
  520. check = 1;
  521. if (check > svs.maxclients)
  522. check = svs.maxclients;
  523. if (check == svs.maxclients)
  524. i = 1;
  525. else
  526. i = check + 1;
  527. for ( ; ; i++)
  528. {
  529. if (i == svs.maxclients+1)
  530. i = 1;
  531. ent = EDICT_NUM(i);
  532. if (i == check)
  533. break; // didn't find anything else
  534. if (ent->free)
  535. continue;
  536. if (ent->v.health <= 0)
  537. continue;
  538. if ((int)ent->v.flags & FL_NOTARGET)
  539. continue;
  540. // anything that is a client, or has a client as an enemy
  541. break;
  542. }
  543. // get the PVS for the entity
  544. VectorAdd (ent->v.origin, ent->v.view_ofs, org);
  545. leaf = Mod_PointInLeaf (org, sv.worldmodel);
  546. pvs = Mod_LeafPVS (leaf, sv.worldmodel);
  547. memcpy (checkpvs, pvs, (sv.worldmodel->numleafs+7)>>3 );
  548. return i;
  549. }
  550. /*
  551. =================
  552. PF_checkclient
  553. Returns a client (or object that has a client enemy) that would be a
  554. valid target.
  555. If there are more than one valid options, they are cycled each frame
  556. If (self.origin + self.viewofs) is not in the PVS of the current target,
  557. it is not returned at all.
  558. name checkclient ()
  559. =================
  560. */
  561. #define MAX_CHECK 16
  562. int c_invis, c_notvis;
  563. void PF_checkclient (void)
  564. {
  565. edict_t *ent, *self;
  566. mleaf_t *leaf;
  567. int l;
  568. vec3_t view;
  569. // find a new check if on a new frame
  570. if (sv.time - sv.lastchecktime >= 0.1)
  571. {
  572. sv.lastcheck = PF_newcheckclient (sv.lastcheck);
  573. sv.lastchecktime = sv.time;
  574. }
  575. // return check if it might be visible
  576. ent = EDICT_NUM(sv.lastcheck);
  577. if (ent->free || ent->v.health <= 0)
  578. {
  579. RETURN_EDICT(sv.edicts);
  580. return;
  581. }
  582. // if current entity can't possibly see the check entity, return 0
  583. self = PROG_TO_EDICT(pr_global_struct->self);
  584. VectorAdd (self->v.origin, self->v.view_ofs, view);
  585. leaf = Mod_PointInLeaf (view, sv.worldmodel);
  586. l = (leaf - sv.worldmodel->leafs) - 1;
  587. if ( (l<0) || !(checkpvs[l>>3] & (1<<(l&7)) ) )
  588. {
  589. c_notvis++;
  590. RETURN_EDICT(sv.edicts);
  591. return;
  592. }
  593. // might be able to see it
  594. c_invis++;
  595. RETURN_EDICT(ent);
  596. }
  597. //============================================================================
  598. /*
  599. =================
  600. PF_stuffcmd
  601. Sends text over to the client's execution buffer
  602. stuffcmd (clientent, value)
  603. =================
  604. */
  605. void PF_stuffcmd (void)
  606. {
  607. int entnum;
  608. char *str;
  609. client_t *old;
  610. entnum = G_EDICTNUM(OFS_PARM0);
  611. if (entnum < 1 || entnum > svs.maxclients)
  612. PR_RunError ("Parm 0 not a client");
  613. str = G_STRING(OFS_PARM1);
  614. old = host_client;
  615. host_client = &svs.clients[entnum-1];
  616. Host_ClientCommands ("%s", str);
  617. host_client = old;
  618. }
  619. /*
  620. =================
  621. PF_localcmd
  622. Sends text over to the client's execution buffer
  623. localcmd (string)
  624. =================
  625. */
  626. void PF_localcmd (void)
  627. {
  628. char *str;
  629. str = G_STRING(OFS_PARM0);
  630. Cbuf_AddText (str);
  631. }
  632. /*
  633. =================
  634. PF_cvar
  635. float cvar (string)
  636. =================
  637. */
  638. void PF_cvar (void)
  639. {
  640. char *str;
  641. str = G_STRING(OFS_PARM0);
  642. G_FLOAT(OFS_RETURN) = Cvar_VariableValue (str);
  643. }
  644. /*
  645. =================
  646. PF_cvar_set
  647. float cvar (string)
  648. =================
  649. */
  650. void PF_cvar_set (void)
  651. {
  652. char *var, *val;
  653. var = G_STRING(OFS_PARM0);
  654. val = G_STRING(OFS_PARM1);
  655. Cvar_Set (var, val);
  656. }
  657. /*
  658. =================
  659. PF_findradius
  660. Returns a chain of entities that have origins within a spherical area
  661. findradius (origin, radius)
  662. =================
  663. */
  664. void PF_findradius (void)
  665. {
  666. edict_t *ent, *chain;
  667. float rad;
  668. float *org;
  669. vec3_t eorg;
  670. int i, j;
  671. chain = (edict_t *)sv.edicts;
  672. org = G_VECTOR(OFS_PARM0);
  673. rad = G_FLOAT(OFS_PARM1);
  674. ent = NEXT_EDICT(sv.edicts);
  675. for (i=1 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent))
  676. {
  677. if (ent->free)
  678. continue;
  679. if (ent->v.solid == SOLID_NOT)
  680. continue;
  681. for (j=0 ; j<3 ; j++)
  682. eorg[j] = org[j] - (ent->v.origin[j] + (ent->v.mins[j] + ent->v.maxs[j])*0.5);
  683. if (Length(eorg) > rad)
  684. continue;
  685. ent->v.chain = EDICT_TO_PROG(chain);
  686. chain = ent;
  687. }
  688. RETURN_EDICT(chain);
  689. }
  690. /*
  691. =========
  692. PF_dprint
  693. =========
  694. */
  695. void PF_dprint (void)
  696. {
  697. Con_Printf ("%s",PF_VarString(0));
  698. }
  699. char pr_string_temp[128];
  700. void PF_ftos (void)
  701. {
  702. float v;
  703. v = G_FLOAT(OFS_PARM0);
  704. if (v == (int)v)
  705. sprintf (pr_string_temp, "%d",(int)v);
  706. else
  707. sprintf (pr_string_temp, "%5.1f",v);
  708. G_INT(OFS_RETURN) = pr_string_temp - pr_strings;
  709. }
  710. void PF_fabs (void)
  711. {
  712. float v;
  713. v = G_FLOAT(OFS_PARM0);
  714. G_FLOAT(OFS_RETURN) = fabs(v);
  715. }
  716. void PF_vtos (void)
  717. {
  718. sprintf (pr_string_temp, "'%5.1f %5.1f %5.1f'", G_VECTOR(OFS_PARM0)[0], G_VECTOR(OFS_PARM0)[1], G_VECTOR(OFS_PARM0)[2]);
  719. G_INT(OFS_RETURN) = pr_string_temp - pr_strings;
  720. }
  721. void PF_Spawn (void)
  722. {
  723. edict_t *ed;
  724. ed = ED_Alloc();
  725. RETURN_EDICT(ed);
  726. }
  727. void PF_Remove (void)
  728. {
  729. edict_t *ed;
  730. ed = G_EDICT(OFS_PARM0);
  731. ED_Free (ed);
  732. }
  733. // entity (entity start, .string field, string match) find = #5;
  734. void PF_Find (void)
  735. {
  736. int e;
  737. int f;
  738. char *s, *t;
  739. edict_t *ed;
  740. e = G_EDICTNUM(OFS_PARM0);
  741. f = G_INT(OFS_PARM1);
  742. s = G_STRING(OFS_PARM2);
  743. if (!s)
  744. PR_RunError ("PF_Find: bad search string");
  745. for (e++ ; e < sv.num_edicts ; e++)
  746. {
  747. ed = EDICT_NUM(e);
  748. if (ed->free)
  749. continue;
  750. t = E_STRING(ed,f);
  751. if (!t)
  752. continue;
  753. if (!strcmp(t,s))
  754. {
  755. RETURN_EDICT(ed);
  756. return;
  757. }
  758. }
  759. RETURN_EDICT(sv.edicts);
  760. }
  761. void PR_CheckEmptyString (char *s)
  762. {
  763. if (s[0] <= ' ')
  764. PR_RunError ("Bad string");
  765. }
  766. void PF_precache_file (void)
  767. { // precache_file is only used to copy files with qcc, it does nothing
  768. G_INT(OFS_RETURN) = G_INT(OFS_PARM0);
  769. }
  770. void PF_precache_sound (void)
  771. {
  772. char *s;
  773. int i;
  774. if (sv.state != ss_loading)
  775. PR_RunError ("PF_Precache_*: Precache can only be done in spawn functions");
  776. s = G_STRING(OFS_PARM0);
  777. G_INT(OFS_RETURN) = G_INT(OFS_PARM0);
  778. PR_CheckEmptyString (s);
  779. for (i=0 ; i<MAX_SOUNDS ; i++)
  780. {
  781. if (!sv.sound_precache[i])
  782. {
  783. sv.sound_precache[i] = s;
  784. return;
  785. }
  786. if (!strcmp(sv.sound_precache[i], s))
  787. return;
  788. }
  789. PR_RunError ("PF_precache_sound: overflow");
  790. }
  791. void PF_precache_model (void)
  792. {
  793. char *s;
  794. int i;
  795. if (sv.state != ss_loading)
  796. PR_RunError ("PF_Precache_*: Precache can only be done in spawn functions");
  797. s = G_STRING(OFS_PARM0);
  798. G_INT(OFS_RETURN) = G_INT(OFS_PARM0);
  799. PR_CheckEmptyString (s);
  800. for (i=0 ; i<MAX_MODELS ; i++)
  801. {
  802. if (!sv.model_precache[i])
  803. {
  804. sv.model_precache[i] = s;
  805. sv.models[i] = Mod_ForName (s, true);
  806. return;
  807. }
  808. if (!strcmp(sv.model_precache[i], s))
  809. return;
  810. }
  811. PR_RunError ("PF_precache_model: overflow");
  812. }
  813. void PF_coredump (void)
  814. {
  815. ED_PrintEdicts ();
  816. }
  817. void PF_traceon (void)
  818. {
  819. pr_trace = true;
  820. }
  821. void PF_traceoff (void)
  822. {
  823. pr_trace = false;
  824. }
  825. void PF_eprint (void)
  826. {
  827. ED_PrintNum (G_EDICTNUM(OFS_PARM0));
  828. }
  829. /*
  830. ===============
  831. PF_walkmove
  832. float(float yaw, float dist) walkmove
  833. ===============
  834. */
  835. void PF_walkmove (void)
  836. {
  837. edict_t *ent;
  838. float yaw, dist;
  839. vec3_t move;
  840. dfunction_t *oldf;
  841. int oldself;
  842. ent = PROG_TO_EDICT(pr_global_struct->self);
  843. yaw = G_FLOAT(OFS_PARM0);
  844. dist = G_FLOAT(OFS_PARM1);
  845. if ( !( (int)ent->v.flags & (FL_ONGROUND|FL_FLY|FL_SWIM) ) )
  846. {
  847. G_FLOAT(OFS_RETURN) = 0;
  848. return;
  849. }
  850. yaw = yaw*M_PI*2 / 360;
  851. move[0] = cos(yaw)*dist;
  852. move[1] = sin(yaw)*dist;
  853. move[2] = 0;
  854. // save program state, because SV_movestep may call other progs
  855. oldf = pr_xfunction;
  856. oldself = pr_global_struct->self;
  857. G_FLOAT(OFS_RETURN) = SV_movestep(ent, move, true);
  858. // restore program state
  859. pr_xfunction = oldf;
  860. pr_global_struct->self = oldself;
  861. }
  862. /*
  863. ===============
  864. PF_droptofloor
  865. void() droptofloor
  866. ===============
  867. */
  868. void PF_droptofloor (void)
  869. {
  870. edict_t *ent;
  871. vec3_t end;
  872. trace_t trace;
  873. ent = PROG_TO_EDICT(pr_global_struct->self);
  874. VectorCopy (ent->v.origin, end);
  875. end[2] -= 256;
  876. trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, end, false, ent);
  877. if (trace.fraction == 1 || trace.allsolid)
  878. G_FLOAT(OFS_RETURN) = 0;
  879. else
  880. {
  881. VectorCopy (trace.endpos, ent->v.origin);
  882. SV_LinkEdict (ent, false);
  883. ent->v.flags = (int)ent->v.flags | FL_ONGROUND;
  884. ent->v.groundentity = EDICT_TO_PROG(trace.ent);
  885. G_FLOAT(OFS_RETURN) = 1;
  886. }
  887. }
  888. /*
  889. ===============
  890. PF_lightstyle
  891. void(float style, string value) lightstyle
  892. ===============
  893. */
  894. void PF_lightstyle (void)
  895. {
  896. int style;
  897. char *val;
  898. client_t *client;
  899. int j;
  900. style = G_FLOAT(OFS_PARM0);
  901. val = G_STRING(OFS_PARM1);
  902. // change the string in sv
  903. sv.lightstyles[style] = val;
  904. // send message to all clients on this server
  905. if (sv.state != ss_active)
  906. return;
  907. for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
  908. if (client->active || client->spawned)
  909. {
  910. MSG_WriteChar (&client->message, svc_lightstyle);
  911. MSG_WriteChar (&client->message,style);
  912. MSG_WriteString (&client->message, val);
  913. }
  914. }
  915. void PF_rint (void)
  916. {
  917. float f;
  918. f = G_FLOAT(OFS_PARM0);
  919. if (f > 0)
  920. G_FLOAT(OFS_RETURN) = (int)(f + 0.5);
  921. else
  922. G_FLOAT(OFS_RETURN) = (int)(f - 0.5);
  923. }
  924. void PF_floor (void)
  925. {
  926. G_FLOAT(OFS_RETURN) = floor(G_FLOAT(OFS_PARM0));
  927. }
  928. void PF_ceil (void)
  929. {
  930. G_FLOAT(OFS_RETURN) = ceil(G_FLOAT(OFS_PARM0));
  931. }
  932. /*
  933. =============
  934. PF_checkbottom
  935. =============
  936. */
  937. void PF_checkbottom (void)
  938. {
  939. edict_t *ent;
  940. ent = G_EDICT(OFS_PARM0);
  941. G_FLOAT(OFS_RETURN) = SV_CheckBottom (ent);
  942. }
  943. /*
  944. =============
  945. PF_pointcontents
  946. =============
  947. */
  948. void PF_pointcontents (void)
  949. {
  950. float *v;
  951. v = G_VECTOR(OFS_PARM0);
  952. G_FLOAT(OFS_RETURN) = SV_PointContents (v);
  953. }
  954. /*
  955. =============
  956. PF_nextent
  957. entity nextent(entity)
  958. =============
  959. */
  960. void PF_nextent (void)
  961. {
  962. int i;
  963. edict_t *ent;
  964. i = G_EDICTNUM(OFS_PARM0);
  965. while (1)
  966. {
  967. i++;
  968. if (i == sv.num_edicts)
  969. {
  970. RETURN_EDICT(sv.edicts);
  971. return;
  972. }
  973. ent = EDICT_NUM(i);
  974. if (!ent->free)
  975. {
  976. RETURN_EDICT(ent);
  977. return;
  978. }
  979. }
  980. }
  981. /*
  982. =============
  983. PF_aim
  984. Pick a vector for the player to shoot along
  985. vector aim(entity, missilespeed)
  986. =============
  987. */
  988. cvar_t sv_aim = {"sv_aim", "0.93"};
  989. void PF_aim (void)
  990. {
  991. edict_t *ent, *check, *bestent;
  992. vec3_t start, dir, end, bestdir;
  993. int i, j;
  994. trace_t tr;
  995. float dist, bestdist;
  996. float speed;
  997. ent = G_EDICT(OFS_PARM0);
  998. speed = G_FLOAT(OFS_PARM1);
  999. VectorCopy (ent->v.origin, start);
  1000. start[2] += 20;
  1001. // try sending a trace straight
  1002. VectorCopy (pr_global_struct->v_forward, dir);
  1003. VectorMA (start, 2048, dir, end);
  1004. tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent);
  1005. if (tr.ent && tr.ent->v.takedamage == DAMAGE_AIM
  1006. && (!teamplay.value || ent->v.team <=0 || ent->v.team != tr.ent->v.team) )
  1007. {
  1008. VectorCopy (pr_global_struct->v_forward, G_VECTOR(OFS_RETURN));
  1009. return;
  1010. }
  1011. // try all possible entities
  1012. VectorCopy (dir, bestdir);
  1013. bestdist = sv_aim.value;
  1014. bestent = NULL;
  1015. check = NEXT_EDICT(sv.edicts);
  1016. for (i=1 ; i<sv.num_edicts ; i++, check = NEXT_EDICT(check) )
  1017. {
  1018. if (check->v.takedamage != DAMAGE_AIM)
  1019. continue;
  1020. if (check == ent)
  1021. continue;
  1022. if (teamplay.value && ent->v.team > 0 && ent->v.team == check->v.team)
  1023. continue; // don't aim at teammate
  1024. for (j=0 ; j<3 ; j++)
  1025. end[j] = check->v.origin[j]
  1026. + 0.5*(check->v.mins[j] + check->v.maxs[j]);
  1027. VectorSubtract (end, start, dir);
  1028. VectorNormalize (dir);
  1029. dist = DotProduct (dir, pr_global_struct->v_forward);
  1030. if (dist < bestdist)
  1031. continue; // to far to turn
  1032. tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent);
  1033. if (tr.ent == check)
  1034. { // can shoot at this one
  1035. bestdist = dist;
  1036. bestent = check;
  1037. }
  1038. }
  1039. if (bestent)
  1040. {
  1041. VectorSubtract (bestent->v.origin, ent->v.origin, dir);
  1042. dist = DotProduct (dir, pr_global_struct->v_forward);
  1043. VectorScale (pr_global_struct->v_forward, dist, end);
  1044. end[2] = dir[2];
  1045. VectorNormalize (end);
  1046. VectorCopy (end, G_VECTOR(OFS_RETURN));
  1047. }
  1048. else
  1049. {
  1050. VectorCopy (bestdir, G_VECTOR(OFS_RETURN));
  1051. }
  1052. }
  1053. /*
  1054. ==============
  1055. PF_changeyaw
  1056. This was a major timewaster in progs, so it was converted to C
  1057. ==============
  1058. */
  1059. void PF_changeyaw (void)
  1060. {
  1061. edict_t *ent;
  1062. float ideal, current, move, speed;
  1063. ent = PROG_TO_EDICT(pr_global_struct->self);
  1064. current = anglemod( ent->v.angles[1] );
  1065. ideal = ent->v.ideal_yaw;
  1066. speed = ent->v.yaw_speed;
  1067. if (current == ideal)
  1068. return;
  1069. move = ideal - current;
  1070. if (ideal > current)
  1071. {
  1072. if (move >= 180)
  1073. move = move - 360;
  1074. }
  1075. else
  1076. {
  1077. if (move <= -180)
  1078. move = move + 360;
  1079. }
  1080. if (move > 0)
  1081. {
  1082. if (move > speed)
  1083. move = speed;
  1084. }
  1085. else
  1086. {
  1087. if (move < -speed)
  1088. move = -speed;
  1089. }
  1090. ent->v.angles[1] = anglemod (current + move);
  1091. }
  1092. /*
  1093. ===============================================================================
  1094. MESSAGE WRITING
  1095. ===============================================================================
  1096. */
  1097. #define MSG_BROADCAST 0 // unreliable to all
  1098. #define MSG_ONE 1 // reliable to one (msg_entity)
  1099. #define MSG_ALL 2 // reliable to all
  1100. #define MSG_INIT 3 // write to the init string
  1101. sizebuf_t *WriteDest (void)
  1102. {
  1103. int entnum;
  1104. int dest;
  1105. edict_t *ent;
  1106. dest = G_FLOAT(OFS_PARM0);
  1107. switch (dest)
  1108. {
  1109. case MSG_BROADCAST:
  1110. return &sv.datagram;
  1111. case MSG_ONE:
  1112. ent = PROG_TO_EDICT(pr_global_struct->msg_entity);
  1113. entnum = NUM_FOR_EDICT(ent);
  1114. if (entnum < 1 || entnum > svs.maxclients)
  1115. PR_RunError ("WriteDest: not a client");
  1116. return &svs.clients[entnum-1].message;
  1117. case MSG_ALL:
  1118. return &sv.reliable_datagram;
  1119. case MSG_INIT:
  1120. return &sv.signon;
  1121. default:
  1122. PR_RunError ("WriteDest: bad destination");
  1123. break;
  1124. }
  1125. return NULL;
  1126. }
  1127. void PF_WriteByte (void)
  1128. {
  1129. MSG_WriteByte (WriteDest(), G_FLOAT(OFS_PARM1));
  1130. }
  1131. void PF_WriteChar (void)
  1132. {
  1133. MSG_WriteChar (WriteDest(), G_FLOAT(OFS_PARM1));
  1134. }
  1135. void PF_WriteShort (void)
  1136. {
  1137. MSG_WriteShort (WriteDest(), G_FLOAT(OFS_PARM1));
  1138. }
  1139. void PF_WriteLong (void)
  1140. {
  1141. MSG_WriteLong (WriteDest(), G_FLOAT(OFS_PARM1));
  1142. }
  1143. void PF_WriteAngle (void)
  1144. {
  1145. MSG_WriteAngle (WriteDest(), G_FLOAT(OFS_PARM1));
  1146. }
  1147. void PF_WriteCoord (void)
  1148. {
  1149. MSG_WriteCoord (WriteDest(), G_FLOAT(OFS_PARM1));
  1150. }
  1151. void PF_WriteString (void)
  1152. {
  1153. MSG_WriteString (WriteDest(), G_STRING(OFS_PARM1));
  1154. }
  1155. void PF_WriteEntity (void)
  1156. {
  1157. MSG_WriteShort (WriteDest(), G_EDICTNUM(OFS_PARM1));
  1158. }
  1159. //=============================================================================
  1160. int SV_ModelIndex (char *name);
  1161. void PF_makestatic (void)
  1162. {
  1163. edict_t *ent;
  1164. int i;
  1165. ent = G_EDICT(OFS_PARM0);
  1166. MSG_WriteByte (&sv.signon,svc_spawnstatic);
  1167. MSG_WriteByte (&sv.signon, SV_ModelIndex(pr_strings + ent->v.model));
  1168. MSG_WriteByte (&sv.signon, ent->v.frame);
  1169. MSG_WriteByte (&sv.signon, ent->v.colormap);
  1170. MSG_WriteByte (&sv.signon, ent->v.skin);
  1171. for (i=0 ; i<3 ; i++)
  1172. {
  1173. MSG_WriteCoord(&sv.signon, ent->v.origin[i]);
  1174. MSG_WriteAngle(&sv.signon, ent->v.angles[i]);
  1175. }
  1176. // throw the entity away now
  1177. ED_Free (ent);
  1178. }
  1179. //=============================================================================
  1180. /*
  1181. ==============
  1182. PF_setspawnparms
  1183. ==============
  1184. */
  1185. void PF_setspawnparms (void)
  1186. {
  1187. edict_t *ent;
  1188. int i;
  1189. client_t *client;
  1190. ent = G_EDICT(OFS_PARM0);
  1191. i = NUM_FOR_EDICT(ent);
  1192. if (i < 1 || i > svs.maxclients)
  1193. PR_RunError ("Entity is not a client");
  1194. // copy spawn parms out of the client_t
  1195. client = svs.clients + (i-1);
  1196. for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
  1197. (&pr_global_struct->parm1)[i] = client->spawn_parms[i];
  1198. }
  1199. /*
  1200. ==============
  1201. PF_changelevel
  1202. ==============
  1203. */
  1204. void PF_changelevel (void)
  1205. {
  1206. char *s;
  1207. // make sure we don't issue two changelevels
  1208. if (svs.changelevel_issued)
  1209. return;
  1210. svs.changelevel_issued = true;
  1211. s = G_STRING(OFS_PARM0);
  1212. Cbuf_AddText (va("changelevel %s\n",s));
  1213. }
  1214. void PF_Fixme (void)
  1215. {
  1216. PR_RunError ("unimplemented bulitin");
  1217. }
  1218. builtin_t pr_builtin[] =
  1219. {
  1220. PF_Fixme,
  1221. PF_makevectors, // void(entity e) makevectors = #1;
  1222. PF_setorigin, // void(entity e, vector o) setorigin = #2;
  1223. PF_setmodel, // void(entity e, string m) setmodel = #3;
  1224. PF_setsize, // void(entity e, vector min, vector max) setsize = #4;
  1225. PF_Fixme, // void(entity e, vector min, vector max) setabssize = #5;
  1226. PF_break, // void() break = #6;
  1227. PF_random, // float() random = #7;
  1228. PF_sound, // void(entity e, float chan, string samp) sound = #8;
  1229. PF_normalize, // vector(vector v) normalize = #9;
  1230. PF_error, // void(string e) error = #10;
  1231. PF_objerror, // void(string e) objerror = #11;
  1232. PF_vlen, // float(vector v) vlen = #12;
  1233. PF_vectoyaw, // float(vector v) vectoyaw = #13;
  1234. PF_Spawn, // entity() spawn = #14;
  1235. PF_Remove, // void(entity e) remove = #15;
  1236. PF_traceline, // float(vector v1, vector v2, float tryents) traceline = #16;
  1237. PF_checkclient, // entity() clientlist = #17;
  1238. PF_Find, // entity(entity start, .string fld, string match) find = #18;
  1239. PF_precache_sound, // void(string s) precache_sound = #19;
  1240. PF_precache_model, // void(string s) precache_model = #20;
  1241. PF_stuffcmd, // void(entity client, string s)stuffcmd = #21;
  1242. PF_findradius, // entity(vector org, float rad) findradius = #22;
  1243. PF_bprint, // void(string s) bprint = #23;
  1244. PF_sprint, // void(entity client, string s) sprint = #24;
  1245. PF_dprint, // void(string s) dprint = #25;
  1246. PF_ftos, // void(string s) ftos = #26;
  1247. PF_vtos, // void(string s) vtos = #27;
  1248. PF_coredump,
  1249. PF_traceon,
  1250. PF_traceoff,
  1251. PF_eprint, // void(entity e) debug print an entire entity
  1252. PF_walkmove, // float(float yaw, float dist) walkmove
  1253. PF_Fixme, // float(float yaw, float dist) walkmove
  1254. PF_droptofloor,
  1255. PF_lightstyle,
  1256. PF_rint,
  1257. PF_floor,
  1258. PF_ceil,
  1259. PF_Fixme,
  1260. PF_checkbottom,
  1261. PF_pointcontents,
  1262. PF_Fixme,
  1263. PF_fabs,
  1264. PF_aim,
  1265. PF_cvar,
  1266. PF_localcmd,
  1267. PF_nextent,
  1268. PF_particle,
  1269. PF_changeyaw,
  1270. PF_Fixme,
  1271. PF_vectoangles,
  1272. PF_WriteByte,
  1273. PF_WriteChar,
  1274. PF_WriteShort,
  1275. PF_WriteLong,
  1276. PF_WriteCoord,
  1277. PF_WriteAngle,
  1278. PF_WriteString,
  1279. PF_WriteEntity,
  1280. PF_Fixme,
  1281. PF_Fixme,
  1282. PF_Fixme,
  1283. PF_Fixme,
  1284. PF_Fixme,
  1285. PF_Fixme,
  1286. PF_Fixme,
  1287. SV_MoveToGoal,
  1288. PF_precache_file,
  1289. PF_makestatic,
  1290. PF_changelevel,
  1291. PF_Fixme,
  1292. PF_cvar_set,
  1293. PF_centerprint,
  1294. PF_ambientsound,
  1295. PF_precache_model,
  1296. PF_precache_sound, // precache_sound2 is different only for qcc
  1297. PF_precache_file,
  1298. PF_setspawnparms
  1299. };
  1300. builtin_t *pr_builtins = pr_builtin;
  1301. int pr_numbuiltins = sizeof(pr_builtin)/sizeof(pr_builtin[0]);