From 57fb12f6c6ee880927e84d21eaf54a0eda8c33f1 Mon Sep 17 00:00:00 2001 From: Lyberta Date: Wed, 12 Apr 2017 08:35:00 +0300 Subject: [PATCH] Added GivePlayerHealth and GivePlayerArmor. --- qcsrc/common/t_items.qc | 24 ++++++++++++++++++++++++ qcsrc/common/t_items.qh | 20 ++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 3298e7fb0..ec237c7d6 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -641,6 +641,30 @@ void Item_ScheduleInitialRespawn(entity e) Item_ScheduleRespawnIn(e, max(0, game_starttime - time) + ((e.respawntimestart) ? e.respawntimestart : ITEM_RESPAWNTIME_INITIAL(e))); } +void GivePlayerHealth(entity player, float amount) +{ + if (amount == 0) + { + return; + } + player.health = bound(player.health, player.health + amount, + g_pickup_healthmega_max); + player.pauserothealth_finished = max(player.pauserothealth_finished, time + + autocvar_g_balance_pause_health_rot); +} + +void GivePlayerArmor(entity player, float amount) +{ + if (amount == 0) + { + return; + } + player.armorvalue = bound(player.armorvalue, player.armorvalue + amount, + g_pickup_armormega_max); + player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + + autocvar_g_balance_pause_armor_rot); +} + void GivePlayerShells(entity player, float amount) { player.ammo_shells = bound(player.ammo_shells, player.ammo_shells + amount, diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index ca03b8a04..6ce04b830 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -82,25 +82,37 @@ void Item_ScheduleRespawn(entity e); void Item_ScheduleInitialRespawn(entity e); -/// \brief Gives player shells. +/// \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 shells to the player. /// \param[in,out] player Player to give shells to. /// \param[in] amount Amount of shells to give. /// \return No return. void GivePlayerShells(entity player, float amount); -/// \brief Gives player bullets. +/// \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 player rockets. +/// \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 player cells. +/// \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. -- 2.39.2