]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 e3a2c8be439a5bcb5d3bc5dd3341856cbc0a2e74..9055a09a1359b87e23e84c0a3922dbef08719039 100644 (file)
@@ -825,9 +825,8 @@ void GiveResourceViaProperty(entity receiver, .float resource_property,
        GiveResource(receiver, GetResourceType(resource_property), 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)
+void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names,
+       float shells, float bullets, float rockets, float cells, float plasma)
 {
        if (num_weapons == 0)
        {
 {
        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.
                        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;
                                {
                                        RandomSelection_AddEnt(it, 1, 1);
                                        break;
@@ -854,52 +853,52 @@ void GivePlayerRandomWeapons(entity player, int num_weapons,
                {
                        return;
                }
                {
                        return;
                }
-               player.weapons |= RandomSelection_chosen_ent.m_wepset;
+               receiver.weapons |= RandomSelection_chosen_ent.m_wepset;
                switch (RandomSelection_chosen_ent.ammo_field)
                {
                        case (ammo_shells):
                        {
                switch (RandomSelection_chosen_ent.ammo_field)
                {
                        case (ammo_shells):
                        {
-                               if (player.ammo_shells != 0)
+                               if (receiver.ammo_shells != 0)
                                {
                                        break;
                                }
                                {
                                        break;
                                }
-                               GivePlayerResource(player, RESOURCE_SHELLS, shells);
+                               GiveResource(receiver, RESOURCE_SHELLS, shells);
                                break;
                        }
                        case (ammo_nails):
                        {
                                break;
                        }
                        case (ammo_nails):
                        {
-                               if (player.ammo_nails != 0)
+                               if (receiver.ammo_nails != 0)
                                {
                                        break;
                                }
                                {
                                        break;
                                }
-                               GivePlayerResource(player, RESOURCE_BULLETS, bullets);
+                               GiveResource(receiver, RESOURCE_BULLETS, bullets);
                                break;
                        }
                        case (ammo_rockets):
                        {
                                break;
                        }
                        case (ammo_rockets):
                        {
-                               if (player.ammo_rockets != 0)
+                               if (receiver.ammo_rockets != 0)
                                {
                                        break;
                                }
                                {
                                        break;
                                }
-                               GivePlayerResource(player, RESOURCE_ROCKETS, rockets);
+                               GiveResource(receiver, RESOURCE_ROCKETS, rockets);
                                break;
                        }
                        case (ammo_cells):
                        {
                                break;
                        }
                        case (ammo_cells):
                        {
-                               if (player.ammo_cells != 0)
+                               if (receiver.ammo_cells != 0)
                                {
                                        break;
                                }
                                {
                                        break;
                                }
-                               GivePlayerResource(player, RESOURCE_CELLS, cells);
+                               GiveResource(receiver, RESOURCE_CELLS, cells);
                                break;
                        }
                        case (ammo_plasma):
                        {
                                break;
                        }
                        case (ammo_plasma):
                        {
-                               if (player.ammo_plasma != 0)
+                               if (receiver.ammo_plasma != 0)
                                {
                                        break;
                                }
                                {
                                        break;
                                }
-                               GivePlayerResource(player, RESOURCE_PLASMA, plasma);
+                               GiveResource(receiver, RESOURCE_PLASMA, plasma);
                                break;
                        }
                }
                                break;
                        }
                }
index bdc63a7ccda5e2e5fcb8f97aa30102132141679f..99fa0783205b2cccbbaa2cc62ebd9b6d7b166298 100644 (file)
@@ -131,19 +131,18 @@ void GiveResource(entity receiver, int resource_type, float amount);
 void GiveResourceViaProperty(entity receiver, .float resource_property,
        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] 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.
 /// \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);
 
 
 float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax);
 
index 1e2eeb7ea59c20265558a7779e086bc45abb2463..d6445e12b6264b1bc1c5dc73f2e0a1728b65d9a8 100644 (file)
@@ -544,7 +544,7 @@ void PutPlayerInServer(entity this)
                this.health = start_health;
                this.armorvalue = start_armorvalue;
                this.weapons = start_weapons;
                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);
                        cvar_string("g_random_start_weapons"), random_start_shells,
                        random_start_bullets, random_start_rockets, random_start_cells,
                        random_start_plasma);