From cc060f009bb6fc15305531073f43cfd6bb92bda5 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Tue, 18 Jan 2022 16:52:47 +0100 Subject: [PATCH] improve player color handling in battle royale --- qcsrc/client/csqcmodel_hooks.qc | 2 +- qcsrc/client/hud/panel/scoreboard.qc | 2 +- qcsrc/common/gamemodes/gamemode/br/sv_br.qc | 18 ++++++++++++++++-- qcsrc/common/gamemodes/gamemode/br/sv_br.qh | 2 -- qcsrc/common/stats.qh | 1 + qcsrc/server/command/cmd.qc | 2 +- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc index 252c5032d..e5363d059 100644 --- a/qcsrc/client/csqcmodel_hooks.qc +++ b/qcsrc/client/csqcmodel_hooks.qc @@ -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; } diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 1e125f6f2..b46ec01c8 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -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); { diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc index 322a551f6..3a092a576 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc +++ b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc @@ -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 diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_br.qh b/qcsrc/common/gamemodes/gamemode/br/sv_br.qh index 010bf2753..38478c5e8 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_br.qh +++ b/qcsrc/common/gamemodes/gamemode/br/sv_br.qh @@ -3,8 +3,6 @@ #include #include -bool squads_colored = false; - void br_Initialize(); REGISTER_MUTATOR(br, false) diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 0659f5b67..be608dae1 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -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) diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index cefc4d5ac..a8a8747e1 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -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 -- 2.39.2