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 ("misc/itemrespawn.wav");
149 // plays music for the level if there is any
152 precache_sound (self.noise);
153 ambientsound ('0 0 0', self.noise, 1.00, ATTN_NONE);
159 // 1 FLICKER (first variety)
160 lightstyle(1, "mmnmmommommnonmmonqnmmo");
162 // 2 SLOW STRONG PULSE
163 lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
165 // 3 CANDLE (first variety)
166 lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
169 lightstyle(4, "mamamamamama");
172 lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
174 // 6 FLICKER (second variety)
175 lightstyle(6, "nmonqnmomnmomomno");
177 // 7 CANDLE (second variety)
178 lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
180 // 8 CANDLE (third variety)
181 lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
183 // 9 SLOW STROBE (fourth variety)
184 lightstyle(9, "aaaaaaaazzzzzzzz");
186 // 10 FLUORESCENT FLICKER
187 lightstyle(10, "mmamammmmammamamaaamammma");
189 // 11 SLOW PULSE NOT FADE TO BLACK
190 lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
192 // styles 32-62 are assigned by the light program for switchable lights
197 if (cvar("g_domination"))
207 // reads and alters data/maplist.cfg (sliding it one line), and returns a
208 // strzoned string containing the next map
209 #define MAPLIST "maplist.cfg"
210 string() Nex_RotateMapList =
213 local string lNextMap;
214 local string lCurrentMap;
215 local string lBuffer;
217 lHandle = fopen( MAPLIST, FILE_READ );
220 // restart the current map if no other map is not found
221 return strzone( mapname );
224 // get the first line that will be moved to the end later
225 lCurrentMap = strzone( fgets( lHandle ) );
228 // restart the current map if no other map is not found
229 return strzone( mapname );
232 // now get the second line which is the map that should be loaded next
233 lBuffer = fgets( lHandle );
234 // if there isnt a second line, nothing needs to be rotated
237 strunzone( lCurrentMap );
238 // restart the current map if no other map is not found
239 return strzone( mapname );
242 // since lBuffer holds the next map, it is assigned to nextmap
243 lNextMap = strzone( lBuffer );
245 // since fgets uses its own buffer we need to move lBuffer to a tempstring
246 // before reading the next line (or lBuffer will be lost)
247 lBuffer = strcat( lBuffer );
249 // read in the rest of the list
253 lLine = fgets( lHandle );
258 lBuffer = strcat( lBuffer, "\n", lLine );
261 lBuffer = strcat( lBuffer, "\n", lCurrentMap );
263 // dismiss lCurrentmap now
264 strunzone( lCurrentMap );
266 // and close the file handle
269 // open the maplist for output this one
270 lHandle = fopen( MAPLIST, FILE_WRITE );
272 // this shouldnt happen!
273 // print a warning/error message
274 dprint( "Couldn't open ", MAPLIST, " for output!\n" );
276 strunzone( lNextMap );
278 // we return the currently running map
279 return strzone( mapname );
282 fputs( lHandle, lBuffer );
291 float intermission_running;
292 float intermission_exittime;
293 float alreadychangedlevel;
297 local string nextmap;
298 local float n, nummaps;
300 if (alreadychangedlevel)
302 alreadychangedlevel = TRUE;
303 if (cvar("samelevel")) // if samelevel is set, stay on same level
304 changelevel (mapname);
313 // restart current map if no cycle is found
315 fh = fopen("maplist.cfg", FILE_READ);
334 changelevel (nextmap);
337 //nextmap = Nex_RotateMapList();
338 //changelevel (nextmap);
339 //strunzone (nextmap);
341 s = cvar_string("g_maplist");
342 nummaps = tokenize(s);
343 // if no map list, restart current one
350 if (argv(n) == mapname)
359 changelevel (nextmap);
368 When the player presses attack or jump, change to the next level
371 void() IntermissionThink =
373 if (time < intermission_exittime)
376 if (time < intermission_exittime + 10 && !self.button0 && !self.button1 && !self.button2 && !self.button3)
386 Returns the entity to view from
390 entity() FindIntermission =
395 // look for info_intermission first
396 spot = find (world, classname, "info_intermission");
398 { // pick a random one
402 spot = find (spot, classname, "info_intermission");
404 spot = find (spot, classname, "info_intermission");
410 // then look for the start position
411 spot = find (world, classname, "info_player_start");
415 // testinfo_player_start is only found in regioned levels
416 spot = find (world, classname, "testplayerstart");
420 // then look for the start position
421 spot = find (world, classname, "info_player_deathmatch");
425 //objerror ("FindIntermission: no spot");
431 ===============================================================================
435 ===============================================================================
439 go to the next level for deathmatch
440 only called if a time or frag limit has expired
446 intermission_running = 1;
448 // enforce a wait time before allowing changelevel
449 intermission_exittime = time + 5;
451 WriteByte (MSG_ALL, SVC_CDTRACK);
452 WriteByte (MSG_ALL, 3);
453 WriteByte (MSG_ALL, 3);
455 //pos = FindIntermission ();
457 other = find (world, classname, "player");
458 while (other != world)
460 //other.nextthink = time + 0.5;
461 other.takedamage = DAMAGE_NO;
462 other.solid = SOLID_NOT;
463 other.movetype = MOVETYPE_NONE;
464 other.angles = other.v_angle;
465 other.angles_x = other.angles_x * -1;
469 other.modelindex = 0;
470 other.weaponentity = world; // remove weapon model
471 other.view_ofs = '0 0 0';
472 other.angles = other.v_angle = pos.mangle;
475 other.angles = other.v_angle = pos.angles;
476 other.v_angle_x = other.v_angle_x * -1;
478 other.fixangle = TRUE; // turn this way immediately
479 setorigin (other, pos.origin);
482 other = find (other, classname, "player");
485 WriteByte (MSG_ALL, SVC_INTERMISSION);
492 Exit deathmatch games upon conditions
497 local float timelimit;
498 local float fraglimit;
500 if (intermission_running)
501 if (time >= intermission_exittime + 60)
507 if (gameover) // someone else quit the game already
510 timelimit = cvar("timelimit") * 60;
511 fraglimit = cvar("fraglimit");
513 if (timelimit && time >= timelimit)
519 if (fraglimit && self.frags >= fraglimit)