]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/ca_fixes_and_more'
authorMario <zacjardine@y7mail.com>
Fri, 5 Dec 2014 11:29:07 +0000 (22:29 +1100)
committerMario <zacjardine@y7mail.com>
Fri, 5 Dec 2014 11:29:07 +0000 (22:29 +1100)
17 files changed:
gamemodes.cfg
qcsrc/client/Main.qc
qcsrc/client/main.qh
qcsrc/client/scoreboard.qc
qcsrc/common/constants.qh
qcsrc/common/mapinfo.qh
qcsrc/common/notifications.qh
qcsrc/server/bot/bot.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/command/cmd.qc
qcsrc/server/command/sv_cmd.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/gamemode_ca.qc
qcsrc/server/mutators/gamemode_freezetag.qc
qcsrc/server/mutators/gamemode_invasion.qc
qcsrc/server/teamplay.qc

index ec140d30dd663f607dca3db5471724d378073962..c31f7f9013a9d4e4e0fc26262175878985d71ecd 100644 (file)
@@ -225,10 +225,10 @@ set g_assault 0 "Assault: attack the enemy base as fast as you can, then defend
 // ============
 //  clan arena
 // ============
-set g_ca 0 "Clan Arena: Played in rounds, once you're dead you're out! The team with survivors wins the round."
-set g_ca_point_limit 10 "point limit 10 is standard for clan arena"
-set g_ca_point_leadlimit 0
-set g_ca_spectate_enemies 0 "Allow spectating enemy player by dead player during clan arena games."
+set g_ca 0 "Clan Arena: Played in rounds, once you're dead you're out! The team with survivors wins the round"
+seta g_ca_point_limit -1 "Clan Arena point limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta g_ca_point_leadlimit -1 "Clan Arena point lead limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+set g_ca_spectate_enemies 0 "Allow spectating enemy player by dead player during clan arena games"
 set g_ca_warmup 10 "how long the players will have time to run around the map before the round starts"
 set g_ca_damage2score_multiplier 0.01
 set g_ca_round_timelimit 180 "round time limit in seconds"
index 809802dff18e629504928ef8b48ea359d2402879..2a97056a43d21b7568ea143c620e911b6e7d41c5 100644 (file)
@@ -606,6 +606,27 @@ void Ent_Nagger()
        warmup_stage = (nags & 16);
 }
 
+void Ent_EliminatedPlayers()
+{
+       float sf, i, j, b, f;
+
+       sf = ReadByte();
+       if(sf & 1)
+       {
+               for(j = 0; j < maxclients; ++j)
+                       if(playerslots[j])
+                               playerslots[j].eliminated = 1;
+               for(i = 1; i <= maxclients; i += 8)
+               {
+                       f = ReadByte();
+                       for(j = i-1, b = 1; b < 256; b *= 2, ++j)
+                               if (!(f & b))
+                                       if(playerslots[j])
+                                               playerslots[j].eliminated = 0;
+               }
+       }
+}
+
 void Ent_RandomSeed()
 {
        float s;
@@ -804,6 +825,7 @@ void CSQC_Ent_Update(float bIsNewEntity)
                case ENT_CLIENT_RAINSNOW: Ent_RainOrSnow(); break;
                case ENT_CLIENT_LASER: Ent_Laser(); break;
                case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
+               case ENT_CLIENT_ELIMINATEDPLAYERS: Ent_EliminatedPlayers(); break;
                case ENT_CLIENT_WAYPOINT: Ent_WaypointSprite(); break;
                case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
                case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
index 815c20a33ed1788eb16129b136bfe18372f3fe87..5bf3e5bc61fc47e2b5d8fce0e20cce11e0d5024d 100644 (file)
@@ -86,6 +86,7 @@ entity teamslots[17];    // 17 teams (including "spectator team")
 .float gotscores;
 .entity owner;
 .float ready;
+.float eliminated;
 
 .void(void) draw;
 .void(void) draw2d;
index 337a63e04f8807c66c3697af09efcb473703e8c1..657fa72ff9789bddf1b6e06c9f4e69a54027bd8d 100644 (file)
@@ -676,7 +676,7 @@ string HUD_FixScoreboardColumnWidth(float i, string str)
        return str;
 }
 
-void HUD_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_number)
+void HUD_PrintScoreboardItem(vector pos, vector item_size, entity pl, float is_self, float pl_number)
 {
        vector tmp, rgb;
        rgb = Team_ColorRGB(pl.team);
@@ -690,18 +690,17 @@ void HUD_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_numb
                rgb_y = autocvar_scoreboard_color_bg_g + 0.5;
                rgb_z = autocvar_scoreboard_color_bg_b + 0.5; }
 
