Only only players can get random weapons.
authorLyberta <lyberta@lyberta.net>
Mon, 28 Aug 2017 06:11:53 +0000 (09:11 +0300)
committerLyberta <lyberta@lyberta.net>
Mon, 28 Aug 2017 06:11:53 +0000 (09:11 +0300)
qcsrc/common/t_items.qc
qcsrc/common/t_items.qh
qcsrc/server/client.qc

index e3a2c8b..9055a09 100644 (file)
@@ -825,9 +825,8 @@ void GiveResourceViaProperty(entity receiver, .float resource_property,
        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)
+void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names,
+       float shells, float bullets, float rockets, float cells, float plasma)
 {
        if (num_weapons == 0)
        {
@@ -843,7 +842,7 @@ void GivePlayerRandomWeapons(entity player, int num_weapons,
                        FOREACH(Weapons, it != WEP_Null,
                        {
                                // Finding a weapon which player doesn't have.
-                               if (!(player.weapons & it.m_wepset) && (it.netname == weapon))
+                               if (!(receiver.weapons & it.m_wepset) && (it.netname == weapon))
                                {
                                        RandomSelection_AddEnt(it, 1, 1);
                                        break;
@@ -854,52 +853,52 @@ void GivePlayerRandomWeapons(entity player, int num_weapons,
                {
                        return;
                }
-               player.weapons |= RandomSelection_chosen_ent.m_wepset;
+               receiver.weapons |= RandomSelection_chosen_ent.m_wepset;
                switch (RandomSelection_chosen_ent.ammo_field)
                {
                        case (ammo_shells):
                        {
-                               if (player.ammo_shells != 0)
+                               if (receiver.ammo_shells != 0)
                                {
                                        break;
                                }
-                               GivePlayerResource(player, RESOURCE_SHELLS, shells);
+                               GiveResource(receiver, RESOURCE_SHELLS, shells);
                                break;
                        }
                        case (ammo_nails):
                        {
-                               if (player.ammo_nails != 0)
+                               if (receiver.ammo_nails != 0)
                                {
                                        break;
                                }
-                               GivePlayerResource(player, RESOURCE_BULLETS, bullets);
+                               GiveResource(receiver, RESOURCE_BULLETS, bullets);
                                break;
                        }
                        case (ammo_rockets):
                        {
-                               if (player.ammo_rockets != 0)
+                               if (receiver.ammo_rockets != 0)
                                {
                                        break;
                                }
-                               GivePlayerResource(player, RESOURCE_ROCKETS, rockets);
+                               GiveResource(receiver, RESOURCE_ROCKETS, rockets);
                                break;
                        }
                        case (ammo_cells):
                        {
-                               if (player.ammo_cells != 0)
+                               if (receiver.ammo_cells != 0)
                                {
                                        break;
                                }
-                               GivePlayerResource(player, RESOURCE_CELLS, cells);
+                               GiveResource(receiver, RESOURCE_CELLS, cells);
                                break;
                        }
                        case (ammo_plasma):
                        {
-                               if (player.ammo_plasma != 0)
+                               if (receiver.ammo_plasma != 0)
                                {
                                        break;
                                }
-                               GivePlayerResource(player, RESOURCE_PLASMA, plasma);
+                               GiveResource(receiver, RESOURCE_PLASMA, plasma);
                                break;
                        }
                }
index bdc63a7..99fa078 100644 (file)
@@ -131,19 +131,18 @@ void GiveResource(entity receiver, int resource_type, float amount);
 void GiveResourceViaProperty(entity receiver, .float resource_property,
        float amount);
 
-/// \brief Give several random weapons and ammo to the player.
-/// \param[in,out] player Player to give weapons to.
+/// \brief Give several random weapons and ammo to the entity.
+/// \param[in,out] receiver Entity 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.
+/// \param[in] plasma 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);
+void GiveRandomWeapons(entity receiver, 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);
 
index 1e2eeb7..d6445e1 100644 (file)
@@ -544,7 +544,7 @@ void PutPlayerInServer(entity this)
                this.health = start_health;
                this.armorvalue = start_armorvalue;
                this.weapons = start_weapons;
-               GivePlayerRandomWeapons(this, random_start_weapons_count,
+               GiveRandomWeapons(this, random_start_weapons_count,
                        cvar_string("g_random_start_weapons"), random_start_shells,
                        random_start_bullets, random_start_rockets, random_start_cells,
                        random_start_plasma);