]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix sleuth vs murderer when single battle happens, Karma warning notification added
authorLegendaryGuard <rootuser999@gmail.com>
Tue, 27 Apr 2021 20:09:34 +0000 (22:09 +0200)
committerLegendaryGuard <rootuser999@gmail.com>
Tue, 27 Apr 2021 20:09:34 +0000 (22:09 +0200)
qcsrc/common/gamemodes/gamemode/mmm/sv_mmm.qc
qcsrc/common/notifications/all.inc

index 7443b3000ca8914387428ba4c93476b6f79fa8b4..e822fbebeac51b6d55983a698bd5c2716babe010 100644 (file)
@@ -222,6 +222,17 @@ float mmm_CheckWinner()
        return 1;
 }
 
+void Karma_WarningCheck(entity it)
+{
+       float totalmeankarma = ((autocvar_g_mmm_max_karma_points + autocvar_g_mmm_min_karma_points + it.karmapoints) / 3);
+       if (it.karmapoints <= totalmeankarma)
+       {
+               Send_Notification(NOTIF_ONE_ONLY, it, MSG_INFO, INFO_MMM_KARMAWARNING);
+               //centerprint(it, strcat(BOLD_OPERATOR, "^1KARMA WARNING!\n^3Here, have the Rifle!"));
+               GiveWeapon(it, WEP_RIFLE.m_id, OP_PLUS, 1);
+       }
+}
+
 void mmm_RoundStart()
 {
        allowed_to_spawn = boolean(warmup_stage);
@@ -330,17 +341,12 @@ void mmm_RoundStart()
 
        FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it),
        {
-               float totalmeankarma = ((autocvar_g_mmm_max_karma_points + autocvar_g_mmm_min_karma_points + it.karmapoints) / 3);
                karma_Control(it);
                it.activekillerrole = false;
 
                if(it.mmm_status == MMM_STATUS_CIVILIAN)
                {
-                       if (it.karmapoints <= totalmeankarma)
-                       {
-                               centerprint(it, strcat(BOLD_OPERATOR, "^1KARMA WARNING!\n^3Here, have the Rifle!"));
-                               GiveWeapon(it, WEP_RIFLE.m_id, OP_PLUS, 1);
-                       }
+                       Karma_WarningCheck(it);
                        //Gives Mine Layer weapon to the player
                        GiveWeapon(it, WEP_MINE_LAYER.m_id, OP_PLUS, 1);
                        Send_Notification(NOTIF_ONE_ONLY, it, MSG_CENTER, CENTER_MMM_CIVILIAN);
@@ -349,11 +355,7 @@ void mmm_RoundStart()
                }
                else if(it.mmm_status == MMM_STATUS_MURDERER)
                {
-                       if (it.karmapoints <= totalmeankarma)
-                       {
-                               centerprint(it, strcat(BOLD_OPERATOR, "^1KARMA WARNING!\n^3Here, have the Rifle!"));
-                               GiveWeapon(it, WEP_RIFLE.m_id, OP_PLUS, 1);
-                       }
+                       Karma_WarningCheck(it);
                        //Gives Mine Layer weapon to the player
                        GiveWeapon(it, WEP_MINE_LAYER.m_id, OP_PLUS, 1);
                        Send_Notification(NOTIF_ONE_ONLY, it, MSG_CENTER, CENTER_MMM_MURDERER);
@@ -362,11 +364,7 @@ void mmm_RoundStart()
                }
                else if(it.mmm_status == MMM_STATUS_SLEUTH)
                {
-                       if (it.karmapoints <= totalmeankarma)
-                       {
-                               centerprint(it, strcat(BOLD_OPERATOR, "^1KARMA WARNING!\n^3Here, have the Rifle!"));
-                               GiveWeapon(it, WEP_RIFLE.m_id, OP_PLUS, 1);
-                       }
+                       Karma_WarningCheck(it);
                        //Gives Shockwave and Mine Layer weapon to the player
                        GiveWeapon(it, WEP_SHOCKWAVE.m_id, OP_PLUS, 1);
                        GiveWeapon(it, WEP_MINE_LAYER.m_id, OP_PLUS, 1);
@@ -674,7 +672,31 @@ MUTATOR_HOOKFUNCTION(mmm, Damage_Calculate)
 MUTATOR_HOOKFUNCTION(mmm, PlayerPreThink)
 {
        entity player = M_ARGV(0, entity);
-       
+       int playercount = 0;
+       bool playercheck = false;
+
+       if (playercheck != true)
+       {
+               FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it),
+               {
+                       ++playercount;
+               });
+               playercheck = true;
+       }
+
+       //if the murderer is still here around, then avoid illogical winning
+       if (playercheck == true)
+       {
+               FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it),
+               {
+                       if (playercount == 3)
+                       {
+                               if (it.mmm_status == MMM_STATUS_SLEUTH)
+                                       it.mmm_status = MMM_STATUS_CIVILIAN;
+                       }
+               });
+       }
+
        if(IS_PLAYER(player) || player.caplayer)
        {
                if (player.karmaspectated != true)
index 32273000d72b5400620570e1791ee610a1971fcd..9fe1d9cf49de51e20fc9f4a916baf365732a32f6 100644 (file)
@@ -452,6 +452,7 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input !=
     MSG_INFO_NOTIF(MMM_SLEUTH,                              N_CHATCON,  0, 0, "", "",           "",                     _("^BGYou are ^4Sleuth^BG!"), "")
     MSG_INFO_NOTIF(MMM_WHOISSLEUTH,                         N_CHATCON,  1, 0, "s1", "",         "",                     _("^BG%s is ^4Sleuth^BG!"), "")
     MSG_INFO_NOTIF(MMM_CORPSEDETECTION,                     N_CHATCON,  1, 0, "s1", "",         "",                     _("^BG%s"), "")
+    MSG_INFO_NOTIF(MMM_KARMAWARNING,                        N_CHATCON,  0, 0, "", "",           "",                     _("^K1KARMA WARNING! ^3Here, have the Rifle!"), "")
 
     MSG_INFO_NOTIF(VERSION_BETA,                            N_CONSOLE,  2, 0, "s1 s2", "",      "",                     _("^F4NOTE: ^BGThe server is running ^F1Xonotic %s (beta)^BG, you have ^F2Xonotic %s"), "")
     MSG_INFO_NOTIF(VERSION_OLD,                             N_CHATCON,  2, 0, "s1 s2", "",      "",                     _("^F4NOTE: ^BGThe server is running ^F1Xonotic %s^BG, you have ^F2Xonotic %s"), "")