]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
make sure battle royale squads are balanced
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Mon, 15 May 2023 23:20:21 +0000 (01:20 +0200)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Mon, 15 May 2023 23:20:21 +0000 (01:20 +0200)
qcsrc/common/gamemodes/gamemode/br/sv_br.qc
qcsrc/common/gamemodes/gamemode/br/sv_squad.qc

index dee0dbfebae040aeadd04002fb9600a2fff56c1c..0f416376668b142df0b546267928448464a0233e 100644 (file)
@@ -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);
index 6b9b1ffba926a86a024f21b1d71aaae652bc7e1d..428b0cd548222099ca81040bce4465aa2f436231 100644 (file)
@@ -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;