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