10 game = cvar ("gamecfg"); // load game options
12 precache_model ("models/player/marine.zym");
13 precache_model ("models/player/specop.zym");
14 precache_model ("models/player/mulder.zym");
15 precache_model ("models/player/insurrectionist.zym");
16 precache_model ("models/player/fshock.zym");
17 //precache_model ("models/player/grunt.zym");
18 //precache_model ("models/player/pyria.zym");
19 precache_model ("models/player/lurk.zym");
20 precache_model ("models/player/visitant.zym");
21 precache_model ("models/player/headhunter.zym");
22 //precache_model ("models/player/jeandarc.zym");
23 precache_model ("models/player/robot.zym");
24 //precache_model ("models/player/lycanthrope.zym");
25 //precache_model ("models/player/shock.zym");
26 //precache_model ("models/player/carni.zym");
28 precache_model ("models/misc/chatbubble.spr");
30 precache_model ("models/weapons/g_shotgun.md3");
31 precache_model ("models/weapons/g_uzi.md3");
32 precache_model ("models/weapons/g_gl.md3");
33 precache_model ("models/weapons/g_electro.md3");
34 precache_model ("models/weapons/g_crylink.md3");
35 precache_model ("models/weapons/g_nex.md3");
36 precache_model ("models/weapons/g_hagar.md3");
37 precache_model ("models/weapons/g_rl.md3");
39 precache_model ("models/weapons/v_laser.md3");
40 precache_model ("models/weapons/v_shotgun.md3");
41 precache_model ("models/weapons/v_uzi.md3");
42 precache_model ("models/weapons/v_gl.md3");
43 precache_model ("models/weapons/v_electro.md3");
44 precache_model ("models/weapons/v_crylink.md3");
45 precache_model ("models/weapons/v_nex.md3");
46 precache_model ("models/weapons/v_hagar.md3");
47 precache_model ("models/weapons/v_rl.md3");
49 precache_model ("models/sprites/plasmahitwall.spr32");
50 precache_model ("models/sprites/muzzleflash.spr32");
51 precache_model ("models/sprites/plasmashot.spr32");
52 precache_model ("models/sprites/dpexplosion1.spr32");
53 precache_model ("models/sprites/dpexplosion2.spr32");
55 precache_model ("models/grenademodel.md3");
56 precache_model ("models/hagarmissile.mdl");
57 precache_model ("models/rocket.md3");
58 precache_model ("models/bullet.mdl");
59 precache_model ("models/casing_bronze.mdl");
60 precache_model ("models/casing_shell.mdl");
61 precache_model ("models/casing_steel.mdl");
62 precache_model ("models/beam.mdl");
63 precache_model ("models/flash.md3");
64 precache_model ("models/nexflash.md3");
65 precache_model ("models/laser.mdl");
66 precache_model ("models/elaser.mdl");
67 precache_model ("models/ebomb.mdl");
68 precache_model ("models/plasma.mdl");
69 precache_model ("models/plasmatrail.mdl");
70 precache_model ("models/tracer.mdl");
72 precache_model ("models/items/g_h1.md3");
73 precache_model ("models/items/g_h25.md3");
74 precache_model ("models/items/g_h100.md3");
76 precache_model ("models/items/g_a1.md3");
77 precache_model ("models/items/g_a25.md3");
79 precache_model ("models/weapons/w_uzi.zym");
80 precache_model ("models/weapons/w_laser.zym");
81 precache_model ("models/weapons/w_shotgun.zym");
82 precache_model ("models/weapons/w_gl.zym");
83 precache_model ("models/weapons/w_electro.zym");
84 precache_model ("models/weapons/w_crylink.zym");
85 precache_model ("models/weapons/w_nex.zym");
86 precache_model ("models/weapons/w_hagar.zym");
87 precache_model ("models/weapons/w_rl.zym");
89 precache_model ("models/items/a_shells.md3");
90 precache_model ("models/items/a_cells.md3");
91 precache_model ("models/items/a_rockets.md3");
92 precache_model ("models/items/a_bullets.mdl");
94 precache_model ("models/items/g_strength.md3");
95 precache_model ("models/items/g_invincible.md3");
97 precache_model ("models/gibs/eye.md3");
98 precache_model ("models/gibs/gib1.md3");
99 precache_model ("models/gibs/gib2.md3");
100 precache_model ("models/gibs/gib3.md3");
101 precache_model ("models/gibs/gib4.md3");
102 precache_model ("models/gibs/gib5.md3");
103 precache_model ("models/gibs/gib6.md3");
104 precache_model ("models/gibs/chunk.mdl");
105 precache_model ("models/gibs/bloodyskull.md3");
107 precache_sound ("weapons/lasergun_fire.wav");
108 precache_sound ("weapons/laserimpact.wav");
109 precache_sound ("weapons/uzi_fire.wav");
110 precache_sound ("weapons/shotgun_fire.wav");
111 precache_sound ("weapons/grenade_fire.wav");
112 precache_sound ("weapons/grenade_impact.wav");
113 precache_sound ("weapons/grenade_bounce.wav");
114 precache_sound ("weapons/nexfire.wav");
115 precache_sound ("weapons/neximpact.wav");
116 precache_sound ("weapons/electro_fire.wav");
117 precache_sound ("weapons/electro_fly.wav");
118 precache_sound ("weapons/missile_fly.wav");
119 precache_sound ("weapons/rocket_fire.wav");
120 precache_sound ("weapons/rocket_impact.wav");
121 precache_sound ("weapons/hagar_fire.wav");
122 precache_sound ("weapons/hagar_fire2.wav");
123 precache_sound ("weapons/hagexp1.wav");
124 precache_sound ("weapons/hagexp2.wav");
125 precache_sound ("weapons/hagexp3.wav");
126 precache_sound ("weapons/ric1.wav");
127 precache_sound ("weapons/ric2.wav");
128 precache_sound ("weapons/ric3.wav");
129 precache_sound ("weapons/weaponpickup.wav");
130 precache_sound ("weapons/crylink.wav");
131 precache_sound ("weapons/crylink2.wav");
132 precache_sound ("weapons/plasmahit.wav");
133 precache_sound ("weapons/uzi_fire_secondary.wav");
134 precache_sound ("weapons/tink1.wav");
135 precache_sound ("weapons/weapon_switch.wav");
137 precache_sound ("misc/itempickup.wav");
138 precache_sound ("misc/bodyimpact1.wav");
139 precache_sound ("misc/bodyimpact2.wav");
140 precache_sound ("misc/armorimpact.wav");
141 precache_sound ("misc/hit.wav");
142 precache_sound ("misc/teleport.wav");
143 precache_sound ("misc/megahealth.wav");
144 precache_sound ("misc/mediumhealth.wav");
145 precache_sound ("misc/gib.wav");
146 precache_sound ("misc/jumppad.wav");
147 precache_sound ("misc/hitground1.wav");
148 precache_sound ("misc/hitground2.wav");
149 precache_sound ("misc/hitground3.wav");
150 precache_sound ("misc/hitground4.wav");
151 precache_sound ("misc/talk.wav");
152 precache_sound ("misc/gib_splat01.wav");
153 precache_sound ("misc/gib_splat02.wav");
154 precache_sound ("misc/gib_splat03.wav");
155 precache_sound ("misc/gib_splat04.wav");
156 precache_sound ("misc/powerup.wav");
158 precache_sound ("misc/itemrespawn.wav");
161 // plays music for the level if there is any
164 precache_sound (self.noise);
165 ambientsound ('0 0 0', self.noise, 1.00, ATTN_NONE);
171 // 1 FLICKER (first variety)
172 lightstyle(1, "mmnmmommommnonmmonqnmmo");
174 // 2 SLOW STRONG PULSE
175 lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
177 // 3 CANDLE (first variety)
178 lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
181 lightstyle(4, "mamamamamama");
184 lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
186 // 6 FLICKER (second variety)
187 lightstyle(6, "nmonqnmomnmomomno");
189 // 7 CANDLE (second variety)
190 lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
192 // 8 CANDLE (third variety)
193 lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
195 // 9 SLOW STROBE (fourth variety)
196 lightstyle(9, "aaaaaaaazzzzzzzz");
198 // 10 FLUORESCENT FLICKER
199 lightstyle(10, "mmamammmmammamamaaamammma");
201 // 11 SLOW PULSE NOT FADE TO BLACK
202 lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
204 // styles 32-62 are assigned by the light program for switchable lights
209 if (cvar("g_domination"))
218 // reads and alters data/maplist.cfg (sliding it one line), and returns a
219 // strzoned string containing the next map
220 #define MAPLIST "maplist.cfg"
221 string() Nex_RotateMapList =
224 local string lNextMap;
225 local string lCurrentMap;
226 local string lBuffer;
228 lHandle = fopen( MAPLIST, FILE_READ );
231 // restart the current map if no other map is not found
232 return strzone( mapname );
235 // get the first line that will be moved to the end later
236 lCurrentMap = strzone( fgets( lHandle ) );
239 // restart the current map if no other map is not found
240 return strzone( mapname );
243 // now get the second line which is the map that should be loaded next
244 lBuffer = fgets( lHandle );
245 // if there isnt a second line, nothing needs to be rotated
248 strunzone( lCurrentMap );
249 // restart the current map if no other map is not found
250 return strzone( mapname );
253 // since lBuffer holds the next map, it is assigned to nextmap
254 lNextMap = strzone( lBuffer );
256 // since fgets uses its own buffer we need to move lBuffer to a tempstring
257 // before reading the next line (or lBuffer will be lost)
258 lBuffer = strcat( lBuffer );
260 // read in the rest of the list
264 lLine = fgets( lHandle );
269 lBuffer = strcat( lBuffer, "\n", lLine );
272 lBuffer = strcat( lBuffer, "\n", lCurrentMap );
274 // dismiss lCurrentmap now
275 strunzone( lCurrentMap );
277 // and close the file handle
280 // open the maplist for output this one
281 lHandle = fopen( MAPLIST, FILE_WRITE );
283 // this shouldnt happen!
284 // print a warning/error message
285 dprint( "Couldn't open ", MAPLIST, " for output!\n" );
287 strunzone( lNextMap );
289 // we return the currently running map
290 return strzone( mapname );
293 fputs( lHandle, lBuffer );
301 float intermission_running;
302 float intermission_exittime;
303 float alreadychangedlevel;
307 local string nextmap;
308 if (alreadychangedlevel)
310 alreadychangedlevel = TRUE;
311 if (cvar("samelevel")) // if samelevel is set, stay on same level
312 changelevel (mapname);
320 // restart current map if no cycle is found
322 fh = fopen("maplist.cfg", FILE_READ);
341 changelevel (nextmap);
344 nextmap = Nex_RotateMapList();
345 changelevel (nextmap);
355 When the player presses attack or jump, change to the next level
358 void() IntermissionThink =
360 if (time < intermission_exittime)
363 if (time < intermission_exittime + 60 && !self.button0 && !self.button1 && !self.button2 && !self.button3)
373 Returns the entity to view from
377 entity() FindIntermission =
382 // look for info_intermission first
383 spot = find (world, classname, "info_intermission");
385 { // pick a random one
389 spot = find (spot, classname, "info_intermission");
391 spot = find (spot, classname, "info_intermission");
397 // then look for the start position
398 spot = find (world, classname, "info_player_start");
402 // testinfo_player_start is only found in regioned levels
403 spot = find (world, classname, "testplayerstart");
407 // then look for the start position
408 spot = find (world, classname, "info_player_deathmatch");
412 //objerror ("FindIntermission: no spot");
418 ===============================================================================
422 ===============================================================================
426 go to the next level for deathmatch
427 only called if a time or frag limit has expired
433 intermission_running = 1;
435 // enforce a wait time before allowing changelevel
436 intermission_exittime = time + 5;
438 WriteByte (MSG_ALL, SVC_CDTRACK);
439 WriteByte (MSG_ALL, 3);
440 WriteByte (MSG_ALL, 3);
442 //pos = FindIntermission ();
444 other = find (world, classname, "player");
445 while (other != world)
447 //other.nextthink = time + 0.5;
448 other.takedamage = DAMAGE_NO;
449 other.solid = SOLID_NOT;
450 other.movetype = MOVETYPE_NONE;
451 other.angles = other.v_angle;
452 other.angles_x = other.angles_x * -1;
456 other.modelindex = 0;
457 other.weaponentity = world; // remove weapon model
458 other.view_ofs = '0 0 0';
459 other.angles = other.v_angle = pos.mangle;
462 other.angles = other.v_angle = pos.angles;
463 other.v_angle_x = other.v_angle_x * -1;
465 other.fixangle = TRUE; // turn this way immediately
466 setorigin (other, pos.origin);
469 other = find (other, classname, "player");
472 WriteByte (MSG_ALL, SVC_INTERMISSION);
479 Exit deathmatch games upon conditions
484 local float timelimit;
485 local float fraglimit;
487 if (intermission_running)
488 if (time >= intermission_exittime + 60)
494 if (gameover) // someone else quit the game already
497 timelimit = cvar("timelimit") * 60;
498 fraglimit = cvar("fraglimit");
500 if (timelimit && time >= timelimit)
506 if (fraglimit && self.frags >= fraglimit)