From: Lyberta Date: Wed, 16 Aug 2017 00:16:25 +0000 (+0300) Subject: Merge branch 'master' into Lyberta/GivePlayerAmmo X-Git-Tag: xonotic-v0.8.5~2459^2~25 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=2183056a5b6e75d2e025aa6c718eeb6f87de31b6;hp=afb903877a0d219164d80c8b7b09662f84b978a8 Merge branch 'master' into Lyberta/GivePlayerAmmo --- diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index f5b3b2c19f..61bc7dc578 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -648,6 +648,69 @@ 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 GivePlayerAmmo(entity player, .float ammotype, float amount) +{ + float maxvalue = 999; + switch (ammotype) + { + case ammo_shells: + { + maxvalue = g_pickup_shells_max; + break; + } + case ammo_cells: + { + maxvalue = g_pickup_cells_max; + break; + } + case ammo_rockets: + { + maxvalue = g_pickup_rockets_max; + break; + } + case ammo_plasma: + { + maxvalue = g_pickup_plasma_max; + break; + } + case ammo_nails: + { + maxvalue = g_pickup_nails_max; + break; + } + case ammo_fuel: + { + maxvalue = g_pickup_fuel_max; + break; + } + } + player.(ammotype) = min(player.(ammotype) + amount, maxvalue); +} + float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode) { if (!item.(ammotype)) diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index e52604d994..331d3ac8c3 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -85,6 +85,26 @@ void Item_ScheduleRespawnIn(entity e, float t); void Item_ScheduleRespawn(entity e); void Item_ScheduleInitialRespawn(entity e); + +/// \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 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 GivePlayerAmmo(entity player, .float ammotype, float amount); + float ITEM_MODE_NONE = 0; float ITEM_MODE_HEALTH = 1; float ITEM_MODE_ARMOR = 2;