From: terencehill Date: Sat, 5 Dec 2020 09:09:49 +0000 (+0100) Subject: Show full oxygen bar with a low alpha, fade it in until oxygen reaches the middle... X-Git-Tag: xonotic-v0.8.5~642^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=54d0f3f276d0f00eae8eb77ac0f34db28b8945b7;p=xonotic%2Fxonotic-data.pk3dir.git Show full oxygen bar with a low alpha, fade it in until oxygen reaches the middle of the bar --- diff --git a/_hud_common.cfg b/_hud_common.cfg index f2be854d5..0b2893224 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -83,6 +83,7 @@ seta hud_panel_ammo_hide_ondeath 0 "hide this panel when dead" seta hud_panel_powerups_hide_ondeath 0 "hide this panel when dead" +seta hud_panel_healtharmor_oxygenbar_startalpha "0.2" "start alpha of the oxygen bar" seta hud_panel_healtharmor_maxhealth "200" "when you have this much health, the health status bar is full" seta hud_panel_healtharmor_maxarmor "200" "when you have this much armor, the armor status bar is full" seta hud_panel_healtharmor_progressbar_gfx_damage 5 "show damage effect when damaged at least by this amount; 0 disables the effect" diff --git a/qcsrc/client/hud/panel/healtharmor.qc b/qcsrc/client/hud/panel/healtharmor.qc index 993bf091d..7e6e33339 100644 --- a/qcsrc/client/hud/panel/healtharmor.qc +++ b/qcsrc/client/hud/panel/healtharmor.qc @@ -94,12 +94,21 @@ void HUD_HealthArmor() mySize -= '2 2 0' * panel_bg_padding; } - float air_alpha = 1; - if (STAT(AIR_FINISHED) && time > STAT(AIR_FINISHED)) + float air_alpha; + if (!STAT(AIR_FINISHED)) + air_alpha = 0; + else if (time > STAT(AIR_FINISHED)) { air_alpha = blink_synced(0.5, 0.5, 7, STAT(AIR_FINISHED), -1); air_time = 10; } + else + { + float fade_time = 10 / 2; + float start_alpha = autocvar_hud_panel_healtharmor_oxygenbar_startalpha; + float f = (STAT(AIR_FINISHED) - time - fade_time) / fade_time; + air_alpha = bound(0, start_alpha + (1 - start_alpha) * (1 - f), 1); + } int baralign = autocvar_hud_panel_healtharmor_baralign; int iconalign = autocvar_hud_panel_healtharmor_iconalign; diff --git a/qcsrc/client/hud/panel/healtharmor.qh b/qcsrc/client/hud/panel/healtharmor.qh index 7bd7b8893..538d18780 100644 --- a/qcsrc/client/hud/panel/healtharmor.qh +++ b/qcsrc/client/hud/panel/healtharmor.qh @@ -10,6 +10,7 @@ bool autocvar_hud_panel_healtharmor_hide_ondeath = false; int autocvar_hud_panel_healtharmor_iconalign; int autocvar_hud_panel_healtharmor_maxarmor; int autocvar_hud_panel_healtharmor_maxhealth; +float autocvar_hud_panel_healtharmor_oxygenbar_startalpha = 0.2; bool autocvar_hud_panel_healtharmor_progressbar; string autocvar_hud_panel_healtharmor_progressbar_armor; string autocvar_hud_panel_healtharmor_progressbar_health;