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");
55 precache_model ("models/uziflash.md3");
57 precache_model ("models/items/g_h1.md3");
58 precache_model ("models/items/g_h25.md3");
59 precache_model ("models/items/g_h100.md3");
61 precache_model ("models/items/g_a1.md3");
62 precache_model ("models/items/g_a25.md3");
64 precache_model ("models/weapons/w_uzi.zym");
65 precache_model ("models/weapons/w_laser.zym");
66 precache_model ("models/weapons/w_shotgun.zym");
67 precache_model ("models/weapons/w_gl.zym");
68 precache_model ("models/weapons/w_electro.zym");
69 precache_model ("models/weapons/w_crylink.zym");
70 precache_model ("models/weapons/w_nex.zym");
71 precache_model ("models/weapons/w_hagar.zym");
72 precache_model ("models/weapons/w_rl.zym");
74 precache_model ("models/items/a_shells.md3");
75 precache_model ("models/items/a_cells.md3");
76 precache_model ("models/items/a_rockets.md3");
77 precache_model ("models/items/a_bullets.mdl");
79 precache_model ("models/items/g_strength.md3");
80 precache_model ("models/items/g_invincible.md3");
82 precache_model ("models/gibs/eye.md3");
83 precache_model ("models/gibs/gib1.md3");
84 precache_model ("models/gibs/gib2.md3");
85 precache_model ("models/gibs/gib3.md3");
86 precache_model ("models/gibs/gib4.md3");
87 precache_model ("models/gibs/gib5.md3");
88 precache_model ("models/gibs/gib6.md3");
89 precache_model ("models/gibs/chunk.mdl");
90 precache_model ("models/gibs/bloodyskull.md3");
92 precache_sound ("weapons/lasergun_fire.wav");
93 precache_sound ("weapons/laserimpact.wav");
94 precache_sound ("weapons/uzi_fire.wav");
95 precache_sound ("weapons/shotgun_fire.wav");
96 precache_sound ("weapons/grenade_fire.wav");
97 precache_sound ("weapons/grenade_impact.wav");
98 precache_sound ("weapons/grenade_bounce.wav");
99 precache_sound ("weapons/nexfire.wav");
100 precache_sound ("weapons/neximpact.wav");
101 precache_sound ("weapons/electro_fire.wav");
102 precache_sound ("weapons/electro_fly.wav");
103 precache_sound ("weapons/missile_fly.wav");
104 precache_sound ("weapons/rocket_fire.wav");
105 precache_sound ("weapons/rocket_impact.wav");
106 precache_sound ("weapons/hagar_fire.wav");
107 precache_sound ("weapons/hagar_fire2.wav");
108 precache_sound ("weapons/hagexp1.wav");
109 precache_sound ("weapons/hagexp2.wav");
110 precache_sound ("weapons/hagexp3.wav");
111 precache_sound ("weapons/ric1.wav");
112 precache_sound ("weapons/ric2.wav");
113 precache_sound ("weapons/ric3.wav");
114 precache_sound ("weapons/weaponpickup.wav");
115 precache_sound ("weapons/crylink.wav");
116 precache_sound ("weapons/crylink2.wav");
117 precache_sound ("weapons/plasmahit.wav");
118 precache_sound ("weapons/uzi_fire_secondary.wav");
119 precache_sound ("weapons/tink1.wav");
120 precache_sound ("weapons/weapon_switch.wav");
122 precache_sound ("misc/itempickup.wav");
123 precache_sound ("misc/bodyimpact1.wav");
124 precache_sound ("misc/bodyimpact2.wav");
125 precache_sound ("misc/armorimpact.wav");
126 precache_sound ("misc/hit.wav");
127 precache_sound ("misc/teleport.wav");
128 precache_sound ("misc/megahealth.wav");
129 precache_sound ("misc/mediumhealth.wav");
130 precache_sound ("misc/gib.wav");
131 precache_sound ("misc/jumppad.wav");
132 precache_sound ("misc/hitground1.wav");
133 precache_sound ("misc/hitground2.wav");
134 precache_sound ("misc/hitground3.wav");
135 precache_sound ("misc/hitground4.wav");
136 precache_sound ("misc/talk.wav");
137 precache_sound ("misc/gib_splat01.wav");
138 precache_sound ("misc/gib_splat02.wav");
139 precache_sound ("misc/gib_splat03.wav");
140 precache_sound ("misc/gib_splat04.wav");
141 precache_sound ("misc/powerup.wav");
142 precache_sound ("misc/h20hit1.wav");
144 precache_sound ("player/slime.wav");
145 precache_sound ("player/lava.wav");
147 precache_sound ("announcer/1fragleft.wav");
148 precache_sound ("announcer/2fragsleft.wav");
149 precache_sound ("announcer/3fragsleft.wav");
150 precache_sound ("announcer/1minuteremains.wav");
151 precache_sound ("announcer/firstblood.wav");
153 precache_sound ("misc/itemrespawn.wav");
156 // plays music for the level if there is any
159 precache_sound (self.noise);
160 ambientsound ('0 0 0', self.noise, 1.00, ATTN_NONE);
166 // 1 FLICKER (first variety)
167 lightstyle(1, "mmnmmommommnonmmonqnmmo");
169 // 2 SLOW STRONG PULSE
170 lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
172 // 3 CANDLE (first variety)
173 lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
176 lightstyle(4, "mamamamamama");
179 lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
181 // 6 FLICKER (second variety)
182 lightstyle(6, "nmonqnmomnmomomno");
184 // 7 CANDLE (second variety)
185 lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
187 // 8 CANDLE (third variety)
188 lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
190 // 9 SLOW STROBE (fourth variety)
191 lightstyle(9, "aaaaaaaazzzzzzzz");
193 // 10 FLUORESCENT FLICKER
194 lightstyle(10, "mmamammmmammamamaaamammma");
196 // 11 SLOW PULSE NOT FADE TO BLACK
197 lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
199 // styles 32-62 are assigned by the light program for switchable lights
204 if (cvar("g_domination"))
214 // reads and alters data/maplist.cfg (sliding it one line), and returns a
215 // strzoned string containing the next map
216 #define MAPLIST "maplist.cfg"
217 string() Nex_RotateMapList =
220 local string lNextMap;
221 local string lCurrentMap;
222 local string lBuffer;
224 lHandle = fopen( MAPLIST, FILE_READ );
227 // restart the current map if no other map is not found
228 return strzone( mapname );
231 // get the first line that will be moved to the end later
232 lCurrentMap = strzone( fgets( lHandle ) );
235 // restart the current map if no other map is not found
236 return strzone( mapname );
239 // now get the second line which is the map that should be loaded next
240 lBuffer = fgets( lHandle );
241 // if there isnt a second line, nothing needs to be rotated
244 strunzone( lCurrentMap );
245 // restart the current map if no other map is not found
246 return strzone( mapname );
249 // since lBuffer holds the next map, it is assigned to nextmap
250 lNextMap = strzone( lBuffer );
252 // since fgets uses its own buffer we need to move lBuffer to a tempstring
253 // before reading the next line (or lBuffer will be lost)
254 lBuffer = strcat( lBuffer );
256 // read in the rest of the list
260 lLine = fgets( lHandle );
265 lBuffer = strcat( lBuffer, "\n", lLine );
268 lBuffer = strcat( lBuffer, "\n", lCurrentMap );
270 // dismiss lCurrentmap now
271 strunzone( lCurrentMap );
273 // and close the file handle
276 // open the maplist for output this one
277 lHandle = fopen( MAPLIST, FILE_WRITE );
279 // this shouldnt happen!
280 // print a warning/error message
281 dprint( "Couldn't open ", MAPLIST, " for output!\n" );
283 strunzone( lNextMap );
285 // we return the currently running map
286 return strzone( mapname );
289 fputs( lHandle, lBuffer );
297 float intermission_running;
298 float intermission_exittime;
299 float alreadychangedlevel;
304 local string nextmap;
305 //local float n, nummaps;
307 if (alreadychangedlevel)
309 alreadychangedlevel = TRUE;
310 if (cvar("samelevel")) // if samelevel is set, stay on same level
311 changelevel (mapname);
320 // restart current map if no cycle is found
321 nextmap = strzone(mapname);
322 fh = fopen("maplist.cfg", FILE_READ);
328 if (nextmap == mapname)
331 nextmap = strzone(line);
341 nextmap = strzone(line);
347 changelevel (nextmap);
351 //nextmap = Nex_RotateMapList();
352 //changelevel (nextmap);
353 //strunzone (nextmap);
356 s = cvar_string("g_maplist");
357 nummaps = tokenize(s);
358 // if no map list, restart current one
365 if (argv(n) == mapname)
374 changelevel (nextmap);
384 When the player presses attack or jump, change to the next level
387 void() IntermissionThink =
389 if (time < intermission_exittime)
392 if (time < intermission_exittime + 10 && !self.button0 && !self.button1 && !self.button2 && !self.button3)
402 Returns the entity to view from
406 entity() FindIntermission =
411 // look for info_intermission first
412 spot = find (world, classname, "info_intermission");
414 { // pick a random one
418 spot = find (spot, classname, "info_intermission");
420 spot = find (spot, classname, "info_intermission");
426 // then look for the start position
427 spot = find (world, classname, "info_player_start");
431 // testinfo_player_start is only found in regioned levels
432 spot = find (world, classname, "testplayerstart");
436 // then look for the start position
437 spot = find (world, classname, "info_player_deathmatch");
441 //objerror ("FindIntermission: no spot");
447 ===============================================================================
451 ===============================================================================
455 go to the next level for deathmatch
456 only called if a time or frag limit has expired
462 intermission_running = 1;
464 // enforce a wait time before allowing changelevel
465 intermission_exittime = time + 5;
467 WriteByte (MSG_ALL, SVC_CDTRACK);
468 WriteByte (MSG_ALL, 3);
469 WriteByte (MSG_ALL, 3);
471 //pos = FindIntermission ();
473 other = find (world, classname, "player");
474 while (other != world)
476 //other.nextthink = time + 0.5;
477 other.takedamage = DAMAGE_NO;
478 other.solid = SOLID_NOT;
479 other.movetype = MOVETYPE_NONE;
480 other.angles = other.v_angle;
481 other.angles_x = other.angles_x * -1;
485 other.modelindex = 0;
486 other.weaponentity = world; // remove weapon model
487 other.view_ofs = '0 0 0';
488 other.angles = other.v_angle = pos.mangle;
491 other.angles = other.v_angle = pos.angles;
492 other.v_angle_x = other.v_angle_x * -1;
494 other.fixangle = TRUE; // turn this way immediately
495 setorigin (other, pos.origin);
498 other = find (other, classname, "player");
501 WriteByte (MSG_ALL, SVC_INTERMISSION);
508 Exit deathmatch games upon conditions
511 void() CheckRules_Player =
513 local float fraglimit;
515 if (gameover) // someone else quit the game already
518 fraglimit = cvar("fraglimit");
519 if (fraglimit && self.frags >= fraglimit)
526 float checkrules_oneminutewarning;
527 float checkrules_leaderfrags;
528 entity checkrules_leader;
534 Exit deathmatch games upon conditions
537 void() CheckRules_World =
539 local float timelimit;
540 local float fraglimit;
541 local float checkrules_oldleaderfrags;
542 local entity checkrules_oldleader;
545 if (intermission_running)
546 if (time >= intermission_exittime + 60)
552 if (gameover) // someone else quit the game already
555 timelimit = cvar("timelimit") * 60;
556 fraglimit = cvar("fraglimit");
558 if (timelimit && time >= timelimit)
564 if (!checkrules_oneminutewarning && timelimit && time > timelimit - 60)
566 checkrules_oneminutewarning = TRUE;
567 sound(world, CHAN_AUTO, "announcer/1minuteremains.wav", 1, ATTN_NONE);
570 checkrules_oldleader = checkrules_leader;
571 checkrules_oldleaderfrags = checkrules_leaderfrags;
572 checkrules_leaderfrags = 0;
573 checkrules_leader = world;
574 head = findchain(classname, "player");
577 if (checkrules_leaderfrags < head.frags)
579 checkrules_leaderfrags = head.frags;
580 checkrules_leader = head;
584 if (checkrules_leaderfrags <= 0)
586 checkrules_leader = world;
587 checkrules_leaderfrags = 0;
589 checkrules_leaderfrags = floor(checkrules_leaderfrags);
590 if (checkrules_leaderfrags != checkrules_oldleaderfrags)
592 if (checkrules_leaderfrags == fraglimit - 1)
593 sound(world, CHAN_AUTO, "announcer/1fragleft.wav", 1, ATTN_NONE);
594 else if (checkrules_leaderfrags == fraglimit - 2)
595 sound(world, CHAN_AUTO, "announcer/2fragsleft.wav", 1, ATTN_NONE);
596 else if (checkrules_leaderfrags == fraglimit - 3)
597 sound(world, CHAN_AUTO, "announcer/3fragsleft.wav", 1, ATTN_NONE);
599 // if (checkrules_leader != checkrules_oldleader)// && checkrules_leaderfrags > checkrules_oldleaderfrags)
600 // bprint("^1",checkrules_leader.netname, " has taken the lead with ", ftos(checkrules_leaderfrags), " frags\n");