]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Survival: Correct handling of new toys.
authorLyberta <lyberta@lyberta.net>
Fri, 24 Mar 2017 09:42:12 +0000 (12:42 +0300)
committerLyberta <lyberta@lyberta.net>
Fri, 24 Mar 2017 09:42:12 +0000 (12:42 +0300)
qcsrc/server/mutators/mutator/gamemode_survival.qc

index 848b4caa98139d76bc26440bb9b7b5f09c404553..bdd0ccb588ea49936a17354500c27ebd85652e30 100644 (file)
@@ -513,26 +513,28 @@ void Surv_RemovePlayerFromTeam(entity player, int teamnum)
                        {
                                --surv_numattackerhumans;
                        }
-                       if (surv_autobalance && (surv_numattackers < surv_numdefenders))
+                       if ((surv_autobalance == false) || (surv_numattackers >=
+                               surv_numdefenders))
                        {
-                               // Add bot to keep teams balanced.
-                               FOREACH_CLIENT(true,
+                               return;
+                       }
+                       // Add bot to keep teams balanced.
+                       FOREACH_CLIENT(true,
+                       {
+                               if (it.surv_role == SURVIVAL_ROLE_CANNON_FODDER)
                                {
-                                       if (it.surv_role == SURVIVAL_ROLE_CANNON_FODDER)
+                                       LOG_TRACE("Changing ", it.netname,
+                                               " from cannon fodder to attacker.");
+                                       Surv_SetPlayerRole(it, SURVIVAL_ROLE_PLAYER);
+                                       Surv_ChangeNumberOfPlayers(teamnum, +1);
+                                       if (!IS_DEAD(it))
                                        {
-                                               LOG_TRACE("Changing ", it.netname,
-                                                       " from cannon fodder to attacker.");
-                                               Surv_SetPlayerRole(it, SURVIVAL_ROLE_PLAYER);
-                                               Surv_ChangeNumberOfPlayers(teamnum, +1);
-                                               if (!IS_DEAD(it))
-                                               {
-                                                       Surv_ChangeNumberOfAlivePlayers(teamnum, +1);
-                                               }
-                                               return;
+                                               Surv_ChangeNumberOfAlivePlayers(teamnum, +1);
                                        }
-                               });
-                       }
-                       break;
+                                       return;
+                               }
+                       });
+                       return;
                }
                case surv_defenderteam:
                {
@@ -557,26 +559,28 @@ void Surv_RemovePlayerFromTeam(entity player, int teamnum)
                        {
                                --surv_numdefenderhumans;
                        }
-                       if (surv_autobalance && (surv_numdefenders < surv_numattackers))
+                       if ((surv_autobalance == false) || (surv_numdefenders >=
+                               surv_numattackers))
                        {
-                               // Add bot to keep teams balanced.
-                               FOREACH_CLIENT(true,
-                               {
-                                       if (it.surv_role == SURVIVAL_ROLE_CANNON_FODDER)
-                                       {
-                                               LOG_TRACE("Changing ", it.netname,
-                                                       " from cannon fodder to defender.");
-                                               SetPlayerTeamSimple(it, surv_defenderteam);                                             
-                                               return;
-                                       }
-                               });
+                               return;
                        }
-                       break;
+                       // Add bot to keep teams balanced.
+                       FOREACH_CLIENT(true,
+                       {
+                               if (it.surv_role == SURVIVAL_ROLE_CANNON_FODDER)
+                               {
+                                       LOG_TRACE("Changing ", it.netname,
+                                               " from cannon fodder to defender.");
+                                       SetPlayerTeamSimple(it, surv_defenderteam);                                             
+                                       return;
+                               }
+                       });
+                       return;
                }
                default:
                {
                        LOG_TRACE("Invalid team");
-                       break;
+                       return;
                }
        }
 }
@@ -1723,6 +1727,41 @@ MUTATOR_HOOKFUNCTION(surv, ItemTouch)
                                                ATTEN_NORM);
                                        return MUT_ITEMTOUCH_RETURN;
                                }
+                               case "replacedweapon":
+                               {
+                                       switch (item.weapon)
+                                       {
+                                               case WEP_SHOTGUN.m_id:
+                                               {
+                                                       Surv_GivePlayerShells(player, cvar(
+                                                               "g_pickup_shells_weapon"));
+                                                       break;
+                                               }
+                                               case WEP_RIFLE.m_id:
+                                               {
+                                                       Surv_GivePlayerBullets(player, cvar(
+                                                               "g_pickup_nails_weapon"));
+                                                       break;
+                                               }
+                                               case WEP_MINE_LAYER.m_id:
+                                               case WEP_SEEKER.m_id:
+                                               {
+                                                       Surv_GivePlayerRockets(player, cvar(
+                                                               "g_pickup_rockets_weapon"));
+                                                       break;
+                                               }
+                                               case WEP_HLAC.m_id:
+                                               {
+                                                       Surv_GivePlayerCells(player, cvar(
+                                                               "g_pickup_cells_weapon"));
+                                                       break;
+                                               }
+                                       }
+                                       Item_ScheduleRespawn(item);
+                                       sound(player, CH_TRIGGER, SND_WEAPONPICKUP, VOL_BASE,
+                                               ATTEN_NORM);
+                                       return MUT_ITEMTOUCH_RETURN;
+                               }
                                case "weapon_machinegun":
                                case "weapon_uzi":
                                {