]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix MMM murderer/detective amount calculation
authorz411 <z411@omaera.org>
Tue, 12 Oct 2021 18:37:35 +0000 (15:37 -0300)
committerLegendaryGuard <rootuser999@gmail.com>
Tue, 12 Oct 2021 18:46:06 +0000 (20:46 +0200)
gamemodes-server.cfg
qcsrc/common/gamemodes/gamemode/mmm/sv_mmm.qc

index 8121dab8bb08ef69a127228765855a8610d02f4f..7f577325b7c220f37d471e3ce237bae485befeec 100644 (file)
@@ -576,8 +576,8 @@ set g_duel_not_dm_maps 0 "when this is set, DM maps will NOT be listed in duel"
 set g_mmm 0 "Murder in Megaerebus Manor: A group of space civilians have murderers among them. Murderers must kill civilians, while the civilians have to try to find and kill the murderers"
 set g_mmm_not_lms_maps 0 "when this is set, LMS maps will NOT be listed in mmm"
 set g_mmm_not_dm_maps 0 "when this is set, DM maps will NOT be listed in mmm"
-set g_mmm_civilian_count 0.625 "number of players who will become civilians, set between 0 and 0.9 to use a multiplier of the current players, or 1 and above to specify an exact number of players"
-//set g_mmm_murderer_count 0.25 "number of players who will become murderers, set between 0 and 0.9 to use a multiplier of the current players, or 1 and above to specify an exact number of players"
+set g_mmm_murderer_count 0.25 "number of players who will become murderers, set between 0 and 0.9 to use a multiplier of the current players, or 1 and above to specify an exact number of players"
+set g_mmm_detective_count 0.125 "number of players who will become detectives, set between 0 and 0.9 to use a multiplier of the current players, or 1 and above, to specify an exact number of players. 0 = no detectives"
 set g_mmm_punish_teamkill 0 "enable option to kill the player when they kill an ally"
 set g_mmm_reward_civilian 1 "give a point to all civilian players if the round timelimit is reached, in addition to the points given for kills"
 set g_mmm_warmup 10 "how long the players will have time to run around the map before the round starts"
index 596a3a3f4ffae0ff2bb9c0aad4cfe2d18ec62863..20f28804780f362bfa47f71af22e5f9c6de52c4a 100644 (file)
@@ -1,9 +1,7 @@
 #include "sv_mmm.qh"
 
-//set g_mmm_detective_count 0.125 "number of players who will become detectives, set between 0 and 0.9 to use a multiplier of the current players, or 1 and above to specify an exact number of players"
-//float autocvar_g_mmm_detective_count = 0.125; //I don't think that it'll be used...
-float autocvar_g_mmm_civilian_count = 0.625;
-//float autocvar_g_mmm_murderer_count = 0.25;
+float autocvar_g_mmm_detective_count = 0.125;
+float autocvar_g_mmm_murderer_count = 0.25;
 float autocvar_g_mmm_round_timelimit = 180;
 float autocvar_g_mmm_warmup = 10;
 bool autocvar_g_mmm_punish_teamkill = false;
@@ -243,101 +241,34 @@ void mmm_RoundStart()
                if(IS_PLAYER(it) && !IS_DEAD(it))
                {
                        ++playercount;
-                       it.mmm_status = MMM_STATUS_CIVILIAN;
                }
                else
                        it.mmm_status = 0; // this is mostly a safety check; if a client manages to somehow maintain a mmm status, clear it before the round starts!
                it.mmm_validkills = 0;
        });
        
-       int civilian_count = bound(1, ((autocvar_g_mmm_civilian_count >= 1) ? autocvar_g_mmm_civilian_count : floor(playercount * autocvar_g_mmm_civilian_count)), playercount - 1); // 20%, but ensure at least 1 and less than total
-       int total_civilians = 0;
-       //int murderer_count = bound(1, ((autocvar_g_mmm_murderer_count >= 1) ? autocvar_g_mmm_murderer_count : floor(playercount * autocvar_g_mmm_murderer_count)), playercount - 1); // 20%, but ensure at least 1 and less than total
+       int murderer_count = ((autocvar_g_mmm_murderer_count >= 1) ? autocvar_g_mmm_murderer_count : max(floor(playercount * autocvar_g_mmm_murderer_count), 1)); // There must be at least 1 murderer
+       int detective_count = ((autocvar_g_mmm_detective_count >= 1 || autocvar_g_mmm_detective_count == 0) ? autocvar_g_mmm_detective_count : floor(playercount * autocvar_g_mmm_detective_count)); // It's fine if there are no detectives
+       
        int total_murderers = 0;
-       //int detective_count = bound(1, ((autocvar_g_mmm_detective_count >= 1) ? autocvar_g_mmm_detective_count : floor(playercount * autocvar_g_mmm_detective_count)), playercount - 1); // 20%, but ensure at least 1 and less than total
        int total_detectives = 0;
+       int total_civilians = 0;
 
-       //civilians TOTAL
        FOREACH_CLIENT_RANDOM(IS_PLAYER(it) && !IS_DEAD(it),
        {
-               if(total_civilians >= civilian_count)
-                       break;
-               //LegendGuard fixes the round start again 22-03-2021
-               total_civilians++;
-               if (total_civilians <= 1)
-               {
-                       if (total_murderers <= 1)
-                       {
-                               total_murderers++;
-                               it.mmm_status = MMM_STATUS_MURDERER;
-                       }
-               }
-               else if (total_civilians == 2)
-               {
-                       if (total_detectives >= 1)
-                               break;
-                       else
-                       {
-                               total_detectives++;
-                               it.mmm_status = MMM_STATUS_DETECTIVE;
-                       }
-               }
-               else if (total_civilians == 5)
-               {
-                       if (total_murderers <= 2)
-                               break;
-                       else
-                       {
-                               total_murderers++;
-                               it.mmm_status = MMM_STATUS_MURDERER;
-                       }
-               }
-               else if (total_civilians == 6)
-               {
-                       if (total_detectives >= 2)
-                               break;
-                       else
-                       {
-                               total_detectives++;
-                               it.mmm_status = MMM_STATUS_DETECTIVE;
-                       }
-               }
-               else if (total_civilians == 7)
-               {
-                       if (total_detectives >= 3)
-                               break;
-                       else if (total_murderers == 3)
-                       {
-                               total_murderers++;
-                               it.mmm_status = MMM_STATUS_MURDERER;
-                       }
-                       else
-                       {
-                               total_detectives++;
-                               it.mmm_status = MMM_STATUS_DETECTIVE;
-                       }
-               }
-               else if (total_civilians >= 8)
-               {
-                       if (total_detectives >= 4)
-                               break;
-                       else if (total_murderers == 4)
-                       {
-                               total_murderers++;
-                               it.mmm_status = MMM_STATUS_MURDERER;
-                       }
-                       else
-                       {
-                               total_detectives++;
-                               it.mmm_status = MMM_STATUS_DETECTIVE;
-                       }
-               }
-               else
-               {
-                       total_murderers++; 
+               if (total_murderers < murderer_count) {
                        it.mmm_status = MMM_STATUS_MURDERER;
+                       total_murderers++;
+               } else if (total_detectives < detective_count) {
+                       it.mmm_status = MMM_STATUS_DETECTIVE;
+                       total_detectives++;
+               } else {
+                       it.mmm_status = MMM_STATUS_CIVILIAN;
+                       total_civilians++;
                }
        });
+       
+       //LOG_INFOF("Total players: %d || Murderers: %d, Detectives: %d, Civilians: %d", playercount, total_murderers, total_detectives, total_civilians);
 
        FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it),
        {