From 5f6ecc47ec22671de1057d70652b935bb7ddebe7 Mon Sep 17 00:00:00 2001 From: Lyberta Date: Thu, 13 Apr 2017 08:27:17 +0300 Subject: [PATCH] Changed GivePlayerAmmo. --- qcsrc/common/t_items.qc | 33 ++++++++++++--------------------- qcsrc/common/t_items.qh | 27 +++++---------------------- 2 files changed, 17 insertions(+), 43 deletions(-) diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index ec237c7d63..642c29d29a 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -665,28 +665,19 @@ void GivePlayerArmor(entity player, float amount) autocvar_g_balance_pause_armor_rot); } -void GivePlayerShells(entity player, float amount) +void GivePlayerAmmo(entity player, .float ammotype, float amount) { - player.ammo_shells = bound(player.ammo_shells, player.ammo_shells + amount, - g_pickup_shells_max); -} - -void GivePlayerBullets(entity player, float amount) -{ - player.ammo_nails = bound(player.ammo_nails, player.ammo_nails + amount, - g_pickup_nails_max); -} - -void GivePlayerRockets(entity player, float amount) -{ - player.ammo_rockets = bound(player.ammo_rockets, player.ammo_rockets + - amount, g_pickup_rockets_max); -} - -void GivePlayerCells(entity player, float amount) -{ - player.ammo_cells = bound(player.ammo_cells, player.ammo_cells + amount, - g_pickup_cells_max); + float maxvalue = 999; + switch(ammotype) + { + case ammo_shells: maxvalue = g_pickup_shells_max; + case ammo_cells: maxvalue = g_pickup_cells_max; + case ammo_rockets: maxvalue = g_pickup_rockets_max; + case ammo_plasma: maxvalue = g_pickup_plasma_max; + case ammo_nails: maxvalue = g_pickup_nails_max; + case ammo_fuel: maxvalue = g_pickup_fuel_max; + } + player.(ammotype) = min(player.(ammotype) + amount, maxvalue); } float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode) diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index 6ce04b830c..17e3af939f 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -94,29 +94,12 @@ void GivePlayerHealth(entity player, float amount); /// \return No return. void GivePlayerArmor(entity player, float amount); -/// \brief Gives shells to the player. -/// \param[in,out] player Player to give shells to. -/// \param[in] amount Amount of shells to give. +/// \brief Gives ammo of the specified type to the player. +/// \param[in,out] player Player to give ammo to. +/// \param[in] type Ammo type property. +/// \param[in] amount Amount of ammo to give. /// \return No return. -void GivePlayerShells(entity player, float amount); - -/// \brief Gives bullets to the player. -/// \param[in,out] player Player to give bullets to. -/// \param[in] amount Amount of bullets to give. -/// \return No return. -void GivePlayerBullets(entity player, float amount); - -/// \brief Gives rockets to the player. -/// \param[in,out] player Player to give rockets to. -/// \param[in] amount Amount of rockets to give. -/// \return No return. -void GivePlayerRockets(entity player, float amount); - -/// \brief Gives cells to the player. -/// \param[in,out] player Player to give cells to. -/// \param[in] amount Amount of cells to give. -/// \return No return. -void GivePlayerCells(entity player, float amount); +void GivePlayerAmmo(entity player, .float ammotype, float amount); float ITEM_MODE_NONE = 0; float ITEM_MODE_HEALTH = 1; -- 2.39.2