]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' of git://git.xonotic.org/xonotic/xonotic-data.pk3dir
authorRudolf Polzer <divVerent@xonotic.org>
Mon, 13 Dec 2010 06:00:50 +0000 (07:00 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Mon, 13 Dec 2010 06:00:50 +0000 (07:00 +0100)
1  2 
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc

index e480b4f25aca65701096ef886c752936b118c5b2,475771fd3a23e86c174b5a2592a0122b0babe8f8..12c810f16c7d43fcfbe55f644b5b5c5528785cff
@@@ -724,6 -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;
                }
  
                oldskin = self.skinindex;
 -              self.skinindex = RestrictSkin(stof(self.playerskin));
 +              self.skinindex = stof(self.playerskin);
        }
  
        if(chmdl || oldskin != self.skinindex)
@@@ -1213,6 -1222,7 +1213,7 @@@ Called when a client types 'kill' in th
  =============
  */
  
+ .float clientkill_nexttime;
  void ClientKill_Now_TeamChange()
  {
        if(self.killindicator_teamchange == -1)
                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()
  {
                ClientKill_Now(); // no oldself needed
                return;
        }
+     else if(g_cts && self.health == 1) // health == 1 means that it's silent
+     {
+         self.nextthink = time + 1;
+         self.cnt -= 1;
+     }
        else
        {
                if(self.cnt <= 10)
                        {
                                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"));
                        }
        }
  }
  
- 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;
  
+     if(g_cts && self.killindicator && self.killindicator.health == 1) // self.killindicator.health == 1 means that the kill indicator was spawned by CTS_ClientKill
+     {
+               remove(self.killindicator);
+               self.killindicator = world;
+         ClientKill_Now(); // allow instant kill in this case
+         return;
+     }
        self.killindicator_teamchange = targetteam;
  
-       if(!self.killindicator)
+     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();
        }
        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);
        }
  }
  
@@@ -1346,20 -1388,15 +1379,15 @@@ void ClientKill (void
                ClientKill_TeamChange(0);
  }
  
- void CTS_ClientKill_Think (void)
+ 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
  {
-       self = self.owner; // set self to the player to be killed
-       sprint(self, "^1You were killed in order to prevent cheating!");
-       ClientKill_Now();
- }
- void CTS_ClientKill (float t) // silent version of ClientKill
- {
-       entity e;
-       e = spawn();
-       e.owner = self;
-       e.think = CTS_ClientKill_Think;
-       e.nextthink = t;
+     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;
  }
  
  void DoTeamChange(float destteam)
@@@ -2709,7 -2746,7 +2737,7 @@@ void PlayerPreThink (void
                                if(frametime)
                                        player_anim();
                                button_pressed = (self.BUTTON_ATCK || self.BUTTON_JUMP || self.BUTTON_ATCK2 || self.BUTTON_HOOK || self.BUTTON_USE);
-                               force_respawn = (g_lms || (g_ca) || autocvar_g_forced_respawn);
+                               force_respawn = (g_lms || g_ca || g_cts || autocvar_g_forced_respawn);
                                if (self.deadflag == DEAD_DYING)
                                {
                                        if(force_respawn)
index 2b4981745bfd879b0256d48d4f3e789b6139727e,9fa4784faca6cd6022dfcf24628dd32a8ce14f86..342cbbc3d69e4a8e6e9a011c246e14d892f24a09
@@@ -168,7 -168,7 +168,7 @@@ void CopyBody(float keepvelocity
  float player_getspecies()
  {
        float s;
 -      get_model_parameters(self.playermodel, self.skinindex);
 +      get_model_parameters(self.model, self.skinindex);
        s = get_model_parameters_species;
        get_model_parameters(string_null, 0);
        if(s < 0)
@@@ -669,7 -669,12 +669,12 @@@ void PlayerDamage (entity inflictor, en
                waves = 0;
                sdelay = cvar(strcat("g_", GetGametype(), "_respawn_delay"));
                if(!sdelay)
-                       sdelay = autocvar_g_respawn_delay;
+         {
+             if(g_cts)
+                 sdelay = 0; // no respawn delay in CTS
+             else
+                 sdelay = autocvar_g_respawn_delay;
+         }
                waves = cvar(strcat("g_", GetGametype(), "_respawn_waves"));
                if(!waves)
                        waves = autocvar_g_respawn_waves;
@@@ -1224,7 -1229,7 +1229,7 @@@ void ClearPlayerSounds(
  #undef _VOICEMSG
  }
  
 -void LoadPlayerSounds(string f, float first)
 +float LoadPlayerSounds(string f, float first)
  {
        float fh;
        string s;
        if(fh < 0)
        {
                dprint("Player sound file not found: ", f, "\n");
 -              return;
 +              return 0;
        }
        while((s = fgets(fh)))
        {
                self.field = strzone(strcat(argv(1), " ", argv(2)));
        }
        fclose(fh);
 +      return 1;
  }
  
  .float modelindex_for_playersound;
@@@ -1263,8 -1267,7 +1268,8 @@@ void UpdatePlayerSounds(
        self.skinindex_for_playersound = self.skinindex;
        ClearPlayerSounds();
        LoadPlayerSounds("sound/player/default.sounds", 1);
 -      LoadPlayerSounds(get_model_datafilename(self.playermodel, self.skinindex, "sounds"), 0);
 +      if(!LoadPlayerSounds(get_model_datafilename(self.model, self.skinindex, "sounds"), 0))
 +              LoadPlayerSounds(get_model_datafilename(self.model, 0, "sounds"), 0);
  }
  
  void FakeGlobalSound(string sample, float chan, float voicetype)