]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
improve player color handling in battle royale
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Tue, 18 Jan 2022 15:52:47 +0000 (16:52 +0100)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Tue, 18 Jan 2022 15:52:47 +0000 (16:52 +0100)
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/common/gamemodes/gamemode/br/sv_br.qc
qcsrc/common/gamemodes/gamemode/br/sv_br.qh
qcsrc/common/stats.qh
qcsrc/server/command/cmd.qc

index 252c5032dee4f7687dd5af0d3bc04e6673274393..e5363d0596954618a435c3979d3fd05765e02ba0 100644 (file)
@@ -248,7 +248,7 @@ void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
        }
        else
        {
-               if (fpc == 1 || fpc == 2)
+               if ((!(ISGAMETYPE(BR) && STAT(SQUADCOLORS)) && fpc == 1) || fpc == 2)
                        forceplayercolors_enabled = true;
        }
 
index 1e125f6f29eb21c12d7b818ded60f94d26813b66..b46ec01c89898ac56f44f2ccfcc2a6df23303fbc 100644 (file)
@@ -630,7 +630,7 @@ string Scoreboard_GetName(entity pl)
        {
                sbt_field_icon0 = "gfx/scoreboard/player_ready";
        }
-       else if(!teamplay)
+       else if(!teamplay && !(ISGAMETYPE(BR) && STAT(SQUADCOLORS)))
        {
                int f = entcs_GetClientColors(pl.sv_entnum);
                {
index 322a551f6c0def9b30a3c0f2f1449175a25a05c5..3a092a576465c6d6734cff894894fb9e6a11bf10 100644 (file)
@@ -18,6 +18,8 @@ int br_WinningCondition();
 entity ring;
 entity dropship;
 
+bool squads_colored = false;
+
 .bool br_ring_warned;
 .float br_force_drop_distance;
 
@@ -93,6 +95,10 @@ MUTATOR_HOOKFUNCTION(br, GetPlayerStatus)
 
 MUTATOR_HOOKFUNCTION(br, ClientConnect)
 {
+    entity player = M_ARGV(0, entity);
+
+    STAT(SQUADCOLORS, player) = squads_colored;
+
     if(ring)
         ring_timelimit(ring);
 
@@ -940,16 +946,22 @@ void br_RoundStart(){
     });
 
     squads_colored = autocvar_g_br_squad_colors;
+
+    FOREACH_CLIENT(IS_REAL_CLIENT(it),
+    {
+        STAT(SQUADCOLORS, it) = squads_colored;
+    });
+
     IL_EACH(squads, true,
     {
         if(squads_colored)
         {
             float squad_color;
-            squad_color = floor(random() * 256);
+            squad_color = 16 * floor(random() * 15) + floor(random() * 15); // color 15 is special, don't select it as a squad color
 
             for(entity member = it.br_squad_first; member; member = member.br_squad_next)
             {
-                setcolor(member, squad_color);
+                member.colormap = 1024 + squad_color;
             }
         }
 
@@ -963,6 +975,8 @@ void br_RoundStart(){
 
 void br_Initialize()
 {
+    squads_colored = autocvar_g_br_squad_colors;
+
     // TODO: remove round handler
     round_handler_Spawn(br_CheckPlayers, br_CheckWinner, br_RoundStart);
     round_handler_Init(5, 0, 0); // no warmup or timelimit in battle royale
index 010bf2753bb48be7ea799da4c1caa52a145d3944..38478c5e88374acc18cdd02fbc9306804cd91cc5 100644 (file)
@@ -3,8 +3,6 @@
 #include <common/mutators/base.qh>
 #include <common/scores.qh>
 
-bool squads_colored = false;
-
 void br_Initialize();
 
 REGISTER_MUTATOR(br, false)
index 0659f5b67e8c561ce3a9e41b23501f8303e4708e..be608dae196566a0352440d23aae0799907a2e4a 100644 (file)
@@ -130,6 +130,7 @@ REGISTER_STAT(BLEEDING, bool)
 REGISTER_STAT(DROP, int)
 REGISTER_STAT(SQUADSALIVE, int)
 REGISTER_STAT(PLAYERSALIVE, int)
+REGISTER_STAT(SQUADCOLORS, bool)
 REGISTER_STAT(ROUNDLOST, int)
 REGISTER_STAT(CAPTURE_PROGRESS, float)
 REGISTER_STAT(ENTRAP_ORB, float)
index cefc4d5ac6bc5c51c9609bad0787d999abd92924..a8a8747e1822558f0b3c572b58a5d105b7d4c773 100644 (file)
@@ -906,7 +906,7 @@ void SV_ParseClientCommand(entity this, string command)
                                // since gamecode doesn't have any calls earlier than this, do the connecting message here
                                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_CONNECTING, this.netname);
                        }
-                       if(teamplay || (squads_colored && IN_SQUAD(this)))
+                       if(teamplay)
                                return;
                        break;
                case "c2s": Net_ClientCommand(this, command); return; // handled by net.qh