From 09d714d13af9957944866c7c3a9479e0f98a7662 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Tue, 16 May 2023 01:20:21 +0200 Subject: [PATCH] make sure battle royale squads are balanced --- qcsrc/common/gamemodes/gamemode/br/sv_br.qc | 2 +- qcsrc/common/gamemodes/gamemode/br/sv_squad.qc | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc index dee0dbfeb..0f4163766 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc +++ b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc @@ -1147,7 +1147,7 @@ void br_Start(){ IL_PUSH(squads, new_squad); } - FOREACH_CLIENT(IS_PLAYER(it), { + FOREACH_CLIENT_RANDOM(IS_PLAYER(it), { entity current_squad = br_SquadGetRandomAvail(); br_SquadMember_Add(current_squad, it); GameRules_scoring_add(it, BR_SQUAD, current_squad.br_squad_id); diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_squad.qc b/qcsrc/common/gamemodes/gamemode/br/sv_squad.qc index 6b9b1ffba..428b0cd54 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_squad.qc +++ b/qcsrc/common/gamemodes/gamemode/br/sv_squad.qc @@ -120,8 +120,11 @@ bool br_SquadIsBotsOnly(entity squad) entity br_SquadGetRandomAvail() { + int min_members = max_squad_size; + IL_EACH(squads, it.br_squad_members < min_members, min_members = it.br_squad_members); + int num_avail = 0; - IL_EACH(squads, it.br_squad_members < max_squad_size, ++num_avail); + IL_EACH(squads, it.br_squad_members == min_members, ++num_avail); if(num_avail == 0) return NULL; @@ -129,7 +132,7 @@ entity br_SquadGetRandomAvail() int target_id = floor(random() * num_avail); int current_id = 0; - IL_EACH(squads, it.br_squad_members < max_squad_size, + IL_EACH(squads, it.br_squad_members == min_members, { if(current_id == target_id) return it; -- 2.39.2