Merged Lyberta/URS2 into Lyberta/RandomStartWeapons.
authorLyberta <lyberta@lyberta.net>
Mon, 28 Aug 2017 06:06:45 +0000 (09:06 +0300)
committerLyberta <lyberta@lyberta.net>
Mon, 28 Aug 2017 06:06:45 +0000 (09:06 +0300)
1  2 
qcsrc/common/t_items.qc
qcsrc/common/t_items.qh
qcsrc/server/client.qc

@@@ -817,108 -819,12 +819,93 @@@ void GiveResource(entity receiver, int 
        }
  }
  
- void GivePlayerResourceViaProperty(entity player, .float resource_property,
+ void GiveResourceViaProperty(entity receiver, .float resource_property,
        float amount)
  {
-       GivePlayerResource(player, GetResourceType(resource_property), amount);
- }
- void GivePlayerHealth(entity player, float amount)
- {
-       GivePlayerResource(player, RESOURCE_HEALTH, amount);
- }
- void GivePlayerArmor(entity player, float amount)
- {
-       GivePlayerResource(player, RESOURCE_ARMOR, amount);
- }
- void GivePlayerFuel(entity player, float amount)
- {
-       GivePlayerResource(player, RESOURCE_FUEL, amount);
+       GiveResource(receiver, GetResourceType(resource_property), amount);
  }
  
 +void GivePlayerRandomWeapons(entity player, int num_weapons,
 +      string weapon_names, float shells, float bullets, float rockets,
 +      float cells, float plasma)
 +{
 +      if (num_weapons == 0)
 +      {
 +              return;
 +      }
 +      int num_potential_weapons = tokenize_console(weapon_names);
 +      for (int i = 0; i < num_weapons; ++i)
 +      {
 +              RandomSelection_Init();
 +              for (int j = 0; j < num_potential_weapons; ++j)
 +              {
 +                      string weapon = argv(j);
 +                      FOREACH(Weapons, it != WEP_Null,
 +                      {
 +                              // Finding a weapon which player doesn't have.
 +                              if (!(player.weapons & it.m_wepset) && (it.netname == weapon))
 +                              {
 +                                      RandomSelection_AddEnt(it, 1, 1);
 +                                      break;
 +                              }
 +                      });
 +              }
 +              if (RandomSelection_chosen_ent == NULL)
 +              {
 +                      return;
 +              }
 +              player.weapons |= RandomSelection_chosen_ent.m_wepset;
 +              switch (RandomSelection_chosen_ent.ammo_field)
 +              {
 +                      case (ammo_shells):
 +                      {
 +                              if (player.ammo_shells != 0)
 +                              {
 +                                      break;
 +                              }
 +                              GivePlayerResource(player, RESOURCE_SHELLS, shells);
 +                              break;
 +                      }
 +                      case (ammo_nails):
 +                      {
 +                              if (player.ammo_nails != 0)
 +                              {
 +                                      break;
 +                              }
 +                              GivePlayerResource(player, RESOURCE_BULLETS, bullets);
 +                              break;
 +                      }
 +                      case (ammo_rockets):
 +                      {
 +                              if (player.ammo_rockets != 0)
 +                              {
 +                                      break;
 +                              }
 +                              GivePlayerResource(player, RESOURCE_ROCKETS, rockets);
 +                              break;
 +                      }
 +                      case (ammo_cells):
 +                      {
 +                              if (player.ammo_cells != 0)
 +                              {
 +                                      break;
 +                              }
 +                              GivePlayerResource(player, RESOURCE_CELLS, cells);
 +                              break;
 +                      }
 +                      case (ammo_plasma):
 +                      {
 +                              if (player.ammo_plasma != 0)
 +                              {
 +                                      break;
 +                              }
 +                              GivePlayerResource(player, RESOURCE_PLASMA, plasma);
 +                              break;
 +                      }
 +              }
 +      }
 +}
 +
  float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax)
  {
        if (!item.(ammotype))
@@@ -127,41 -128,9 +128,23 @@@ void GiveResource(entity receiver, int 
  /// \param[in] resource_property Entity property of the resource.
  /// \param[in] amount Amount of resource to give.
  /// \return No return.
- void GivePlayerResourceViaProperty(entity player, .float resource_property,
+ void GiveResourceViaProperty(entity receiver, .float resource_property,
        float amount);
  
- /// \brief Gives health to the player.
- /// \param[in,out] player Player to give health to.
- /// \param[in] amount Amount of health to give.
- /// \return No return.
- void GivePlayerHealth(entity player, float amount);
- /// \brief Gives armor to the player.
- /// \param[in,out] player Player to give armor to.
- /// \param[in] amount Amount of armor to give.
- /// \return No return.
- void GivePlayerArmor(entity player, float amount);
- /// \brief Gives fuel to the player.
- /// \param[in,out] player Player to give fuel to.
- /// \param[in] amount Amount of fuel to give.
- /// \return No return.
- void GivePlayerFuel(entity player, float amount);
 +/// \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.
 +/// \return No return.
 +void GivePlayerRandomWeapons(entity player, int num_weapons,
 +      string weapon_names, float shells, float bullets, float rockets,
 +      float cells, float plasma);
 +
  float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax);
  
  float Item_GiveTo(entity item, entity player);
Simple merge