]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Player templates: Added random ammo.
authorLyberta <lyberta@lyberta.net>
Wed, 16 Aug 2017 00:13:38 +0000 (03:13 +0300)
committerLyberta <lyberta@lyberta.net>
Wed, 16 Aug 2017 00:13:38 +0000 (03:13 +0300)
qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qc
qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qh

index 11650ac5e9c569bc0aee5c8c9ef0c81b2ecb6440..403eff927ea6f25df60a78989e661168aa6bbc43 100644 (file)
@@ -47,6 +47,26 @@ string PlayerTemplate_GetDefaultCvarName(string variable)
                {
                        return "g_start_ammo_fuel";
                }
+               case "random_start_shells":
+               {
+                       return "g_pickup_shells_weapon";
+               }
+               case "random_start_bullets":
+               {
+                       return "g_pickup_nails_weapon";
+               }
+               case "random_start_rockets":
+               {
+                       return "g_pickup_rockets_weapon";
+               }
+               case "random_start_cells":
+               {
+                       return "g_pickup_cells_weapon";
+               }
+               case "random_start_plasma":
+               {
+                       return "g_pickup_plasma_weapon";
+               }
                case "health_regen_factor":
                {
                        return "g_balance_health_regen";
@@ -91,6 +111,11 @@ float PlayerTemplate_GetDefaultFloatValue(string variable)
                case "start_ammo_cells":
                case "start_ammo_plasma":
                case "start_ammo_fuel":
+               case "random_start_shells":
+               case "random_start_bullets":
+               case "random_start_rockets":
+               case "random_start_cells":
+               case "random_start_plasma":
                case "health_regen_factor":
                case "health_regen_linear":
                case "health_rot_factor":
@@ -183,7 +208,8 @@ string PlayerTemplate_GetStringValue(string template, string variable)
 }
 
 void PlayerTemplate_GiveRandomWeapons(entity player, int num_weapons,
-       string weapon_names)
+       string weapon_names, float shells, float bullets, float rockets,
+       float cells, float plasma)
 {
        if (num_weapons == 0)
        {
@@ -211,6 +237,54 @@ void PlayerTemplate_GiveRandomWeapons(entity player, int num_weapons,
                        return;
                }
                player.weapons |= RandomSelection_chosen_ent.m_wepset;
+               switch (RandomSelection_chosen_ent.ammo_field)
+               {
+                       case (ammo_shells):
+                       {
+                               if (player.ammo_shells != 0)
+                               {
+                                       break;
+                               }
+                               GivePlayerAmmo(player, ammo_shells, shells);
+                               break;
+                       }
+                       case (ammo_nails):
+                       {
+                               if (player.ammo_nails != 0)
+                               {
+                                       break;
+                               }
+                               GivePlayerAmmo(player, ammo_nails, bullets);
+                               break;
+                       }
+                       case (ammo_rockets):
+                       {
+                               if (player.ammo_rockets != 0)
+                               {
+                                       break;
+                               }
+                               GivePlayerAmmo(player, ammo_rockets, rockets);
+                               break;
+                       }
+                       case (ammo_cells):
+                       {
+                               if (player.ammo_cells != 0)
+                               {
+                                       break;
+                               }
+                               GivePlayerAmmo(player, ammo_cells, cells);
+                               break;
+                       }
+                       case (ammo_plasma):
+                       {
+                               if (player.ammo_plasma != 0)
+                               {
+                                       break;
+                               }
+                               GivePlayerAmmo(player, ammo_plasma, plasma);
+                               break;
+                       }
+               }
        }
 }
 
@@ -336,9 +410,14 @@ void PlayerTemplate_PlayerSpawn(entity player, string template)
        }
        if (!warmup_stage)
        {
-               GiveRandomWeapons(player, PlayerTemplate_GetFloatValue(template,
-               "num_random_start_weapons"), PlayerTemplate_GetStringValue(template,
-               "random_start_weapons"));
+               PlayerTemplate_GiveRandomWeapons(player,
+                       PlayerTemplate_GetFloatValue(template, "num_random_start_weapons"),
+                       PlayerTemplate_GetStringValue(template, "random_start_weapons"),
+                       PlayerTemplate_GetFloatValue(template, "random_start_shells"),
+                       PlayerTemplate_GetFloatValue(template, "random_start_bullets"),
+                       PlayerTemplate_GetFloatValue(template, "random_start_rockets"),
+                       PlayerTemplate_GetFloatValue(template, "random_start_cells"),
+                       PlayerTemplate_GetFloatValue(template, "random_start_plasma"));
                return;
        }
        // Give random weapons.
index a45b7d1644de750555fb8cb9c610e71aa62b7a8b..2ec2ebe6b48e3a2b4678612d8f2b0cf5a5a156bc 100644 (file)
@@ -40,12 +40,18 @@ float PlayerTemplate_GetFloatValue(string template, string variable);
 /// \return Value of the variable.
 string PlayerTemplate_GetStringValue(string template, string variable);
 
-/// \brief Give several random weapons to the player.
+/// \brief Give several random weapons and ammo to the player.
 /// \param[in,out] player Player to give weapons to.
 /// \param[in] num_weapons Number of weapons to give.
 /// \param[in] weapon_names Names of weapons to give separated by spaces.
+/// \param[in] shells Amount of shells to give with shell-based weapon.
+/// \param[in] bullets Amount of bullets to give with bullet-based weapon.
+/// \param[in] rockets Amount of rockets to give with rocket-based weapon.
+/// \param[in] cells Amount of cells to give with cell-based weapon.
+/// \param[in] cells Amount of plasma to give with plasma-based weapon.
 void PlayerTemplate_GiveRandomWeapons(entity player, int num_weapons,
-       string weapon_names);
+       string weapon_names, float shells, float bullets, float rockets,
+       float cells, float plasma);
 
 /// \brief Gives player items according to the given template's variable.
 /// \param[in] player Player to give items to.