]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/gamec/g_world.c
primitive version of instant action
[divverent/nexuiz.git] / data / qcsrc / gamec / g_world.c
1
2 void worldspawn (void)
3 {
4
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");
22
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/grenexpl.spr");
60         precache_model ("models/sprites/hagar.spr");
61         precache_model ("models/sprites/muzzleflash.spr32");
62         precache_model ("models/sprites/electrocombo.spr32");
63         //precache_model ("models/sprites/plasmahitwall.spr32");
64         //precache_model ("models/sprites/plasmashot.spr32");
65         precache_model ("models/sprites/rockexpl.spr");
66         precache_model ("models/tracer.mdl");
67         precache_model ("models/uziflash.md3");
68         precache_model ("models/weapons/g_crylink.md3");
69         precache_model ("models/weapons/g_electro.md3");
70         precache_model ("models/weapons/g_gl.md3");
71         precache_model ("models/weapons/g_hagar.md3");
72         precache_model ("models/weapons/g_nex.md3");
73         precache_model ("models/weapons/g_rl.md3");
74         precache_model ("models/weapons/g_shotgun.md3");
75         precache_model ("models/weapons/g_uzi.md3");
76         precache_model ("models/weapons/v_crylink.md3");
77         precache_model ("models/weapons/v_electro.md3");
78         precache_model ("models/weapons/v_gl.md3");
79         precache_model ("models/weapons/v_hagar.md3");
80         precache_model ("models/weapons/v_laser.md3");
81         precache_model ("models/weapons/v_nex.md3");
82         precache_model ("models/weapons/v_rl.md3");
83         precache_model ("models/weapons/v_shotgun.md3");
84         precache_model ("models/weapons/v_uzi.md3");
85         precache_model ("models/weapons/w_crylink.zym");
86         precache_model ("models/weapons/w_electro.zym");
87         precache_model ("models/weapons/w_gl.zym");
88         precache_model ("models/weapons/w_hagar.zym");
89         precache_model ("models/weapons/w_laser.zym");
90         precache_model ("models/weapons/w_nex.zym");
91         precache_model ("models/weapons/w_rl.zym");
92         precache_model ("models/weapons/w_shotgun.zym");
93         precache_model ("models/weapons/w_uzi.zym");
94
95         // laser for laser-guided weapons
96         precache_model ("models/laser_dot.mdl");
97
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.ogg");
111         precache_sound ("misc/hitground2.ogg");
112         precache_sound ("misc/hitground3.ogg");
113         precache_sound ("misc/hitground4.ogg");
114         precache_sound ("misc/itempickup.ogg");
115         precache_sound ("misc/itemrespawn.ogg");
116         precache_sound ("misc/jumppad.ogg");
117         precache_sound ("misc/mediumhealth.ogg");
118         precache_sound ("misc/megahealth.ogg");
119         precache_sound ("misc/minihealth.ogg");
120         precache_sound ("misc/powerup.ogg");
121         precache_sound ("misc/powerup_shield.ogg");
122         precache_sound ("misc/talk.wav");
123         precache_sound ("misc/teleport.ogg");
124         precache_sound ("plats/medplat1.wav");
125         precache_sound ("plats/medplat2.wav");
126         precache_sound ("player/lava.wav");
127         precache_sound ("player/slime.wav");
128         precache_sound ("weapons/crylink_fire.ogg");
129         precache_sound ("weapons/electro_bounce.ogg");
130         precache_sound ("weapons/electro_fire.ogg");
131         precache_sound ("weapons/electro_fire2.ogg");
132         precache_sound ("weapons/electro_fly.wav");
133         precache_sound ("weapons/electro_impact.ogg");
134         precache_sound ("weapons/electro_impact_combo.ogg");
135         precache_sound ("weapons/grenade_bounce.ogg");
136         precache_sound ("weapons/grenade_fire.ogg");
137         precache_sound ("weapons/grenade_impact.ogg");
138         precache_sound ("weapons/hagar_fire.ogg");
139         precache_sound ("weapons/hagexp1.ogg");
140         precache_sound ("weapons/hagexp2.ogg");
141         precache_sound ("weapons/hagexp3.ogg");
142         precache_sound ("weapons/hook_fire.ogg");
143         precache_sound ("weapons/hook_impact.ogg");
144         precache_sound ("weapons/lasergun_fire.ogg");
145         precache_sound ("weapons/laserimpact.ogg");
146         precache_sound ("weapons/nexfire.ogg");
147         precache_sound ("weapons/neximpact.ogg");
148         precache_sound ("weapons/ric1.ogg");
149         precache_sound ("weapons/ric2.ogg");
150         precache_sound ("weapons/ric3.ogg");
151         precache_sound ("weapons/rocket_fire.ogg");
152         precache_sound ("weapons/rocket_fly.wav");
153         precache_sound ("weapons/rocket_impact.ogg");
154         precache_sound ("weapons/shotgun_fire.ogg");
155         precache_sound ("weapons/tink1.ogg");
156         precache_sound ("weapons/uzi_fire.ogg");
157         precache_sound ("weapons/weapon_switch.ogg");
158         precache_sound ("weapons/weaponpickup.ogg");
159
160         //precache_sound ("announce/male/kill10.ogg");
161         //precache_sound ("announce/male/kill15.ogg");
162         //precache_sound ("announce/male/kill20.ogg");
163         //precache_sound ("announce/male/kill25.ogg");
164         //precache_sound ("announce/male/kill3.ogg");
165         //precache_sound ("announce/male/kill30.ogg");
166         //precache_sound ("announce/male/kill4.ogg");
167         //precache_sound ("announce/male/kill5.ogg");
168         //precache_sound ("announce/male/kill6.ogg");
169         //precache_sound ("announce/male/mapkill1.ogg");
170         //precache_sound ("announce/robotic/last_second_save.ogg");
171         //precache_sound ("announce/robotic/narrowly_averted.ogg");
172         //precache_sound ("minstagib/mockery.ogg");
173
174         // announcer sounds - male      
175         precache_sound ("announcer/male/03kills.ogg");  
176         precache_sound ("announcer/male/05kills.ogg");  
177         precache_sound ("announcer/male/10kills.ogg");  
178         precache_sound ("announcer/male/15kills.ogg");  
179         precache_sound ("announcer/male/20kills.ogg");  
180         precache_sound ("announcer/male/25kills.ogg");  
181         precache_sound ("announcer/male/30kills.ogg");  
182         precache_sound ("announcer/male/botlike.ogg");  
183         precache_sound ("announcer/male/electrobitch.ogg");     
184         precache_sound ("announcer/male/welcome.ogg");  
185         precache_sound ("announcer/male/yoda.ogg");     
186
187         // announcer sounds - robotic
188         precache_sound ("announcer/robotic/1fragleft.ogg");
189         precache_sound ("announcer/robotic/1minuteremains.ogg");
190         precache_sound ("announcer/robotic/2fragsleft.ogg");
191         precache_sound ("announcer/robotic/3fragsleft.ogg");
192         precache_sound ("announcer/robotic/lastsecond.ogg");
193         precache_sound ("announcer/robotic/narrowly.ogg");
194         
195         // plays music for the level if there is any
196         if (self.noise)
197         {
198                 precache_sound (self.noise);
199                 ambientsound ('0 0 0', self.noise, 1.00, ATTN_NONE);
200         }
201
202                 // 0 normal
203         lightstyle(0, "m");
204
205         // 1 FLICKER (first variety)
206         lightstyle(1, "mmnmmommommnonmmonqnmmo");
207
208         // 2 SLOW STRONG PULSE
209         lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
210
211         // 3 CANDLE (first variety)
212         lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
213
214         // 4 FAST STROBE
215         lightstyle(4, "mamamamamama");
216
217         // 5 GENTLE PULSE 1
218         lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
219
220         // 6 FLICKER (second variety)
221         lightstyle(6, "nmonqnmomnmomomno");
222
223         // 7 CANDLE (second variety)
224         lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
225
226         // 8 CANDLE (third variety)
227         lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
228
229         // 9 SLOW STROBE (fourth variety)
230         lightstyle(9, "aaaaaaaazzzzzzzz");
231
232         // 10 FLUORESCENT FLICKER
233         lightstyle(10, "mmamammmmammamamaaamammma");
234
235         // 11 SLOW PULSE NOT FADE TO BLACK
236         lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
237
238         // styles 32-62 are assigned by the light program for switchable lights
239
240         // 63 testing
241         lightstyle(63, "a");
242
243         player_count = 0;
244         lms_dead_count = 0;
245         lms_lowest_lives = 0;
246
247         InitGameplayMode();
248         //if (cvar("g_domination"))
249         //      dom_init();
250 }
251
252 void light (void)
253 {
254         makestatic (self);
255 }
256
257
258 // reads and alters data/maplist.cfg (sliding it one line), and returns a
259 // strzoned string containing the next map
260 string() Nex_RotateMapList =
261 {
262         local float lHandle;
263         local string lNextMap;
264         local string lCurrentMap;
265         local string lBuffer;
266
267         lHandle = fopen( "maplist.cfg", FILE_READ );
268         if( lHandle < 0 ) {
269                 fclose( lHandle );
270                 // restart the current map if no other map is not found
271                 return strzone( mapname );
272         }
273
274         // get the first line that will be moved to the end later
275         lCurrentMap = strzone( fgets( lHandle ) );
276         if( !lCurrentMap ) {
277                 fclose( lHandle );
278                 // restart the current map if no other map is not found
279                 return strzone( mapname );
280         }
281
282         // now get the second line which is the map that should be loaded next
283         lBuffer = fgets( lHandle );
284         // if there isnt a second line, nothing needs to be rotated
285         if( !lBuffer ) {
286                 fclose( lHandle );
287                 strunzone( lCurrentMap );
288                 // restart the current map if no other map is not found
289                 return strzone( mapname );
290         }
291
292         // since lBuffer holds the next map, it is assigned to nextmap
293         lNextMap = strzone( lBuffer );
294
295         // since fgets uses its own buffer we need to move lBuffer to a tempstring
296         // before reading the next line (or lBuffer will be lost)
297         lBuffer = strcat( lBuffer );
298
299         // read in the rest of the list
300         while( 1 )  {
301                 local string lLine;
302
303                 lLine = fgets( lHandle );
304                 if( !lLine ) {
305                         break;
306                 }
307
308                 lBuffer = strcat( lBuffer, "\n", lLine );
309         }
310         // rotate the list
311         lBuffer = strcat( lBuffer, "\n", lCurrentMap );
312
313         // dismiss lCurrentmap now
314         strunzone( lCurrentMap );
315
316         // and close the file handle
317         fclose( lHandle );
318
319         // open the maplist for output this one
320         lHandle = fopen( "maplist.cfg", FILE_WRITE );
321         if( lHandle < 0 ) {
322                 // this shouldnt happen!
323                 // print a warning/error message
324                 dprint( "Couldn't open ", "maplist.cfg", " for output!\n" );
325
326                 strunzone( lNextMap );
327
328                 // we return the currently running map
329                 return strzone( mapname );
330         }
331
332         fputs( lHandle, lBuffer );
333
334         fclose( lHandle );
335
336         return lNextMap;
337 };
338
339 void() GotoNextMap =
340 {
341         //local string nextmap;
342         //local float n, nummaps;
343         //local string s;
344         string exit_cfg;
345         if (alreadychangedlevel)
346                 return;
347         alreadychangedlevel = TRUE;
348
349         // if an exit cfg is defined by exiting map, exec it.
350         exit_cfg = cvar_string("exit_cfg");
351         if(exit_cfg != "")
352                 localcmd(strcat("exec \"", exit_cfg, "\"\n"));
353
354         ResetGameCvars();
355
356
357         if (cvar("lastlevel"))
358         {
359                 localcmd(strcat("set lastlevel 0\n"));
360                 localcmd(strcat("togglemenu\n"));
361         }
362         else if (cvar("samelevel")) // if samelevel is set, stay on same level
363         {
364                 localcmd(strcat("exec \"maps/", mapname, ".mapcfg\"\n"));
365                 //changelevel (mapname);
366         }
367         else
368         {
369                 // method 0
370                 local float lCurrent;
371                 local float lSize;
372
373                 lSize = tokenize( cvar_string( "g_maplist" ) );
374                 lCurrent = cvar( "g_maplist_index" );
375
376                 lCurrent = lCurrent + 1;
377                 if( lCurrent >= lSize ) {
378                         lCurrent = 0;
379                 }
380
381                 cvar_set( "g_maplist_index", ftos( lCurrent ) );
382
383
384                 localcmd(strcat("exec \"maps/", argv( lCurrent ), ".mapcfg\"\n"));
385                 //changelevel( argv( lCurrent ) );
386
387
388                 /*
389                 // method 1
390
391                 //local entity pos;
392                 local float fh;
393                 local string line;
394
395                 // restart current map if no cycle is found
396                 nextmap = strzone(mapname);
397                 fh = fopen("maplist.cfg", FILE_READ);
398                 if (fh >= 0)
399                 {
400                         while (1)
401                         {
402                                 line = fgets(fh);
403                                 if (nextmap == mapname)
404                                 {
405                                         strunzone(nextmap);
406                                         nextmap = strzone(line);
407                                 }
408                                 if (!line)
409                                         break;
410                                 if (line == mapname)
411                                 {
412                                         line = fgets(fh);
413                                         if (!line)
414                                                 break;
415                                         strunzone(nextmap);
416                                         nextmap = strzone(line);
417                                         break;
418                                 }
419                         }
420                         fclose(fh);
421                 }
422                 changelevel (nextmap);
423                 strunzone(nextmap);*/
424
425                 // method 2
426                 //nextmap = Nex_RotateMapList();
427                 //changelevel (nextmap);
428                 //strunzone (nextmap);
429                 // method 3
430                 /*
431                 s = cvar_string("g_maplist");
432                 nummaps = tokenize(s);
433                 // if no map list, restart current one
434                 nextmap = mapname;
435                 if (nummaps >= 1)
436                 {
437                         n = 0;
438                         while (n < nummaps)
439                         {
440                                 if (argv(n) == mapname)
441                                         break;
442                                 n = n + 1;
443                         }
444                         n = n + 1;
445                         if (n >= nummaps)
446                                 n = 0;
447                         nextmap = argv(n);
448                 }
449                 changelevel (nextmap);
450                 */
451         }
452 };
453
454
455 /*
456 ============
457 IntermissionThink
458
459 When the player presses attack or jump, change to the next level
460 ============
461 */
462 void() IntermissionThink =
463 {
464         if (time < intermission_exittime)
465                 return;
466
467         if (time < intermission_exittime + 10 && !self.button0 && !self.button1 && !self.button2 && !self.button3)
468                 return;
469
470         GotoNextMap ();
471 };
472
473 /*
474 ============
475 FindIntermission
476
477 Returns the entity to view from
478 ============
479 */
480 /*
481 entity() FindIntermission =
482 {
483         local   entity spot;
484         local   float cyc;
485
486 // look for info_intermission first
487         spot = find (world, classname, "info_intermission");
488         if (spot)
489         {       // pick a random one
490                 cyc = random() * 4;
491                 while (cyc > 1)
492                 {
493                         spot = find (spot, classname, "info_intermission");
494                         if (!spot)
495                                 spot = find (spot, classname, "info_intermission");
496                         cyc = cyc - 1;
497                 }
498                 return spot;
499         }
500
501 // then look for the start position
502         spot = find (world, classname, "info_player_start");
503         if (spot)
504                 return spot;
505
506 // testinfo_player_start is only found in regioned levels
507         spot = find (world, classname, "testplayerstart");
508         if (spot)
509                 return spot;
510
511 // then look for the start position
512         spot = find (world, classname, "info_player_deathmatch");
513         if (spot)
514                 return spot;
515
516         //objerror ("FindIntermission: no spot");
517         return world;
518 };
519 */
520
521 /*
522 ===============================================================================
523
524 RULES
525
526 ===============================================================================
527 */
528
529 /*
530 go to the next level for deathmatch
531 only called if a time or frag limit has expired
532 */
533 void() NextLevel =
534 {
535         gameover = TRUE;
536
537         intermission_running = 1;
538
539 // enforce a wait time before allowing changelevel
540         intermission_exittime = time + 5;
541
542         WriteByte (MSG_ALL, SVC_CDTRACK);
543         WriteByte (MSG_ALL, 3);
544         WriteByte (MSG_ALL, 3);
545
546         //pos = FindIntermission ();
547
548         other = find (world, classname, "player");
549         while (other != world)
550         {
551                 //other.nextthink = time + 0.5;
552                 other.takedamage = DAMAGE_NO;
553                 other.solid = SOLID_NOT;
554                 other.movetype = MOVETYPE_NONE;
555                 other.angles = other.v_angle;
556                 other.angles_x = other.angles_x * -1;
557                 /*
558                 if (pos != world);
559                 {
560                         other.modelindex = 0;
561                         other.weaponentity = world; // remove weapon model
562                         other.view_ofs = '0 0 0';
563                         other.angles = other.v_angle = pos.mangle;
564                         if (!other.angles)
565                         {
566                                 other.angles = other.v_angle = pos.angles;
567                                 other.v_angle_x = other.v_angle_x * -1;
568                         }
569                         other.fixangle = TRUE;          // turn this way immediately
570                         setorigin (other, pos.origin);
571                 }
572                 */
573                 other = find (other, classname, "player");
574         }
575
576         WriteByte (MSG_ALL, SVC_INTERMISSION);
577 };
578
579 /*
580 ============
581 CheckRules_Player
582
583 Exit deathmatch games upon conditions
584 ============
585 */
586 void() CheckRules_Player =
587 {
588         local float fraglimit;
589
590         if (gameover)   // someone else quit the game already
591                 return;
592
593         // fixme: don't check players; instead check dom_team and ctf_team entities
594
595         fraglimit = cvar("fraglimit");
596
597         if(!cvar("g_lms") && !(cvar("teamplay") && (cvar("deathmatch") || cvar("g_runematch"))))
598         {
599                 if (fraglimit && self.frags >= fraglimit)
600                 {
601                         NextLevel ();
602                         return;
603                 }
604         }
605 };
606
607 float checkrules_oneminutewarning;
608 float checkrules_leaderfrags;
609 entity checkrules_leader;
610 float tdm_max_score, tdm_old_score;
611
612 /*
613 ============
614 CheckRules_World
615
616 Exit deathmatch games upon conditions
617 ============
618 */
619 void() CheckRules_World =
620 {
621         local float timelimit;
622         local float fraglimit;
623         local float checkrules_oldleaderfrags;
624         local entity checkrules_oldleader;
625         local entity head;
626         
627         if (intermission_running)
628         if (time >= intermission_exittime + 60)
629         {
630                 GotoNextMap();
631                 return;
632         }
633
634         if (gameover)   // someone else quit the game already
635                 return;
636
637         timelimit = cvar("timelimit") * 60;
638         fraglimit = cvar("fraglimit");
639
640         if (timelimit && time >= timelimit)
641         {
642                 NextLevel ();
643                 return;
644         }
645
646         if (!checkrules_oneminutewarning && timelimit && time > timelimit - 60)
647         {
648                 checkrules_oneminutewarning = TRUE;
649                 sound(world, CHAN_AUTO, "announcer/robotic/1minuteremains.ogg", 1, ATTN_NONE);
650         }
651
652         // last man camping winning conditions
653         if(cvar("g_lms"))
654         {
655                 local float clients;
656                 clients = player_count + bot_number + actualurrebots;
657
658                 if(lms_dead_count < 0)
659                         lms_dead_count = 0;
660                 
661                 // goto next map if only one player is alive or 
662                 // if there is only one player as spectator (could happen with g_lms_join_anytime 1)
663                 if((clients > 1 && (clients - lms_dead_count) <= 1) || 
664                   (clients == 1 && lms_dead_count == 1))
665                         NextLevel();
666                 return;
667         }
668
669         if(cvar("teamplay") && (cvar("deathmatch") || cvar("g_runematch")) && fraglimit)
670         {
671                 team1_score = team2_score = team3_score = team4_score = 0;
672                 
673                 head = findchain(classname, "player");
674                 while (head)
675                 {
676                         if(head.team == COLOR_TEAM1)
677                                 team1_score += head.frags;
678                         else if(head.team == COLOR_TEAM2)
679                                 team2_score += head.frags;
680                         else if(head.team == COLOR_TEAM3)
681                                 team3_score += head.frags;
682                         else if(head.team == COLOR_TEAM4)
683                                 team4_score += head.frags;
684                         head = head.chain;
685                 }
686                 
687                 tdm_old_score = tdm_max_score;
688                 tdm_max_score = max(team1_score, team2_score, team3_score, team4_score);
689
690                 if(tdm_max_score >= fraglimit)
691                         NextLevel();
692
693                 if(tdm_max_score != tdm_old_score)
694                 {
695                         if(tdm_max_score == fraglimit - 1)
696                                 sound(world, CHAN_AUTO, "announcer/robotic/1fragleft.ogg", 1, ATTN_NONE);
697                         else if(tdm_max_score == fraglimit - 2)
698                                 sound(world, CHAN_AUTO, "announcer/robotic/2fragsleft.ogg", 1, ATTN_NONE);
699                         else if(tdm_max_score == fraglimit - 3)
700                                 sound(world, CHAN_AUTO, "announcer/robotic/3fragsleft.ogg", 1, ATTN_NONE);
701                 }
702                 return;
703         }
704         
705         checkrules_oldleader = checkrules_leader;
706         checkrules_oldleaderfrags = checkrules_leaderfrags;
707         checkrules_leaderfrags = 0;
708         checkrules_leader = world;
709         head = findchain(classname, "player");
710         while (head)
711         {
712                 if (checkrules_leaderfrags < head.frags)
713                 {
714                         checkrules_leaderfrags = head.frags;
715                         checkrules_leader = head;
716                 }
717                 head = head.chain;
718         }
719         if (checkrules_leaderfrags <= 0)
720         {
721                 checkrules_leader = world;
722                 checkrules_leaderfrags = 0;
723         }
724         checkrules_leaderfrags = floor(checkrules_leaderfrags);
725         if (checkrules_leaderfrags != checkrules_oldleaderfrags)
726         {
727                 if (checkrules_leaderfrags == fraglimit - 1)
728                         sound(world, CHAN_AUTO, "announcer/robotic/1fragleft.ogg", 1, ATTN_NONE);
729                 else if (checkrules_leaderfrags == fraglimit - 2)
730                         sound(world, CHAN_AUTO, "announcer/robotic/2fragsleft.ogg", 1, ATTN_NONE);
731                 else if (checkrules_leaderfrags == fraglimit - 3)
732                         sound(world, CHAN_AUTO, "announcer/robotic/3fragsleft.ogg", 1, ATTN_NONE);
733         }
734 //      if (checkrules_leader != checkrules_oldleader)// && checkrules_leaderfrags > checkrules_oldleaderfrags)
735 //              bprint("^1",checkrules_leader.netname, " has taken the lead with ", ftos(checkrules_leaderfrags), " frags\n");
736 };