SERVER: Instant health regeneration when above threshold, slower below. Longer regen delay times

This commit is contained in:
Steam Deck User 2023-03-10 12:20:43 -05:00
parent 6284935b81
commit 41cd921c5f
4 changed files with 31 additions and 8 deletions

View file

@ -1191,7 +1191,7 @@ void() Draw_Crosshair =
drawfill([(g_width/2 + g_height/2),0,0], [g_width, g_height, 0], '0 0 0', 1, 0);
}
if (getstatf(STAT_HEALTH) < 11)
if (getstatf(STAT_HEALTH) < 1)
return;
if (crosshair_spread_time > time && crosshair_spread_time)
@ -1529,7 +1529,7 @@ void(float width, float height) HUD_Draw =
HUD_Achievements(width, height);
if (!getstatf(STAT_SPECTATING) && (getstatf(STAT_HEALTH) > 10) && !score_show)
if (!getstatf(STAT_SPECTATING) && (getstatf(STAT_HEALTH) > 1) && !score_show)
{
if (vmodel.model == GetWeaponModel(getstatf(STAT_ACTIVEWEAPON), FALSE) && vmodel.model != "" || getstatf(STAT_WEAPONZOOM) == 2)

View file

@ -4,7 +4,7 @@
used for any sort of down, hit, etc that the player or entity
experiences
Copyright (C) 2021 NZ:P Team
Copyright (C) 2021-2023 NZ:P Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -480,11 +480,23 @@ void(entity victim,entity attacker, float damage, float d_style) DamageHandler =
// Abstinence Program
victim.ach_tracker_abst = 1;
victim.health = victim.health - damage;
victim.health_delay = time + 2;
victim.health -= damage;
// Determine how long to wait before regenerating based on our Health ratio
float ratio = victim.health / victim.max_health;
// Badly hurt = longer delay.
if (ratio <= 0.2) {
victim.health_delay = time + 5;
// We're really low, so let's regen REALLY slow.
victim.health_was_very_low = true;
} else {
victim.health_delay = time + 2.4;
}
// shake the camera on impact
local vector distance;
vector distance;
distance = attacker.angles - victim.angles;
// just to prevent radical punchangles

View file

@ -152,6 +152,7 @@ void Weapon_Logic();
.float reload_delay2;
.float switch_delay;
.float health_delay;
.float health_was_very_low;
.float progress_bar;
.float progress_bar_time;
.float progress_bar_percent;

View file

@ -380,11 +380,21 @@ void() PlayerPostThink =
#endif // FTE
// Health Regeneration
if (self.health_delay < time && self.health != self.max_health && !self.downed)
{
self.health = self.health + 5;
if (self.max_health < self.health)
// If we weren't super low on health, regen is instant.
if (self.health_was_very_low == true) {
self.health += 120 * frametime;
} else {
self.health = self.max_health;
}
// Make sure we mark that we weren't just super hurt anymore.
if (self.max_health <= self.health) {
self.health = self.max_health;
self.health_was_very_low = false;
}
}
if (self.progress_bar) {