10 game = cvar ("gamecfg"); // load game options
12 precache_model ("models/misc/chatbubble.spr");
14 precache_model ("models/weapons/g_shotgun.md3");
15 precache_model ("models/weapons/g_uzi.md3");
16 precache_model ("models/weapons/g_gl.md3");
17 precache_model ("models/weapons/g_electro.md3");
18 precache_model ("models/weapons/g_crylink.md3");
19 precache_model ("models/weapons/g_nex.md3");
20 precache_model ("models/weapons/g_hagar.md3");
21 precache_model ("models/weapons/g_rl.md3");
23 precache_model ("models/weapons/v_laser.md3");
24 precache_model ("models/weapons/v_shotgun.md3");
25 precache_model ("models/weapons/v_uzi.md3");
26 precache_model ("models/weapons/v_gl.md3");
27 precache_model ("models/weapons/v_electro.md3");
28 precache_model ("models/weapons/v_crylink.md3");
29 precache_model ("models/weapons/v_nex.md3");
30 precache_model ("models/weapons/v_hagar.md3");
31 precache_model ("models/weapons/v_rl.md3");
33 precache_model ("models/sprites/plasmahitwall.spr32");
34 precache_model ("models/sprites/muzzleflash.spr32");
35 precache_model ("models/sprites/plasmashot.spr32");
36 precache_model ("models/sprites/dpexplosion1.spr32");
37 precache_model ("models/sprites/dpexplosion2.spr32");
39 precache_model ("models/grenademodel.md3");
40 precache_model ("models/hagarmissile.mdl");
41 precache_model ("models/rocket.md3");
42 precache_model ("models/bullet.mdl");
43 precache_model ("models/casing_bronze.mdl");
44 precache_model ("models/casing_shell.mdl");
45 precache_model ("models/casing_steel.mdl");
46 precache_model ("models/beam.mdl");
47 precache_model ("models/flash.md3");
48 precache_model ("models/nexflash.md3");
49 precache_model ("models/laser.mdl");
50 precache_model ("models/elaser.mdl");
51 precache_model ("models/ebomb.mdl");
52 precache_model ("models/plasma.mdl");
53 precache_model ("models/plasmatrail.mdl");
54 precache_model ("models/tracer.mdl");
56 precache_model ("models/items/g_h1.md3");
57 precache_model ("models/items/g_h25.md3");
58 precache_model ("models/items/g_h100.md3");
60 precache_model ("models/items/g_a1.md3");
61 precache_model ("models/items/g_a25.md3");
63 precache_model ("models/weapons/w_uzi.zym");
64 precache_model ("models/weapons/w_laser.zym");
65 precache_model ("models/weapons/w_shotgun.zym");
66 precache_model ("models/weapons/w_gl.zym");
67 precache_model ("models/weapons/w_electro.zym");
68 precache_model ("models/weapons/w_crylink.zym");
69 precache_model ("models/weapons/w_nex.zym");
70 precache_model ("models/weapons/w_hagar.zym");
71 precache_model ("models/weapons/w_rl.zym");
73 precache_model ("models/items/a_shells.md3");
74 precache_model ("models/items/a_cells.md3");
75 precache_model ("models/items/a_rockets.md3");
76 precache_model ("models/items/a_bullets.mdl");
78 precache_model ("models/items/g_strength.md3");
79 precache_model ("models/items/g_invincible.md3");
81 precache_model ("models/gibs/eye.md3");
82 precache_model ("models/gibs/gib1.md3");
83 precache_model ("models/gibs/gib2.md3");
84 precache_model ("models/gibs/gib3.md3");
85 precache_model ("models/gibs/gib4.md3");
86 precache_model ("models/gibs/gib5.md3");
87 precache_model ("models/gibs/gib6.md3");
88 precache_model ("models/gibs/chunk.mdl");
89 precache_model ("models/gibs/bloodyskull.md3");
91 precache_sound ("weapons/lasergun_fire.wav");
92 precache_sound ("weapons/laserimpact.wav");
93 precache_sound ("weapons/uzi_fire.wav");
94 precache_sound ("weapons/shotgun_fire.wav");
95 precache_sound ("weapons/grenade_fire.wav");
96 precache_sound ("weapons/grenade_impact.wav");
97 precache_sound ("weapons/grenade_bounce.wav");
98 precache_sound ("weapons/nexfire.wav");
99 precache_sound ("weapons/neximpact.wav");
100 precache_sound ("weapons/electro_fire.wav");
101 precache_sound ("weapons/electro_fly.wav");
102 precache_sound ("weapons/missile_fly.wav");
103 precache_sound ("weapons/rocket_fire.wav");
104 precache_sound ("weapons/rocket_impact.wav");
105 precache_sound ("weapons/hagar_fire.wav");
106 precache_sound ("weapons/hagar_fire2.wav");
107 precache_sound ("weapons/hagexp1.wav");
108 precache_sound ("weapons/hagexp2.wav");
109 precache_sound ("weapons/hagexp3.wav");
110 precache_sound ("weapons/ric1.wav");
111 precache_sound ("weapons/ric2.wav");
112 precache_sound ("weapons/ric3.wav");
113 precache_sound ("weapons/weaponpickup.wav");
114 precache_sound ("weapons/crylink.wav");
115 precache_sound ("weapons/crylink2.wav");
116 precache_sound ("weapons/plasmahit.wav");
117 precache_sound ("weapons/uzi_fire_secondary.wav");
118 precache_sound ("weapons/tink1.wav");
119 precache_sound ("weapons/weapon_switch.wav");
121 precache_sound ("misc/itempickup.wav");
122 precache_sound ("misc/bodyimpact1.wav");
123 precache_sound ("misc/bodyimpact2.wav");
124 precache_sound ("misc/armorimpact.wav");
125 precache_sound ("misc/hit.wav");
126 precache_sound ("misc/teleport.wav");
127 precache_sound ("misc/megahealth.wav");
128 precache_sound ("misc/mediumhealth.wav");
129 precache_sound ("misc/gib.wav");
130 precache_sound ("misc/jumppad.wav");
131 precache_sound ("misc/hitground1.wav");
132 precache_sound ("misc/hitground2.wav");
133 precache_sound ("misc/hitground3.wav");
134 precache_sound ("misc/hitground4.wav");
135 precache_sound ("misc/talk.wav");
136 precache_sound ("misc/gib_splat01.wav");
137 precache_sound ("misc/gib_splat02.wav");
138 precache_sound ("misc/gib_splat03.wav");
139 precache_sound ("misc/gib_splat04.wav");
140 precache_sound ("misc/powerup.wav");
141 precache_sound ("misc/h20hit1.wav");
143 precache_sound ("player/slime.wav");
144 precache_sound ("player/lava.wav");
146 precache_sound ("announcer/1fragleft.wav");
147 precache_sound ("announcer/2fragsleft.wav");
148 precache_sound ("announcer/3fragsleft.wav");
149 precache_sound ("announcer/1minuteremains.wav");
150 precache_sound ("announcer/firstblood.wav");
152 precache_sound ("misc/itemrespawn.wav");
155 // plays music for the level if there is any
158 precache_sound (self.noise);
159 ambientsound ('0 0 0', self.noise, 1.00, ATTN_NONE);
165 // 1 FLICKER (first variety)
166 lightstyle(1, "mmnmmommommnonmmonqnmmo");
168 // 2 SLOW STRONG PULSE
169 lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
171 // 3 CANDLE (first variety)
172 lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
175 lightstyle(4, "mamamamamama");
178 lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
180 // 6 FLICKER (second variety)
181 lightstyle(6, "nmonqnmomnmomomno");
183 // 7 CANDLE (second variety)
184 lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
186 // 8 CANDLE (third variety)
187 lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
189 // 9 SLOW STROBE (fourth variety)
190 lightstyle(9, "aaaaaaaazzzzzzzz");
192 // 10 FLUORESCENT FLICKER
193 lightstyle(10, "mmamammmmammamamaaamammma");
195 // 11 SLOW PULSE NOT FADE TO BLACK
196 lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
198 // styles 32-62 are assigned by the light program for switchable lights
203 if (cvar("g_domination"))
213 // reads and alters data/maplist.cfg (sliding it one line), and returns a
214 // strzoned string containing the next map
215 #define MAPLIST "maplist.cfg"
216 string() Nex_RotateMapList =
219 local string lNextMap;
220 local string lCurrentMap;
221 local string lBuffer;
223 lHandle = fopen( MAPLIST, FILE_READ );
226 // restart the current map if no other map is not found
227 return strzone( mapname );
230 // get the first line that will be moved to the end later
231 lCurrentMap = strzone( fgets( lHandle ) );
234 // restart the current map if no other map is not found
235 return strzone( mapname );
238 // now get the second line which is the map that should be loaded next
239 lBuffer = fgets( lHandle );
240 // if there isnt a second line, nothing needs to be rotated
243 strunzone( lCurrentMap );
244 // restart the current map if no other map is not found
245 return strzone( mapname );
248 // since lBuffer holds the next map, it is assigned to nextmap
249 lNextMap = strzone( lBuffer );
251 // since fgets uses its own buffer we need to move lBuffer to a tempstring
252 // before reading the next line (or lBuffer will be lost)
253 lBuffer = strcat( lBuffer );
255 // read in the rest of the list
259 lLine = fgets( lHandle );
264 lBuffer = strcat( lBuffer, "\n", lLine );
267 lBuffer = strcat( lBuffer, "\n", lCurrentMap );
269 // dismiss lCurrentmap now
270 strunzone( lCurrentMap );
272 // and close the file handle
275 // open the maplist for output this one
276 lHandle = fopen( MAPLIST, FILE_WRITE );
278 // this shouldnt happen!
279 // print a warning/error message
280 dprint( "Couldn't open ", MAPLIST, " for output!\n" );
282 strunzone( lNextMap );
284 // we return the currently running map
285 return strzone( mapname );
288 fputs( lHandle, lBuffer );
296 float intermission_running;
297 float intermission_exittime;
298 float alreadychangedlevel;
303 local string nextmap;
304 //local float n, nummaps;
306 if (alreadychangedlevel)
308 alreadychangedlevel = TRUE;
309 if (cvar("samelevel")) // if samelevel is set, stay on same level
310 changelevel (mapname);
319 // restart current map if no cycle is found
321 fh = fopen("maplist.cfg", FILE_READ);
340 changelevel (nextmap);
343 //nextmap = Nex_RotateMapList();
344 //changelevel (nextmap);
345 //strunzone (nextmap);
348 s = cvar_string("g_maplist");
349 nummaps = tokenize(s);
350 // if no map list, restart current one
357 if (argv(n) == mapname)
366 changelevel (nextmap);
376 When the player presses attack or jump, change to the next level
379 void() IntermissionThink =
381 if (time < intermission_exittime)
384 if (time < intermission_exittime + 10 && !self.button0 && !self.button1 && !self.button2 && !self.button3)
394 Returns the entity to view from
398 entity() FindIntermission =
403 // look for info_intermission first
404 spot = find (world, classname, "info_intermission");
406 { // pick a random one
410 spot = find (spot, classname, "info_intermission");
412 spot = find (spot, classname, "info_intermission");
418 // then look for the start position
419 spot = find (world, classname, "info_player_start");
423 // testinfo_player_start is only found in regioned levels
424 spot = find (world, classname, "testplayerstart");
428 // then look for the start position
429 spot = find (world, classname, "info_player_deathmatch");
433 //objerror ("FindIntermission: no spot");
439 ===============================================================================
443 ===============================================================================
447 go to the next level for deathmatch
448 only called if a time or frag limit has expired
454 intermission_running = 1;
456 // enforce a wait time before allowing changelevel
457 intermission_exittime = time + 5;
459 WriteByte (MSG_ALL, SVC_CDTRACK);
460 WriteByte (MSG_ALL, 3);
461 WriteByte (MSG_ALL, 3);
463 //pos = FindIntermission ();
465 other = find (world, classname, "player");
466 while (other != world)
468 //other.nextthink = time + 0.5;
469 other.takedamage = DAMAGE_NO;
470 other.solid = SOLID_NOT;
471 other.movetype = MOVETYPE_NONE;
472 other.angles = other.v_angle;
473 other.angles_x = other.angles_x * -1;
477 other.modelindex = 0;
478 other.weaponentity = world; // remove weapon model
479 other.view_ofs = '0 0 0';
480 other.angles = other.v_angle = pos.mangle;
483 other.angles = other.v_angle = pos.angles;
484 other.v_angle_x = other.v_angle_x * -1;
486 other.fixangle = TRUE; // turn this way immediately
487 setorigin (other, pos.origin);
490 other = find (other, classname, "player");
493 WriteByte (MSG_ALL, SVC_INTERMISSION);
500 Exit deathmatch games upon conditions
503 void() CheckRules_Player =
505 local float fraglimit;
507 if (gameover) // someone else quit the game already
510 fraglimit = cvar("fraglimit");
511 if (fraglimit && self.frags >= fraglimit)
518 float checkrules_oneminutewarning;
519 float checkrules_leaderfrags;
520 entity checkrules_leader;
526 Exit deathmatch games upon conditions
529 void() CheckRules_World =
531 local float timelimit;
532 local float fraglimit;
533 local float checkrules_oldleaderfrags;
534 local entity checkrules_oldleader;
537 if (intermission_running)
538 if (time >= intermission_exittime + 60)
544 if (gameover) // someone else quit the game already
547 timelimit = cvar("timelimit") * 60;
548 fraglimit = cvar("fraglimit");
550 if (timelimit && time >= timelimit)
556 if (!checkrules_oneminutewarning && timelimit && time > timelimit - 60)
558 checkrules_oneminutewarning = TRUE;
559 sound(world, CHAN_AUTO, "announcer/1minuteremains.wav", 1, ATTN_NONE);
562 checkrules_oldleader = checkrules_leader;
563 checkrules_oldleaderfrags = checkrules_leaderfrags;
564 checkrules_leaderfrags = 0;
565 checkrules_leader = world;
566 head = findchain(classname, "player");
569 if (checkrules_leaderfrags < head.frags)
571 checkrules_leaderfrags = head.frags;
572 checkrules_leader = head;
576 if (checkrules_leaderfrags <= 0)
578 checkrules_leader = world;
579 checkrules_leaderfrags = 0;
581 checkrules_leaderfrags = floor(checkrules_leaderfrags);
582 if (checkrules_leaderfrags != checkrules_oldleaderfrags)
584 if (checkrules_leaderfrags == fraglimit - 1)
585 sound(world, CHAN_AUTO, "announcer/1fragleft.wav", 1, ATTN_NONE);
586 else if (checkrules_leaderfrags == fraglimit - 2)
587 sound(world, CHAN_AUTO, "announcer/2fragsleft.wav", 1, ATTN_NONE);
588 else if (checkrules_leaderfrags == fraglimit - 3)
589 sound(world, CHAN_AUTO, "announcer/3fragsleft.wav", 1, ATTN_NONE);
591 if (checkrules_leader != checkrules_oldleader && checkrules_leaderfrags > checkrules_oldleaderfrags)
592 bprint(checkrules_leader.netname, " has taken the lead with ", ftos(checkrules_leaderfrags), " frags\n");