1 void() spawnfunc_info_player_deathmatch; // needed for the other spawnpoints
3 string ColoredTeamName(float t);
5 float RandomSelection_totalweight;
6 float RandomSelection_best_priority;
7 entity RandomSelection_chosen_ent;
8 float RandomSelection_chosen_float;
9 void RandomSelection_Init()
11 RandomSelection_totalweight = 0;
12 RandomSelection_chosen_ent = world;
13 RandomSelection_chosen_float = 0;
14 RandomSelection_best_priority = -1;
16 void RandomSelection_Add(entity e, float f, float weight, float priority)
18 if(priority > RandomSelection_best_priority)
20 RandomSelection_best_priority = priority;
21 RandomSelection_chosen_ent = e;
22 RandomSelection_chosen_float = f;
23 RandomSelection_totalweight = weight;
25 else if(priority == RandomSelection_best_priority)
27 RandomSelection_totalweight += weight;
28 if(random() * RandomSelection_totalweight <= weight)
30 RandomSelection_chosen_ent = e;
31 RandomSelection_chosen_float = f;
36 float DistributeEvenly_amount;
37 float DistributeEvenly_totalweight;
38 void DistributeEvenly_Init(float amount, float totalweight)
40 if(DistributeEvenly_amount)
42 dprint("DistributeEvenly_Init: UNFINISHED DISTRIBUTION (", ftos(DistributeEvenly_amount), " for ");
43 dprint(ftos(DistributeEvenly_totalweight), " left!)\n");
46 DistributeEvenly_amount = 0;
48 DistributeEvenly_amount = amount;
49 DistributeEvenly_totalweight = totalweight;
51 float DistributeEvenly_Get(float weight)
56 f = floor(0.5 + DistributeEvenly_amount * weight / DistributeEvenly_totalweight);
57 DistributeEvenly_totalweight -= weight;
58 DistributeEvenly_amount -= f;
62 void move_out_of_solid_expand(entity e, vector by)
65 tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
68 if(trace_fraction < 1)
71 // adjust origin in the other direction...
72 e.origin = e.origin - by * (1 - trace_fraction);
76 void move_out_of_solid(entity e)
81 traceline(o, o, MOVE_WORLDONLY, e);
84 dprint("origin is in solid too! (", vtos(o), ")");
88 tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
96 move_out_of_solid_expand(e, '1 0 0' * m0_x); e.mins_x = m0_x;
97 move_out_of_solid_expand(e, '1 0 0' * m1_x); e.maxs_x = m1_x;
98 move_out_of_solid_expand(e, '0 1 0' * m0_y); e.mins_y = m0_y;
99 move_out_of_solid_expand(e, '0 1 0' * m1_y); e.maxs_y = m1_y;
100 move_out_of_solid_expand(e, '0 0 1' * m0_z); e.mins_z = m0_z;
101 move_out_of_solid_expand(e, '0 0 1' * m1_z); e.maxs_z = m1_z;
102 setorigin(e, e.origin);
104 tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
107 dprint("could not get out of solid (", vtos(o), ")\n");
112 string STR_PLAYER = "player";
115 #define FOR_EACH_CLIENT(v) for(v = world; (v = findflags(v, flags, FL_CLIENT)) != world; )
116 #define FOR_EACH_REALCLIENT(v) FOR_EACH_CLIENT(v) if(clienttype(v) == CLIENTTYPE_REAL)
117 #define FOR_EACH_PLAYER(v) for(v = world; (v = find(v, classname, STR_PLAYER)) != world; )
118 #define FOR_EACH_REALPLAYER(v) FOR_EACH_PLAYER(v) if(clienttype(v) == CLIENTTYPE_REAL)
120 #define FOR_EACH_CLIENTSLOT(v) for(v = world; (v = nextent(v)) && (num_for_edict(v) <= maxclients); )
121 #define FOR_EACH_CLIENT(v) FOR_EACH_CLIENTSLOT(v) if(v.flags & FL_CLIENT)
122 #define FOR_EACH_REALCLIENT(v) FOR_EACH_CLIENT(v) if(clienttype(v) == CLIENTTYPE_REAL)
123 #define FOR_EACH_PLAYER(v) FOR_EACH_CLIENT(v) if(v.classname == STR_PLAYER)
124 #define FOR_EACH_REALPLAYER(v) FOR_EACH_REALCLIENT(v) if(v.classname == STR_PLAYER)
127 // change that to actually calling strcat when running on an engine without
128 // unlimited tempstrings:
129 // string strcat1(string s) = #115; // FRIK_FILE
130 #define strcat1(s) (s)
135 void bcenterprint(string s)
137 // TODO replace by MSG_ALL (would show it to spectators too, though)?
139 FOR_EACH_PLAYER(head)
140 if(clienttype(head) == CLIENTTYPE_REAL)
141 centerprint(head, s);
144 void ServerConsoleEcho(string s, float check_dangerous)
147 if (checkextension("DP_SV_PRINT"))
156 ch = substring(s, 0, 1);
157 if(ch != "\"" && ch != "\r" && ch != "\n")
159 s = substring(s, 1, strlen(s) - 1);
170 void GameLogEcho(string s, float check_dangerous)
175 if(cvar("sv_eventlog_files"))
180 matches = cvar("sv_eventlog_files_counter") + 1;
181 cvar_set("sv_eventlog_files_counter", ftos(matches));
184 fn = strcat(substring("00000000", 0, 8 - strlen(fn)), fn);
185 fn = strcat(cvar_string("sv_eventlog_files_nameprefix"), fn, cvar_string("sv_eventlog_files_namesuffix"));
186 logfile = fopen(fn, FILE_APPEND);
187 fputs(logfile, ":logversion:2\n");
191 if(cvar("sv_eventlog_files_timestamps"))
192 fputs(logfile, strcat(":time:", strftime(TRUE, "%Y-%m-%d %H:%M:%S", "\n", s, "\n")));
194 fputs(logfile, strcat(s, "\n"));
197 if(cvar("sv_eventlog_console"))
199 ServerConsoleEcho(s, check_dangerous);
206 // will be opened later
211 if(logfile_open && logfile >= 0)
218 void relocate_spawnpoint()
220 // nudge off the floor
221 setorigin(self, self.origin + '0 0 1');
223 tracebox(self.origin, PL_MIN, PL_MAX, self.origin, TRUE, self);
224 if (trace_startsolid)
226 objerror("player spawn point in solid, mapper sucks!\n");
230 if(cvar("g_spawnpoints_autodrop"))
232 setsize(self, PL_MIN, PL_MAX);
236 self.use = spawnpoint_use;
237 self.team_saved = self.team;
241 if(g_ctf || g_assault || g_onslaught || g_domination)
243 have_team_spawns = 1;
246 #define strstr strstrofs
248 // NOTE: DO NOT USE THIS FUNCTION TOO OFTEN.
249 // IT WILL MOST PROBABLY DESTROY _ALL_ OTHER TEMP
250 // STRINGS AND TAKE QUITE LONG. haystack and needle MUST
251 // BE CONSTANT OR strzoneD!
252 float strstr(string haystack, string needle, float offset)
256 len = strlen(needle);
257 endpos = strlen(haystack) - len;
258 while(offset <= endpos)
260 found = substring(haystack, offset, len);
269 float NUM_NEAREST_ENTITIES = 4;
270 entity nearest_entity[NUM_NEAREST_ENTITIES];
271 float nearest_length[NUM_NEAREST_ENTITIES];
272 entity findnearest(vector point, .string field, string value, vector axismod)
283 localhead = find(world, field, value);
286 if((localhead.items == IT_KEY1 || localhead.items == IT_KEY2) && localhead.target == "###item###")
287 dist = localhead.oldorigin;
289 dist = localhead.origin;
291 dist = dist_x * axismod_x * '1 0 0' + dist_y * axismod_y * '0 1 0' + dist_z * axismod_z * '0 0 1';
294 for(i = 0; i < num_nearest; ++i)
296 if(len < nearest_length[i])
300 // now i tells us where to insert at
301 // INSERTION SORT! YOU'VE SEEN IT! RUN!
302 if(i < NUM_NEAREST_ENTITIES)
304 for(j = NUM_NEAREST_ENTITIES - 1; j >= i; --j)
306 nearest_length[j + 1] = nearest_length[j];
307 nearest_entity[j + 1] = nearest_entity[j];
309 nearest_length[i] = len;
310 nearest_entity[i] = localhead;
311 if(num_nearest < NUM_NEAREST_ENTITIES)
312 num_nearest = num_nearest + 1;
315 localhead = find(localhead, field, value);
318 // now use the first one from our list that we can see
319 for(i = 0; i < num_nearest; ++i)
321 traceline(point, nearest_entity[i].origin, TRUE, world);
322 if(trace_fraction == 1)
326 dprint("Nearest point (");
327 dprint(nearest_entity[0].netname);
328 dprint(") is not visible, using a visible one.\n");
330 return nearest_entity[i];
337 dprint("Not seeing any location point, using nearest as fallback.\n");
339 dprint("Candidates were: ");
340 for(j = 0; j < num_nearest; ++j)
344 dprint(nearest_entity[j].netname);
349 return nearest_entity[0];
352 void spawnfunc_target_location()
354 self.classname = "target_location";
355 // location name in netname
356 // eventually support: count, teamgame selectors, line of sight?
359 void spawnfunc_info_location()
361 self.classname = "target_location";
362 self.message = self.netname;
365 string NearestLocation(vector p)
370 loc = findnearest(p, classname, "target_location", '1 1 1');
377 loc = findnearest(p, target, "###item###", '1 1 4');
384 string formatmessage(string msg)
391 msg_save = strzone(msg);
397 break; // too many replacements
399 p = strstr(msg_save, "%", p); // NOTE: this destroys msg as it's a tempstring!
402 replacement = substring(msg_save, p, 2);
403 escape = substring(msg_save, p + 1, 1);
406 else if(escape == "a")
407 replacement = ftos(floor(self.armorvalue));
408 else if(escape == "h")
409 replacement = ftos(floor(self.health));
410 else if(escape == "l")
411 replacement = NearestLocation(self.origin);
412 else if(escape == "y")
413 replacement = NearestLocation(self.cursor_trace_endpos);
414 else if(escape == "d")
415 replacement = NearestLocation(self.death_origin);
416 else if(escape == "w")
421 wep = self.switchweapon;
424 replacement = W_Name(wep);
426 else if(escape == "W")
428 if(self.items & IT_SHELLS) replacement = "shells";
429 else if(self.items & IT_NAILS) replacement = "bullets";
430 else if(self.items & IT_ROCKETS) replacement = "rockets";
431 else if(self.items & IT_CELLS) replacement = "cells";
432 else replacement = "batteries"; // ;)
434 else if(escape == "x")
436 replacement = self.cursor_trace_ent.netname;
437 if(!replacement || !self.cursor_trace_ent)
438 replacement = "nothing";
440 else if(escape == "p")
442 if(self.last_selected_player)
443 replacement = self.last_selected_player.netname;
445 replacement = "(nobody)";
447 msg = strcat(substring(msg_save, 0, p), replacement);
448 msg = strcat(msg, substring(msg_save, p+2, strlen(msg_save) - (p+2)));
450 msg_save = strzone(msg);
453 msg = strcat(msg_save, "");
464 >0: receives a cvar from name=argv(f) value=argv(f+1)
466 void GetCvars_handleString(float f, .string field, string name)
471 strunzone(self.field);
478 strunzone(self.field);
479 self.field = strzone(argv(f + 1));
483 stuffcmd(self, strcat("sendcvar ", name, "\n"));
485 void GetCvars_handleFloat(float f, .float field, string name)
493 self.field = stof(argv(f + 1));
496 stuffcmd(self, strcat("sendcvar ", name, "\n"));
498 void GetCvars(float f)
500 GetCvars_handleFloat(f, autoswitch, "cl_autoswitch");
501 GetCvars_handleFloat(f, cvar_cl_hidewaypoints, "cl_hidewaypoints");
502 GetCvars_handleFloat(f, cvar_cl_zoomfactor, "cl_zoomfactor");
503 GetCvars_handleFloat(f, cvar_cl_zoomspeed, "cl_zoomspeed");
504 GetCvars_handleFloat(f, cvar_cl_playerdetailreduction, "cl_playerdetailreduction");
505 GetCvars_handleFloat(f, cvar_cl_nogibs, "cl_nogibs");
506 GetCvars_handleFloat(f, cvar_scr_centertime, "scr_centertime");
507 GetCvars_handleFloat(f, cvar_cl_shownames, "cl_shownames");
508 GetCvars_handleString(f, cvar_g_nexuizversion, "g_nexuizversion");
509 GetCvars_handleFloat(f, cvar_cl_handicap, "cl_handicap");
512 float fexists(string f)
515 fh = fopen(f, FILE_READ);
522 void backtrace(string msg)
525 dev = cvar("developer");
526 cvar_set("developer", "1");
528 dprint("--- CUT HERE ---\nWARNING: ");
531 remove(world); // isn't there any better way to cause a backtrace?
532 dprint("\n--- CUT UNTIL HERE ---\n");
533 cvar_set("developer", ftos(dev));
536 void DistributeFragsAmongTeam(entity p, float targetteam, float factor)
547 // p.frags = 0; // do not harm the new team!
548 // return; // won't distribute negative scores
554 f = ceil(factor * p.frags);
555 p.frags = p.frags - f;
558 FOR_EACH_PLAYER(head)
560 if(head.team == targetteam)
566 DistributeEvenly_Init(f, nTeam);
568 FOR_EACH_PLAYER(head)
570 if(head.team == targetteam)
571 head.frags = head.frags + DistributeEvenly_Get(1);
574 string Team_ColorCode(float teamid)
576 if(teamid == COLOR_TEAM1)
578 else if(teamid == COLOR_TEAM2)
580 else if(teamid == COLOR_TEAM3)
582 else if(teamid == COLOR_TEAM4)
587 string Team_ColorName(float t)
589 // fixme: Search for team entities and get their .netname's!
600 string Team_ColorNameLowerCase(float t)
602 // fixme: Search for team entities and get their .netname's!
615 string decolorize(string s)
624 ch1 = substring(s, 0, 1);
625 ch2 = substring(s, 1, 1);
630 out = strcat(out, "^^");
654 out = strcat(out, "^^");
656 s = substring(s, n, strlen(s) - n);
660 s = substring(s, 1, strlen(s) - 1);
661 out = strcat(out, ch1);
666 #define strdecolorize(s) decolorize(s)
667 #define strlennocol(s) strlen(decolorize(s))
670 #define CENTERPRIO_POINT 1
671 #define CENTERPRIO_SPAM 2
672 #define CENTERPRIO_REBALANCE 2
673 #define CENTERPRIO_VOTE 4
674 #define CENTERPRIO_NORMAL 5
675 #define CENTERPRIO_MAPVOTE 9
676 #define CENTERPRIO_IDLEKICK 50
677 #define CENTERPRIO_ADMIN 99
678 .float centerprint_priority;
679 .float centerprint_expires;
680 void centerprint_atprio(entity e, float prio, string s)
682 if(intermission_running)
683 if(prio < CENTERPRIO_MAPVOTE)
685 if(time > e.centerprint_expires)
686 e.centerprint_priority = 0;
687 if(prio >= e.centerprint_priority)
689 e.centerprint_priority = prio;
690 if(timeoutStatus == 2)
691 e.centerprint_expires = time + (e.cvar_scr_centertime * TIMEOUT_SLOWMO_VALUE);
693 e.centerprint_expires = time + e.cvar_scr_centertime;
694 centerprint_builtin(e, s);
697 void centerprint_expire(entity e, float prio)
699 if(prio == e.centerprint_priority)
701 e.centerprint_priority = 0;
702 centerprint_builtin(e, "");
705 void centerprint(entity e, string s)
707 centerprint_atprio(e, CENTERPRIO_NORMAL, s);
712 // decolorizes and team colors the player name when needed
713 string playername(entity p)
716 if(teams_matter && !intermission_running && p.classname == "player")
718 t = Team_ColorCode(p.team);
719 return strcat(t, strdecolorize(p.netname));
725 vector randompos(vector m1, vector m2)
729 v_x = m2_x * random() + m1_x;
730 v_y = m2_y * random() + m1_y;
731 v_z = m2_z * random() + m1_z;
735 // requires that m2>m1 in all coordinates, and that m4>m3
736 float boxesoverlap(vector m1, vector m2, vector m3, vector m4) {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;};
738 // requires the same, but is a stronger condition
739 float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) {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;};
741 float g_pickup_shells;
742 float g_pickup_shells_max;
743 float g_pickup_nails;
744 float g_pickup_nails_max;
745 float g_pickup_rockets;
746 float g_pickup_rockets_max;
747 float g_pickup_cells;
748 float g_pickup_cells_max;
749 float g_pickup_armorsmall;
750 float g_pickup_armorsmall_max;
751 float g_pickup_armormedium;
752 float g_pickup_armormedium_max;
753 float g_pickup_armorlarge;
754 float g_pickup_armorlarge_max;
755 float g_pickup_healthsmall;
756 float g_pickup_healthsmall_max;
757 float g_pickup_healthmedium;
758 float g_pickup_healthmedium_max;
759 float g_pickup_healthlarge;
760 float g_pickup_healthlarge_max;
761 float g_pickup_healthmega;
762 float g_pickup_healthmega_max;
765 float start_switchweapon;
766 float start_ammo_shells;
767 float start_ammo_nails;
768 float start_ammo_rockets;
769 float start_ammo_cells;
771 float start_armorvalue;
773 void readlevelcvars(void)
775 sv_cheats = cvar("sv_cheats");
776 sv_gentle = cvar("sv_gentle");
777 sv_foginterval = cvar("sv_foginterval");
778 g_cloaked = cvar("g_cloaked");
779 g_footsteps = cvar("g_footsteps");
780 g_grappling_hook = cvar("g_grappling_hook");
781 g_instagib = cvar("g_instagib");
782 g_laserguided_missile = cvar("g_laserguided_missile");
783 g_midair = cvar("g_midair");
784 g_minstagib = cvar("g_minstagib");
785 g_nixnex = cvar("g_nixnex");
786 g_nixnex_with_laser = cvar("g_nixnex_with_laser");
787 g_norecoil = cvar("g_norecoil");
788 g_rocketarena = cvar("g_rocketarena");
789 g_vampire = cvar("g_vampire");
790 g_tourney = cvar("g_tourney");
791 sv_maxidle = cvar("sv_maxidle");
792 sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle");
793 sv_pogostick = cvar("sv_pogostick");
794 sv_doublejump = cvar("sv_doublejump");
796 g_pickup_shells = cvar("g_pickup_shells");
797 g_pickup_shells_max = cvar("g_pickup_shells_max");
798 g_pickup_nails = cvar("g_pickup_nails");
799 g_pickup_nails_max = cvar("g_pickup_nails_max");
800 g_pickup_rockets = cvar("g_pickup_rockets");
801 g_pickup_rockets_max = cvar("g_pickup_rockets_max");
802 g_pickup_cells = cvar("g_pickup_cells");
803 g_pickup_cells_max = cvar("g_pickup_cells_max");
804 g_pickup_armorsmall = cvar("g_pickup_armorsmall");
805 g_pickup_armorsmall_max = cvar("g_pickup_armorsmall_max");
806 g_pickup_armormedium = cvar("g_pickup_armormedium");
807 g_pickup_armormedium_max = cvar("g_pickup_armormedium_max");
808 g_pickup_armorlarge = cvar("g_pickup_armorlarge");
809 g_pickup_armorlarge_max = cvar("g_pickup_armorlarge_max");
810 g_pickup_healthsmall = cvar("g_pickup_healthsmall");
811 g_pickup_healthsmall_max = cvar("g_pickup_healthsmall_max");
812 g_pickup_healthmedium = cvar("g_pickup_healthmedium");
813 g_pickup_healthmedium_max = cvar("g_pickup_healthmedium_max");
814 g_pickup_healthlarge = cvar("g_pickup_healthlarge");
815 g_pickup_healthlarge_max = cvar("g_pickup_healthlarge_max");
816 g_pickup_healthmega = cvar("g_pickup_healthmega");
817 g_pickup_healthmega_max = cvar("g_pickup_healthmega_max");
819 // initialize starting values for players
821 start_switchweapon = 0;
822 start_ammo_shells = 0;
823 start_ammo_nails = 0;
824 start_ammo_rockets = 0;
825 start_ammo_cells = 0;
826 start_health = cvar("g_balance_health_start");
827 start_armorvalue = cvar("g_balance_armor_start");
831 start_items = IT_NEX;
832 start_switchweapon = WEP_NEX;
833 weapon_action(start_switchweapon, WR_PRECACHE);
834 start_ammo_cells = 999;
836 else if(g_rocketarena)
838 start_items = IT_ROCKET_LAUNCHER;
839 start_switchweapon = WEP_ROCKET_LAUNCHER;
840 weapon_action(start_switchweapon, WR_PRECACHE);
841 start_ammo_rockets = 999;
846 // will be done later
851 start_armorvalue = 0;
852 start_items = IT_NEX;
853 start_switchweapon = WEP_NEX;
854 weapon_action(start_switchweapon, WR_PRECACHE);
855 start_ammo_cells = cvar("g_minstagib_ammo_start");
856 g_minstagib_invis_alpha = cvar("g_minstagib_invis_alpha");
862 start_ammo_shells = cvar("g_lms_start_ammo_shells");
863 start_ammo_nails = cvar("g_lms_start_ammo_nails");
864 start_ammo_rockets = cvar("g_lms_start_ammo_rockets");
865 start_ammo_cells = cvar("g_lms_start_ammo_cells");
866 start_health = cvar("g_lms_start_health");
867 start_armorvalue = cvar("g_lms_start_armor");
870 start_ammo_shells = cvar("g_tourney_start_ammo_shells");
871 start_ammo_nails = cvar("g_tourney_start_ammo_nails");
872 start_ammo_rockets = cvar("g_tourney_start_ammo_rockets");
873 start_ammo_cells = cvar("g_tourney_start_ammo_cells");
874 start_health = cvar("g_tourney_start_health");
875 start_armorvalue = cvar("g_tourney_start_armor");
877 else if (cvar("g_use_ammunition")) {
878 start_ammo_shells = cvar("g_start_ammo_shells");
879 start_ammo_nails = cvar("g_start_ammo_nails");
880 start_ammo_rockets = cvar("g_start_ammo_rockets");
881 start_ammo_cells = cvar("g_start_ammo_cells");
883 start_ammo_shells = cvar("g_pickup_shells_max");
884 start_ammo_nails = cvar("g_pickup_nails_max");
885 start_ammo_rockets = cvar("g_pickup_rockets_max");
886 start_ammo_cells = cvar("g_pickup_cells_max");
889 if (cvar("g_start_weapon_laser") || g_lms)
891 start_items = start_items | IT_LASER;
892 start_switchweapon = WEP_LASER;
893 weapon_action(start_switchweapon, WR_PRECACHE);
895 if (cvar("g_start_weapon_shotgun") || g_lms)
897 start_items = start_items | IT_SHOTGUN;
898 start_switchweapon = WEP_SHOTGUN;
899 weapon_action(start_switchweapon, WR_PRECACHE);
901 if (cvar("g_start_weapon_uzi") || g_lms || g_tourney)
903 start_items = start_items | IT_UZI;
904 start_switchweapon = WEP_UZI;
905 weapon_action(start_switchweapon, WR_PRECACHE);
907 if (cvar("g_start_weapon_grenadelauncher") || g_lms || g_tourney)
909 start_items = start_items | IT_GRENADE_LAUNCHER;
910 start_switchweapon = WEP_GRENADE_LAUNCHER;
911 weapon_action(start_switchweapon, WR_PRECACHE);
913 if (cvar("g_start_weapon_electro") || g_lms || g_tourney)
915 start_items = start_items | IT_ELECTRO;
916 start_switchweapon = WEP_ELECTRO;
917 weapon_action(start_switchweapon, WR_PRECACHE);
919 if (cvar("g_start_weapon_crylink") || g_lms || g_tourney)
921 start_items = start_items | IT_CRYLINK;
922 start_switchweapon = WEP_CRYLINK;
923 weapon_action(start_switchweapon, WR_PRECACHE);
925 if (cvar("g_start_weapon_nex") || g_lms || g_tourney)
927 start_items = start_items | IT_NEX;
928 start_switchweapon = WEP_NEX;
929 weapon_action(start_switchweapon, WR_PRECACHE);
931 if (cvar("g_start_weapon_hagar") || g_lms || g_tourney)
933 start_items = start_items | IT_HAGAR;
934 start_switchweapon = WEP_HAGAR;
935 weapon_action(start_switchweapon, WR_PRECACHE);
937 if (cvar("g_start_weapon_rocketlauncher") || g_lms || g_tourney)
939 start_items = start_items | IT_ROCKET_LAUNCHER;
940 start_switchweapon = WEP_ROCKET_LAUNCHER;
941 weapon_action(start_switchweapon, WR_PRECACHE);
947 // TODO sound pack system
950 string precache_sound_builtin (string s) = #19;
951 void(entity e, float chan, string samp, float vol, float atten) sound_builtin = #8;
952 string precache_sound(string s)
954 return precache_sound_builtin(strcat(soundpack, s));
956 void play2(entity e, string filename)
958 stuffcmd(e, strcat("play2 ", soundpack, filename, "\n"));
960 void sound(entity e, float chan, string samp, float vol, float atten)
962 sound_builtin(e, chan, strcat(soundpack, samp), vol, atten);
966 string precache_sound (string s) = #19;
967 void(entity e, float chan, string samp, float vol, float atten) sound = #8;
968 void play2(entity e, string filename)
970 stuffcmd(e, strcat("play2 ", filename, "\n"));
973 void play2team(float t, string filename)
976 FOR_EACH_REALPLAYER(head)
979 play2(head, filename);
983 void PrecachePlayerSounds(string f);
984 void precache_all_models(string pattern)
986 float globhandle, i, n;
989 globhandle = search_begin(pattern, TRUE, FALSE);
992 n = search_getsize(globhandle);
993 for(i = 0; i < n; ++i)
995 //print(search_getfilename(globhandle, i), "\n");
996 f = search_getfilename(globhandle, i);
998 PrecachePlayerSounds(strcat(f, ".sounds"));
1000 search_end(globhandle);
1005 // gamemode related things
1006 precache_model ("models/misc/chatbubble.spr");
1007 precache_model ("models/misc/teambubble.spr");
1010 precache_model ("models/runematch/curse.mdl");
1011 precache_model ("models/runematch/rune.mdl");
1014 // Precache all player models if desired
1015 if (cvar("sv_precacheplayermodels"))
1017 PrecachePlayerSounds("sound/player/default.sounds");
1018 precache_all_models("models/player/*.zym");
1019 precache_all_models("models/player/*.dpm");
1020 precache_all_models("models/player/*.md3");
1021 precache_all_models("models/player/*.psk");
1022 //precache_model("models/player/carni.zym");
1023 //precache_model("models/player/crash.zym");
1024 //precache_model("models/player/grunt.zym");
1025 //precache_model("models/player/headhunter.zym");
1026 //precache_model("models/player/insurrectionist.zym");
1027 //precache_model("models/player/jeandarc.zym");
1028 //precache_model("models/player/lurk.zym");
1029 //precache_model("models/player/lycanthrope.zym");
1030 //precache_model("models/player/marine.zym");
1031 //precache_model("models/player/nexus.zym");
1032 //precache_model("models/player/pyria.zym");
1033 //precache_model("models/player/shock.zym");
1034 //precache_model("models/player/skadi.zym");
1035 //precache_model("models/player/specop.zym");
1036 //precache_model("models/player/visitant.zym");
1041 precache_sound ("misc/footstep01.wav");
1042 precache_sound ("misc/footstep02.wav");
1043 precache_sound ("misc/footstep03.wav");
1044 precache_sound ("misc/footstep04.wav");
1045 precache_sound ("misc/footstep05.wav");
1046 precache_sound ("misc/footstep06.wav");
1049 // gore and miscellaneous sounds
1050 //precache_sound ("misc/h2ohit.wav");
1051 precache_model ("models/gibs/bloodyskull.md3");
1052 precache_model ("models/gibs/chunk.mdl");
1053 precache_model ("models/gibs/eye.md3");
1054 precache_model ("models/gibs/gib1.md3");
1055 precache_model ("models/gibs/gib2.md3");
1056 precache_model ("models/gibs/gib3.md3");
1057 precache_model ("models/gibs/gib4.md3");
1058 precache_model ("models/gibs/gib5.md3");
1059 precache_model ("models/gibs/gib6.md3");
1060 precache_model ("models/gibs/smallchest.md3");
1061 precache_model ("models/gibs/chest.md3");
1062 precache_model ("models/gibs/arm.md3");
1063 precache_model ("models/gibs/leg1.md3");
1064 precache_model ("models/gibs/leg2.md3");
1065 precache_model ("models/hook.md3");
1066 precache_sound ("misc/armorimpact.wav");
1067 precache_sound ("misc/bodyimpact1.wav");
1068 precache_sound ("misc/bodyimpact2.wav");
1069 precache_sound ("misc/gib.wav");
1070 precache_sound ("misc/gib_splat01.wav");
1071 precache_sound ("misc/gib_splat02.wav");
1072 precache_sound ("misc/gib_splat03.wav");
1073 precache_sound ("misc/gib_splat04.wav");
1074 precache_sound ("misc/hit.wav");
1075 precache_sound ("misc/hitground1.wav");
1076 precache_sound ("misc/hitground2.wav");
1077 precache_sound ("misc/hitground3.wav");
1078 precache_sound ("misc/hitground4.wav");
1079 precache_sound ("misc/null.wav");
1080 precache_sound ("misc/spawn.wav");
1081 precache_sound ("misc/talk.wav");
1082 precache_sound ("misc/teleport.wav");
1083 precache_sound ("player/lava.wav");
1084 precache_sound ("player/slime.wav");
1086 // announcer sounds - male
1087 //precache_sound ("announcer/male/electrobitch.wav");
1088 precache_sound ("announcer/male/03kills.wav");
1089 precache_sound ("announcer/male/05kills.wav");
1090 precache_sound ("announcer/male/10kills.wav");
1091 precache_sound ("announcer/male/15kills.wav");
1092 precache_sound ("announcer/male/20kills.wav");
1093 precache_sound ("announcer/male/25kills.wav");
1094 precache_sound ("announcer/male/30kills.wav");
1095 precache_sound ("announcer/male/botlike.wav");
1096 precache_sound ("announcer/male/yoda.wav");
1098 // announcer sounds - robotic
1099 precache_sound ("announcer/robotic/prepareforbattle.wav");
1100 precache_sound ("announcer/robotic/begin.wav");
1101 precache_sound ("announcer/robotic/timeoutcalled.wav");
1102 precache_sound ("announcer/robotic/1fragleft.wav");
1103 precache_sound ("announcer/robotic/1minuteremains.wav");
1104 precache_sound ("announcer/robotic/2fragsleft.wav");
1105 precache_sound ("announcer/robotic/3fragsleft.wav");
1108 precache_sound ("announcer/robotic/lastsecond.wav");
1109 precache_sound ("announcer/robotic/narrowly.wav");
1112 precache_model ("models/sprites/1.spr32");
1113 precache_model ("models/sprites/2.spr32");
1114 precache_model ("models/sprites/3.spr32");
1115 precache_model ("models/sprites/4.spr32");
1116 precache_model ("models/sprites/5.spr32");
1117 precache_model ("models/sprites/6.spr32");
1118 precache_model ("models/sprites/7.spr32");
1119 precache_model ("models/sprites/8.spr32");
1120 precache_model ("models/sprites/9.spr32");
1121 precache_model ("models/sprites/10.spr32");
1122 precache_sound ("announcer/robotic/1.ogg");
1123 precache_sound ("announcer/robotic/2.ogg");
1124 precache_sound ("announcer/robotic/3.ogg");
1125 precache_sound ("announcer/robotic/4.ogg");
1126 precache_sound ("announcer/robotic/5.ogg");
1127 precache_sound ("announcer/robotic/6.ogg");
1128 precache_sound ("announcer/robotic/7.ogg");
1129 precache_sound ("announcer/robotic/8.ogg");
1130 precache_sound ("announcer/robotic/9.ogg");
1131 precache_sound ("announcer/robotic/10.ogg");
1133 // common weapon precaches
1134 precache_sound ("weapons/weapon_switch.wav");
1135 precache_sound ("weapons/weaponpickup.wav");
1136 if (cvar("g_grappling_hook"))
1138 precache_sound ("weapons/hook_fire.wav"); // hook
1139 precache_sound ("weapons/hook_impact.wav"); // hook
1142 if (cvar("sv_precacheweapons") || g_nixnex)
1144 //precache weapon models/sounds
1147 while (wep <= WEP_LAST)
1149 weapon_action(wep, WR_PRECACHE);
1154 // plays music for the level if there is any
1157 precache_sound (self.noise);
1158 ambientsound ('0 0 0', self.noise, 1.00, ATTN_NONE);