]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/miscfunctions.qc
- New game mode: Key Hunt
[divverent/nexuiz.git] / data / qcsrc / server / miscfunctions.qc
1 void() info_player_deathmatch; // needed for the other spawnpoints
2 string ColoredTeamName(float t);
3
4 float DistributeEvenly_amount;
5 float DistributeEvenly_totalweight;
6 void DistributeEvenly_Init(float amount, float totalweight)
7 {
8         if(DistributeEvenly_amount)
9         {
10                 dprint("DistributeEvenly_Init: UNFINISHED DISTRIBUTION (", ftos(DistributeEvenly_amount), " for ");
11                 dprint(ftos(DistributeEvenly_totalweight), "left!\n");
12         }
13         DistributeEvenly_amount = amount;
14         DistributeEvenly_totalweight = totalweight;
15 }
16 float DistributeEvenly_Get(float weight)
17 {
18         float f;
19         if(weight <= 0)
20                 return 0;
21         f = floor(0.5 + DistributeEvenly_amount * weight / DistributeEvenly_totalweight);
22         DistributeEvenly_totalweight -= weight;
23         DistributeEvenly_amount -= f;
24         return f;
25 }
26
27 void move_out_of_solid_expand(entity e, vector by)
28 {
29         float eps = 0.0625;
30         tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
31         if(trace_startsolid)
32                 return;
33         if(trace_fraction < 1)
34         {
35                 // hit something
36                 // adjust origin in the other direction...
37                 e.origin = e.origin - by * (1 - trace_fraction);
38         }
39 }
40
41 void move_out_of_solid(entity e)
42 {
43         vector o, m0, m1;
44
45         o = e.origin;
46         traceline(o, o, MOVE_WORLDONLY, e);
47         if(trace_startsolid)
48         {
49                 dprint("origin is in solid too! (", vtos(o), ")");
50                 return;
51         }
52
53         tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
54         if(!trace_startsolid)
55                 return;
56
57         m0 = e.mins;
58         m1 = e.maxs;
59         e.mins = '0 0 0';
60         e.maxs = '0 0 0';
61         move_out_of_solid_expand(e, '1 0 0' * m0_x); e.mins_x = m0_x;
62         move_out_of_solid_expand(e, '1 0 0' * m1_x); e.maxs_x = m1_x;
63         move_out_of_solid_expand(e, '0 1 0' * m0_y); e.mins_y = m0_y;
64         move_out_of_solid_expand(e, '0 1 0' * m1_y); e.maxs_y = m1_y;
65         move_out_of_solid_expand(e, '0 0 1' * m0_z); e.mins_z = m0_z;
66         move_out_of_solid_expand(e, '0 0 1' * m1_z); e.maxs_z = m1_z;
67         setorigin(e, e.origin);
68
69         tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
70         if(trace_startsolid)
71         {
72                 dprint("could not get out of solid (", vtos(o), ")");
73                 return;
74         }
75 }
76
77 // converts a number to a string with the indicated number of decimals
78 // works for up to 10 decimals!
79 string ftos_decimals(float number, float decimals)
80 {
81         string result;
82         string tmp;
83         float len;
84
85         // if negative, cut off the sign first
86         if(number < 0)
87                 return strcat("-", ftos_decimals(-number, decimals));
88         // it now is always positive!
89
90         // 3.516 -> 352
91         number = floor(number * pow(10, decimals) + 0.5);
92
93         // 352 -> "352"
94         result = ftos(number);
95         len = strlen(result);
96         // does it have a decimal point (should not happen)? If there is one, it is always at len-7)
97                 // if ftos had fucked it up, which should never happen: "34278.000000"
98         if(len >= 7)
99                 if(substring(result, len - 7, 1) == ".")
100                 {
101                         dprint("ftos(integer) has comma? Can't be. Affected result: ", result, "\n");
102                         result = substring(result, 0, len - 7);
103                         len -= 7;
104                 }
105                 // "34278"
106         // is it too short? If yes, insert leading zeroes
107         if(len <= decimals)
108         {
109                 result = strcat(substring("0000000000", 0, decimals - len + 1), result);
110                 len = decimals + 1;
111         }
112         // and now... INSERT THE POINT!
113         tmp = substring(result, len - decimals, decimals);
114         result = strcat(substring(result, 0, len - decimals), ".", tmp);
115         return result;
116 }
117
118 #define FOR_EACH_CLIENT(v) for(v = world; (v = findflags(v, flags, FL_CLIENT)) != world; )
119 #define FOR_EACH_REALCLIENT(v) FOR_EACH_CLIENT(v) if(clienttype(v) == CLIENTTYPE_REAL)
120 string STR_PLAYER = "player";
121 #define FOR_EACH_PLAYER(v) for(v = world; (v = find(v, classname, STR_PLAYER)) != world; )
122 #define FOR_EACH_REALPLAYER(v) FOR_EACH_PLAYER(v) if(clienttype(v) == CLIENTTYPE_REAL)
123
124 // change that to actually calling strcat when running on an engine without
125 // unlimited tempstrings:
126 // string strcat1(string s) = #115; // FRIK_FILE
127 #define strcat1(s) (s)
128
129 float logfile_open;
130 float logfile;
131
132 void(string s) bcenterprint
133 {
134         // TODO replace by MSG_ALL (would show it to spectators too, though)?
135         entity head;
136         FOR_EACH_PLAYER(head)
137                 if(clienttype(head) == CLIENTTYPE_REAL)
138                         centerprint(head, s);
139 }
140
141 void(string s, float check_dangerous) ServerConsoleEcho =
142 {
143         local string ch;
144         if (checkextension("DP_SV_PRINT"))
145                 print(s, "\n");
146         else
147         {
148                 localcmd("echo \"");
149                 if(check_dangerous)
150                 {
151                         while(strlen(s))
152                         {
153                                 ch = substring(s, 0, 1);
154                                 if(ch != "\"" && ch != "\r" && ch != "\n")
155                                         localcmd(ch);
156                                 s = substring(s, 1, strlen(s) - 1);
157                         }
158                 }
159                 else
160                 {
161                         localcmd(s);
162                 }
163                 localcmd("\"\n");
164         }
165 }
166
167 void(string s, float check_dangerous) GameLogEcho =
168 {
169         string fn;
170         float matches;
171
172         if(cvar("sv_eventlog_files"))
173         {
174                 if(!logfile_open)
175                 {
176                         logfile_open = TRUE;
177                         matches = cvar("sv_eventlog_files_counter") + 1;
178                         cvar_set("sv_eventlog_files_counter", ftos(matches));
179                         fn = ftos(matches);
180                         if(strlen(fn) < 8)
181                                 fn = strcat(substring("00000000", 0, 8 - strlen(fn)), fn);
182                         fn = strcat(cvar_string("sv_eventlog_files_nameprefix"), fn, cvar_string("sv_eventlog_files_namesuffix"));
183                         logfile = fopen(fn, FILE_APPEND);
184                 }
185                 if(logfile >= 0)
186                         fputs(logfile, strcat(s, "\n"));
187         }
188         if(cvar("sv_eventlog_console"))
189         {
190                 ServerConsoleEcho(s, check_dangerous);
191         }
192 }
193
194 void() GameLogInit =
195 {
196         logfile_open = 0;
197         // will be opened later
198 }
199
200 void() GameLogClose =
201 {
202         if(logfile_open && logfile >= 0)
203         {
204                 fclose(logfile);
205                 logfile = -1;
206         }
207 }
208
209 float math_mod(float a, float b)
210 {
211         return a - (floor(a / b) * b);
212 }
213
214 void relocate_spawnpoint()
215 {
216         // nudge off the floor
217         setorigin(self, self.origin + '0 0 1');
218
219         tracebox(self.origin, PL_MIN, PL_MAX, self.origin, TRUE, self);
220         if (trace_startsolid)
221         {
222                 objerror("player spawn point in solid, mapper sucks!\n");
223                 return;
224         }
225
226         if(cvar("g_spawnpoints_autodrop"))
227         {
228                 setsize(self, PL_MIN, PL_MAX);
229                 droptofloor();
230         }
231 }
232
233 // NOTE: DO NOT USE THIS FUNCTION TOO OFTEN.
234 // IT WILL MOST PROBABLY DESTROY _ALL_ OTHER TEMP
235 // STRINGS AND TAKE QUITE LONG. haystack and needle MUST
236 // BE CONSTANT OR strzoneD!
237 float(string haystack, string needle, float offset) strstr =
238 {
239         float len, endpos;
240         string found;
241         len = strlen(needle);
242         endpos = strlen(haystack) - len;
243         while(offset <= endpos)
244         {
245                 found = substring(haystack, offset, len);
246                 if(found == needle)
247                         return offset;
248                 offset = offset + 1;
249         }
250         return -1;
251 }
252
253 float NUM_NEAREST_ENTITIES = 4;
254 entity nearest_entity[NUM_NEAREST_ENTITIES];
255 float nearest_length[NUM_NEAREST_ENTITIES];
256 entity(vector point, .string field, string value, vector axismod) findnearest =
257 {
258         entity localhead;
259         float i;
260         float j;
261         float len;
262         vector dist;
263
264         float num_nearest;
265         num_nearest = 0;
266
267         localhead = find(world, field, value);
268         while(localhead)
269         {
270                 if((localhead.items == IT_KEY1 || localhead.items == IT_KEY2) && localhead.target == "###item###")
271                         dist = localhead.oldorigin;
272                 else
273                         dist = localhead.origin;
274                 dist = dist - point;
275                 dist = dist_x * axismod_x * '1 0 0' + dist_y * axismod_y * '0 1 0' + dist_z * axismod_z * '0 0 1';
276                 len = vlen(dist);
277
278                 for(i = 0; i < num_nearest; ++i)
279                 {
280                         if(len < nearest_length[i])
281                                 break;
282                 }
283
284                 // now i tells us where to insert at
285                 //   INSERTION SORT! YOU'VE SEEN IT! RUN!
286                 if(i < NUM_NEAREST_ENTITIES)
287                 {
288                         for(j = NUM_NEAREST_ENTITIES - 1; j >= i; --j)
289                         {
290                                 nearest_length[j + 1] = nearest_length[j];
291                                 nearest_entity[j + 1] = nearest_entity[j];
292                         }
293                         nearest_length[i] = len;
294                         nearest_entity[i] = localhead;
295                         if(num_nearest < NUM_NEAREST_ENTITIES)
296                                 num_nearest = num_nearest + 1;
297                 }
298
299                 localhead = find(localhead, field, value);
300         }
301
302         // now use the first one from our list that we can see
303         for(i = 0; i < num_nearest; ++i)
304         {
305                 traceline(point, nearest_entity[i].origin, TRUE, world);
306                 if(trace_fraction == 1)
307                 {
308                         if(i != 0)
309                         {
310                                 dprint("Nearest point (");
311                                 dprint(nearest_entity[0].netname);
312                                 dprint(") is not visible, using a visible one.\n");
313                         }
314                         return nearest_entity[i];
315                 }
316         }
317
318         if(num_nearest == 0)
319                 return world;
320
321         dprint("Not seeing any location point, using nearest as fallback.\n");
322         /* DEBUGGING CODE:
323         dprint("Candidates were: ");
324         for(j = 0; j < num_nearest; ++j)
325         {
326                 if(j != 0)
327                         dprint(", ");
328                 dprint(nearest_entity[j].netname);
329         }
330         dprint("\n");
331         */
332
333         return nearest_entity[0];
334 }
335
336 void() target_location =
337 {
338         self.classname = "target_location";
339         // location name in netname
340         // eventually support: count, teamgame selectors, line of sight?
341 };
342
343 void() info_location =
344 {
345         self.classname = "target_location";
346         self.message = self.netname;
347 };
348
349 string NearestLocation(vector p)
350 {
351         entity loc;
352         string ret;
353         ret = "somewhere";
354         loc = findnearest(p, classname, "target_location", '1 1 1');
355         if(loc)
356         {
357                 ret = loc.message;
358         }
359         else
360         {
361                 loc = findnearest(p, target, "###item###", '1 1 4');
362                 if(loc)
363                         ret = loc.netname;
364         }
365         return ret;
366 }
367
368 string(string msg) formatmessage =
369 {
370         float p;
371         float n;
372         string msg_save;
373         string escape;
374         string replacement;
375         msg_save = strzone(msg);
376         p = 0;
377         n = 7;
378         while(1)
379         {
380                 if(n < 1)
381                         break; // too many replacements
382                 n = n - 1;
383                 p = strstr(msg_save, "%", p); // NOTE: this destroys msg as it's a tempstring!
384                 if(p < 0)
385                         break;
386                 replacement = substring(msg_save, p, 2);
387                 escape = substring(msg_save, p + 1, 1);
388                 if(escape == "%")
389                         replacement = "%";
390                 else if(escape == "a")
391                         replacement = ftos(floor(self.armorvalue));
392                 else if(escape == "h")
393                         replacement = ftos(floor(self.health));
394                 else if(escape == "l")
395                         replacement = NearestLocation(self.origin);
396                 else if(escape == "y")
397                         replacement = NearestLocation(self.cursor_trace_endpos);
398                 else if(escape == "d")
399                         replacement = NearestLocation(self.death_origin);
400                 else if(escape == "w")
401                 {
402                         float wep;
403                         wep = self.weapon;
404                         if(!wep)
405                                 wep = self.switchweapon;
406                         if(!wep)
407                                 wep = self.cnt;
408                         replacement = W_Name(wep);
409                 }
410                 else if(escape == "W")
411                 {
412                         if(self.items & IT_SHELLS) replacement = "shells";
413                         else if(self.items & IT_NAILS) replacement = "bullets";
414                         else if(self.items & IT_ROCKETS) replacement = "rockets";
415                         else if(self.items & IT_CELLS) replacement = "cells";
416                         else replacement = "batteries"; // ;)
417                 }
418                 else if(escape == "x")
419                 {
420                         replacement = self.cursor_trace_ent.netname;
421                         if(!replacement || !self.cursor_trace_ent)
422                                 replacement = "nothing";
423                 }
424                 else if(escape == "p")
425                 {
426                         if(self.last_selected_player)
427                                 replacement = self.last_selected_player.netname;
428                         else
429                                 replacement = "(nobody)";
430                 }
431                 msg = strcat(substring(msg_save, 0, p), replacement);
432                 msg = strcat(msg, substring(msg_save, p+2, strlen(msg_save) - (p+2)));
433                 strunzone(msg_save);
434                 msg_save = strzone(msg);
435                 p = p + 2;
436         }
437         msg = strcat(msg_save, "");
438         strunzone(msg_save);
439         return msg;
440 }
441
442 /*
443 =============
444 GetCvars
445 =============
446 Called with:
447   0:  sends the request
448   >0: receives a cvar from name=argv(f) value=argv(f+1)
449 */
450 void GetCvars_handleString(float f, .string field, string name)
451 {
452         if(f < 0)
453         {
454                 if(self.field)
455                         strunzone(self.field);
456         }
457         else if(f > 0)
458         {
459                 if(argv(f) == name)
460                 {
461                         if(self.field)
462                                 strunzone(self.field);
463                         self.field = strzone(argv(f + 1));
464                 }
465         }
466         else
467                 stuffcmd(self, strcat("sendcvar ", name, "\n"));
468 }
469 void GetCvars_handleFloat(float f, .float field, string name)
470 {
471         if(f < 0)
472         {
473         }
474         else if(f > 0)
475         {
476                 if(argv(f) == name)
477                         self.field = stof(argv(f + 1));
478         }
479         else
480                 stuffcmd(self, strcat("sendcvar ", name, "\n"));
481 }
482 void GetCvars(float f)
483 {
484         GetCvars_handleFloat(f, autoswitch, "cl_autoswitch");
485         GetCvars_handleFloat(f, cvar_cl_hidewaypoints, "cl_hidewaypoints");
486         GetCvars_handleFloat(f, cvar_cl_zoomfactor, "cl_zoomfactor");
487         GetCvars_handleFloat(f, cvar_cl_zoomspeed, "cl_zoomspeed");
488         GetCvars_handleFloat(f, cvar_cl_playerdetailreduction, "cl_playerdetailreduction");
489         GetCvars_handleFloat(f, cvar_cl_nogibs, "cl_nogibs");
490         GetCvars_handleFloat(f, cvar_scr_centertime, "scr_centertime");
491         GetCvars_handleFloat(f, cvar_cl_shownames, "cl_shownames");
492         GetCvars_handleString(f, cvar_g_nexuizversion, "g_nexuizversion");
493 }
494
495 float fexists(string f)
496 {
497         float fh;
498         fh = fopen(f, FILE_READ);
499         if(fh < 0)
500                 return FALSE;
501         fclose(fh);
502         return TRUE;
503 }
504
505 void backtrace(string msg)
506 {
507         float dev;
508         dev = cvar("developer");
509         cvar_set("developer", "1");
510         dprint("\n");
511         dprint("--- CUT HERE ---\nWARNING: ");
512         dprint(msg);
513         dprint("\n");
514         remove(world); // isn't there any better way to cause a backtrace?
515         dprint("\n--- CUT UNTIL HERE ---\n");
516         cvar_set("developer", ftos(dev));
517 }
518
519 void DistributeFragsAmongTeam(entity p, float targetteam, float factor)
520 {
521         float nTeam;
522         entity head;
523         float f;
524
525         if(!teams_matter)
526                 return;
527
528         //if(p.frags < 0)
529         //{
530         //      p.frags = 0; // do not harm the new team!
531         //      return; // won't distribute negative scores
532         //}
533
534         if(p.frags == -666)
535                 return;
536
537         f = ceil(factor * p.frags);
538         p.frags = p.frags - f;
539
540         nTeam = 0;
541         FOR_EACH_PLAYER(head)
542                 if(head != p)
543                         if(head.team == targetteam)
544                                 nTeam = nTeam + 1;
545
546         if(nTeam == 0)
547                 return;
548
549         DistributeEvenly_Init(f, nTeam);
550
551         FOR_EACH_PLAYER(head)
552                 if(head != p)
553                         if(head.team == targetteam)
554                                 head.frags = head.frags + DistributeEvenly_Get(1);
555 }
556
557 string Team_ColorCode(float teamid)
558 {
559         if(teamid == COLOR_TEAM1)
560                 return "^1";
561         else if(teamid == COLOR_TEAM2)
562                 return "^4";
563         else if(teamid == COLOR_TEAM3)
564                 return "^3";
565         else if(teamid == COLOR_TEAM4)
566                 return "^6";
567         else
568                 return "^7";
569 }
570
571 /*
572 string decolorize(string s)
573 {
574         string out;
575         out = "";
576         while(s != "")
577         {
578                 float n;
579                 string ch1, ch2;
580                 n = 1;
581                 ch1 = substring(s, 0, 1);
582                 ch2 = substring(s, 1, 1);
583                 if(ch1 == "^")
584                 {
585                         n = 2;
586                         if(ch2 == "^")
587                                 out = strcat(out, "^^");
588                         else if(ch2 == "0")
589                                 out = strcat1(out);
590                         else if(ch2 == "1")
591                                 out = strcat1(out);
592                         else if(ch2 == "2")
593                                 out = strcat1(out);
594                         else if(ch2 == "3")
595                                 out = strcat1(out);
596                         else if(ch2 == "4")
597                                 out = strcat1(out);
598                         else if(ch2 == "5")
599                                 out = strcat1(out);
600                         else if(ch2 == "6")
601                                 out = strcat1(out);
602                         else if(ch2 == "7")
603                                 out = strcat1(out);
604                         else if(ch2 == "8")
605                                 out = strcat1(out);
606                         else if(ch2 == "9")
607                                 out = strcat1(out);
608                         else
609                         {
610                                 n = 1;
611                                 out = strcat(out, "^^");
612                         }
613                         s = substring(s, n, strlen(s) - n);
614                 }
615                 else
616                 {
617                         s = substring(s, 1, strlen(s) - 1);
618                         out = strcat(out, ch1);
619                 }
620         }
621         return out;
622 }
623 #define strdecolorize(s) decolorize(s)
624 #define strlennocol(s) strlen(decolorize(s))
625 */
626
627 #define CENTERPRIO_POINT 1
628 #define CENTERPRIO_SPAM 2
629 #define CENTERPRIO_REBALANCE 2
630 #define CENTERPRIO_VOTE 4
631 #define CENTERPRIO_NORMAL 5
632 #define CENTERPRIO_MAPVOTE 9
633 #define CENTERPRIO_ADMIN 99
634 .float centerprint_priority;
635 .float centerprint_expires;
636 void centerprint_atprio(entity e, float prio, string s)
637 {
638         if(intermission_running)
639                 if(prio < CENTERPRIO_MAPVOTE)
640                         return;
641         if(time > e.centerprint_expires)
642                 e.centerprint_priority = 0;
643         if(prio >= e.centerprint_priority)
644         {
645                 e.centerprint_priority = prio;
646                 e.centerprint_expires = time + e.cvar_scr_centertime;
647                 centerprint_builtin(e, s);
648         }
649 }
650 void centerprint_expire(entity e, float prio)
651 {
652         if(prio == e.centerprint_priority)
653         {
654                 e.centerprint_priority = 0;
655                 centerprint_builtin(e, "");
656         }
657 }
658 void centerprint(entity e, string s)
659 {
660         centerprint_atprio(e, CENTERPRIO_NORMAL, s);
661 }
662
663 void VoteNag();
664
665 // decolorizes and team colors the player name when needed
666 string playername(entity p)
667 {
668         string t;
669         if(teams_matter && !intermission_running && p.classname == "player")
670         {
671                 t = Team_ColorCode(p.team);
672                 return strcat(t, strdecolorize(p.netname));
673         }
674         else
675                 return p.netname;
676 }
677
678 // requires that m2>m1 in all coordinates, and that m4>m3
679 float(vector m1, vector m2, vector m3, vector m4) boxesoverlap = {return m2_x >= m3_x && m1_x <= m4_x && m2_y >= m3_y && m1_y <= m4_y && m2_z >= m3_z && m1_z <= m4_z;};
680
681 // requires the same, but is a stronger condition
682 float(vector smins, vector smaxs, vector bmins, vector bmaxs) boxinsidebox = {return smins_x >= bmins_x && smaxs_x <= bmaxs_x && smins_y >= bmins_y && smaxs_y <= bmaxs_y && smins_z >= bmins_z && smaxs_z <= bmaxs_z;};
683
684 float g_pickup_shells;
685 float g_pickup_shells_max;
686 float g_pickup_nails;
687 float g_pickup_nails_max;
688 float g_pickup_rockets;
689 float g_pickup_rockets_max;
690 float g_pickup_cells;
691 float g_pickup_cells_max;
692 float g_pickup_armorshard;
693 float g_pickup_armorshard_max;
694 float g_pickup_armor;
695 float g_pickup_armor_max;
696 float g_pickup_healthshard;
697 float g_pickup_healthshard_max;
698 float g_pickup_health;
699 float g_pickup_health_max;
700 float g_pickup_healthmega;
701 float g_pickup_healthmega_max;
702
703 void readlevelcvars(void)
704 {
705         g_pickup_shells                    = cvar("g_pickup_shells");
706         g_pickup_shells_max                = cvar("g_pickup_shells_max");
707         g_pickup_nails                     = cvar("g_pickup_nails");
708         g_pickup_nails_max                 = cvar("g_pickup_nails_max");
709         g_pickup_rockets                   = cvar("g_pickup_rockets");
710         g_pickup_rockets_max               = cvar("g_pickup_rockets_max");
711         g_pickup_cells                     = cvar("g_pickup_cells");
712         g_pickup_cells_max                 = cvar("g_pickup_cells_max");
713         g_pickup_armorshard                = cvar("g_pickup_armorshard");
714         g_pickup_armorshard_max            = cvar("g_pickup_armorshard_max");
715         g_pickup_armor                     = cvar("g_pickup_armor");
716         g_pickup_armor_max                 = cvar("g_pickup_armor_max");
717         g_pickup_healthshard               = cvar("g_pickup_healthshard");
718         g_pickup_healthshard_max           = cvar("g_pickup_healthshard_max");
719         g_pickup_health                    = cvar("g_pickup_health");
720         g_pickup_health_max                = cvar("g_pickup_health_max");
721         g_pickup_healthmega                = cvar("g_pickup_healthmega");
722         g_pickup_healthmega_max            = cvar("g_pickup_healthmega_max");
723 }
724
725 /*
726 // TODO sound pack system
727 string soundpack;
728
729 string precache_sound_builtin (string s) = #19;
730 void(entity e, float chan, string samp, float vol, float atten) sound_builtin = #8;
731 string precache_sound(string s)
732 {
733         return precache_sound_builtin(strcat(soundpack, s));
734 }
735 void play2(entity e, string filename)
736 {
737         stuffcmd(e, strcat("play2 ", soundpack, filename, "\n"));
738 }
739 void sound(entity e, float chan, string samp, float vol, float atten)
740 {
741         sound_builtin(e, chan, strcat(soundpack, samp), vol, atten);
742 }
743 */
744
745 string precache_sound (string s) = #19;
746 void(entity e, float chan, string samp, float vol, float atten) sound = #8;
747 void play2(entity e, string filename)
748 {
749         stuffcmd(e, strcat("play2 ", filename, "\n"));
750 }