7 game = cvar ("gamecfg"); // load game options
9 //precache_model ("progs/beam.mdl");
10 precache_model ("models/bullet.mdl");
11 precache_model ("models/casing_bronze.mdl");
12 precache_model ("models/casing_shell.mdl");
13 precache_model ("models/casing_steel.mdl");
14 precache_model ("models/ebomb.mdl");
15 precache_model ("models/elaser.mdl");
16 precache_model ("models/flash.md3");
17 precache_model ("models/gibs/bloodyskull.md3");
18 precache_model ("models/gibs/chunk.mdl");
19 precache_model ("models/gibs/eye.md3");
20 precache_model ("models/gibs/gib1.md3");
21 precache_model ("models/gibs/gib2.md3");
22 precache_model ("models/gibs/gib3.md3");
23 precache_model ("models/gibs/gib4.md3");
24 precache_model ("models/gibs/gib5.md3");
25 precache_model ("models/gibs/gib6.md3");
26 precache_model ("models/grenademodel.md3");
27 precache_model ("models/hagarmissile.mdl");
28 precache_model ("models/items/a_bullets.mdl");
29 precache_model ("models/items/a_cells.md3");
30 precache_model ("models/items/a_rockets.md3");
31 precache_model ("models/items/a_shells.md3");
32 precache_model ("models/items/g_a1.md3");
33 precache_model ("models/items/g_a25.md3");
34 precache_model ("models/items/g_h1.md3");
35 precache_model ("models/items/g_h25.md3");
36 precache_model ("models/items/g_h100.md3");
37 precache_model ("models/items/g_invincible.md3");
38 precache_model ("models/items/g_strength.md3");
39 precache_model ("models/laser.mdl");
40 precache_model ("models/misc/chatbubble.spr");
41 precache_model ("models/nexflash.md3");
42 precache_model ("models/plasma.mdl");
43 precache_model ("models/plasmatrail.mdl");
44 precache_model ("models/rocket.md3");
45 precache_model ("models/sprites/grenadeexplosion.spr32");
46 precache_model ("models/sprites/hagarexplosion.spr32");
47 precache_model ("models/sprites/muzzleflash.spr32");
48 //precache_model ("models/sprites/plasmahitwall.spr32");
49 //precache_model ("models/sprites/plasmashot.spr32");
50 precache_model ("models/sprites/rocketexplosion.spr32");
51 precache_model ("models/tracer.mdl");
52 precache_model ("models/uziflash.md3");
53 precache_model ("models/weapons/g_crylink.md3");
54 precache_model ("models/weapons/g_electro.md3");
55 precache_model ("models/weapons/g_gl.md3");
56 precache_model ("models/weapons/g_hagar.md3");
57 precache_model ("models/weapons/g_nex.md3");
58 precache_model ("models/weapons/g_rl.md3");
59 precache_model ("models/weapons/g_shotgun.md3");
60 precache_model ("models/weapons/g_uzi.md3");
61 precache_model ("models/weapons/v_crylink.md3");
62 precache_model ("models/weapons/v_electro.md3");
63 precache_model ("models/weapons/v_gl.md3");
64 precache_model ("models/weapons/v_hagar.md3");
65 precache_model ("models/weapons/v_laser.md3");
66 precache_model ("models/weapons/v_nex.md3");
67 precache_model ("models/weapons/v_rl.md3");
68 precache_model ("models/weapons/v_shotgun.md3");
69 precache_model ("models/weapons/v_uzi.md3");
70 precache_model ("models/weapons/w_crylink.zym");
71 precache_model ("models/weapons/w_electro.zym");
72 precache_model ("models/weapons/w_gl.zym");
73 precache_model ("models/weapons/w_hagar.zym");
74 precache_model ("models/weapons/w_laser.zym");
75 precache_model ("models/weapons/w_nex.zym");
76 precache_model ("models/weapons/w_rl.zym");
77 precache_model ("models/weapons/w_shotgun.zym");
78 precache_model ("models/weapons/w_uzi.zym");
79 precache_sound ("announcer/1fragleft.wav");
80 precache_sound ("announcer/1minuteremains.wav");
81 precache_sound ("announcer/2fragsleft.wav");
82 precache_sound ("announcer/3fragsleft.wav");
83 precache_sound ("announcer/welcometonexuiz.wav");
84 precache_sound ("misc/armor1.wav");
85 precache_sound ("misc/armor25.wav");
86 precache_sound ("misc/armorimpact.wav");
87 precache_sound ("misc/bodyimpact1.wav");
88 precache_sound ("misc/bodyimpact2.wav");
89 precache_sound ("misc/gib.wav");
90 precache_sound ("misc/gib_splat01.wav");
91 precache_sound ("misc/gib_splat02.wav");
92 precache_sound ("misc/gib_splat03.wav");
93 precache_sound ("misc/gib_splat04.wav");
94 //precache_sound ("misc/h2ohit.wav");
95 precache_sound ("misc/hit.wav");
96 precache_sound ("misc/hitground1.wav");
97 precache_sound ("misc/hitground2.wav");
98 precache_sound ("misc/hitground3.wav");
99 precache_sound ("misc/hitground4.wav");
100 precache_sound ("misc/itempickup.wav");
101 precache_sound ("misc/itemrespawn.wav");
102 precache_sound ("misc/jumppad.wav");
103 precache_sound ("misc/mediumhealth.wav");
104 precache_sound ("misc/megahealth.wav");
105 precache_sound ("misc/minihealth.wav");
106 precache_sound ("misc/powerup.wav");
107 precache_sound ("misc/talk.wav");
108 precache_sound ("misc/teleport.wav");
109 precache_sound ("plats/medplat1.wav");
110 precache_sound ("plats/medplat2.wav");
111 precache_sound ("player/lava.wav");
112 precache_sound ("player/slime.wav");
113 precache_sound ("weapons/crylink.wav");
114 precache_sound ("weapons/crylink2.wav");
115 precache_sound ("weapons/electro_fire.wav");
116 precache_sound ("weapons/electro_fly.wav");
117 precache_sound ("weapons/electro_impact.wav");
118 precache_sound ("weapons/grenade_bounce.wav");
119 precache_sound ("weapons/grenade_fire.wav");
120 precache_sound ("weapons/grenade_impact.wav");
121 precache_sound ("weapons/hagar_fire.wav");
122 precache_sound ("weapons/hagexp1.wav");
123 precache_sound ("weapons/hagexp2.wav");
124 precache_sound ("weapons/hagexp3.wav");
125 precache_sound ("weapons/lasergun_fire.wav");
126 precache_sound ("weapons/laserimpact.wav");
127 precache_sound ("weapons/nexfire.wav");
128 precache_sound ("weapons/neximpact.wav");
129 precache_sound ("weapons/ric1.wav");
130 precache_sound ("weapons/ric2.wav");
131 precache_sound ("weapons/ric3.wav");
132 precache_sound ("weapons/rocket_fire.wav");
133 precache_sound ("weapons/rocket_fly.wav");
134 precache_sound ("weapons/rocket_impact.wav");
135 precache_sound ("weapons/shotgun_fire.wav");
136 precache_sound ("weapons/tink1.wav");
137 precache_sound ("weapons/uzi_fire.wav");
138 precache_sound ("weapons/weapon_switch.wav");
139 precache_sound ("weapons/weaponpickup.wav");
143 // plays music for the level if there is any
146 precache_sound (self.noise);
147 ambientsound ('0 0 0', self.noise, 1.00, ATTN_NONE);
153 // 1 FLICKER (first variety)
154 lightstyle(1, "mmnmmommommnonmmonqnmmo");
156 // 2 SLOW STRONG PULSE
157 lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
159 // 3 CANDLE (first variety)
160 lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
163 lightstyle(4, "mamamamamama");
166 lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
168 // 6 FLICKER (second variety)
169 lightstyle(6, "nmonqnmomnmomomno");
171 // 7 CANDLE (second variety)
172 lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
174 // 8 CANDLE (third variety)
175 lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
177 // 9 SLOW STROBE (fourth variety)
178 lightstyle(9, "aaaaaaaazzzzzzzz");
180 // 10 FLUORESCENT FLICKER
181 lightstyle(10, "mmamammmmammamamaaamammma");
183 // 11 SLOW PULSE NOT FADE TO BLACK
184 lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
186 // styles 32-62 are assigned by the light program for switchable lights
191 if (cvar("g_domination"))
201 // reads and alters data/maplist.cfg (sliding it one line), and returns a
202 // strzoned string containing the next map
203 #define MAPLIST "maplist.cfg"
204 string() Nex_RotateMapList =
207 local string lNextMap;
208 local string lCurrentMap;
209 local string lBuffer;
211 lHandle = fopen( MAPLIST, FILE_READ );
214 // restart the current map if no other map is not found
215 return strzone( mapname );
218 // get the first line that will be moved to the end later
219 lCurrentMap = strzone( fgets( lHandle ) );
222 // restart the current map if no other map is not found
223 return strzone( mapname );
226 // now get the second line which is the map that should be loaded next
227 lBuffer = fgets( lHandle );
228 // if there isnt a second line, nothing needs to be rotated
231 strunzone( lCurrentMap );
232 // restart the current map if no other map is not found
233 return strzone( mapname );
236 // since lBuffer holds the next map, it is assigned to nextmap
237 lNextMap = strzone( lBuffer );
239 // since fgets uses its own buffer we need to move lBuffer to a tempstring
240 // before reading the next line (or lBuffer will be lost)
241 lBuffer = strcat( lBuffer );
243 // read in the rest of the list
247 lLine = fgets( lHandle );
252 lBuffer = strcat( lBuffer, "\n", lLine );
255 lBuffer = strcat( lBuffer, "\n", lCurrentMap );
257 // dismiss lCurrentmap now
258 strunzone( lCurrentMap );
260 // and close the file handle
263 // open the maplist for output this one
264 lHandle = fopen( MAPLIST, FILE_WRITE );
266 // this shouldnt happen!
267 // print a warning/error message
268 dprint( "Couldn't open ", MAPLIST, " for output!\n" );
270 strunzone( lNextMap );
272 // we return the currently running map
273 return strzone( mapname );
276 fputs( lHandle, lBuffer );
284 float intermission_running;
285 float intermission_exittime;
286 float alreadychangedlevel;
291 local string nextmap;
292 //local float n, nummaps;
294 if (alreadychangedlevel)
296 alreadychangedlevel = TRUE;
297 if (cvar("samelevel")) // if samelevel is set, stay on same level
298 changelevel (mapname);
307 // restart current map if no cycle is found
308 nextmap = strzone(mapname);
309 fh = fopen("maplist.cfg", FILE_READ);
315 if (nextmap == mapname)
318 nextmap = strzone(line);
328 nextmap = strzone(line);
334 changelevel (nextmap);
338 //nextmap = Nex_RotateMapList();
339 //changelevel (nextmap);
340 //strunzone (nextmap);
343 s = cvar_string("g_maplist");
344 nummaps = tokenize(s);
345 // if no map list, restart current one
352 if (argv(n) == mapname)
361 changelevel (nextmap);
371 When the player presses attack or jump, change to the next level
374 void() IntermissionThink =
376 if (time < intermission_exittime)
379 if (time < intermission_exittime + 10 && !self.button0 && !self.button1 && !self.button2 && !self.button3)
389 Returns the entity to view from
393 entity() FindIntermission =
398 // look for info_intermission first
399 spot = find (world, classname, "info_intermission");
401 { // pick a random one
405 spot = find (spot, classname, "info_intermission");
407 spot = find (spot, classname, "info_intermission");
413 // then look for the start position
414 spot = find (world, classname, "info_player_start");
418 // testinfo_player_start is only found in regioned levels
419 spot = find (world, classname, "testplayerstart");
423 // then look for the start position
424 spot = find (world, classname, "info_player_deathmatch");
428 //objerror ("FindIntermission: no spot");
434 ===============================================================================
438 ===============================================================================
442 go to the next level for deathmatch
443 only called if a time or frag limit has expired
449 intermission_running = 1;
451 // enforce a wait time before allowing changelevel
452 intermission_exittime = time + 5;
454 WriteByte (MSG_ALL, SVC_CDTRACK);
455 WriteByte (MSG_ALL, 3);
456 WriteByte (MSG_ALL, 3);
458 //pos = FindIntermission ();
460 other = find (world, classname, "player");
461 while (other != world)
463 //other.nextthink = time + 0.5;
464 other.takedamage = DAMAGE_NO;
465 other.solid = SOLID_NOT;
466 other.movetype = MOVETYPE_NONE;
467 other.angles = other.v_angle;
468 other.angles_x = other.angles_x * -1;
472 other.modelindex = 0;
473 other.weaponentity = world; // remove weapon model
474 other.view_ofs = '0 0 0';
475 other.angles = other.v_angle = pos.mangle;
478 other.angles = other.v_angle = pos.angles;
479 other.v_angle_x = other.v_angle_x * -1;
481 other.fixangle = TRUE; // turn this way immediately
482 setorigin (other, pos.origin);
485 other = find (other, classname, "player");
488 WriteByte (MSG_ALL, SVC_INTERMISSION);
495 Exit deathmatch games upon conditions
498 void() CheckRules_Player =
500 local float fraglimit;
502 if (gameover) // someone else quit the game already
505 fraglimit = cvar("fraglimit");
506 if (fraglimit && self.frags >= fraglimit)
513 float checkrules_oneminutewarning;
514 float checkrules_leaderfrags;
515 entity checkrules_leader;
521 Exit deathmatch games upon conditions
524 void() CheckRules_World =
526 local float timelimit;
527 local float fraglimit;
528 local float checkrules_oldleaderfrags;
529 local entity checkrules_oldleader;
532 if (intermission_running)
533 if (time >= intermission_exittime + 60)
539 if (gameover) // someone else quit the game already
542 timelimit = cvar("timelimit") * 60;
543 fraglimit = cvar("fraglimit");
545 if (timelimit && time >= timelimit)
551 if (!checkrules_oneminutewarning && timelimit && time > timelimit - 60)
553 checkrules_oneminutewarning = TRUE;
554 sound(world, CHAN_AUTO, "announcer/1minuteremains.wav", 1, ATTN_NONE);
557 checkrules_oldleader = checkrules_leader;
558 checkrules_oldleaderfrags = checkrules_leaderfrags;
559 checkrules_leaderfrags = 0;
560 checkrules_leader = world;
561 head = findchain(classname, "player");
564 if (checkrules_leaderfrags < head.frags)
566 checkrules_leaderfrags = head.frags;
567 checkrules_leader = head;
571 if (checkrules_leaderfrags <= 0)
573 checkrules_leader = world;
574 checkrules_leaderfrags = 0;
576 checkrules_leaderfrags = floor(checkrules_leaderfrags);
577 if (checkrules_leaderfrags != checkrules_oldleaderfrags)
579 if (checkrules_leaderfrags == fraglimit - 1)
580 sound(world, CHAN_AUTO, "announcer/1fragleft.wav", 1, ATTN_NONE);
581 else if (checkrules_leaderfrags == fraglimit - 2)
582 sound(world, CHAN_AUTO, "announcer/2fragsleft.wav", 1, ATTN_NONE);
583 else if (checkrules_leaderfrags == fraglimit - 3)
584 sound(world, CHAN_AUTO, "announcer/3fragsleft.wav", 1, ATTN_NONE);
586 // if (checkrules_leader != checkrules_oldleader)// && checkrules_leaderfrags > checkrules_oldleaderfrags)
587 // bprint("^1",checkrules_leader.netname, " has taken the lead with ", ftos(checkrules_leaderfrags), " frags\n");