return health;
}
-float GetResourceLimit(int resource_type)
+float GetResourceLimit(entity player, int resource_type)
{
float limit;
switch (resource_type)
return 0;
}
}
- MUTATOR_CALLHOOK(GetResourceLimit, resource_type, limit);
- limit = M_ARGV(1, float);
+ MUTATOR_CALLHOOK(GetResourceLimit, player, resource_type, limit);
+ limit = M_ARGV(2, float);
if (limit > RESOURCE_AMOUNT_HARD_LIMIT)
{
limit = RESOURCE_AMOUNT_HARD_LIMIT;
resource_type = M_ARGV(1, int);
amount = M_ARGV(2, float);
.float resource_property = GetResourceProperty(resource_type);
- float max_amount = GetResourceLimit(resource_type);
+ float max_amount = GetResourceLimit(player, resource_type);
player.(resource_property) = bound(player.(resource_property),
player.(resource_property) + amount, max_amount);
switch (resource_type)
.float GetResourceProperty(int resource_type);
/// \brief Returns the maximum amount of the given resource.
+/// \param[in] player Player to check.
/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
/// \return Maximum amount of the given resource.
-float GetResourceLimit(int resource_type);
+float GetResourceLimit(entity player, int resource_type);
/// \brief Gives player a resource such as health, armor or ammo.
/// \param[in,out] player Player to give resource to.
float mina, maxa, limith, limita;
maxa = autocvar_g_balance_armor_rotstable;
mina = autocvar_g_balance_armor_regenstable;
- limith = GetResourceLimit(RESOURCE_HEALTH);
- limita = GetResourceLimit(RESOURCE_ARMOR);
+ limith = GetResourceLimit(this, RESOURCE_HEALTH);
+ limita = GetResourceLimit(this, RESOURCE_ARMOR);
regen_health_rotstable = regen_health_rotstable * max_mod;
regen_health_stable = regen_health_stable * max_mod;
maxf = autocvar_g_balance_fuel_rotstable;
minf = autocvar_g_balance_fuel_regenstable;
- limitf = GetResourceLimit(RESOURCE_FUEL);
+ limitf = GetResourceLimit(this, RESOURCE_FUEL);
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);
}
/** Called when the amount of player resources changes. Can be used to override
resource limit. */
#define EV_GetResourceLimit(i, o) \
- /** resource type */ i(int, MUTATOR_ARGV_0_int) \
- /** limit */ i(float, MUTATOR_ARGV_1_float) \
- /**/ o(float, MUTATOR_ARGV_1_float) \
+ /** player */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** resource type */ i(int, MUTATOR_ARGV_1_int) \
+ /** limit */ i(float, MUTATOR_ARGV_2_float) \
+ /**/ o(float, MUTATOR_ARGV_2_float) \
/**/
MUTATOR_HOOKABLE(GetResourceLimit, EV_GetResourceLimit);