From 2ba99a7f8f7c7618856f9ccefec17f72e40117ff Mon Sep 17 00:00:00 2001 From: Lyberta Date: Mon, 28 Aug 2017 09:11:53 +0300 Subject: [PATCH] Only only players can get random weapons. --- qcsrc/common/t_items.qc | 29 ++++++++++++++--------------- qcsrc/common/t_items.qh | 11 +++++------ qcsrc/server/client.qc | 2 +- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index e3a2c8be4..9055a09a1 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -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; } } diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index bdc63a7cc..99fa07832 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -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); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 1e2eeb7ea..d6445e12b 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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); -- 2.39.2