Merge branch 'master' into terencehill/arena_stuff
authorterencehill <piuntn@gmail.com>
Sat, 20 Aug 2011 16:08:09 +0000 (18:08 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 20 Aug 2011 16:08:09 +0000 (18:08 +0200)
Conflicts:
qcsrc/server/arena.qc

1  2 
qcsrc/server/arena.qc
qcsrc/server/cl_player.qc
qcsrc/server/mutators/gamemode_freezetag.qc

diff --combined qcsrc/server/arena.qc
index 09db36618aeae5934dffe40dcf4eb29263632b2e,587b1ec54cef0cac9c4be7447d1961d89c67a974..c89c2b2efada451a84b1990255d437641088195b
@@@ -8,9 -8,9 +8,8 @@@ float arena_roundbased
  entity spawnqueue_first;
  entity spawnqueue_last;
  entity champion;
- string champion_name;
  float warmup;
 -float ca_players;
 -float required_ca_players;
 +float ca_teams_ok;
  .float caplayer;
  
  void PutObserverInServer();
@@@ -28,8 -28,8 +27,8 @@@ float stopalivecheck
  float redalive, bluealive, yellowalive, pinkalive;
  float totalalive;
  .float redalive_stat, bluealive_stat, yellowalive_stat, pinkalive_stat;
 -float redspawned, bluespawned, yellowspawned, pinkspawned;
 -float totalspawned;
 +float red_players, blue_players, yellow_players, pink_players;
 +float total_players;
  
  /**
   * Resets the state of all clients, items, flags, runes, keys, weapons, waypoints, ... of the map.
@@@ -133,7 -133,7 +132,7 @@@ void reset_map(float dorespawn
        }
  
        if(g_keyhunt)
-               kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round+(game_starttime - time), "", kh_StartRound);
+               kh_Controller_SetThink_NoMsg(autocvar_g_balance_keyhunt_delay_round+(game_starttime - time), kh_StartRound);
  
        if(g_arena)
        if(champion && champion.classname == "player" && player_count > 1)
@@@ -203,35 -203,31 +202,31 @@@ float roundStartTime_prev; // prevent n
  void Arena_Warmup()
  {
        float f;
-       string msg;
      entity e;
  
        if((!g_arena && !g_ca && !g_freezetag) || (g_arena && !arena_roundbased) || (time < game_starttime))
                return;
  
        f = ceil(warmup - time);
-       if(f > 0)
-               champion = world; // this is done because a if(champion) will not execute if champion = world
  
        allowed_to_spawn = 0;
  
        if(inWarmupStage)
                allowed_to_spawn = 1;
 -      if(ca_players < required_ca_players)
 +      if(g_ca && !ca_teams_ok)
                allowed_to_spawn = 1;
  
-       msg = NEWLINES;
        if(time < warmup && !inWarmupStage)
        {
                if (g_ca)
                        allowed_to_spawn = 1;
                if(champion && g_arena)
-                       msg = strcat("The Champion is ", champion_name, "^7\n");
-                       //centerprint(self, strcat(msg, "The Champion is ", champion.netname, "^7\n"));
+               {
+                       FOR_EACH_PLAYER(e)
+                               centerprint(e, strcat("The Champion is ", champion.netname));
+               }
  
                if(f != roundStartTime_prev) {
-                       msg = strcat(msg, "Round will start in ", ftos(f),"\n");
-                       //centerprint(self, strcat("Round will start in ", ftos(f),"\n"));
                        roundStartTime_prev = f;
                        if(f == 5)
                                Announce("prepareforbattle");
                        else if(f == 1)
                                Announce("1");
  
-             FOR_EACH_PLAYER(e)
-                 centerprint(e, msg);
+                       FOR_EACH_PLAYER(e)
+                               Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "Round will start in %d", 1, f);
                }
  
                if (g_arena) {
                        self.movement = '0 0 0';
                }
        }
        else if(f > -1 && f != roundStartTime_prev)
        {
                roundStartTime_prev = f;
                Announce("begin");
-               centerprint(self, "^1Begin!\n");
+               FOR_EACH_PLAYER(e)
+                       Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "^1Begin!", 1, 0);
  
                if(g_ca) {
 -                      ca_players = 0;
 +                      float start_red_ca_players, start_blue_ca_players;
  
 -            FOR_EACH_PLAYER(e)
 -                              ca_players += 1;
 +                      FOR_EACH_PLAYER(e) {
 +                              if (e.team == COLOR_TEAM1)
 +                                      start_red_ca_players += 1;
 +                              else if (e.team == COLOR_TEAM2)
 +                                      start_blue_ca_players += 1;
 +                      }
 +                      // teams are ok if there's at least 1 player in each team
 +                      ca_teams_ok = (start_red_ca_players && start_blue_ca_players);
                }
  
          if(self.classname == "player" && self.health > 0 && self.movetype == MOVETYPE_NONE)
              self.movetype = MOVETYPE_WALK;
        }
+       // clear champion to avoid centerprinting again the champion msg
+       if (champion)
+               champion = world;
  }
  
 -void count_spawned_players()
 +void count_players()
  {
 -      // TODO fix "*spawned" name, it should rather be "*players" or so
 -      // not doing this now to prevent merge hell with Tag
 -      // fix after merging with Tag
 -
        // count amount of players in each team
 -      totalspawned = redspawned = bluespawned = yellowspawned = pinkspawned = 0;
 +      total_players = red_players = blue_players = yellow_players = pink_players = 0;
        FOR_EACH_PLAYER(self) {
                if (self.team == COLOR_TEAM1)
                {
 -                      redspawned += 1;
 -                      totalspawned += 1;
 +                      red_players += 1;
 +                      total_players += 1;
                }
                else if (self.team == COLOR_TEAM2)
                {
 -                      bluespawned += 1;
 -                      totalspawned += 1;
 +                      blue_players += 1;
 +                      total_players += 1;
                }
                else if (self.team == COLOR_TEAM3)
                {
 -                      yellowspawned += 1;
 -                      totalspawned += 1;
 +                      yellow_players += 1;
 +                      total_players += 1;
                }
                else if (self.team == COLOR_TEAM4)
                {
 -                      pinkspawned += 1;
 -                      totalspawned += 1;
 +                      pink_players += 1;
 +                      total_players += 1;
                }
        }
  }
@@@ -372,9 -371,10 +372,10 @@@ void count_alive_players(
   *
   * Gets called in StartFrame()
   */
+ float warntime;
  void Spawnqueue_Check()
  {
 -      count_spawned_players();
 +      count_players();
        if(g_ca || g_freezetag) // we want to perform this before the return block below (CA)...
        {
                count_alive_players();
                return;
  
        if(g_ca) {
 -              required_ca_players = max(2, fabs(autocvar_bot_vs_human + 1));
 -
 -              if(ca_players < required_ca_players && (redspawned && bluespawned)) {
 +              if(!ca_teams_ok && (red_players && blue_players)) {
                        reset_map(TRUE);
                }
 -              else if(ca_players < required_ca_players) {
 +              else if(!ca_teams_ok) {
-                       FOR_EACH_PLAYER(self)
-                               centerprint(self, strcat("^1Need at least 1 player in each team to play CA", "^7\n"));
+                       if (time > warntime)
+                       {
+                               FOR_EACH_PLAYER(self)
+                                       Send_CSQC_Centerprint_Generic(self, CPID_ROUND_STARTING, "^1Need at least 1 player in each team to play CA", 2, 0);
+                               warntime = time + 1;
+                       }
                        return;
                }
                else if(!next_round) {
 -                      if((redspawned && !bluespawned) || (bluespawned && !redspawned)) {
 +                      if((red_players && !blue_players) || (blue_players && !red_players)) {
                                next_round = time + 5;
-                               champion = find(world, classname, "player");
-                               if(champion_name)
-                                       strunzone(champion_name);
-                               champion_name = strzone(champion.netname);
                        }
 -                      else if((!redspawned && !bluespawned) || time - warmup > autocvar_g_ca_round_timelimit) {
 +                      else if((!red_players && !blue_players) || time - warmup > autocvar_g_ca_round_timelimit) {
-                               FOR_EACH_CLIENT(self) centerprint(self, strcat("^7Round tied.", "^7\n"));
+                               FOR_EACH_CLIENT(self) centerprint(self, "^7Round tied");
                                next_round = time + 5;
                        }
  
                        if(redalive && !bluealive)
                        {
                                play2all("ctf/red_capture.wav");
-                               FOR_EACH_CLIENT(self) centerprint(self, "^1 RED ^7team wins the round.\n");
+                               FOR_EACH_CLIENT(self) centerprint(self, "^1RED ^7team wins the round");
                                TeamScore_AddToTeam(COLOR_TEAM1, ST_SCORE, +1);
                                stopalivecheck = TRUE;
                        }
                        else if(bluealive && !redalive)
                        {
                                play2all("ctf/blue_capture.wav");
-                               FOR_EACH_CLIENT(self) centerprint(self, "^4 BLUE ^7team wins the round.\n");
+                               FOR_EACH_CLIENT(self) centerprint(self, "^4BLUE ^7team wins the round");
                                TeamScore_AddToTeam(COLOR_TEAM2, ST_SCORE, +1);
                                stopalivecheck = TRUE;
                        }
index 41f9576e3e51ed09fbf97f730115f55409e66e3b,6f82d9f1043c7b30d21d98a6a2c52830944737ca..d80848f5a6f4cbb11db0be0d053f495260011863
@@@ -1,6 -1,5 +1,5 @@@
  .entity accuracy;
  .float accuracy_frags[WEP_MAXCOUNT];
- FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_frags);
  
  float weaponstats_buffer;
  
@@@ -341,11 -340,11 +340,11 @@@ void PlayerCorpseDamage (entity inflict
        if(sound_allowed(MSG_BROADCAST, attacker))
        {
                if (save > 10)
-                       sound (self, CH_SHOTS_SINGLE, "misc/armorimpact.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_SHOTS, "misc/armorimpact.wav", VOL_BASE, ATTN_NORM);
                else if (take > 30)
-                       sound (self, CH_SHOTS_SINGLE, "misc/bodyimpact2.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_SHOTS, "misc/bodyimpact2.wav", VOL_BASE, ATTN_NORM);
                else if (take > 10)
-                       sound (self, CH_SHOTS_SINGLE, "misc/bodyimpact1.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_SHOTS, "misc/bodyimpact1.wav", VOL_BASE, ATTN_NORM);
        }
  
        if (take > 50)
@@@ -388,7 -387,7 +387,7 @@@ void PlayerDamage (entity inflictor, en
        float valid_damage_for_weaponstats;
        float excess;
  
 -      if((g_arena && numspawned < 2) || (g_ca && ca_players < required_ca_players) && !inWarmupStage)
 +      if((g_arena && numspawned < 2) || (g_ca && !ca_teams_ok) && !inWarmupStage)
                return;
  
        dh = max(self.health, 0);
        if(sound_allowed(MSG_BROADCAST, attacker))
        {
                if (save > 10)
-                       sound (self, CH_SHOTS_SINGLE, "misc/armorimpact.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_SHOTS, "misc/armorimpact.wav", VOL_BASE, ATTN_NORM);
                else if (take > 30)
-                       sound (self, CH_SHOTS_SINGLE, "misc/bodyimpact2.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_SHOTS, "misc/bodyimpact2.wav", VOL_BASE, ATTN_NORM);
                else if (take > 10)
-                       sound (self, CH_SHOTS_SINGLE, "misc/bodyimpact1.wav", VOL_BASE, ATTN_NORM); // FIXME possibly remove them?
+                       sound (self, CH_SHOTS, "misc/bodyimpact1.wav", VOL_BASE, ATTN_NORM); // FIXME possibly remove them?
        }
  
        if (take > 50)
index 488a4f124ae378b7b62965d25e5206df491316a9,f74c9951fd4d49027e518057685823896b6a7def..d2c741f0b46ee0e1757e19c6eab076b4818c5f43
@@@ -69,6 -69,7 +69,7 @@@ void freezetag_Freeze(entity attacker
                return;
        self.freezetag_frozen = 1;
        self.freezetag_revive_progress = 0;
+       self.health = 1;
  
        entity ice;
        ice = spawn();
@@@ -113,6 -114,7 +114,7 @@@ void freezetag_Unfreeze(entity attacker
  {
        self.freezetag_frozen = 0;
        self.freezetag_revive_progress = 0;
+       self.health = autocvar_g_balance_health_start;
  
        // remove the ice block
        entity ice;
@@@ -142,7 -144,7 +144,7 @@@ MUTATOR_HOOKFUNCTION(freezetag_RemovePl
                --totalalive;
        }
  
 -      if(totalspawned > 2) // only check for winners if we had more than two players (one of them left, don't let the other player win just because of that)
 +      if(total_players > 2) // only check for winners if we had more than two players (one of them left, don't let the other player win just because of that)
                freezetag_CheckWinner();
  
        freezetag_Unfreeze(world);
@@@ -183,7 -185,7 +185,7 @@@ MUTATOR_HOOKFUNCTION(freezetag_PlayerDi
                bprint("^7", frag_target.netname, "^1 was frozen by ^7", frag_attacker.netname, ".\n");
        }
  
-       frag_target.health = autocvar_g_balance_health_start; // "respawn" the player :P
+       frag_target.health = 1; // "respawn" the player :P
  
        freezetag_CheckWinner();
  
@@@ -194,7 -196,7 +196,7 @@@ MUTATOR_HOOKFUNCTION(freezetag_PlayerSp
  {
      freezetag_Unfreeze(world); // start by making sure that all ice blocks are removed
  
 -      if(totalspawned == 1 && time > game_starttime) // only one player active on server, start a new match immediately
 +      if(total_players == 1 && time > game_starttime) // only one player active on server, start a new match immediately
        if(!next_round && warmup && (time < warmup - autocvar_g_freezetag_warmup || time > warmup)) // not awaiting next round
        {
                next_round = time;
@@@ -244,6 -246,7 +246,7 @@@ MUTATOR_HOOKFUNCTION(freezetag_PlayerPr
        if(n && self.freezetag_frozen) // OK, there is at least one teammate reviving us
        {
                self.freezetag_revive_progress = bound(0, self.freezetag_revive_progress + frametime * autocvar_g_freezetag_revive_speed, 1);
+               self.health = max(1, self.freezetag_revive_progress * autocvar_g_balance_health_start);
  
                if(self.freezetag_revive_progress >= 1)
                {
        else if(!n && self.freezetag_frozen) // only if no teammate is nearby will we reset
        {
                self.freezetag_revive_progress = bound(0, self.freezetag_revive_progress - frametime * autocvar_g_freezetag_revive_clearspeed, 1);
+               self.health = max(1, self.freezetag_revive_progress * autocvar_g_balance_health_start);
        }
        else if(!n)
        {