5 // Precache all player models
6 // Workaround for "invisible players"
7 precache_model("models/player/carni.zym");
8 precache_model("models/player/crash.zym");
9 precache_model("models/player/grunt.zym");
10 precache_model("models/player/headhunter.zym");
11 precache_model("models/player/insurrectionist.zym");
12 precache_model("models/player/jeandarc.zym");
13 precache_model("models/player/lurk.zym");
14 precache_model("models/player/lycanthrope.zym");
15 precache_model("models/player/marine.zym");
16 precache_model("models/player/nexus.zym");
17 precache_model("models/player/pyria.zym");
18 precache_model("models/player/shock.zym");
19 precache_model("models/player/skadi.zym");
20 precache_model("models/player/specop.zym");
21 precache_model("models/player/visitant.zym");
23 //precache_model ("progs/beam.mdl");
24 precache_model ("models/bullet.mdl");
25 precache_model ("models/casing_bronze.mdl");
26 precache_model ("models/casing_shell.mdl");
27 precache_model ("models/casing_steel.mdl");
28 precache_model ("models/ebomb.mdl");
29 precache_model ("models/elaser.mdl");
30 precache_model ("models/flash.md3");
31 precache_model ("models/gibs/bloodyskull.md3");
32 precache_model ("models/gibs/chunk.mdl");
33 precache_model ("models/gibs/eye.md3");
34 precache_model ("models/gibs/gib1.md3");
35 precache_model ("models/gibs/gib2.md3");
36 precache_model ("models/gibs/gib3.md3");
37 precache_model ("models/gibs/gib4.md3");
38 precache_model ("models/gibs/gib5.md3");
39 precache_model ("models/gibs/gib6.md3");
40 precache_model ("models/grenademodel.md3");
41 precache_model ("models/hagarmissile.mdl");
42 precache_model ("models/items/a_bullets.mdl");
43 precache_model ("models/items/a_cells.md3");
44 precache_model ("models/items/a_rockets.md3");
45 precache_model ("models/items/a_shells.md3");
46 precache_model ("models/items/g_a1.md3");
47 precache_model ("models/items/g_a25.md3");
48 precache_model ("models/items/g_h1.md3");
49 precache_model ("models/items/g_h25.md3");
50 precache_model ("models/items/g_h100.md3");
51 precache_model ("models/items/g_invincible.md3");
52 precache_model ("models/items/g_strength.md3");
53 precache_model ("models/laser.mdl");
54 precache_model ("models/misc/chatbubble.spr");
55 precache_model ("models/nexflash.md3");
56 precache_model ("models/plasma.mdl");
57 precache_model ("models/plasmatrail.mdl");
58 precache_model ("models/rocket.md3");
59 precache_model ("models/sprites/grenadeexplosion.spr32");
60 precache_model ("models/sprites/hagarexplosion.spr32");
61 precache_model ("models/sprites/muzzleflash.spr32");
62 //precache_model ("models/sprites/plasmahitwall.spr32");
63 //precache_model ("models/sprites/plasmashot.spr32");
64 precache_model ("models/sprites/rocketexplosion.spr32");
65 precache_model ("models/tracer.mdl");
66 precache_model ("models/uziflash.md3");
67 precache_model ("models/weapons/g_crylink.md3");
68 precache_model ("models/weapons/g_electro.md3");
69 precache_model ("models/weapons/g_gl.md3");
70 precache_model ("models/weapons/g_hagar.md3");
71 precache_model ("models/weapons/g_nex.md3");
72 precache_model ("models/weapons/g_rl.md3");
73 precache_model ("models/weapons/g_shotgun.md3");
74 precache_model ("models/weapons/g_uzi.md3");
75 precache_model ("models/weapons/v_crylink.md3");
76 precache_model ("models/weapons/v_electro.md3");
77 precache_model ("models/weapons/v_gl.md3");
78 precache_model ("models/weapons/v_hagar.md3");
79 precache_model ("models/weapons/v_laser.md3");
80 precache_model ("models/weapons/v_nex.md3");
81 precache_model ("models/weapons/v_rl.md3");
82 precache_model ("models/weapons/v_shotgun.md3");
83 precache_model ("models/weapons/v_uzi.md3");
84 precache_model ("models/weapons/w_crylink.zym");
85 precache_model ("models/weapons/w_electro.zym");
86 precache_model ("models/weapons/w_gl.zym");
87 precache_model ("models/weapons/w_hagar.zym");
88 precache_model ("models/weapons/w_laser.zym");
89 precache_model ("models/weapons/w_nex.zym");
90 precache_model ("models/weapons/w_rl.zym");
91 precache_model ("models/weapons/w_shotgun.zym");
92 precache_model ("models/weapons/w_uzi.zym");
93 precache_sound ("announcer/1fragleft.wav");
94 precache_sound ("announcer/1minuteremains.wav");
95 precache_sound ("announcer/2fragsleft.wav");
96 precache_sound ("announcer/3fragsleft.wav");
97 precache_sound ("announcer/welcometonexuiz.wav");
98 precache_sound ("misc/armor1.wav");
99 precache_sound ("misc/armor25.wav");
100 precache_sound ("misc/armorimpact.wav");
101 precache_sound ("misc/bodyimpact1.wav");
102 precache_sound ("misc/bodyimpact2.wav");
103 precache_sound ("misc/gib.wav");
104 precache_sound ("misc/gib_splat01.wav");
105 precache_sound ("misc/gib_splat02.wav");
106 precache_sound ("misc/gib_splat03.wav");
107 precache_sound ("misc/gib_splat04.wav");
108 //precache_sound ("misc/h2ohit.wav");
109 precache_sound ("misc/hit.wav");
110 precache_sound ("misc/hitground1.wav");
111 precache_sound ("misc/hitground2.wav");
112 precache_sound ("misc/hitground3.wav");
113 precache_sound ("misc/hitground4.wav");
114 precache_sound ("misc/itempickup.wav");
115 precache_sound ("misc/itemrespawn.wav");
116 precache_sound ("misc/jumppad.wav");
117 precache_sound ("misc/mediumhealth.wav");
118 precache_sound ("misc/megahealth.wav");
119 precache_sound ("misc/minihealth.wav");
120 precache_sound ("misc/powerup.wav");
121 precache_sound ("misc/talk.wav");
122 precache_sound ("misc/teleport.wav");
123 precache_sound ("plats/medplat1.wav");
124 precache_sound ("plats/medplat2.wav");
125 precache_sound ("player/lava.wav");
126 precache_sound ("player/slime.wav");
127 precache_sound ("weapons/crylink.wav");
128 precache_sound ("weapons/crylink2.wav");
129 precache_sound ("weapons/electro_fire.wav");
130 precache_sound ("weapons/electro_fly.wav");
131 precache_sound ("weapons/electro_impact.wav");
132 precache_sound ("weapons/grenade_bounce.wav");
133 precache_sound ("weapons/grenade_fire.wav");
134 precache_sound ("weapons/grenade_impact.wav");
135 precache_sound ("weapons/hagar_fire.wav");
136 precache_sound ("weapons/hagexp1.wav");
137 precache_sound ("weapons/hagexp2.wav");
138 precache_sound ("weapons/hagexp3.wav");
139 precache_sound ("weapons/lasergun_fire.wav");
140 precache_sound ("weapons/laserimpact.wav");
141 precache_sound ("weapons/nexfire.wav");
142 precache_sound ("weapons/neximpact.wav");
143 precache_sound ("weapons/ric1.wav");
144 precache_sound ("weapons/ric2.wav");
145 precache_sound ("weapons/ric3.wav");
146 precache_sound ("weapons/rocket_fire.wav");
147 precache_sound ("weapons/rocket_fly.wav");
148 precache_sound ("weapons/rocket_impact.wav");
149 precache_sound ("weapons/shotgun_fire.wav");
150 precache_sound ("weapons/tink1.wav");
151 precache_sound ("weapons/uzi_fire.wav");
152 precache_sound ("weapons/weapon_switch.wav");
153 precache_sound ("weapons/weaponpickup.wav");
157 // plays music for the level if there is any
160 precache_sound (self.noise);
161 ambientsound ('0 0 0', self.noise, 1.00, ATTN_NONE);
167 // 1 FLICKER (first variety)
168 lightstyle(1, "mmnmmommommnonmmonqnmmo");
170 // 2 SLOW STRONG PULSE
171 lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
173 // 3 CANDLE (first variety)
174 lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
177 lightstyle(4, "mamamamamama");
180 lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
182 // 6 FLICKER (second variety)
183 lightstyle(6, "nmonqnmomnmomomno");
185 // 7 CANDLE (second variety)
186 lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
188 // 8 CANDLE (third variety)
189 lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
191 // 9 SLOW STROBE (fourth variety)
192 lightstyle(9, "aaaaaaaazzzzzzzz");
194 // 10 FLUORESCENT FLICKER
195 lightstyle(10, "mmamammmmammamamaaamammma");
197 // 11 SLOW PULSE NOT FADE TO BLACK
198 lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
200 // styles 32-62 are assigned by the light program for switchable lights
206 //if (cvar("g_domination"))
216 // reads and alters data/maplist.cfg (sliding it one line), and returns a
217 // strzoned string containing the next map
218 string() Nex_RotateMapList =
221 local string lNextMap;
222 local string lCurrentMap;
223 local string lBuffer;
225 lHandle = fopen( "maplist.cfg", FILE_READ );
228 // restart the current map if no other map is not found
229 return strzone( mapname );
232 // get the first line that will be moved to the end later
233 lCurrentMap = strzone( fgets( lHandle ) );
236 // restart the current map if no other map is not found
237 return strzone( mapname );
240 // now get the second line which is the map that should be loaded next
241 lBuffer = fgets( lHandle );
242 // if there isnt a second line, nothing needs to be rotated
245 strunzone( lCurrentMap );
246 // restart the current map if no other map is not found
247 return strzone( mapname );
250 // since lBuffer holds the next map, it is assigned to nextmap
251 lNextMap = strzone( lBuffer );
253 // since fgets uses its own buffer we need to move lBuffer to a tempstring
254 // before reading the next line (or lBuffer will be lost)
255 lBuffer = strcat( lBuffer );
257 // read in the rest of the list
261 lLine = fgets( lHandle );
266 lBuffer = strcat( lBuffer, "\n", lLine );
269 lBuffer = strcat( lBuffer, "\n", lCurrentMap );
271 // dismiss lCurrentmap now
272 strunzone( lCurrentMap );
274 // and close the file handle
277 // open the maplist for output this one
278 lHandle = fopen( "maplist.cfg", FILE_WRITE );
280 // this shouldnt happen!
281 // print a warning/error message
282 dprint( "Couldn't open ", "maplist.cfg", " for output!\n" );
284 strunzone( lNextMap );
286 // we return the currently running map
287 return strzone( mapname );
290 fputs( lHandle, lBuffer );
299 //local string nextmap;
300 //local float n, nummaps;
303 if (alreadychangedlevel)
305 alreadychangedlevel = TRUE;
307 // if an exit cfg is defined by exiting map, exec it.
308 exit_cfg = cvar_string("exit_cfg");
310 localcmd(strcat("exec \"", exit_cfg, "\"\n"));
315 if (cvar("samelevel")) // if samelevel is set, stay on same level
317 localcmd(strcat("exec \"maps/", mapname, ".mapcfg\"\n"));
318 //changelevel (mapname);
323 local float lCurrent;
326 lSize = tokenize( cvar_string( "g_maplist" ) );
327 lCurrent = cvar( "g_maplist_index" );
329 lCurrent = lCurrent + 1;
330 if( lCurrent >= lSize ) {
334 cvar_set( "g_maplist_index", ftos( lCurrent ) );
337 localcmd(strcat("exec \"maps/", argv( lCurrent ), ".mapcfg\"\n"));
338 //changelevel( argv( lCurrent ) );
348 // restart current map if no cycle is found
349 nextmap = strzone(mapname);
350 fh = fopen("maplist.cfg", FILE_READ);
356 if (nextmap == mapname)
359 nextmap = strzone(line);
369 nextmap = strzone(line);
375 changelevel (nextmap);
376 strunzone(nextmap);*/
379 //nextmap = Nex_RotateMapList();
380 //changelevel (nextmap);
381 //strunzone (nextmap);
384 s = cvar_string("g_maplist");
385 nummaps = tokenize(s);
386 // if no map list, restart current one
393 if (argv(n) == mapname)
402 changelevel (nextmap);
412 When the player presses attack or jump, change to the next level
415 void() IntermissionThink =
417 if (time < intermission_exittime)
420 if (time < intermission_exittime + 10 && !self.button0 && !self.button1 && !self.button2 && !self.button3)
430 Returns the entity to view from
434 entity() FindIntermission =
439 // look for info_intermission first
440 spot = find (world, classname, "info_intermission");
442 { // pick a random one
446 spot = find (spot, classname, "info_intermission");
448 spot = find (spot, classname, "info_intermission");
454 // then look for the start position
455 spot = find (world, classname, "info_player_start");
459 // testinfo_player_start is only found in regioned levels
460 spot = find (world, classname, "testplayerstart");
464 // then look for the start position
465 spot = find (world, classname, "info_player_deathmatch");
469 //objerror ("FindIntermission: no spot");
475 ===============================================================================
479 ===============================================================================
483 go to the next level for deathmatch
484 only called if a time or frag limit has expired
490 intermission_running = 1;
492 // enforce a wait time before allowing changelevel
493 intermission_exittime = time + 5;
495 WriteByte (MSG_ALL, SVC_CDTRACK);
496 WriteByte (MSG_ALL, 3);
497 WriteByte (MSG_ALL, 3);
499 //pos = FindIntermission ();
501 other = find (world, classname, "player");
502 while (other != world)
504 //other.nextthink = time + 0.5;
505 other.takedamage = DAMAGE_NO;
506 other.solid = SOLID_NOT;
507 other.movetype = MOVETYPE_NONE;
508 other.angles = other.v_angle;
509 other.angles_x = other.angles_x * -1;
513 other.modelindex = 0;
514 other.weaponentity = world; // remove weapon model
515 other.view_ofs = '0 0 0';
516 other.angles = other.v_angle = pos.mangle;
519 other.angles = other.v_angle = pos.angles;
520 other.v_angle_x = other.v_angle_x * -1;
522 other.fixangle = TRUE; // turn this way immediately
523 setorigin (other, pos.origin);
526 other = find (other, classname, "player");
529 WriteByte (MSG_ALL, SVC_INTERMISSION);
536 Exit deathmatch games upon conditions
539 void() CheckRules_Player =
541 local float fraglimit;
543 if (gameover) // someone else quit the game already
546 // fixme: don't check players; instead check dom_team and ctf_team entities
548 fraglimit = cvar("fraglimit");
550 if(cvar("g_domination"))
552 // fixme: check team frags, not players!
553 if (fraglimit && self.frags >= fraglimit)
561 if (fraglimit && self.frags >= fraglimit)
569 float checkrules_oneminutewarning;
570 float checkrules_leaderfrags;
571 entity checkrules_leader;
577 Exit deathmatch games upon conditions
580 void() CheckRules_World =
582 local float timelimit;
583 local float fraglimit;
584 local float checkrules_oldleaderfrags;
585 local entity checkrules_oldleader;
588 if (intermission_running)
589 if (time >= intermission_exittime + 60)
595 if (gameover) // someone else quit the game already
598 timelimit = cvar("timelimit") * 60;
599 fraglimit = cvar("fraglimit");
601 if (timelimit && time >= timelimit)
607 if (!checkrules_oneminutewarning && timelimit && time > timelimit - 60)
609 checkrules_oneminutewarning = TRUE;
610 sound(world, CHAN_AUTO, "announcer/1minuteremains.wav", 1, ATTN_NONE);
613 checkrules_oldleader = checkrules_leader;
614 checkrules_oldleaderfrags = checkrules_leaderfrags;
615 checkrules_leaderfrags = 0;
616 checkrules_leader = world;
617 head = findchain(classname, "player");
620 if (checkrules_leaderfrags < head.frags)
622 checkrules_leaderfrags = head.frags;
623 checkrules_leader = head;
627 if (checkrules_leaderfrags <= 0)
629 checkrules_leader = world;
630 checkrules_leaderfrags = 0;
632 checkrules_leaderfrags = floor(checkrules_leaderfrags);
633 if (checkrules_leaderfrags != checkrules_oldleaderfrags)
635 if (checkrules_leaderfrags == fraglimit - 1)
636 sound(world, CHAN_AUTO, "announcer/1fragleft.wav", 1, ATTN_NONE);
637 else if (checkrules_leaderfrags == fraglimit - 2)
638 sound(world, CHAN_AUTO, "announcer/2fragsleft.wav", 1, ATTN_NONE);
639 else if (checkrules_leaderfrags == fraglimit - 3)
640 sound(world, CHAN_AUTO, "announcer/3fragsleft.wav", 1, ATTN_NONE);
642 // if (checkrules_leader != checkrules_oldleader)// && checkrules_leaderfrags > checkrules_oldleaderfrags)
643 // bprint("^1",checkrules_leader.netname, " has taken the lead with ", ftos(checkrules_leaderfrags), " frags\n");