From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Mon, 15 May 2023 23:20:21 +0000 (+0200) Subject: make sure battle royale squads are balanced X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=09d714d13af9957944866c7c3a9479e0f98a7662;p=xonotic%2Fxonotic-data.pk3dir.git make sure battle royale squads are balanced --- 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;