X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ft_items.qc;h=61bc7dc5785a945f1729e63d1bff192ff3e38eab;hb=2183056a5b6e75d2e025aa6c718eeb6f87de31b6;hp=e674eff42827fcef768132e9fa4c45693d7d354f;hpb=22f5546e0106c82601b8e92281cd34ec9d864423;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index e674eff42..61bc7dc57 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)) @@ -702,7 +765,7 @@ float Item_GiveTo(entity item, entity player) // if the player is using their best weapon before items are given, they // probably want to switch to an even better weapon after items are given - if(player.autoswitch) + if(CS(player).autoswitch) { for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { @@ -1730,7 +1793,7 @@ float GiveItems(entity e, float beginarg, float endarg) int _switchweapon = 0; - if(e.autoswitch) + if(CS(e).autoswitch) { for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) {