if(frag_target != frag_attacker)
if(!IS_DEAD(frag_target))
{
- frag_attacker.health += bound(0, damage_take, frag_target.health);
- frag_attacker.health = bound(0, frag_attacker.health, autocvar_g_balance_health_limit);
+ GivePlayerHealth(frag_attacker, bound(0, damage_take, frag_target.health));
}
}
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;
+ }
+ // Ugly hack. We do not check if health goes beyond hard limit since
+ // currently it is done in player_regen. We need to bring back this check
+ // when other code is ported to this function.
+ player.health = bound(player.health, player.health + amount,
+ autocvar_g_balance_health_limit);
+ // Correct code:
+ //player.health = bound(player.health, player.health + amount,
+ // min(autocvar_g_balance_health_limit, ITEM_COUNT_HARD_LIMIT));
+ player.pauserothealth_finished = max(player.pauserothealth_finished, time +
+ autocvar_g_balance_pause_health_rot);
+}
+
+void GivePlayerArmor(entity player, float amount)
+{
+ if (amount == 0)
+ {
+ return;
+ }
+ // Ugly hack. We do not check if armor goes beyond hard limit since
+ // currently it is done in player_regen. We need to bring back this check
+ // when other code is ported to this function.
+ player.armorvalue = bound(player.armorvalue, player.armorvalue + amount,
+ autocvar_g_balance_armor_limit);
+ // Correct code:
+ //player.armorvalue = bound(player.armorvalue, player.armorvalue + amount,
+ // min(autocvar_g_balance_armor_limit, ITEM_COUNT_HARD_LIMIT));
+ player.pauserotarmor_finished = max(player.pauserotarmor_finished, time +
+ autocvar_g_balance_pause_armor_rot);
+}
+
+void GivePlayerAmmo(entity player, .float ammotype, float amount)
+{
+ if (amount == 0)
+ {
+ return;
+ }
+ float maxvalue = ITEM_COUNT_HARD_LIMIT;
+ 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;
+ }
+ }
+ player.(ammotype) = min(player.(ammotype) + amount,
+ min(maxvalue, ITEM_COUNT_HARD_LIMIT));
+}
+
+void GivePlayerFuel(entity player, float amount)
+{
+ if (amount == 0)
+ {
+ return;
+ }
+ player.ammo_fuel = bound(player.ammo_fuel, player.ammo_fuel + amount,
+ min(g_pickup_fuel_max, ITEM_COUNT_HARD_LIMIT));
+ player.pauserotfuel_finished = max(player.pauserotfuel_finished, time +
+ autocvar_g_balance_pause_fuel_rot);
+}
+
float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode)
{
if (!item.(ammotype))
#include <server/defs.qh>
#endif
+/// \brief Unconditional maximum amount of items the player can have.
+const int ITEM_COUNT_HARD_LIMIT = 999;
+
const int AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel
// item networking
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);
+
+/// \brief Gives fuel to the player.
+/// \param[in,out] player Player to give fuel to.
+/// \param[in] amount Amount of fuel to give.
+/// \return No return.
+void GivePlayerFuel(entity player, float amount);
+
float ITEM_MODE_NONE = 0;
float ITEM_MODE_HEALTH = 1;
float ITEM_MODE_ARMOR = 2;
regen_health_stable = M_ARGV(9, float);
regen_health_rotstable = M_ARGV(10, float);
-
if(!mutator_returnvalue)
if(!STAT(FROZEN, this))
{
this.ammo_fuel = CalcRotRegen(this.ammo_fuel, minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear, frametime * (time > this.pauseregen_finished) * ((this.items & ITEM_JetpackRegen.m_itemid) != 0), maxf, autocvar_g_balance_fuel_rot, autocvar_g_balance_fuel_rotlinear, frametime * (time > this.pauserotfuel_finished), limitf);
}
+ // Ugly hack to make sure the haelth and armor don't go beyond hard limit.
+ // TODO: Remove this hack when all code uses GivePlayerHealth and
+ // GivePlayerArmor.
+ if (this.health > ITEM_COUNT_HARD_LIMIT)
+ {
+ this.health = ITEM_COUNT_HARD_LIMIT;
+ }
+ if (this.armorvalue > ITEM_COUNT_HARD_LIMIT)
+ {
+ this.armorvalue = ITEM_COUNT_HARD_LIMIT;
+ }
+ // End hack.
}
bool zoomstate_set;