]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/cl_client.qc
cleanup of spawn code;
[divverent/nexuiz.git] / data / qcsrc / server / cl_client.qc
1 .float wantswelcomemessage;
2 .string netname_previous;
3
4 void spawnfunc_info_player_survivor (void)
5 {
6         spawnfunc_info_player_deathmatch();
7 }
8
9 void spawnfunc_info_player_start (void)
10 {
11         spawnfunc_info_player_deathmatch();
12 }
13
14 void spawnfunc_info_player_deathmatch (void)
15 {
16         self.classname = "info_player_deathmatch";
17         relocate_spawnpoint();
18 }
19
20 void() spawnpoint_use =
21 {
22         if(teams_matter)
23         if(have_team_spawns)
24         {
25                 self.team = activator.team;
26                 some_spawn_has_been_used = 1;
27         }
28 };
29
30 // Returns:
31 //   -1 if a spawn can't be used
32 //   otherwise, a weight of the spawnpoint
33 float Spawn_Score(entity spot, entity playerlist, float teamcheck)
34 {
35         float shortest, thisdist;
36         entity player;
37
38         // filter out spots for the wrong team
39         if(teamcheck)
40         if(spot.team != teamcheck)
41                 return -1;
42
43         // filter out spots for assault
44         if(spot.target != "") {
45                 local entity ent;
46                 ent = find(world, targetname, spot.target);
47                 while(ent) {
48                         if(ent.classname == "target_objective")
49                                 if(ent.health < 0 || ent.health >= ASSAULT_VALUE_INACTIVE)
50                                         return -1;
51                         ent = find(ent, targetname, spot.target);
52                 }
53         }
54
55         player = playerlist;
56         shortest = vlen(world.maxs - world.mins);
57         for(player = playerlist; player; player = player.chain)
58                 if (player != self)
59                 {
60                         thisdist = vlen(player.origin - spot.origin);
61                         if (thisdist < shortest)
62                                 shortest = thisdist;
63                 }
64         return shortest;
65 }
66
67 float spawn_allbad;
68 float spawn_allgood;
69 entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindist, float teamcheck)
70 {
71         local entity spot, spotlist, spotlistend;
72         spawn_allgood = TRUE;
73         spawn_allbad = TRUE;
74
75         spotlist = world;
76         spotlistend = world;
77
78         for(spot = firstspot; spot; spot = spot.chain)
79         {
80                 spot.frags = Spawn_Score(spot, playerlist, teamcheck);
81
82                 if(cvar("spawn_debugview"))
83                 {
84                         setmodel(spot, "models/runematch/rune.mdl");
85                         if(spot.frags < mindist)
86                         {
87                                 spot.colormod = '1 0 0';
88                                 spot.scale = 1;
89                         }
90                         else
91                         {
92                                 spot.colormod = '0 1 0';
93                                 spot.scale = spot.frags / mindist;
94                         }
95                 }
96
97                 if(spot.frags >= 0) // spawning allowed here
98                 {
99                         if(spot.frags < mindist)
100                         {
101                                 // too short distance
102                                 spawn_allgood = FALSE;
103                         }
104                         else 
105                         {
106                                 // perfect
107                                 spawn_allbad = FALSE;
108
109                                 if(spotlistend)
110                                         spotlistend.chain = spot;
111                                 spotlistend = spot;
112                                 if(!spotlist)
113                                         spotlist = spot;
114                         }
115                 }
116         }
117
118         return spotlist;
119 }
120
121 entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exponent)
122 {
123         // weight of a point: bound(lower, mindisttoplayer, upper)^exponent
124         // multiplied by spot.cnt (useful if you distribute many spawnpoints in a small area)
125         local entity spot;
126
127         RandomSelection_Init();
128         for(spot = firstspot; spot; spot = spot.chain)
129                 RandomSelection_Add(spot, 0, pow(bound(lower, spot.frags, upper), exponent) * spot.cnt);
130
131         return RandomSelection_chosen_ent;
132 }
133
134 /*
135 =============
136 SelectSpawnPoint
137
138 Finds a point to respawn
139 =============
140 */
141 entity SelectSpawnPoint (float anypoint)
142 {
143         local float teamcheck;
144         local entity firstspot_new;
145         local entity spot, firstspot, playerlist;
146
147         spot = find (world, classname, "testplayerstart");
148         if (spot)
149                 return spot;
150
151         teamcheck = 0;
152
153         if(!anypoint && have_team_spawns)
154                 teamcheck = self.team;
155
156         // get the list of players
157         playerlist = findchain(classname, "player");
158         // get the entire list of spots
159         firstspot = findchain(classname, "info_player_deathmatch");
160         // filter out the bad ones
161         // (note this returns the original list if none survived)
162         firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 100, teamcheck);
163         if(!firstspot_new)
164                 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, -1, teamcheck);
165         firstspot = firstspot_new;
166
167         // there is 50/50 chance of choosing a random spot or the furthest spot
168         // (this means that roughly every other spawn will be furthest, so you
169         // usually won't get fragged at spawn twice in a row)
170         if (arena_roundbased)
171         {
172                 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 800, teamcheck);
173                 if(firstspot_new)
174                         firstspot = firstspot_new;
175                 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
176         }
177         else if (random() > cvar("g_spawn_furthest"))
178                 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
179         else
180                 spot = Spawn_WeightedPoint(firstspot, 1, 5000, 5); // chooses a far far away spawnpoint
181
182         if(cvar("spawn_debugview"))
183         {
184                 print("spot mindistance: ", ftos(spot.frags), "\n");
185         }
186
187         if (!spot)
188         {
189                 if(cvar("spawn_debug"))
190                         GotoNextMap();
191                 else
192                 {
193                         if(some_spawn_has_been_used)
194                                 return world; // team can't spawn any more, because of actions of other team
195                         else
196                                 error("Cannot find a spawn point - please fix the map!");
197                 }
198         }
199
200         return spot;
201 }
202
203 /*
204 =============
205 CheckPlayerModel
206
207 Checks if the argument string can be a valid playermodel.
208 Returns a valid one in doubt.
209 =============
210 */
211 string FallbackPlayerModel = "models/player/marine.zym";
212 string CheckPlayerModel(string plyermodel) {
213         if(strlen(plyermodel) < 4)
214                 return FallbackPlayerModel;
215         if( substring(plyermodel,0,14) != "models/player/")
216                 return FallbackPlayerModel;
217         else if(cvar("sv_servermodelsonly"))
218         {
219                 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".zym")
220                 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".dpm")
221                 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".md3")
222                 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".psk")
223                         return FallbackPlayerModel;
224                 if(!fexists(plyermodel))
225                         return FallbackPlayerModel;
226         }
227         return plyermodel;
228 }
229
230 /*
231 =============
232 Client_customizeentityforclient
233
234 LOD reduction
235 =============
236 */
237 float Client_customizeentityforclient()
238 {
239 #ifdef ALLOW_VARIABLE_LOD
240         // self: me
241         // other: the player viewing me
242         float distance;
243         float f;
244
245         if(self.flags & FL_NOTARGET) // we don't need LOD for spectators
246                 return TRUE;
247
248         if(other.cvar_cl_playerdetailreduction <= 0)
249         {
250                 if(other.cvar_cl_playerdetailreduction <= -2)
251                         self.modelindex = self.modelindex_lod2;
252                 else if(other.cvar_cl_playerdetailreduction <= -1)
253                         self.modelindex = self.modelindex_lod1;
254                 else
255                         self.modelindex = self.modelindex_lod0;
256         }
257         else
258         {
259                 distance = vlen(self.origin - other.origin);
260                 f = (distance + 100.0) * other.cvar_cl_playerdetailreduction;
261                 if(f > 10000)
262                         self.modelindex = self.modelindex_lod2;
263                 else if(f > 5000)
264                         self.modelindex = self.modelindex_lod1;
265                 else
266                         self.modelindex = self.modelindex_lod0;
267         }
268 #endif
269
270         return TRUE;
271 }
272
273 void UpdatePlayerSounds();
274 void setmodel_lod(entity e, string modelname)
275 {
276 #ifdef ALLOW_VARIABLE_LOD
277         string s;
278
279         // FIXME: this only supports 3-letter extensions
280         s = strcat(substring(modelname, 0, strlen(modelname) - 4), "_1", substring(modelname, 0, strlen(modelname) - 4));
281         if(fexists(s))
282         {
283                 precache_model(s);
284                 setmodel(e, s); // players have high precision
285                 self.modelindex_lod1 = self.modelindex;
286         }
287         else
288                 self.modelindex_lod1 = -1;
289
290         s = strcat(substring(modelname, 0, strlen(modelname) - 4), "_2", substring(modelname, 0, strlen(modelname) - 4));
291         if(fexists(s))
292         {
293                 precache_model(s);
294                 setmodel(e, s); // players have high precision
295                 self.modelindex_lod2 = self.modelindex;
296         }
297         else
298                 self.modelindex_lod2 = -1;
299
300         precache_model(modelname);
301         setmodel(e, modelname); // players have high precision
302         self.modelindex_lod0 = self.modelindex;
303
304         if(self.modelindex_lod1 < 0)
305                 self.modelindex_lod1 = self.modelindex;
306
307         if(self.modelindex_lod2 < 0)
308                 self.modelindex_lod2 = self.modelindex;
309 #else
310         precache_model(modelname);
311         setmodel(e, modelname); // players have high precision
312 #endif
313         player_setupanimsformodel();
314         UpdatePlayerSounds();
315 }
316
317 /*
318 =============
319 PutObserverInServer
320
321 putting a client as observer in the server
322 =============
323 */
324 void PutObserverInServer (void)
325 {
326         entity  spot;
327         spot = SelectSpawnPoint (TRUE);
328         if(!spot)
329                 error("No spawnpoints for observers?!?\n");
330         RemoveGrapplingHook(self); // Wazat's Grappling Hook
331
332         if(clienttype(self) == CLIENTTYPE_REAL)
333         {
334                 msg_entity = self;
335                 WriteByte(MSG_ONE, SVC_SETVIEW);
336                 WriteEntity(MSG_ONE, self);
337         }
338
339         DropAllRunes(self);
340         kh_Key_DropAll(self, TRUE);
341
342         if(self.flagcarried)
343                 DropFlag(self.flagcarried);
344
345         WaypointSprite_PlayerDead();
346
347         DistributeFragsAmongTeam(self, self.team, 1);
348
349         if(self.frags <= 0 && self.frags > -666 && g_lms && self.killcount != -666)
350                 bprint ("^4", self.netname, "^4 has no more lives left\n");
351         else if(self.killcount != -666)
352                 bprint ("^4", self.netname, "^4 is spectating now\n");
353
354         self.spectatortime = time;
355         
356         self.classname = "observer";
357         self.health = -666;
358         self.takedamage = DAMAGE_NO;
359         self.solid = SOLID_NOT;
360         self.movetype = MOVETYPE_NOCLIP;
361         self.flags = FL_CLIENT | FL_NOTARGET;
362         self.armorvalue = 666;
363         self.effects = 0;
364         self.armorvalue = cvar("g_balance_armor_start");
365         self.pauserotarmor_finished = 0;
366         self.pauserothealth_finished = 0;
367         self.pauseregen_finished = 0;
368         self.damageforcescale = 0;
369         self.death_time = 0;
370         self.dead_frame = 0;
371         self.deaths = 0;
372         self.alpha = 0;
373         self.scale = 0;
374         self.fade_time = 0;
375         self.pain_frame = 0;
376         self.pain_finished = 0;
377         self.strength_finished = 0;
378         self.invincible_finished = 0;
379         self.pushltime = 0;
380         self.think = SUB_Null;
381         self.nextthink = 0;
382         self.hook_time = 0;
383         self.runes = 0;
384         self.deadflag = DEAD_NO;
385         self.angles = spot.angles;
386         self.angles_z = 0;
387         self.fixangle = TRUE;
388         self.crouch = FALSE;
389
390         self.view_ofs = PL_VIEW_OFS;
391         setorigin (self, spot.origin);
392         setsize (self, '0 0 0', '0 0 0');
393         self.oldorigin = self.origin;
394         self.items = 0;
395         self.model = "";
396         self.modelindex = 0;
397         self.weapon = 0;
398         self.weaponmodel = "";
399         self.weaponentity = world;
400         self.killcount = -666;
401         self.velocity = '0 0 0';
402         self.avelocity = '0 0 0';
403         self.punchangle = '0 0 0';
404         self.punchvector = '0 0 0';
405         self.oldvelocity = self.velocity;
406         self.customizeentityforclient = Client_customizeentityforclient;
407         self.viewzoom = 1;
408         self.wantswelcomemessage = 1;
409
410         if(g_arena)
411         {
412                 if(self.frags != -2)
413                 {
414                         Spawnqueue_Insert(self);
415                 }
416                 else
417                 {
418                         Spawnqueue_Unmark(self);
419                         Spawnqueue_Remove(self);
420                 }
421         }
422         else if(!g_lms)
423                 self.frags = -666;
424 }
425
426 float RestrictSkin(float s)
427 {
428         if(!teams_matter)
429                 return s;
430         if(s == 6)
431                 return 6;
432         return mod(s, 3);
433 }
434
435 void FixPlayermodel()
436 {
437         local string defaultmodel;
438         local float defaultskin;
439         local vector m1, m2;
440
441         defaultmodel = "";
442
443         if(cvar("sv_defaultcharacter") == 1) {
444                 defaultskin = 0;
445
446                 if(teams_matter)
447                 {
448                         defaultmodel = cvar_string(strcat("sv_defaultplayermodel_", Team_ColorNameLowerCase(self.team)));
449                         defaultskin = cvar(strcat("sv_defaultplayerskin_", Team_ColorNameLowerCase(self.team)));
450                 }
451
452                 if(defaultmodel == "")
453                 {
454                         defaultmodel = cvar_string("sv_defaultplayermodel");
455                         defaultskin = cvar("sv_defaultplayerskin");
456                 }
457         }
458
459         if(defaultmodel != "")
460         {
461                 if (defaultmodel != self.model)
462                 {
463                         m1 = self.mins;
464                         m2 = self.maxs;
465                         setmodel_lod (self, defaultmodel);
466                         setsize (self, m1, m2);
467                 }
468
469                 self.skin = defaultskin;
470         } else {
471                 if (self.playermodel != self.model)
472                 {
473                         self.playermodel = CheckPlayerModel(self.playermodel);
474                         m1 = self.mins;
475                         m2 = self.maxs;
476                         setmodel_lod (self, self.playermodel);
477                         setsize (self, m1, m2);
478                 }
479
480                 self.skin = RestrictSkin(stof(self.playerskin));
481         }
482
483         if(!teams_matter)
484                 if(strlen(cvar_string("sv_defaultplayercolors")))
485                         if(self.clientcolors != cvar("sv_defaultplayercolors"))
486                                 setcolor(self, cvar("sv_defaultplayercolors"));
487 }
488
489 /*
490 =============
491 PutClientInServer
492
493 Called when a client spawns in the server
494 =============
495 */
496 void PutClientInServer (void)
497 {
498         if(clienttype(self) == CLIENTTYPE_BOT)
499         {
500                 self.classname = "player";
501         }
502         else if(clienttype(self) == CLIENTTYPE_REAL)
503         {
504                 msg_entity = self;
505                 WriteByte(MSG_ONE, SVC_SETVIEW);
506                 WriteEntity(MSG_ONE, self);
507         }
508
509         // player is dead and becomes observer
510         if(g_lms && self.frags < 1)
511                 self.classname = "observer";
512
513         if(g_arena)
514         if(!self.spawned)
515                 self.classname = "observer";
516
517         if(self.classname == "player") {
518                 entity  spot;
519
520                 spot = SelectSpawnPoint (FALSE);
521                 if(!spot)
522                 {
523                         centerprint(self, "Sorry, no spawnpoints available!\nHope your team can fix it...");
524                         return; // spawn failed
525                 }
526
527                 RemoveGrapplingHook(self); // Wazat's Grappling Hook
528
529                 self.classname = "player";
530                 self.iscreature = TRUE;
531                 self.movetype = MOVETYPE_WALK;
532                 self.solid = SOLID_SLIDEBOX;
533                 self.flags = FL_CLIENT;
534                 self.takedamage = DAMAGE_AIM;
535                 if(g_minstagib)
536                         self.effects = EF_FULLBRIGHT;
537                 else
538                         self.effects = 0;
539                 self.air_finished = time + 12;
540                 self.dmg = 2;
541
542                 self.ammo_shells = start_ammo_shells;
543                 self.ammo_nails = start_ammo_nails;
544                 self.ammo_rockets = start_ammo_rockets;
545                 self.ammo_cells = start_ammo_cells;
546                 self.health = start_health;
547                 self.armorvalue = start_armorvalue;
548                 self.items = start_items;
549                 self.switchweapon = start_switchweapon;
550                 self.cnt = start_switchweapon;
551                 self.weapon = 0;
552                 self.jump_interval = time;
553
554                 self.spawnshieldtime = time + cvar("g_spawnshieldtime");
555                 self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
556                 self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
557                 self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
558                 //extend the pause of rotting if client was reset at the beginning of the countdown
559                 if(!cvar("sv_ready_restart_after_countdown") && time < restart_countdown) {
560                         self.spawnshieldtime += RESTART_COUNTDOWN;
561                         self.pauserotarmor_finished += RESTART_COUNTDOWN;
562                         self.pauserothealth_finished += RESTART_COUNTDOWN;
563                         self.pauseregen_finished += RESTART_COUNTDOWN;
564                 }
565                 self.damageforcescale = 2;
566                 self.death_time = 0;
567                 self.dead_frame = 0;
568                 self.alpha = 0;
569                 self.scale = 0;
570                 self.fade_time = 0;
571                 self.pain_frame = 0;
572                 self.pain_finished = 0;
573                 self.strength_finished = 0;
574                 self.invincible_finished = 0;
575                 self.pushltime = 0;
576                 //self.speed_finished = 0;
577                 //self.slowmo_finished = 0;
578                 // players have no think function
579                 self.think = SUB_Null;
580                 self.nextthink = 0;
581                 self.hook_time = 0;
582
583                 self.runes = 0;
584
585                 self.deadflag = DEAD_NO;
586
587                 self.angles = spot.angles;
588
589                 self.angles_z = 0; // never spawn tilted even if the spot says to
590                 self.fixangle = TRUE; // turn this way immediately
591                 self.velocity = '0 0 0';
592                 self.avelocity = '0 0 0';
593                 self.punchangle = '0 0 0';
594                 self.punchvector = '0 0 0';
595                 self.oldvelocity = self.velocity;
596
597                 self.viewzoom = 0.6;
598                 self.has_zoomed = 0;
599
600                 self.customizeentityforclient = Client_customizeentityforclient;
601
602                 self.model = "";
603                 FixPlayermodel();
604
605                 self.crouch = FALSE;
606                 self.view_ofs = PL_VIEW_OFS;
607                 setsize (self, PL_MIN, PL_MAX);
608                 self.spawnorigin = spot.origin;
609                 setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 24));
610                 // don't reset back to last position, even if new position is stuck in solid
611                 self.oldorigin = self.origin;
612
613                 if(g_arena)
614                 {
615                         Spawnqueue_Remove(self);
616                         Spawnqueue_Mark(self);
617                 }
618
619                 self.event_damage = PlayerDamage;
620
621                 self.bot_attack = TRUE;
622
623                 self.statdraintime = time + 5;
624                 self.button0 = self.button1 = self.button2 = self.button3 = 0;
625
626                 if(self.killcount == -666) {
627                         self.killcount = 0;
628                         if(!g_arena)
629                         if(!g_lms)
630                                 self.frags = 0;
631                 }
632
633                 self.cnt = WEP_LASER;
634                 self.nixnex_lastchange_id = -1;
635
636                 CL_SpawnWeaponentity();
637                 self.alpha = default_player_alpha;
638                 self.colormod = '1 1 1' * cvar("g_player_brightness");
639                 self.exteriorweaponentity.alpha = default_weapon_alpha;
640
641                 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval")*2;
642                 self.lms_traveled_distance = 0;
643                 self.speedrunning = FALSE;
644
645                 if(cvar("spawn_debug"))
646                 {
647                         sprint(self, strcat("spawnpoint origin:  ", vtos(spot.origin), "\n"));
648                         remove(spot);   // usefull for checking if there are spawnpoints, that let drop through the floor
649                 }
650
651                 //stuffcmd(self, "chase_active 0");
652                 //stuffcmd(self, "set viewsize $tmpviewsize \n");
653
654                 if (cvar("g_spawnsound"))
655                         sound (self, CHAN_AUTO, "misc/spawn.wav", 1, ATTN_NORM);
656
657                 if(g_assault) {
658                         if(self.team == assault_attacker_team)
659                                 centerprint(self, "You are attacking!\n");
660                         else
661                                 centerprint(self, "You are defending!\n");
662                 }
663
664         } else if(self.classname == "observer") {
665                 PutObserverInServer ();
666         }
667 }
668
669 /*
670 =============
671 SetNewParms
672 =============
673 */
674 void SetNewParms (void)
675 {
676
677 }
678
679 /*
680 =============
681 SetChangeParms
682 =============
683 */
684 void SetChangeParms (void)
685 {
686
687 }
688
689 /*
690 =============
691 ClientKill
692
693 Called when a client types 'kill' in the console
694 =============
695 */
696
697 void ClientKill_Now_TeamChange()
698 {
699         if(self.killindicator_teamchange == -1)
700         {
701                 self.team = -1;
702                 JoinBestTeam( self, FALSE, FALSE );
703         }
704         else
705         {
706                 SV_ChangeTeam(self.killindicator_teamchange - 1);
707         }
708 }
709
710 void ClientKill_Now()
711 {
712         if(self.killindicator_teamchange)
713                 ClientKill_Now_TeamChange();
714
715         // in any case:
716         Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
717 }
718 void KillIndicator_Think()
719 {
720         if (!self.owner.modelindex)
721         {
722                 self.owner.killindicator = world;
723                 remove(self);
724                 return;
725         }
726
727         if(self.cnt <= 0)
728         {
729                 self = self.owner;
730                 ClientKill_Now(); // no oldself needed
731                 return;
732         }
733         else
734         {
735                 if(self.cnt <= 10)
736                         setmodel(self, strcat("models/sprites/", ftos(self.cnt), ".spr32"));
737                 if(clienttype(self.owner) == CLIENTTYPE_REAL)
738                 {
739                         if(self.cnt <= 10)
740                                 play2(self.owner, strcat("announcer/robotic/", ftos(self.cnt), ".ogg"));
741                         if(self.owner.killindicator_teamchange)
742                         {
743                                 if(self.owner.killindicator_teamchange == -1)
744                                         centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds"));
745                                 else
746                                         centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
747                         }
748                         else
749                                 centerprint(self.owner, strcat("^1Suicide in ", ftos(self.cnt), " seconds"));
750                 }
751                 self.nextthink = time + 1;
752                 self.cnt -= 1;
753         }
754 }
755
756 void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto
757 {
758         float killtime;
759         entity e;
760         killtime = cvar("g_balance_kill_delay");
761
762         self.killindicator_teamchange = targetteam;
763
764         if(!self.killindicator)
765         {
766                 if(killtime <= 0 || !self.modelindex || self.deadflag != DEAD_NO)
767                 {
768                         ClientKill_Now();
769                 }
770                 else
771                 {
772                         self.killindicator = spawn();
773                         self.killindicator.owner = self;
774                         self.killindicator.scale = 0.5;
775                         setattachment(self.killindicator, self, "");
776                         setorigin(self.killindicator, '0 0 52');
777                         self.killindicator.think = KillIndicator_Think;
778                         self.killindicator.nextthink = time + (self.lip) * 0.05;
779                         self.killindicator.cnt = ceil(killtime);
780                         self.killindicator.count = bound(0, ceil(killtime), 10);
781                         sprint(self, strcat("^1You'll be dead in ", ftos(self.killindicator.cnt), " seconds\n"));
782
783                         for(e = world; (e = find(e, classname, "body")) != world; )
784                         {
785                                 if(e.enemy != self)
786                                         continue;
787                                 e.killindicator = spawn();
788                                 e.killindicator.owner = e;
789                                 e.killindicator.scale = 0.5;
790                                 setattachment(e.killindicator, e, "");
791                                 setorigin(e.killindicator, '0 0 52');
792                                 e.killindicator.think = KillIndicator_Think;
793                                 e.killindicator.nextthink = time + (e.lip) * 0.05;
794                                 e.killindicator.cnt = ceil(killtime);
795                         }
796                         self.lip = 0;
797                 }
798         }
799         if(self.killindicator)
800         {
801                 if(targetteam)
802                         self.killindicator.colormod = TeamColor(targetteam);
803                 else
804                         self.killindicator.colormod = '0 0 0';
805         }
806 }
807
808 void ClientKill (void)
809 {
810         ClientKill_TeamChange(0);
811 }
812
813 void DoTeamChange(float destteam)
814 {
815         float t, c0;
816         if(!cvar("teamplay"))
817         {
818                 if(destteam >= 0)
819                         SetPlayerColors(self, destteam);
820                 return;
821         }
822         if(self.classname == "player")
823         if(destteam == -1)
824         {
825                 CheckAllowedTeams(self);
826                 t = FindSmallestTeam(self, TRUE);
827                 switch(self.team)
828                 {
829                         case COLOR_TEAM1: c0 = c1; break;
830                         case COLOR_TEAM2: c0 = c2; break;
831                         case COLOR_TEAM3: c0 = c3; break;
832                         case COLOR_TEAM4: c0 = c4; break;
833                         default:          c0 = 999;
834                 }
835                 switch(t)
836                 {
837                         case 1:
838                                 if(c0 > c1)
839                                         destteam = COLOR_TEAM1;
840                                 break;
841                         case 2:
842                                 if(c0 > c2)
843                                         destteam = COLOR_TEAM2;
844                                 break;
845                         case 3:
846                                 if(c0 > c3)
847                                         destteam = COLOR_TEAM3;
848                                 break;
849                         case 4:
850                                 if(c0 > c4)
851                                         destteam = COLOR_TEAM4;
852                                 break;
853                 }
854                 if(destteam == -1)
855                         return;
856         }
857         if(destteam == self.team && !self.killindicator)
858                 return;
859         ClientKill_TeamChange(destteam);
860 }
861
862 void FixClientCvars(entity e)
863 {
864         // send prediction settings to the client
865         stuffcmd(e, "\nin_bindmap 0 0\n");
866         /*
867          * we no longer need to stuff this. Remove this comment block if you feel 
868          * 2.3 and higher (or was it 2.2.3?) don't need these any more
869         stuffcmd(e, strcat("cl_gravity ", ftos(cvar("sv_gravity")), "\n"));
870         stuffcmd(e, strcat("cl_movement_accelerate ", ftos(cvar("sv_accelerate")), "\n"));
871         stuffcmd(e, strcat("cl_movement_friction ", ftos(cvar("sv_friction")), "\n"));
872         stuffcmd(e, strcat("cl_movement_maxspeed ", ftos(cvar("sv_maxspeed")), "\n"));
873         stuffcmd(e, strcat("cl_movement_airaccelerate ", ftos(cvar("sv_airaccelerate")), "\n"));
874         stuffcmd(e, strcat("cl_movement_maxairspeed ", ftos(cvar("sv_maxairspeed")), "\n"));
875         stuffcmd(e, strcat("cl_movement_stopspeed ", ftos(cvar("sv_stopspeed")), "\n"));
876         stuffcmd(e, strcat("cl_movement_jumpvelocity ", ftos(cvar("sv_jumpvelocity")), "\n"));
877         stuffcmd(e, strcat("cl_movement_stepheight ", ftos(cvar("sv_stepheight")), "\n"));
878         stuffcmd(e, strcat("set cl_movement_friction_on_land ", ftos(cvar("sv_friction_on_land")), "\n"));
879         stuffcmd(e, strcat("set cl_movement_airaccel_qw ", ftos(cvar("sv_airaccel_qw")), "\n"));
880         stuffcmd(e, strcat("set cl_movement_airaccel_sideways_friction ", ftos(cvar("sv_airaccel_sideways_friction")), "\n"));
881         stuffcmd(e, "cl_movement_edgefriction 1\n");
882          */
883 }
884
885 /*
886 =============
887 ClientConnect
888
889 Called when a client connects to the server
890 =============
891 */
892 string ColoredTeamName(float t);
893 //void dom_player_join_team(entity pl);
894 void ClientConnect (void)
895 {
896         local string s;
897         float wep;
898
899         if(Ban_IsClientBanned(self))
900         {
901                 s = strcat("^1NOTE:^7 banned client ", self.netaddress, " just tried to enter\n");
902                 dropclient(self);
903                 bprint(s);
904                 return;
905         }
906
907         self.classname = "player_joining";
908         self.flags = self.flags | FL_CLIENT;
909         self.version_nagtime = time + 10 + random() * 10;
910
911         if(player_count<0)
912         {
913                 dprint("BUG player count is lower than zero, this cannot happen!\n");
914                 player_count = 0;
915         }
916
917         bot_clientconnect();
918
919         //if(g_domination)
920         //      dom_player_join_team(self);
921
922         //JoinBestTeam(self, FALSE, FALSE);
923
924         if((cvar("sv_spectate") == 1 && !g_lms) || cvar("g_campaign")) {
925                 self.classname = "observer";
926         } else {
927                 self.classname = "player";
928                 campaign_bots_may_start = 1;
929         }
930
931         self.playerid = (playerid_last = playerid_last + 1);
932         if(cvar("sv_eventlog"))
933         {
934                 if(clienttype(self) == CLIENTTYPE_REAL)
935                         s = "player";
936                 else
937                         s = "bot";
938                 GameLogEcho(strcat(":join:", ftos(self.playerid), ":", s, ":", self.netname), TRUE);
939                 s = strcat(":team:", ftos(self.playerid), ":");
940                 s = strcat(s, ftos(self.team));
941                 GameLogEcho(s, FALSE);
942         }
943         self.netname_previous = strzone(self.netname);
944
945         //stuffcmd(self, "set tmpviewsize $viewsize \n");
946
947         bprint ("^4",self.netname);
948         bprint ("^4 connected");
949
950         if(g_domination || g_ctf)
951         {
952                 bprint(" and joined the ");
953                 bprint(ColoredTeamName(self.team));
954         }
955
956         bprint("\n");
957
958         self.welcomemessage_time = 0;
959
960         stuffcmd(self, strcat("exec maps/", mapname, ".cfg\n"));
961         // TODO: is this being used for anything else than cd tracks?
962         // Remember: SVC_CDTRACK exists. Maybe it should be used.
963         //
964         stuffcmd(self, "cl_particles_reloadeffects\n");
965
966         FixClientCvars(self);
967
968         // spawnfunc_waypoint sprites
969         WaypointSprite_InitClient(self);
970
971         // Wazat's grappling hook
972         SetGrappleHookBindings();
973
974         // get autoswitch state from player when he toggles it
975         stuffcmd(self, "alias autoswitch \"set cl_autoswitch $1 ; cmd autoswitch $1\"\n"); // default.cfg-ed in 2.4.1
976
977         // get version info from player
978         stuffcmd(self, "cmd clientversion $gameversion\n");
979
980         // send all weapon info strings
981         stuffcmd(self, "register_bestweapon clear\n"); // clear the Quake stuff
982         wep = WEP_FIRST;
983         while (wep <= WEP_LAST)
984         {
985                 weapon_action(wep, WR_REGISTER);
986                 wep = wep + 1;
987         }
988
989         // get other cvars from player
990         GetCvars(0);
991
992         // set cvar for team scoreboard
993         if (teams_matter)
994         {
995                 local float t;
996                 t = cvar("teamplay");
997                 // we have to stuff the correct teamplay value because if this is a listen server, this changes the teamplay mode of the server itself, which is bad
998                 stuffcmd(self, strcat("set teamplay ", ftos(t), "\n"));
999         }
1000         else
1001                 stuffcmd(self, "set teamplay 0\n");
1002
1003         // notify about available teams
1004         if(teamplay)
1005         {
1006                 CheckAllowedTeams(self);
1007                 t = 0; if(c1 >= 0) t |= 1; if(c2 >= 0) t |= 2; if(c3 >= 0) t |= 4; if(c4 >= 0) t |= 8;
1008                 stuffcmd(self, strcat("set _teams_available ", ftos(t), "\n"));
1009         }
1010         else
1011                 stuffcmd(self, "set _teams_available 0\n");
1012
1013         stuffcmd(self, strcat("set gametype ", ftos(game), "\n"));
1014
1015         if(g_lms)
1016         {
1017                 self.frags = LMS_NewPlayerLives();
1018                 if(!self.frags)
1019                         self.frags = -666;
1020         }
1021         else if(g_arena)
1022         {
1023                 self.classname = "observer";
1024                 Spawnqueue_Insert(self);
1025         }
1026
1027         bot_relinkplayerlist();
1028
1029         self.spectatortime = time;
1030         if(blockSpectators)
1031         {
1032                 sprint(self, strcat("^7You have to become a player within the next ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
1033         }
1034
1035         self.jointime = time;
1036         self.allowedTimeouts = cvar("sv_timeout_number");
1037 }
1038
1039 /*
1040 =============
1041 ClientDisconnect
1042
1043 Called when a client disconnects from the server
1044 =============
1045 */
1046 void(entity e) DropFlag;
1047 .entity chatbubbleentity;
1048 .entity teambubbleentity;
1049 void ClientDisconnect (void)
1050 {
1051         float save;
1052         if(cvar("sv_eventlog"))
1053                 GameLogEcho(strcat(":part:", ftos(self.playerid)), FALSE);
1054         bprint ("^4",self.netname);
1055         bprint ("^4 disconnected\n");
1056
1057         if (self.chatbubbleentity)
1058         {
1059                 remove (self.chatbubbleentity);
1060                 self.chatbubbleentity = world;
1061         }
1062
1063         if (self.teambubbleentity)
1064         {
1065                 remove (self.teambubbleentity);
1066                 self.teambubbleentity = world;
1067         }
1068
1069         if (self.killindicator)
1070         {
1071                 remove (self.killindicator);
1072                 self.killindicator = world;
1073         }
1074
1075         WaypointSprite_PlayerGone();
1076
1077         DropAllRunes(self);
1078         kh_Key_DropAll(self, TRUE);
1079
1080         if(self.flagcarried)
1081                 DropFlag(self.flagcarried);
1082
1083         DistributeFragsAmongTeam(self, self.team, 1);
1084
1085         save = self.flags;
1086         self.flags = self.flags - (self.flags & FL_CLIENT);
1087         bot_relinkplayerlist();
1088         self.flags = save;
1089
1090         // remove laserdot
1091         if(self.weaponentity)
1092                 if(self.weaponentity.lasertarget)
1093                         remove(self.weaponentity.lasertarget);
1094
1095         if(g_arena)
1096         {
1097                 Spawnqueue_Unmark(self);
1098                 Spawnqueue_Remove(self);
1099         }
1100
1101         if(self.netname_previous)
1102                 strunzone(self.netname_previous);
1103
1104         // free cvars
1105         GetCvars(-1);
1106 }
1107
1108 .float buttonchat;
1109 void() ChatBubbleThink =
1110 {
1111         self.nextthink = time;
1112         if (!self.owner.modelindex || self.owner.chatbubbleentity != self)
1113         {
1114                 self.owner.chatbubbleentity = world;
1115                 remove(self);
1116                 return;
1117         }
1118         setorigin(self, self.owner.origin + '0 0 15' + self.owner.maxs_z * '0 0 1');
1119         if (self.owner.buttonchat && !self.owner.deadflag)
1120                 self.model = self.mdl;
1121         else
1122                 self.model = "";
1123 };
1124
1125 void() UpdateChatBubble =
1126 {
1127         if (!self.modelindex)
1128                 return;
1129         // spawn a chatbubble entity if needed
1130         if (!self.chatbubbleentity)
1131         {
1132                 self.chatbubbleentity = spawn();
1133                 self.chatbubbleentity.owner = self;
1134                 self.chatbubbleentity.exteriormodeltoclient = self;
1135                 self.chatbubbleentity.think = ChatBubbleThink;
1136                 self.chatbubbleentity.nextthink = time;
1137                 setmodel(self.chatbubbleentity, "models/misc/chatbubble.spr"); // precision set below
1138                 setorigin(self.chatbubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
1139                 self.chatbubbleentity.mdl = self.chatbubbleentity.model;
1140                 self.chatbubbleentity.model = "";
1141                 self.chatbubbleentity.effects = EF_LOWPRECISION;
1142         }
1143 }
1144
1145
1146 void() TeamBubbleThink =
1147 {
1148         self.nextthink = time;
1149         if (!self.owner.modelindex || self.owner.teambubbleentity != self)
1150         {
1151                 self.owner.teambubbleentity = world;
1152                 remove(self);
1153                 return;
1154         }
1155 //      setorigin(self, self.owner.origin + '0 0 15' + self.owner.maxs_z * '0 0 1');  // bandwidth hog. setattachment does this now
1156         if (self.owner.buttonchat || self.owner.deadflag || self.owner.killindicator)
1157                 self.model = "";
1158         else
1159                 self.model = self.mdl;
1160
1161 };
1162
1163 float() TeamBubble_customizeentityforclient
1164 {
1165         return (self.owner != other && self.owner.team == other.team && other.killcount > -666);
1166 }
1167
1168 void() UpdateTeamBubble =
1169 {
1170         if (!self.modelindex || !cvar("teamplay"))
1171                 return;
1172         // spawn a teambubble entity if needed
1173         if (!self.teambubbleentity && cvar("teamplay"))
1174         {
1175                 self.teambubbleentity = spawn();
1176                 self.teambubbleentity.owner = self;
1177                 self.teambubbleentity.exteriormodeltoclient = self;
1178                 self.teambubbleentity.think = TeamBubbleThink;
1179                 self.teambubbleentity.nextthink = time;
1180                 setmodel(self.teambubbleentity, "models/misc/teambubble.spr"); // precision set below
1181 //              setorigin(self.teambubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
1182                 setorigin(self.teambubbleentity, self.teambubbleentity.origin + '0 0 15' + self.maxs_z * '0 0 1');
1183                 setattachment(self.teambubbleentity, self, "");  // sticks to moving player better, also conserves bandwidth
1184                 self.teambubbleentity.mdl = self.teambubbleentity.model;
1185                 self.teambubbleentity.model = self.teambubbleentity.mdl;
1186                 self.teambubbleentity.customizeentityforclient = TeamBubble_customizeentityforclient;
1187                 self.teambubbleentity.effects = EF_LOWPRECISION;
1188         }
1189 }
1190
1191 // LordHavoc: this hack will be removed when proper _pants/_shirt layers are
1192 // added to the model skins
1193 /*void() UpdateColorModHack =
1194 {
1195         local float c;
1196         c = self.clientcolors & 15;
1197         // LordHavoc: only bothering to support white, green, red, yellow, blue
1198              if (teamplay == 0) self.colormod = '0 0 0';
1199         else if (c ==  0) self.colormod = '1.00 1.00 1.00';
1200         else if (c ==  3) self.colormod = '0.10 1.73 0.10';
1201         else if (c ==  4) self.colormod = '1.73 0.10 0.10';
1202         else if (c == 12) self.colormod = '1.22 1.22 0.10';
1203         else if (c == 13) self.colormod = '0.10 0.10 1.73';
1204         else self.colormod = '1 1 1';
1205 };*/
1206
1207 void respawn(void)
1208 {
1209         CopyBody(1);
1210         self.effects |= EF_NODRAW; // prevent another CopyBody
1211         PutClientInServer();
1212 }
1213
1214 /**
1215  * When sv_timeout is used this function returs strings like
1216  * "Timeout begins in 2 seconds!\n" or "Timeout ends in 23 seconds!\n".
1217  * Called by centerprint functions
1218  * @param addOneSecond boolean, set to 1 if the welcome-message centerprint asks for the text
1219  */
1220 string getTimeoutText(float addOneSecond) {
1221         if (!cvar("sv_timeout") || !timeoutStatus)
1222                 return "";
1223
1224         local string retStr;
1225         if (timeoutStatus == 1) {
1226                 if (addOneSecond == 1) {
1227                         retStr = strcat("Timeout begins in ", ftos(remainingLeadTime + 1), " seconds!\n");
1228                 }
1229                 else {
1230                         retStr = strcat("Timeout begins in ", ftos(remainingLeadTime), " seconds!\n");
1231                 }
1232                 return retStr;
1233         }
1234         else if (timeoutStatus == 2) {
1235                 if (addOneSecond) {
1236                         retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime + 1), " seconds!\n");
1237                         //don't show messages like "Timeout ends in 0 seconds"...
1238                         if ((remainingTimeoutTime + 1) > 0)
1239                                 return retStr;
1240                         else
1241                                 return "";
1242                 }
1243                 else {
1244                         retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime), " seconds!\n");
1245                         //don't show messages like "Timeout ends in 0 seconds"...
1246                         if (remainingTimeoutTime > 0)
1247                                 return retStr;
1248                         else
1249                                 return "";
1250                 }
1251         }
1252         else return "";
1253 }
1254
1255 void player_powerups (void)
1256 {
1257         if (g_minstagib)
1258         {
1259                 if (self.items & IT_STRENGTH)
1260                 {
1261                         if (time > self.strength_finished)
1262                         {
1263                                 if (g_minstagib_invis_alpha > 0)
1264                                 {
1265                                         self.alpha = default_player_alpha;
1266                                         self.exteriorweaponentity.alpha = default_weapon_alpha;
1267                                         self.effects = self.effects | EF_FULLBRIGHT;
1268                                 }
1269                                 else
1270                                 {
1271                                         self.effects -= self.effects & EF_NODRAW;
1272                                 }
1273                                 self.items = self.items - (self.items & IT_STRENGTH);
1274                                 sprint(self, "^3Invisibility has worn off\n");
1275                         }
1276                 }
1277                 else
1278                 {
1279                         if (time < self.strength_finished)
1280                         {
1281                                 if (g_minstagib_invis_alpha > 0)
1282                                 {
1283                                         self.alpha = g_minstagib_invis_alpha;
1284                                         self.exteriorweaponentity.alpha = g_minstagib_invis_alpha;
1285                                         self.effects -= self.effects & EF_FULLBRIGHT;
1286                                 }
1287                                 else
1288                                 {
1289                                         self.effects = self.effects | EF_NODRAW;
1290                                 }
1291                                 self.items = self.items | IT_STRENGTH;
1292                                 sprint(self, "^3You are invisible\n");
1293                         }
1294                 }
1295
1296                 if (self.items & IT_INVINCIBLE)
1297                 {
1298                         if (time > self.invincible_finished)
1299                         {
1300                                 self.items = self.items - (self.items & IT_INVINCIBLE);
1301                                 sprint(self, "^3Speed has worn off\n");
1302                         }
1303                 }
1304                 else
1305                 {
1306                         if (time < self.invincible_finished)
1307                         {
1308                                 self.items = self.items | IT_INVINCIBLE;
1309                                 sprint(self, "^3You are on speed\n");
1310                         }
1311                 }
1312                 return;
1313         }
1314
1315         self.effects = self.effects - (self.effects & (EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT));
1316         if (self.items & IT_STRENGTH)
1317         {
1318                 self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
1319                 if (time > self.strength_finished)
1320                 {
1321                         self.items = self.items - (self.items & IT_STRENGTH);
1322                         sprint(self, "^3Strength has worn off\n");
1323                 }
1324         }
1325         else
1326         {
1327                 if (time < self.strength_finished)
1328                 {
1329                         self.items = self.items | IT_STRENGTH;
1330                         sprint(self, "^3Strength infuses your weapons with devastating power\n");
1331                 }
1332         }
1333         if (self.items & IT_INVINCIBLE)
1334         {
1335                 self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
1336                 if (time > self.invincible_finished)
1337                 {
1338                         self.items = self.items - (self.items & IT_INVINCIBLE);
1339                         sprint(self, "^3Shield has worn off\n");
1340                 }
1341         }
1342         else
1343         {
1344                 if (time < self.invincible_finished)
1345                 {
1346                         self.items = self.items | IT_INVINCIBLE;
1347                         sprint(self, "^3Shield surrounds you\n");
1348                 }
1349         }
1350
1351         if (cvar("g_fullbrightplayers"))
1352                 self.effects = self.effects | EF_FULLBRIGHT;
1353
1354         // midair gamemode: damage only while in the air
1355         // if in midair mode, being on ground grants temporary invulnerability
1356         // (this is so that multishot weapon don't clear the ground flag on the
1357         // first damage in the frame, leaving the player vulnerable to the
1358         // remaining hits in the same frame)
1359         if (self.flags & FL_ONGROUND)
1360         if (g_midair)
1361                 self.spawnshieldtime = max(self.spawnshieldtime, time + cvar("g_midair_shieldtime"));
1362
1363         if (time < self.spawnshieldtime)
1364                 self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT);
1365 }
1366
1367 float CalcRegen(float current, float stable, float regenfactor)
1368 {
1369         if(current > stable)
1370                 return current;
1371         else if(current > stable - 0.25) // when close enough, "snap"
1372                 return stable;
1373         else
1374                 return min(stable, current + (stable - current) * regenfactor * frametime);
1375 }
1376
1377 void player_regen (void)
1378 {
1379         float maxh, maxa, limith, limita, max_mod, regen_mod, rot_mod, limit_mod;
1380         maxh = cvar("g_balance_health_stable");
1381         maxa = cvar("g_balance_armor_stable");
1382         limith = cvar("g_balance_health_limit");
1383         limita = cvar("g_balance_armor_limit");
1384
1385         if (g_minstagib || (g_lms && !cvar("g_lms_regenerate")))
1386                 return;
1387
1388         max_mod = regen_mod = rot_mod = limit_mod = 1;
1389
1390         if (self.runes & RUNE_REGEN)
1391         {
1392                 if (self.runes & CURSE_VENOM) // do we have both rune/curse?
1393                 {
1394                         regen_mod = cvar("g_balance_rune_regen_combo_regenrate");
1395                         max_mod = cvar("g_balance_rune_regen_combo_hpmod");
1396                         limit_mod = cvar("g_balance_rune_regen_combo_limitmod");
1397                 }
1398                 else
1399                 {
1400                         regen_mod = cvar("g_balance_rune_regen_regenrate");
1401                         max_mod = cvar("g_balance_rune_regen_hpmod");
1402                         limit_mod = cvar("g_balance_rune_regen_limitmod");
1403                 }
1404         }
1405         else if (self.runes & CURSE_VENOM)
1406         {
1407                 max_mod = cvar("g_balance_curse_venom_hpmod");
1408                 if (self.runes & RUNE_REGEN) // do we have both rune/curse?
1409                         rot_mod = cvar("g_balance_rune_regen_combo_rotrate");
1410                 else
1411                         rot_mod = cvar("g_balance_curse_venom_rotrate");
1412                 limit_mod = cvar("g_balance_curse_venom_limitmod");
1413                 //if (!self.runes & RUNE_REGEN)
1414                 //      rot_mod = cvar("g_balance_curse_venom_rotrate");
1415         }
1416         maxh = maxh * max_mod;
1417         //maxa = maxa * max_mod;
1418         limith = limith * limit_mod;
1419         limita = limita * limit_mod;
1420
1421         if (self.armorvalue > maxa)
1422         {
1423                 if (time > self.pauserotarmor_finished)
1424                 {
1425                         self.armorvalue = max(maxa, self.armorvalue + (maxa - self.armorvalue) * cvar("g_balance_armor_rot") * frametime);
1426                         self.armorvalue = max(maxa, self.armorvalue - cvar("g_balance_armor_rotlinear") * frametime);
1427                 }
1428         }
1429         else if (self.armorvalue < maxa)
1430         {
1431                 if (time > self.pauseregen_finished)
1432                 {
1433                         self.armorvalue = CalcRegen(self.armorvalue, maxa, cvar("g_balance_armor_regen"));
1434                         self.armorvalue = min(maxa, self.armorvalue + cvar("g_balance_armor_regenlinear") * frametime);
1435                 }
1436         }
1437         if (self.health > maxh)
1438         {
1439                 if (time > self.pauserothealth_finished)
1440                 {
1441                         self.health = max(maxh, self.health + (maxh - self.health) * rot_mod*cvar("g_balance_health_rot") * frametime);
1442                         self.health = max(maxh, self.health - rot_mod*cvar("g_balance_health_rotlinear") * frametime);
1443                 }
1444         }
1445         else if (self.health < maxh)
1446         {
1447                 if (time > self.pauseregen_finished)
1448                 {
1449                         self.health = CalcRegen(self.health, maxh, regen_mod * cvar("g_balance_health_regen"));
1450                         self.health = min(maxh, self.health + regen_mod*cvar("g_balance_health_regenlinear") * frametime);
1451                 }
1452         }
1453
1454         if (self.health > limith)
1455                 self.health = limith;
1456         if (self.armorvalue > limita)
1457                 self.armorvalue = limita;
1458
1459         // if player rotted to death...  die!
1460         if(self.health < 1)
1461                 self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
1462 }
1463
1464 /*
1465 ======================
1466 spectate mode routines
1467 ======================
1468 */
1469 void SpectateCopy(entity spectatee) {
1470         self.armortype = spectatee.armortype;
1471         self.armorvalue = spectatee.armorvalue;
1472         self.currentammo = spectatee.currentammo;
1473         self.effects = spectatee.effects;
1474         self.health = spectatee.health;
1475         self.impulse = 0;
1476         self.items = spectatee.items;
1477         self.punchangle = spectatee.punchangle;
1478         self.view_ofs = spectatee.view_ofs;
1479         self.v_angle = spectatee.v_angle;
1480         self.viewzoom = spectatee.viewzoom;
1481         self.velocity = spectatee.velocity;
1482         self.dmg_take = spectatee.dmg_take;
1483         self.dmg_save = spectatee.dmg_save;
1484         self.dmg_inflictor = spectatee.dmg_inflictor;
1485         self.angles = spectatee.v_angle;
1486         self.fixangle = TRUE;
1487         setorigin(self, spectatee.origin);
1488         setsize(self, spectatee.mins, spectatee.maxs);
1489 }
1490
1491 float SpectateUpdate() {
1492         if(!self.enemy)
1493                 return 0;
1494
1495         if (self == self.enemy)
1496                 return 0;
1497         
1498         if(self.enemy.flags & FL_NOTARGET)
1499                 return 0;
1500
1501         SpectateCopy(self.enemy);
1502
1503         return 1;
1504 }
1505
1506 float SpectateNext() {
1507         other = find(self.enemy, classname, "player");
1508         if (!other) {
1509                 other = find(other, classname, "player");
1510         }
1511         if (other) {
1512                 self.enemy = other;
1513         }
1514         if(self.enemy.classname == "player") {
1515                 msg_entity = self;
1516                 WriteByte(MSG_ONE, SVC_SETVIEW);
1517                 WriteEntity(MSG_ONE, self.enemy);
1518                 self.wantswelcomemessage = 1;
1519                 //stuffcmd(self, "set viewsize $tmpviewsize \n");
1520                 if(!SpectateUpdate())
1521                         PutObserverInServer();
1522                 return 1;
1523         } else {
1524                 return 0;
1525         }
1526 }
1527
1528 /*
1529 =============
1530 ShowRespawnCountdown()
1531
1532 Update a respawn countdown display.
1533 =============
1534 */
1535 void ShowRespawnCountdown()
1536 {
1537         float number;
1538         if(self.deadflag == DEAD_NO) // just respawned?
1539                 return;
1540         else
1541         {
1542                 number = ceil(self.death_time - time);
1543                 if(number <= 0)
1544                         return;
1545                 if(number <= self.respawn_countdown)
1546                 {
1547                         self.respawn_countdown = number - 1;
1548                         if(ceil(self.death_time - (time + 0.5)) == number) // only say it if it is the same number even in 0.5s; to prevent overlapping sounds
1549                                 play2(self, strcat("announcer/robotic/", ftos(number), ".ogg"));
1550                 }
1551         }
1552 }
1553
1554 void LeaveSpectatorMode()
1555 {
1556         if(isJoinAllowed()) {
1557                 if(!cvar("teamplay") || cvar("g_campaign") || cvar("g_balance_teams")) {
1558                         self.classname = "player";
1559                         if(cvar("g_campaign") || cvar("g_balance_teams") || cvar("g_balance_teams_force"))
1560                                 JoinBestTeam(self, FALSE, TRUE);
1561                         if(cvar("g_campaign"))
1562                                 campaign_bots_may_start = 1;
1563                         PutClientInServer();
1564                         if(!(self.flags & FL_NOTARGET))
1565                                 bprint ("^4", self.netname, "^4 is playing now\n");
1566                         centerprint(self,"");
1567                         return;
1568                 } else {
1569                         stuffcmd(self,"menu_showteamselect\n");
1570                         return;
1571                 }
1572         }
1573         else {
1574                 //player may not join because of g_maxplayers is set
1575                 centerprint_atprio(self, CENTERPRIO_MAPVOTE, PREVENT_JOIN_TEXT);
1576         }
1577 }
1578
1579 /**
1580  * Determines whether the player is allowed to join. This depends on cvar
1581  * g_maxplayers, if it isn't used this function always return TRUE, otherwise
1582  * it checks whether the number of currently playing players exceeds g_maxplayers.
1583  * @return bool TRUE if the player is allowed to join, false otherwise
1584  */
1585 float isJoinAllowed() {
1586         if (!cvar("g_maxplayers"))
1587                 return TRUE;
1588
1589         local entity e;
1590         local float currentlyPlaying;
1591         FOR_EACH_REALPLAYER(e) {
1592                 if(e.classname == "player")
1593                         currentlyPlaying += 1;
1594         }
1595         if(currentlyPlaying < cvar("g_maxplayers"))
1596                 return TRUE;
1597
1598         return FALSE;
1599 }
1600
1601 /**
1602  * Checks whether the client is an observer or spectator, if so, he will get kicked after
1603  * g_maxplayers_spectator_blocktime seconds
1604  */
1605 void checkSpectatorBlock() {
1606         if(self.classname == "spectator" || self.classname == "observer") {
1607                 if( time > (self.spectatortime + cvar("g_maxplayers_spectator_blocktime")) ) {
1608                         sprint(self, "^7You were kicked from the server because you are spectator and spectators aren't allowed at the moment.\n");
1609                         dropclient(self);
1610                 }
1611         }
1612 }
1613
1614 float vercmp_recursive(string v1, string v2)
1615 {
1616         float dot1, dot2;
1617         string s1, s2;
1618         float r;
1619
1620         dot1 = strstrofs(v1, ".", 0);
1621         dot2 = strstrofs(v2, ".", 0);
1622         if(dot1 == -1)
1623                 s1 = v1;
1624         else
1625                 s1 = substring(v1, 0, dot1);
1626         if(dot2 == -1)
1627                 s2 = v2;
1628         else
1629                 s2 = substring(v2, 0, dot2);
1630
1631         r = stof(s1) - stof(s2);
1632         if(r != 0)
1633                 return r;
1634
1635         r = strcasecmp(s1, s2);
1636         if(r != 0)
1637                 return r;
1638
1639         if(dot1 == -1)
1640                 if(dot2 == -1)
1641                         return 0;
1642                 else
1643                         return -1;
1644         else
1645                 if(dot2 == -1)
1646                         return 1;
1647                 else
1648                         return vercmp_recursive(substring(v1, dot1 + 1, 999), substring(v2, dot2 + 1, 999));
1649 }
1650
1651 float vercmp(string v1, string v2)
1652 {
1653         if(strcasecmp(v1, v2) == 0) // early out check
1654                 return 0;
1655         return vercmp_recursive(v1, v2);
1656 }
1657
1658 void ObserverThink()
1659 {
1660         if (self.flags & FL_JUMPRELEASED) {
1661                 if (self.button2 && self.version == cvar("gameversion")) {
1662                         self.welcomemessage_time = 0;
1663                         self.flags = self.flags - FL_JUMPRELEASED;
1664                         LeaveSpectatorMode();
1665                         return;
1666                 } else if(self.button0 && self.version == cvar("gameversion")) {
1667                         self.welcomemessage_time = 0;
1668                         self.flags = self.flags - FL_JUMPRELEASED;
1669                         if(SpectateNext() == 1) {
1670                                 self.classname = "spectator";
1671                         }
1672                 }
1673         } else {
1674                 if (!(self.button0 || self.button2)) {
1675                         self.flags = self.flags | FL_JUMPRELEASED;
1676                 }
1677         }
1678         if(self.button4)
1679                 self.wantswelcomemessage = 0;
1680         if(self.wantswelcomemessage)
1681                 PrintWelcomeMessage(self);
1682 }
1683
1684 void SpectatorThink()
1685 {
1686         if (self.flags & FL_JUMPRELEASED) {
1687                 if (self.button2 && self.version == cvar("gameversion")) {
1688                         self.welcomemessage_time = 0;
1689                         self.flags = self.flags - FL_JUMPRELEASED;
1690                         LeaveSpectatorMode();
1691                         return;
1692                 } else if(self.button0) {
1693                         self.welcomemessage_time = 0;
1694                         self.flags = self.flags - FL_JUMPRELEASED;
1695                         if(SpectateNext() == 1) {
1696                                 self.classname = "spectator";
1697                         } else {
1698                                 self.classname = "observer";
1699                                 PutClientInServer();
1700                         }
1701                 } else if (self.button3) {
1702                         self.welcomemessage_time = 0;
1703                         self.flags = self.flags - FL_JUMPRELEASED;
1704                         self.classname = "observer";
1705                         PutClientInServer();
1706                 } else {
1707                         if(!SpectateUpdate())
1708                                 PutObserverInServer();
1709                 }
1710         } else {
1711                 if (!(self.button0 || self.button3)) {
1712                         self.flags = self.flags | FL_JUMPRELEASED;
1713                 }
1714         }
1715         if(self.button4)
1716                 self.wantswelcomemessage = 0;
1717         if(self.wantswelcomemessage)
1718                 PrintWelcomeMessage(self);
1719         self.flags = self.flags | FL_CLIENT | FL_NOTARGET;
1720 }
1721
1722 /*
1723 =============
1724 PlayerPreThink
1725
1726 Called every frame for each client before the physics are run
1727 =============
1728 */
1729 void() ctf_setstatus;
1730 .float vote_nagtime;
1731 void PlayerPreThink (void)
1732 {
1733         if(blockSpectators)
1734                 checkSpectatorBlock();
1735         
1736         if(self.netname_previous != self.netname)
1737         {
1738                 if(cvar("sv_eventlog"))
1739                         GameLogEcho(strcat(":name:", ftos(self.playerid), ":", self.netname), TRUE);
1740                 if(self.netname_previous)
1741                         strunzone(self.netname_previous);
1742                 self.netname_previous = strzone(self.netname);
1743         }
1744
1745         // version nagging
1746         if(self.version_nagtime)
1747                 if(self.cvar_g_nexuizversion)
1748                         if(time > self.version_nagtime)
1749                         {
1750                                 if(strstr(self.cvar_g_nexuizversion, "svn", 0) < 0)
1751                                 {
1752                                         if(strstr(cvar_string("g_nexuizversion"), "svn", 0) >= 0)
1753                                         {
1754                                                 dprint("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), " (beta)^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n");
1755                                                 sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), " (beta)^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n"));
1756                                         }
1757                                         else
1758                                         {
1759                                                 float r;
1760                                                 r = vercmp(self.cvar_g_nexuizversion, cvar_string("g_nexuizversion"));
1761                                                 if(r < 0)
1762                                                 {
1763                                                         dprint("^1NOTE^7 to ", self.netname, "^7 - ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7 is out, and you still have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1 - get the update from ^4http://www.nexuiz.com/^1!\n");
1764                                                         sprint(self, strcat("\{1}^1NOTE: ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7 is out, and you still have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1 - get the update from ^4http://www.nexuiz.com/^1!\n"));
1765                                                 }
1766                                                 else if(r > 0)
1767                                                 {
1768                                                         dprint("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n");
1769                                                         sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n"));
1770                                                 }
1771                                         }
1772                                 }
1773                                 self.version_nagtime = 0;
1774                         }
1775
1776         // vote nagging
1777         if(self.cvar_scr_centertime)
1778                 if(time > self.vote_nagtime)
1779                 {
1780                         VoteNag();
1781                         self.vote_nagtime = time + self.cvar_scr_centertime * 0.6;
1782                 }
1783
1784         // GOD MODE info
1785         if(!(self.flags & FL_GODMODE)) if(self.max_armorvalue)
1786         {
1787                 sprint(self, strcat("godmode saved you ", ftos(self.max_armorvalue), " units of damage, cheater!\n"));
1788                 self.max_armorvalue = 0;
1789         }
1790
1791         if(frametime)
1792                 antilag_record(self);
1793
1794         if(self.classname == "player") {
1795 //              if(self.netname == "Wazat")
1796 //                      bprint(self.classname, "\n");
1797
1798                 CheckRules_Player();
1799
1800                 if(self.button7)
1801                         PrintWelcomeMessage(self);
1802
1803                 if(g_lms || !cvar("sv_spectate"))
1804                 if((time - self.jointime) <= cvar("welcome_message_time"))
1805                         PrintWelcomeMessage(self);
1806
1807                 if (intermission_running)
1808                 {
1809                         IntermissionThink ();   // otherwise a button could be missed between
1810                         return;                                 // the think tics
1811                 }
1812
1813                 if(self.teleport_time)
1814                 if(time > self.teleport_time)
1815                 {
1816                         self.teleport_time = 0;
1817                         self.effects = self.effects - (self.effects & EF_NODRAW);
1818                         if(self.weaponentity)
1819                                 self.weaponentity.flags = self.weaponentity.flags - (self.weaponentity.flags & EF_NODRAW);
1820                 }
1821
1822                 Nixnex_GiveCurrentWeapon();
1823
1824                 if(frametime > 0) // don't do this in cl_movement frames, just in server ticks
1825                         UpdateSelectedPlayer();
1826
1827                 //don't allow the player to turn around while game is paused!
1828                 if(timeoutStatus == 2) {
1829                         self.v_angle = self.lastV_angle;
1830                         self.angles = self.lastV_angle;
1831                         self.fixangle = TRUE;
1832                 }
1833
1834                 if (self.deadflag != DEAD_NO)
1835                 {
1836                         float button_pressed, force_respawn;
1837                         player_anim();
1838                         button_pressed = (self.button0 || self.button2 || self.button3 || self.button6 || self.buttonuse);
1839                         force_respawn = (g_lms || cvar("g_forced_respawn"));
1840                         if (self.deadflag == DEAD_DYING)
1841                         {
1842                                 if(force_respawn)
1843                                         self.deadflag = DEAD_RESPAWNING;
1844                                 else if(!button_pressed)
1845                                         self.deadflag = DEAD_DEAD;
1846                         }
1847                         else if (self.deadflag == DEAD_DEAD)
1848                         {
1849                                 if(button_pressed)
1850                                         self.deadflag = DEAD_RESPAWNABLE;
1851                         }
1852                         else if (self.deadflag == DEAD_RESPAWNABLE)
1853                         {
1854                                 if(!button_pressed)
1855                                         self.deadflag = DEAD_RESPAWNING;
1856                         }
1857                         else if (self.deadflag == DEAD_RESPAWNING)
1858                         {
1859                                 if(time > self.death_time)
1860                                 {
1861                                         self.death_time = time + 1; // only retry once a second
1862                                         respawn();
1863                                 }
1864                         }
1865                         ShowRespawnCountdown();
1866                         return;
1867                 }
1868
1869                 if(g_lms && !self.deadflag && cvar("g_lms_campcheck_interval"))
1870                 {
1871                         vector dist;
1872
1873                         // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
1874                         dist = self.oldorigin - self.origin;
1875                         dist_z = 0;
1876                         self.lms_traveled_distance += fabs(vlen(dist));
1877
1878                         if((cvar("g_campaign") && !campaign_bots_may_start) || (time < restart_countdown))
1879                         {
1880                                 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval")*2;
1881                                 self.lms_traveled_distance = 0;
1882                         }
1883
1884                         if(time > self.lms_nextcheck)
1885                         {
1886                                 //sprint(self, "distance: ", ftos(self.lms_traveled_distance), "\n");
1887                                 if(self.lms_traveled_distance < cvar("g_lms_campcheck_distance"))
1888                                 {
1889                                         centerprint(self, cvar_string("g_lms_campcheck_message"));
1890                                         // FIXME KadaverJack: gibbing player here causes playermodel to bounce around, instead of eye.md3
1891                                         // I wasn't able to find out WHY that happens, so I put a workaround in place that shall prevent players from being gibbed :(
1892                                         Damage(self, self, self, bound(0, cvar("g_lms_campcheck_damage"), self.health + self.armorvalue * cvar("g_balance_armor_blockpercent") + 5), DEATH_CAMP, self.origin, '0 0 0');
1893                                 }
1894                                 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval");
1895                                 self.lms_traveled_distance = 0;
1896                         }
1897                 }
1898
1899                 if (self.button5 && !self.hook.state)
1900                 {
1901                         if (!self.crouch)
1902                         {
1903                                 self.crouch = TRUE;
1904                                 self.view_ofs = PL_CROUCH_VIEW_OFS;
1905                                 setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX);
1906                                 player_setanim(self.anim_duck, FALSE, TRUE, TRUE);
1907                         }
1908                 }
1909                 else
1910                 {
1911                         if (self.crouch)
1912                         {
1913                                 tracebox(self.origin, PL_MIN, PL_MAX, self.origin, FALSE, self);
1914                                 if (!trace_startsolid)
1915                                 {
1916                                         self.crouch = FALSE;
1917                                         self.view_ofs = PL_VIEW_OFS;
1918                                         setsize (self, PL_MIN, PL_MAX);
1919                                 }
1920                         }
1921                 }
1922
1923                 FixPlayermodel();
1924
1925                 GrapplingHookFrame();
1926
1927                 W_WeaponFrame();
1928
1929                 {
1930                         float zoomfactor, zoomspeed, zoomdir;
1931                         zoomfactor = self.cvar_cl_zoomfactor;
1932                         if(zoomfactor < 1 || zoomfactor > 16)
1933                                 zoomfactor = 2.5;
1934                         zoomspeed = self.cvar_cl_zoomspeed;
1935                         if(zoomspeed >= 0) // < 0 is instant zoom
1936                                 if(zoomspeed < 0.5 || zoomspeed > 16)
1937                                         zoomspeed = 3.5;
1938
1939                         zoomdir = self.button4;
1940                         if(self.button3)
1941                                 if(self.weapon == WEP_NEX)
1942                                         if(!g_minstagib)
1943                                                 zoomdir = 1;
1944
1945                         if(zoomdir)
1946                                 self.has_zoomed = 1;
1947
1948                         if(self.has_zoomed)
1949                         {
1950                                 if(zoomspeed <= 0) // instant zoom
1951                                 {
1952                                         if(zoomdir)
1953                                                 self.viewzoom = 1 / zoomfactor;
1954                                         else
1955                                                 self.viewzoom = 1;
1956                                 }
1957                                 else
1958                                 {
1959                                         // geometric zoom would be:
1960                                         //   self.viewzoom = bound(1 / zoomfactor, self.viewzoom * pow(zoomfactor, (zoomdir ? -1 : 1) * frametime * zoomspeed), 1);
1961                                         // however, testing showed that arithmetic/harmonic zoom works better
1962                                         if(zoomdir)
1963                                                 // self.viewzoom = 1 / bound(1, 1 / self.viewzoom + (zoomdir ? 1 : -1) * frametime * zoomspeed * (zoomfactor - 1), zoomfactor);
1964                                                 // zoom in = arithmetic: 1x, 2x, 3x, 4x, ..., 8x
1965                                                 self.viewzoom = 1 / bound(1, 1 / self.viewzoom + frametime * zoomspeed * (zoomfactor - 1), zoomfactor);
1966                                         else
1967                                                 // self.viewzoom = bound(1 / zoomfactor, self.viewzoom + (zoomdir ? -1 : 1) * frametime * zoomspeed * (1 - 1 / zoomfactor), 1);
1968                                                 // zoom out = harmonic: 8/1x, 8/2x, 8/3x, 8/4x, ..., 8/8x
1969                                                 self.viewzoom = bound(1 / zoomfactor, self.viewzoom + frametime * zoomspeed * (1 - 1 / zoomfactor), 1);
1970                                 }
1971                         }
1972                         else
1973                                 self.viewzoom = min(1, self.viewzoom + frametime); // spawn zoom-in
1974                 }
1975
1976                 player_powerups();
1977                 player_regen();
1978                 player_anim();
1979
1980                 if (g_minstagib)
1981                         minstagib_ammocheck();
1982
1983                 ctf_setstatus();
1984                 kh_setstatus();
1985
1986                 //self.angles_y=self.v_angle_y + 90;   // temp
1987
1988                 //if (TetrisPreFrame()) return;
1989         } else if(gameover) {
1990                 if (intermission_running)
1991                         IntermissionThink ();   // otherwise a button could be missed between
1992                 return;
1993         } else if(self.classname == "observer") {
1994                 ObserverThink();
1995         } else if(self.classname == "spectator") {
1996                 SpectatorThink();
1997         }
1998 }
1999
2000
2001 /*
2002 =============
2003 PlayerPostThink
2004
2005 Called every frame for each client after the physics are run
2006 =============
2007 */
2008 void PlayerPostThink (void)
2009 {
2010         // Savage: Check for nameless players
2011         if (strlen(self.netname) < 1) {
2012                 self.netname = "Player";
2013                 stuffcmd(self, "seta _cl_name Player\n");
2014         }
2015
2016         if(self.classname == "player") {
2017                 CheckRules_Player();
2018                 UpdateChatBubble();
2019                 UpdateTeamBubble();
2020                 if (self.impulse)
2021                         ImpulseCommands();
2022                 if (intermission_running)
2023                         return;         // intermission or finale
2024
2025                 //PrintWelcomeMessage(self);
2026                 //if (TetrisPostFrame()) return;
2027
2028                 // restart countdown
2029                 if (restart_countdown) {
2030                         if(time < restart_countdown) {
2031                                 if (!cvar("sv_ready_restart_after_countdown"))
2032                                 {
2033                                         self.movetype = MOVETYPE_NONE;          
2034                                         self.velocity = '0 0 0';
2035                                         self.avelocity = '0 0 0';
2036                                         self.movement = '0 0 0';
2037                                 }
2038                         }
2039                         else
2040                         {
2041                                 //allow the player to move again if sv_ready_restart_after_countdown is not used and countdown is over
2042                                 if (!cvar("sv_ready_restart_after_countdown"))
2043                                 {
2044                                         if(self.movetype == MOVETYPE_NONE)
2045                                         {
2046                                                 self.movetype = MOVETYPE_WALK;
2047                                         }
2048                                 }
2049                         }
2050                 }
2051                 
2052         } else if (self.classname == "observer") {
2053                 //do nothing
2054         } else if (self.classname == "spectator") {
2055                 //do nothing
2056         }
2057
2058         Arena_Warmup();
2059 }