-       // Layout:
-       tmp_x = sbwidth;
-       tmp_y = hud_fontsize_y * 1.25;
-       tmp_z = 0;
-
+       vector h_pos = pos - '1 1 0';
+       vector h_size = item_size + '2 0 0';
        // alternated rows highlighting
        if(is_self)
-               drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
+               drawfill(h_pos, h_size, rgb, scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
        else if((scoreboard_highlight) && (!mod(pl_number,2)))
-               drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
+               drawfill(h_pos, h_size, rgb, scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
 
+       tmp_x = item_size_x;
        tmp_y = 0;
+       tmp_z = 0;
 
        for(i = 0; i < hud_num_fields; ++i)
        {
@@ -800,6 +799,9 @@ void HUD_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_numb
                        pos_x -= hud_size[i] + hud_fontsize_x;
                }
        }
+
+       if(pl.eliminated)
+               drawfill(h_pos, h_size, '0 0 0', 0.5, DRAWFLAG_NORMAL);
 }
 
 /*
@@ -913,6 +915,10 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
        pos_y += 1.25 * hud_fontsize_y; // skip the header
        pos_y += autocvar_scoreboard_border_thickness;
 
+       // item size
+       tmp_x = sbwidth;
+       tmp_y = hud_fontsize_y * 1.25;
+
        // fill the table and draw the rows
        i = 0;
        if (teamplay)
@@ -920,7 +926,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
                {
                        if(pl.team != tm.team)
                                continue;
-                       HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localnum), i);
+                       HUD_PrintScoreboardItem(pos, tmp, pl, (pl.sv_entnum == player_localnum), i);
                        pos_y += 1.25 * hud_fontsize_y;
                        ++i;
                }
@@ -929,7 +935,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
                {
                        if(pl.team == NUM_SPECTATOR)
                                continue;
-                       HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localnum), i);
+                       HUD_PrintScoreboardItem(pos, tmp, pl, (pl.sv_entnum == player_localnum), i);
                        pos_y += 1.25 * hud_fontsize_y;
                        ++i;
                }
@@ -1336,12 +1342,16 @@ void HUD_DrawScoreboard()
        float specs;
        specs = 0;
        tmp = pos;
+       vector item_size;
+       item_size_x = sbwidth;
+       item_size_y = hud_fontsize_y * 1.25;
+       item_size_z = 0;
        for(pl = players.sort_next; pl; pl = pl.sort_next)
        {
                if(pl.team != NUM_SPECTATOR)
                        continue;
                pos_y += 1.25 * hud_fontsize_y;
-               HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localnum), specs);
+               HUD_PrintScoreboardItem(pos, item_size, pl, (pl.sv_entnum == player_localnum), specs);
                ++specs;
        }
 
index fb6d781c0c1e16e10e5cfb4fa3a591537b311050..2be0112d79ea149954224636dfb225c70704392a 100644 (file)
@@ -96,7 +96,7 @@ const float ENT_CLIENT_BUMBLE_RAYGUN = 35;
 const float ENT_CLIENT_SPAWNPOINT = 36;
 const float ENT_CLIENT_SPAWNEVENT = 37;
 const float ENT_CLIENT_NOTIFICATION = 38;
-
+const float ENT_CLIENT_ELIMINATEDPLAYERS = 39;
 const float ENT_CLIENT_TURRET = 40;
 const float ENT_CLIENT_AUXILIARYXHAIR = 50;
 const float ENT_CLIENT_VEHICLE = 60;
index a933a6db50a5a4f93e4cc15231f8ef5642b56584..3eae41ea676871158176370606ab65bb136be9a3 100644 (file)
@@ -53,7 +53,7 @@ REGISTER_GAMETYPE(_("Team Deathmatch"),tdm,g_tdm,TEAM_DEATHMATCH,"timelimit=20 p
 REGISTER_GAMETYPE(_("Capture the Flag"),ctf,g_ctf,CTF,"timelimit=20 caplimit=10 leadlimit=0",_("Find and bring the enemy flag to your base to capture it"));
 #define g_ctf IS_GAMETYPE(CTF)
 
-REGISTER_GAMETYPE(_("Clan Arena"),ca,g_ca,CA,"timelimit=20 pointlimit=10 leadlimit=0",_("Kill all enemy teammates to win the round"));
+REGISTER_GAMETYPE(_("Clan Arena"),ca,g_ca,CA,"timelimit=20 pointlimit=10 teams=2 leadlimit=0",_("Kill all enemy teammates to win the round"));
 #define g_ca IS_GAMETYPE(CA)
 
 REGISTER_GAMETYPE(_("Domination"),dom,g_domination,DOMINATION,"timelimit=20 pointlimit=200 teams=2 leadlimit=0",_("Capture all the control points to win"));
index b45c648f7fa8839242533ffb71330756fe489266..fe7f4ec2aa507680dd6ae545cc1c86730a68aa64 100644 (file)
@@ -438,6 +438,8 @@ void Send_Notification_WOCOVA(
        MSG_INFO_NOTIF(1, INFO_DEATH_SELF_VH_WAKI_ROCKET,      2, 1, "s1 s2loc spree_lost", "s1",       "notify_death",         _("^BG%s^K1 couldn't find shelter from a Racer rocket%s%s"), "") \
        MSG_INFO_NOTIF(1, INFO_DEATH_SELF_VOID,                2, 1, "s1 s2loc spree_lost", "s1",       "notify_void",          _("^BG%s^K1 was in the wrong place%s%s"), "") \
        MULTITEAM_INFO(1, INFO_DEATH_TEAMKILL_, 4,             3, 1, "s1 s2 s3loc spree_end", "s2 s1",  "notify_teamkill_%s",   _("^BG%s^K1 was betrayed by ^BG%s^K1%s%s"), "") \
+       MSG_INFO_NOTIF(1, INFO_CA_JOIN_LATE,                   0, 0, "", "",                            "",                     _("^F1Round already started, you will join the game in the next round"), "") \
+       MSG_INFO_NOTIF(1, INFO_CA_LEAVE,                       0, 0, "", "",                            "",                     _("^F2You will spectate in the next round"), "") \
        MSG_INFO_NOTIF(1, INFO_DOMINATION_CAPTURE_TIME,        2, 2, "s1 s2 f1 f2", "",                 "",                     _("^BG%s^BG%s^BG (%s points every %s seconds)"), "") \
        MSG_INFO_NOTIF(1, INFO_FREEZETAG_FREEZE,               2, 0, "s1 s2", "",                       "",                     _("^BG%s^K1 was frozen by ^BG%s"), "") \
        MSG_INFO_NOTIF(1, INFO_FREEZETAG_REVIVED,              2, 0, "s1 s2", "",                       "",                     _("^BG%s^K3 was revived by ^BG%s"), "") \
@@ -562,6 +564,7 @@ void Send_Notification_WOCOVA(
        MULTITEAM_CENTER##teams(default,prefix,strnum,flnum,args,cpid,durcnt,normal,gentle)
 
 #define MSG_CENTER_NOTIFICATIONS \
+       MSG_CENTER_NOTIF(1, CENTER_ALONE,                       0, 0, "",             NO_CPID,             "0 0", _("^F4You are now alone!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_ASSAULT_ATTACKING,           0, 0, "",             CPID_ASSAULT_ROLE,   "0 0", _("^BGYou are attacking!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_ASSAULT_DEFENDING,           0, 0, "",             CPID_ASSAULT_ROLE,   "0 0", _("^BGYou are defending!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_COUNTDOWN_BEGIN,             0, 0, "",             CPID_ROUND,          "2 0", _("^F4Begin!"), "") \
@@ -671,8 +674,8 @@ void Send_Notification_WOCOVA(
        MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_ROUNDSTART,          0, 1, "",              CPID_KEYHUNT_OTHER,    "1 f1", _("^F4Round will start in ^COUNT"), "") \
        MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_SCAN,                0, 1, "",              CPID_KEYHUNT_OTHER,    "f1 0", _("^BGScanning frequency range..."), "") \
        MULTITEAM_CENTER(1, CENTER_KEYHUNT_START_, 4,           0, 0, "",              CPID_KEYHUNT,          "0 0", _("^BGYou are starting with the ^TC^TT Key"), "") \
-       MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_WAIT,                0, 4, "missing_teams", CPID_KEYHUNT_OTHER,    "0 0", _("^BGWaiting for players to join...\nNeed active players for: %s"), "") \
-       MSG_CENTER_NOTIF(1, CENTER_MISSING_TEAMS,               0, 4, "missing_teams", CPID_MISSING_TEAMS,    "-1 0", _("^BGWaiting for players to join...\nNeed active players for: %s"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_WAIT,                0, 1, "missing_teams", CPID_KEYHUNT_OTHER,    "0 0", _("^BGWaiting for players to join...\nNeed active players for: %s"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_MISSING_TEAMS,               0, 1, "missing_teams", CPID_MISSING_TEAMS,    "-1 0", _("^BGWaiting for players to join...\nNeed active players for: %s"), "") \
        MSG_CENTER_NOTIF(1, CENTER_MISSING_PLAYERS,             0, 1, "f1",            CPID_MISSING_PLAYERS,  "-1 0", _("^BGWaiting for %s player(s) to join..."), "") \
        MSG_CENTER_NOTIF(1, CENTER_MINSTA_FINDAMMO,             0, 0, "",              CPID_MINSTA_FINDAMMO,  "1 9", _("^F4^COUNT^BG left to find some ammo!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_MINSTA_FINDAMMO_FIRST,       0, 0, "",              CPID_MINSTA_FINDAMMO,  "1 10", _("^BGGet some ammo or you'll be dead in ^F4^COUNT^BG!"), _("^BGGet some ammo! ^F4^COUNT^BG left!")) \
@@ -1017,7 +1020,7 @@ string arg_slot[NOTIF_MAX_ARGS];
     ARG_CASE(ARG_CS_SV_HA,  "f3race_time",   mmssss(f3)) \
     ARG_CASE(ARG_CS_SV,     "race_col",      CCR(((f1 == 1) ? "^F1" : "^F2"))) \
     ARG_CASE(ARG_CS_SV,     "race_diff",     ((f2 > f3) ? sprintf(CCR("^1[+%s]"), mmssss(f2 - f3)) : sprintf(CCR("^2[-%s]"), mmssss(f3 - f2)))) \
-    ARG_CASE(ARG_CS,        "missing_teams", notif_arg_missing_teams(f1, f2, f3, f4)) \
+    ARG_CASE(ARG_CS,        "missing_teams", notif_arg_missing_teams(f1)) \
     ARG_CASE(ARG_CS,        "pass_key",      ((((tmp_s = getcommandkey("pass", "+use")) != "pass") && !(strstrofs(tmp_s, "not bound", 0) >= 0)) ? sprintf(CCR(_(" ^F1(Press %s)")), tmp_s) : "")) \
     ARG_CASE(ARG_CS,        "frag_ping",     notif_arg_frag_ping(TRUE, f2)) \
     ARG_CASE(ARG_CS,        "frag_stats",    notif_arg_frag_stats(f2, f3, f4)) \
@@ -1062,26 +1065,26 @@ string notif_arg_frag_stats(float fhealth, float farmor, float fping)
                return sprintf(CCR(_("\n(^F4Dead^BG)%s")), notif_arg_frag_ping(FALSE, fping));
 }
 
-string notif_arg_missing_teams(float f1, float f2, float f3, float f4)
+string notif_arg_missing_teams(float f1)
 {
        return sprintf("%s%s%s%s",
-               (f1 ?
-                       sprintf("%s%s", Team_ColoredFullName(f1 - 1), ((f2 + f3 + f4) ? ", " : ""))
+               ((f1 & 1) ?
+                       sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_1), ((f1 & (2 + 4 + 8)) ? ", " : ""))
                        :
                        ""
                ),
-               (f2 ?
-                       sprintf("%s%s", Team_ColoredFullName(f2 - 1), ((f3 + f4) ? ", " : ""))
+               ((f1 & 2) ?
+                       sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_2), ((f1 & (4 + 8)) ? ", " : ""))
                        :
                        ""
                ),
-               (f3 ?
-                       sprintf("%s%s", Team_ColoredFullName(f3 - 1), (f4 ? ", " : ""))
+               ((f1 & 4) ?
+                       sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_3), ((f1 & 8) ? ", " : ""))
                        :
                        ""
                ),
-               (f4 ?
-                       Team_ColoredFullName(f4 - 1)
+               ((f1 & 8) ?
+                       Team_ColoredFullName(NUM_TEAM_4)
                        :
                        ""
                )
index b93d87ad29f229736686045c546f26d0af1101a6..40b769ddd3fb4a78f3b156995a2cf53153800869 100644 (file)
@@ -43,7 +43,7 @@ void bot_think()
        //self.bot_painintensity = self.bot_painintensity + self.bot_oldhealth - self.health;
        //self.bot_painintensity = bound(0, self.bot_painintensity, 100);
 
-       if (autocvar_g_campaign && !campaign_bots_may_start)
+       if (!IS_PLAYER(self) || (autocvar_g_campaign && !campaign_bots_may_start))
        {
                self.bot_nextthink = time + 0.5;
                return;
index f55c2658b77ff057a7573c1d098c8880313d31af..578e8707e026796ce227b5724d201a637554b3d2 100644 (file)
@@ -258,6 +258,7 @@ void PutObserverInServer (void)
        self.punchvector = '0 0 0';
        self.oldvelocity = self.velocity;
        self.fire_endtime = -1;
+       self.event_damage = func_null;
 }
 
 .float model_randomizer;
@@ -783,8 +784,8 @@ void ClientKill_Now()
        if(self.killindicator_teamchange)
                ClientKill_Now_TeamChange();
 
-       // in any case:
-       Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
+       if(IS_PLAYER(self))
+               Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
 
        // now I am sure the player IS dead
 }
@@ -1983,7 +1984,7 @@ float nJoinAllowed(entity ignore) {
 
        float currentlyPlaying = 0;
        FOR_EACH_REALCLIENT(e)
-               if(IS_PLAYER(e) || e.caplayer == 1)
+               if(IS_PLAYER(e) || e.caplayer)
                        currentlyPlaying += 1;
 
        if(currentlyPlaying < autocvar_g_maxplayers)
@@ -1997,7 +1998,10 @@ float nJoinAllowed(entity ignore) {
  * g_maxplayers_spectator_blocktime seconds
  */
 void checkSpectatorBlock() {
-       if(IS_SPEC(self) || IS_OBSERVER(self)) {
+       if(IS_SPEC(self) || IS_OBSERVER(self))
+       if(!self.caplayer)
+       if(IS_REAL_CLIENT(self))
+       {
                if( time > (self.spectatortime + autocvar_g_maxplayers_spectator_blocktime) ) {
                        Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_QUIT_KICK_SPECTATING);
                        dropclient(self);
index 5aab58832053d745835460e21c310116f364e01a..a3221a1bc103f7e3fcfb49efc95b813abc20dd41 100644 (file)
@@ -343,6 +343,9 @@ void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, float
 
 void calculate_player_respawn_time()
 {
+       if(g_ca)
+               return;
+
        float gametype_setting_tmp;
        float sdelay_max = GAMETYPE_DEFAULTED_SETTING(respawn_delay_max);
        float sdelay_small = GAMETYPE_DEFAULTED_SETTING(respawn_delay_small);
@@ -721,6 +724,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                self.flags &= ~FL_ONGROUND;
                // dying animation
                self.deadflag = DEAD_DYING;
+
                // when to allow respawn
                calculate_player_respawn_time();
 
index 51a04b59135e01e3ac0fd9b6bd62c1d25271651f..7d67c4f30d621c751f0cb5ed9c627451f9a71a77 100644 (file)
@@ -152,6 +152,8 @@ void ClientCommand_join(float request)
                        {
                                if(!IS_PLAYER(self) && !lockteams)
                                {
+                                       if(self.caplayer)
+                                               return;
                                        if(nJoinAllowed(self))
                                        {
                                                if(autocvar_g_campaign) { campaign_bots_may_start = 1; }
@@ -580,15 +582,11 @@ void ClientCommand_spectate(float request)
                                        }
                                }
 
-                               if(IS_PLAYER(self) && autocvar_sv_spectate == 1)
-                                       ClientKill_TeamChange(-2); // observe
-
-                               // in CA, allow a dead player to move to spectators (without that, caplayer!=0 will be moved back to the player list)
-                               // note: if arena game mode is ever done properly, this needs to be removed.
-                               if(self.caplayer && (IS_SPEC(self) || IS_OBSERVER(self)))
+                               if((IS_PLAYER(self) || self.caplayer) && autocvar_sv_spectate == 1)
                                {
-                                       sprint(self, "WARNING: you will spectate in the next round.\n");
-                                       self.caplayer = 0;
+                                       if(self.caplayer && (IS_SPEC(self) || IS_OBSERVER(self)))
+                                               Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CA_LEAVE);
+                                       ClientKill_TeamChange(-2); // observe
                                }
                        }
                        return; // never fall through to usage
index c0da029c51248b0fbafb4eaee9053a4f898acfde..edeb571c0dd62f0ec374699f2ac8c82e37233d01 100644 (file)
@@ -213,6 +213,8 @@ void GameCommand_allspec(float request, float argc)
                        FOR_EACH_REALPLAYER(client)
                        {
                                self = client;
+                               if(self.caplayer)
+                                       self.caplayer = 0;
                                PutObserverInServer();
                                ++i;
                        }
@@ -1045,6 +1047,8 @@ void GameCommand_moveplayer(float request, float argc)
                                                if(!IS_SPEC(client) && !IS_OBSERVER(client))
                                                {
                                                        self = client;
+                                                       if(self.caplayer)
+                                                               self.caplayer = 0;
                                                        PutObserverInServer();
 
                                                        successful = strcat(successful, (successful ? ", " : ""), client.netname);
@@ -1150,9 +1154,10 @@ void GameCommand_nospectators(float request)
                {
                        blockSpectators = 1;
                        entity plr;
-                       FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
+                       FOR_EACH_REALCLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
                        {
                                if(IS_SPEC(plr) || IS_OBSERVER(plr))
+                               if(!plr.caplayer)
                                {
                                        plr.spectatortime = time;
                                        Send_Notification(NOTIF_ONE_ONLY, plr, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
index fc9e84e586c2c1d63735016edd3e05e075e96692..f3f4d71bc45e7a841599447ae9883925f7490d66 100644 (file)
@@ -1590,6 +1590,44 @@ void Net_LinkEntity(entity e, float docull, float dt, float(entity, float) sendf
     }
 }
 
+
+entity eliminatedPlayers;
+.float(entity) isEliminated;
+float EliminatedPlayers_SendEntity(entity to, float sendflags)
+{
+       float i, f, b;
+       entity e;
+       WriteByte(MSG_ENTITY, ENT_CLIENT_ELIMINATEDPLAYERS);
+       WriteByte(MSG_ENTITY, sendflags);
+
+       if(sendflags & 1)
+       {
+               for(i = 1; i <= maxclients; i += 8)
+               {
+                       for(f = 0, e = edict_num(i), b = 1; b < 256; b *= 2, e = nextent(e))
+                       {
+                               if(eliminatedPlayers.isEliminated(e))
+                                       f |= b;
+                       }
+                       WriteByte(MSG_ENTITY, f);
+               }
+       }
+
+       return TRUE;
+}
+
+void EliminatedPlayers_Init(float(entity) isEliminated_func)
+{
+       if(eliminatedPlayers)
+       {
+               backtrace("Can't spawn eliminatedPlayers again!");
+               return;
+       }
+       Net_LinkEntity(eliminatedPlayers = spawn(), FALSE, 0, EliminatedPlayers_SendEntity);
+       eliminatedPlayers.isEliminated = isEliminated_func;
+}
+
+
 void adaptor_think2touch()
 {
     entity o;
index 8b38ceb096a8cd537eda2238aad552d6fb7ae103..e3c07f59e3807ddab5fa4f75eafb993fe1177650 100644 (file)
@@ -113,42 +113,57 @@ void CA_RoundStart()
                allowed_to_spawn = FALSE;
 }
 
-float prev_total_players;
+float prev_missing_teams_mask;
 float CA_CheckTeams()
 {
        allowed_to_spawn = TRUE;
        CA_count_alive_players();
        if(CA_ALIVE_TEAMS_OK())
        {
-               if(prev_total_players > 0)
+               if(prev_missing_teams_mask > 0)
                        Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
-               prev_total_players = -1;
+               prev_missing_teams_mask = -1;
                return 1;
        }
-       if(prev_total_players != total_players)
+       if(total_players == 0)
        {
-               float p1 = 0, p2 = 0, p3 = 0, p4 = 0;
-               if(!redalive) p1 = NUM_TEAM_1;
-               if(!bluealive) p2 = NUM_TEAM_2;
-               if(ca_teams >= 3)
-               if(!yellowalive) p3 = NUM_TEAM_3;
-               if(ca_teams >= 4)
-               if(!pinkalive) p4 = NUM_TEAM_4;
-               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, p1, p2, p3, p4);
-               prev_total_players = total_players;
+               if(prev_missing_teams_mask > 0)
+                       Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
+               prev_missing_teams_mask = -1;
+               return 0;
+       }
+       float missing_teams_mask = (!redalive) + (!bluealive) * 2;
+       if(ca_teams >= 3) missing_teams_mask += (!yellowalive) * 4;
+       if(ca_teams >= 4) missing_teams_mask += (!pinkalive) * 8;
+       if(prev_missing_teams_mask != missing_teams_mask)
+       {
+               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
+               prev_missing_teams_mask = missing_teams_mask;
        }
        return 0;
 }
 
+float ca_isEliminated(entity e)
+{
+       if(e.caplayer == 1 && (e.deadflag != DEAD_NO || e.frags == FRAGS_LMS_LOSER))
+               return TRUE;
+       if(e.caplayer == 0.5)
+               return TRUE;
+       return FALSE;
+}
+
 MUTATOR_HOOKFUNCTION(ca_PlayerSpawn)
 {
        self.caplayer = 1;
+       if(!warmup_stage)
+               eliminatedPlayers.SendFlags |= 1;
        return 1;
 }
 
 MUTATOR_HOOKFUNCTION(ca_PutClientInServer)
 {
        if(!allowed_to_spawn)
+       if(IS_PLAYER(self)) // this is true even when player is trying to join
        {
                self.classname = "observer";
                if(self.jointime != time) //not when connecting
@@ -156,7 +171,7 @@ MUTATOR_HOOKFUNCTION(ca_PutClientInServer)
                {
                        self.caplayer = 0.5;
                        if(IS_REAL_CLIENT(self))
-                               sprint(self, "You will join the game in the next round.\n");
+                               Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CA_JOIN_LATE);
                }
        }
        return 1;
@@ -167,6 +182,11 @@ MUTATOR_HOOKFUNCTION(ca_reset_map_players)
        FOR_EACH_CLIENT(self)
        {
                self.killcount = 0;
+               if(!self.caplayer && IS_BOT_CLIENT(self))
+               {
+                       self.team = -1;
+                       self.caplayer = 1;
+               }
                if(self.caplayer)
                {
                        self.classname = "player";
@@ -195,10 +215,47 @@ MUTATOR_HOOKFUNCTION(ca_GetTeamCount)
        return 0;
 }
 
+entity ca_LastPlayerForTeam()
+{
+       entity pl, last_pl = world;
+       FOR_EACH_PLAYER(pl)
+       {
+               if(pl.health >= 1)
+               if(pl != self)
+               if(pl.team == self.team)
+               if(!last_pl)
+                       last_pl = pl;
+               else
+                       return world;
+       }
+       return last_pl;
+}
+
+void ca_LastPlayerForTeam_Notify()
+{
+       if(round_handler_IsActive())
+       if(round_handler_IsRoundStarted())
+       {
+               entity pl = ca_LastPlayerForTeam();
+               if(pl)
+                       Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
+       }
+}
+
 MUTATOR_HOOKFUNCTION(ca_PlayerDies)
 {
+       ca_LastPlayerForTeam_Notify();
        if(!allowed_to_spawn)
                self.respawn_flags =  RESPAWN_SILENT;
+       if(!warmup_stage)
+               eliminatedPlayers.SendFlags |= 1;
+       return 1;
+}
+
+MUTATOR_HOOKFUNCTION(ca_ClientDisconnect)
+{
+       if(self.caplayer == 1)
+               ca_LastPlayerForTeam_Notify();
        return 1;
 }
 
@@ -209,10 +266,14 @@ MUTATOR_HOOKFUNCTION(ca_ForbidPlayerScore_Clear)
 
 MUTATOR_HOOKFUNCTION(ca_MakePlayerObserver)
 {
+       if(self.caplayer == 1)
+               ca_LastPlayerForTeam_Notify();
        if(self.killindicator_teamchange == -2)
                self.caplayer = 0;
        if(self.caplayer)
                self.frags = FRAGS_LMS_LOSER;
+       if(!warmup_stage)
+               eliminatedPlayers.SendFlags |= 1;
        return 1;
 }
 
@@ -299,6 +360,8 @@ void ca_Initialize()
        addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
        addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
        addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
+
+       EliminatedPlayers_Init(ca_isEliminated);
 }
 
 MUTATOR_DEFINITION(gamemode_ca)
@@ -311,6 +374,7 @@ MUTATOR_DEFINITION(gamemode_ca)
        MUTATOR_HOOK(reset_map_players, ca_reset_map_players, CBC_ORDER_ANY);
        MUTATOR_HOOK(GetTeamCount, ca_GetTeamCount, CBC_ORDER_EXCLUSIVE);
        MUTATOR_HOOK(PlayerDies, ca_PlayerDies, CBC_ORDER_ANY);
+       MUTATOR_HOOK(ClientDisconnect, ca_ClientDisconnect, CBC_ORDER_ANY);
        MUTATOR_HOOK(ForbidPlayerScore_Clear, ca_ForbidPlayerScore_Clear, CBC_ORDER_ANY);
        MUTATOR_HOOK(ForbidThrowCurrentWeapon, ca_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
        MUTATOR_HOOK(GiveFragsForKill, ca_GiveFragsForKill, CBC_ORDER_FIRST);
index ffdc1612dde1235608c2874da85eefc60dd37c15..9034887d82712e61b1144d312a424ea5812694b9 100644 (file)
@@ -26,31 +26,36 @@ void freezetag_count_alive_players()
                e.yellowalive_stat = yellowalive;
                e.pinkalive_stat = pinkalive;
        }
+
+       eliminatedPlayers.SendFlags |= 1;
 }
 #define FREEZETAG_ALIVE_TEAMS() ((redalive > 0) + (bluealive > 0) + (yellowalive > 0) + (pinkalive > 0))
 #define FREEZETAG_ALIVE_TEAMS_OK() (FREEZETAG_ALIVE_TEAMS() == freezetag_teams)
 
-float prev_total_players;
+float prev_missing_teams_mask;
 float freezetag_CheckTeams()
 {
        if(FREEZETAG_ALIVE_TEAMS_OK())
        {
-               if(prev_total_players > 0)
+               if(prev_missing_teams_mask > 0)
                        Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
-               prev_total_players = -1;
+               prev_missing_teams_mask = -1;
                return 1;
        }
-       if(prev_total_players != total_players)
+       if(total_players == 0)
+       {
+               if(prev_missing_teams_mask > 0)
+                       Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
+               prev_missing_teams_mask = -1;
+               return 0;
+       }
+       float missing_teams_mask = (!redalive) + (!bluealive) * 2;
+       if(freezetag_teams >= 3) missing_teams_mask += (!yellowalive) * 4;
+       if(freezetag_teams >= 4) missing_teams_mask += (!pinkalive) * 8;
+       if(prev_missing_teams_mask != missing_teams_mask)
        {
-               float p1 = 0, p2 = 0, p3 = 0, p4 = 0;
-               if(!redalive) p1 = NUM_TEAM_1;
-               if(!bluealive) p2 = NUM_TEAM_2;
-               if(freezetag_teams >= 3)
-               if(!yellowalive) p3 = NUM_TEAM_3;
-               if(freezetag_teams >= 4)
-               if(!pinkalive) p4 = NUM_TEAM_4;
-               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, p1, p2, p3, p4);
-               prev_total_players = total_players;
+               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
+               prev_missing_teams_mask = missing_teams_mask;
        }
        return 0;
 }
@@ -122,6 +127,34 @@ float freezetag_CheckWinner()
        return 1;
 }
 
+entity freezetag_LastPlayerForTeam()
+{
+       entity pl, last_pl = world;
+       FOR_EACH_PLAYER(pl)
+       {
+               if(pl.health >= 1)
+               if(!pl.frozen)
+               if(pl != self)
+               if(pl.team == self.team)
+               if(!last_pl)
+                       last_pl = pl;
+               else
+                       return world;
+       }
+       return last_pl;
+}
+
+void freezetag_LastPlayerForTeam_Notify()
+{
+       if(round_handler_IsActive())
+       if(round_handler_IsRoundStarted())
+       {
+               entity pl = freezetag_LastPlayerForTeam();
+               if(pl)
+                       Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
+       }
+}
+
 void freezetag_Add_Score(entity attacker)
 {
        if(attacker == self)
@@ -163,6 +196,13 @@ void freezetag_Unfreeze(entity attacker)
        Unfreeze(self);
 }
 
+float freezetag_isEliminated(entity e)
+{
+       if(e.frozen == 1 || e.deadflag != DEAD_NO)
+               return TRUE;
+       return FALSE;
+}
+
 
 // ================
 // Bot player logic
@@ -275,6 +315,8 @@ void havocbot_role_ft_freeing()
 MUTATOR_HOOKFUNCTION(freezetag_RemovePlayer)
 {
        self.health = 0; // neccessary to update correctly alive stats
+       if(!self.frozen)
+               freezetag_LastPlayerForTeam_Notify();
        freezetag_Unfreeze(world);
        freezetag_count_alive_players();
        return 1;
@@ -301,6 +343,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerDies)
                {
                        freezetag_Add_Score(frag_attacker);
                        freezetag_count_alive_players();
+                       freezetag_LastPlayerForTeam_Notify();
                }
                else
                        freezetag_Unfreeze(world); // remove ice
@@ -313,6 +356,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerDies)
                return 1;
 
        freezetag_Freeze(frag_attacker);
+       freezetag_LastPlayerForTeam_Notify();
 
        if(frag_attacker == frag_target || frag_attacker == world)
        {
@@ -509,6 +553,8 @@ void freezetag_Initialize()
        addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
        addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
        addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
+
+       EliminatedPlayers_Init(freezetag_isEliminated);
 }
 
 MUTATOR_DEFINITION(gamemode_freezetag)
index 8448a215e93bdbc989c01bfcfadbcf6d4702ab8c..364cb7fe3b513630e6e990db2334ed7e1b0ddb1e 100644 (file)
@@ -416,8 +416,6 @@ void invasion_DelayedInit() // Do this check with a delay so we can wait for tea
        round_handler_Spawn(Invasion_CheckPlayers, Invasion_CheckWinner, Invasion_RoundStart);
        round_handler_Init(5, autocvar_g_invasion_warmup, autocvar_g_invasion_round_timelimit);
 
-       allowed_to_spawn = TRUE;
-
        inv_roundcnt = 0;
        inv_maxrounds = 15; // 15?
 }
index 90302bc45b36c3f23bf68f083b25c56d59d50a6b..285e52c80f0a68580a14aa7cb13d4525017123b1 100644 (file)
@@ -515,7 +515,7 @@ void GetTeamCounts(entity ignore)
        FOR_EACH_CLIENT(head)
        {
                float t;
-               if(IS_PLAYER(head))
+               if(IS_PLAYER(head) || head.caplayer)
                        t = head.team;
                else if(head.team_forced > 0)
                        t = head.team_forced; // reserve the spot