]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Merge branch 'master' of git://git.xonotic.org/xonotic/xonotic-data.pk3dir
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index a19aba97f9e2d5ff7bea5203625e64c04a8d5c12..12c810f16c7d43fcfbe55f644b5b5c5528785cff 100644 (file)
@@ -724,15 +724,6 @@ void PutObserverInServer (void)
                self.frags = FRAGS_SPECTATOR;
 }
 
-float RestrictSkin(float s)
-{
-       if(!teams_matter)
-               return s;
-       if(s == 6)
-               return 6;
-       return mod(s, 3);
-}
-
 void FixPlayermodel()
 {
        local string defaultmodel;
@@ -794,7 +785,7 @@ void FixPlayermodel()
                }
 
                oldskin = self.skinindex;
-               self.skinindex = RestrictSkin(stof(self.playerskin));
+               self.skinindex = stof(self.playerskin);
        }
 
        if(chmdl || oldskin != self.skinindex)
@@ -1222,6 +1213,7 @@ Called when a client types 'kill' in the console
 =============
 */
 
+.float clientkill_nexttime;
 void ClientKill_Now_TeamChange()
 {
        if(self.killindicator_teamchange == -1)
@@ -1229,24 +1221,30 @@ void ClientKill_Now_TeamChange()
                self.team = -1;
                JoinBestTeam( self, FALSE, FALSE );
        }
+       else if(self.killindicator_teamchange == -2)
+       {
+               if(g_ca)
+                       self.caplayer = 0;
+               if(blockSpectators)
+                       sprint(self, strcat("^7You have to become a player within the next ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
+               PutObserverInServer();
+       }
        else
                SV_ChangeTeam(self.killindicator_teamchange - 1);
 }
 
 void ClientKill_Now()
 {
+       remove(self.killindicator);
+       self.killindicator = world;
+
        if(self.killindicator_teamchange)
                ClientKill_Now_TeamChange();
 
        // in any case:
        Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
 
-       if(self.killindicator)
-       {
-               dprint("Cleaned up after a leaked kill indicator.\n");
-               remove(self.killindicator);
-               self.killindicator = world;
-       }
+       // now I am sure the player IS dead
 }
 void KillIndicator_Think()
 {
@@ -1263,7 +1261,7 @@ void KillIndicator_Think()
                ClientKill_Now(); // no oldself needed
                return;
        }
-    else if(g_cts)
+    else if(g_cts && self.health == 1) // health == 1 means that it's silent
     {
         self.nextthink = time + 1;
         self.cnt -= 1;
@@ -1280,6 +1278,8 @@ void KillIndicator_Think()
                        {
                                if(self.owner.killindicator_teamchange == -1)
                                        centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds"));
+                               else if(self.owner.killindicator_teamchange == -2)
+                                       centerprint(self.owner, strcat("Spectating in ", ftos(self.cnt), " seconds"));
                                else
                                        centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
                        }
@@ -1291,29 +1291,34 @@ void KillIndicator_Think()
        }
 }
 
-void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto
+void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 = spec
 {
        float killtime;
        entity e;
        killtime = autocvar_g_balance_kill_delay;
 
-       if(g_race_qualifying)
+       if(g_race_qualifying || g_cts)
                killtime = 0;
 
-       self.killindicator_teamchange = targetteam;
-
-    if(g_cts) // allow an instant kill in CTS
+    if(g_cts && self.killindicator && self.killindicator.health == 1) // self.killindicator.health == 1 means that the kill indicator was spawned by CTS_ClientKill
     {
-        if(self.killcnt < 5) // 5 kills in 5 seconds allowed
-        {
-            self.killcnt += 1;
-            ClientKill_Now();
-        }
+               remove(self.killindicator);
+               self.killindicator = world;
+
+        ClientKill_Now(); // allow instant kill in this case
         return;
     }
 
-    else if(!self.killindicator)
+       self.killindicator_teamchange = targetteam;
+
+    if(!self.killindicator)
        {
+               if(self.modelindex && self.deadflag == DEAD_NO)
+               {
+                       killtime = max(killtime, self.clientkill_nexttime - time);
+                       self.clientkill_nexttime = time + killtime + autocvar_g_balance_kill_antispam;
+               }
+
                if(killtime <= 0 || !self.modelindex || self.deadflag != DEAD_NO)
                {
                        ClientKill_Now();
@@ -1349,10 +1354,14 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto
        }
        if(self.killindicator)
        {
-               if(targetteam)
-                       self.killindicator.colormod = TeamColor(targetteam);
-               else
+               if(targetteam == 0) // just die
                        self.killindicator.colormod = '0 0 0';
+               else if(targetteam == -1) // auto
+                       self.killindicator.colormod = '0 1 0';
+               else if(targetteam == -2) // spectate
+                       self.killindicator.colormod = '0.5 0.5 0.5';
+               else
+                       self.killindicator.colormod = TeamColor(targetteam);
        }
 }
 
@@ -1370,13 +1379,14 @@ void ClientKill (void)
                ClientKill_TeamChange(0);
 }
 
-void CTS_ClientKill (entity e) // silent version of ClientKill
+void CTS_ClientKill (entity e) // silent version of ClientKill, used when player finishes a CTS run. Useful to prevent cheating by running back to the start line and starting out with more speed
 {
     e.killindicator = spawn();
     e.killindicator.owner = e;
     e.killindicator.think = KillIndicator_Think;
     e.killindicator.nextthink = time + (e.lip) * 0.05;
     e.killindicator.cnt = ceil(autocvar_g_cts_finish_kill_delay);
+    e.killindicator.health = 1; // this is used to indicate that it should be silent
     e.lip = 0;
 }
 
@@ -2877,9 +2887,6 @@ void PlayerPreThink (void)
                if(g_nexball)
                        nexball_setstatus();
 
-        if(g_cts)
-            self.killcnt = max(0, self.killcount - sys_frametime);
-
                self.dmg_team = max(0, self.dmg_team - autocvar_g_teamdamage_resetspeed * frametime);
 
                //self.angles_y=self.v_angle_y + 90;   // temp