BUILD_MOD ?=
ifndef ZIP
- ifneq ($(shell which zip),)
+ ifneq ($(shell which zip 2>/dev/null),)
ZIP := zip -9
endif
- ifneq ($(shell which 7z),)
+ ifneq ($(shell which 7z 2>/dev/null),)
ZIP := 7z a -tzip -mx=9
endif
- ifneq ($(shell which 7za),)
+ ifneq ($(shell which 7za 2>/dev/null),)
ZIP := 7za a -tzip -mx=9
endif
ifndef ZIP
- $(warning "No zip in ($(PATH))")
+ $(warning "No zip / 7z / 7za in ($(PATH))")
ZIP := : zip_not_found
endif
endif
float nb_pb_period;
// Spectating
+// -1 - observing
+// 0 - playing
+// >0 - id of spectated player
float spectatee_status;
// short mapname
if(frag_target.takedamage)
if(DIFF_TEAM(frag_attacker, frag_target))
{
- float hp = GetResourceAmount(frag_attacker, RESOURCE_HEALTH);
- SetResourceAmount(frag_attacker, RESOURCE_HEALTH, bound(0, hp + bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal, GetResourceAmount(frag_target, RESOURCE_HEALTH)), g_pickup_healthsmall_max));
- if(frag_target.armorvalue)
- frag_attacker.armorvalue = bound(0, frag_attacker.armorvalue + bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal, frag_target.armorvalue), g_pickup_armorsmall_max);
+ float amount = bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal,
+ GetResourceAmount(frag_target, RESOURCE_HEALTH));
+ GiveResourceWithLimit(frag_attacker, RESOURCE_HEALTH, amount, g_pickup_healthsmall_max);
+ if (frag_target.armorvalue)
+ {
+ amount = bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal,
+ GetResourceAmount(frag_target, RESOURCE_ARMOR));
+ GiveResourceWithLimit(frag_attacker, RESOURCE_ARMOR, amount, g_pickup_armorsmall_max);
+ }
}
M_ARGV(4, float) = frag_damage;
}
}
make_impure(NEW(DamageText, server_entity_index, entcs.origin, false, health, armor, potential_damage, deathtype, friendlyfire));
- } else if (autocvar_cl_damagetext_2d) {
+ } else if (autocvar_cl_damagetext_2d && spectatee_status != -1) {
+ // never show 2d damagetext when observing
+ // on some maps (hearth_v2, The_Yard), sometimes has_origin is false even though observers should know about all players
+ // it happens mostly with bots but occasionally also with players
+
// screen coords only
vector screen_pos = vec2(vid_conwidth * autocvar_cl_damagetext_2d_pos.x, vid_conheight * autocvar_cl_damagetext_2d_pos.y);
IL_EACH(g_drawables_2d, it.instanceOfDamageText && it.m_screen_coords && it.m_group == server_entity_index, {
float hp = GetResourceAmount(toucher, RESOURCE_HEALTH);
if (hp < maxhealth)
{
- if ( this.nade_show_particles )
+ if (this.nade_show_particles)
+ {
Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
- SetResourceAmount(toucher, RESOURCE_HEALTH, min(hp + health_factor, maxhealth));
+ }
+ GiveResourceWithLimit(toucher, RESOURCE_HEALTH, health_factor, maxhealth);
}
- toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
}
else if ( health_factor < 0 )
{
{
return false;
}
- if ((player_amount + amount) > ammomax)
- {
- amount = ammomax - player_amount;
- }
- GiveResource(player, resource_type, amount);
+ GiveResourceWithLimit(player, resource_type, amount, ammomax);
return true;
}
if (g_weapon_stay != 2)
{
return false;
}
- float mi = min(amount, ammomax);
- if (player_amount < mi)
- {
- GiveResource(player, resource_type, mi - player_amount);
- }
+ GiveResourceWithLimit(player, resource_type, amount, min(amount, ammomax));
return true;
}
}
}
+void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
+ float limit)
+{
+ if (amount == 0)
+ {
+ return;
+ }
+ float current_amount = GetResourceAmount(receiver, resource_type);
+ if (current_amount + amount > limit)
+ {
+ amount = limit - current_amount;
+ }
+ GiveResource(receiver, resource_type, amount);
+}
+
int GetResourceType(.float resource_field)
{
switch (resource_field)
/// \return No return.
void GiveResource(entity receiver, int resource_type, float amount);
+/// \brief Gives an entity some resource but not more than a limit.
+/// \param[in,out] receiver Entity to give resource to.
+/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] amount Amount of resource to give.
+/// \param[in] limit Limit of resources to give.
+/// \return No return.
+void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
+ float limit);
+
// ===================== Legacy and/or internal API ===========================
/// \brief Converts an entity field to resource type.