From: terencehill Date: Fri, 20 Mar 2020 19:16:24 +0000 (+0100) Subject: Implement #2393 "Oxygen bar" X-Git-Tag: xonotic-v0.8.5~1144^2~8^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b721a3ee61a4d3d2d894fe817fb1efdb551052b6;p=xonotic%2Fxonotic-data.pk3dir.git Implement #2393 "Oxygen bar" --- diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index 30e5a8bee..9bb1b84a6 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -21,6 +21,7 @@ seta hud_progressbar_shield_color "" "R G B vector of the progress bar backgroun seta hud_progressbar_health_color "" "R G B vector of the progress bar background color" seta hud_progressbar_armor_color "" "R G B vector of the progress bar background color" seta hud_progressbar_fuel_color "" "R G B vector of the progress bar background color" +seta hud_progressbar_oxygen_color "" "R G B vector of the progress bar background color" seta hud_progressbar_nexball_color "" "R G B vector of the progress bar background color" seta hud_progressbar_speed_color "" "R G B vector of the progress bar background color" seta hud_progressbar_acceleration_color "" "R G B vector of the progress bar background color" diff --git a/hud_luma.cfg b/hud_luma.cfg index 813ecbaef..84e73404d 100644 --- a/hud_luma.cfg +++ b/hud_luma.cfg @@ -22,6 +22,7 @@ seta hud_progressbar_shield_color "0.36 1 0.07" seta hud_progressbar_health_color "0.83 0.12 0" seta hud_progressbar_armor_color "0.28 0.8 0" seta hud_progressbar_fuel_color "0.77 0.67 0" +seta hud_progressbar_oxygen_color "0.1 1 1" seta hud_progressbar_nexball_color "0.2 0.65 0.93" seta hud_progressbar_speed_color "0.77 0.67 0" seta hud_progressbar_acceleration_color "0.2 0.65 0.93" diff --git a/hud_luminos.cfg b/hud_luminos.cfg index c5cfe4ac5..2b0d14a27 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -22,6 +22,7 @@ seta hud_progressbar_shield_color "0.6 0 0.6" seta hud_progressbar_health_color "0.6 0 0" seta hud_progressbar_armor_color "0 0.6 0" seta hud_progressbar_fuel_color "0.6 0.6 0" +seta hud_progressbar_oxygen_color "0 1 1" seta hud_progressbar_nexball_color "0.7 0.1 0" seta hud_progressbar_speed_color "1 0.75 0" seta hud_progressbar_acceleration_color "0.5 0.75 1" diff --git a/hud_luminos_minimal.cfg b/hud_luminos_minimal.cfg index b72825846..be4a87ae2 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -22,6 +22,7 @@ seta hud_progressbar_shield_color "0.6 0 0.6" seta hud_progressbar_health_color "0.6 0 0" seta hud_progressbar_armor_color "0 0.6 0" seta hud_progressbar_fuel_color "0.6 0.6 0" +seta hud_progressbar_oxygen_color "0 1 1" seta hud_progressbar_nexball_color "0.7 0.1 0" seta hud_progressbar_speed_color "1 0.75 0" seta hud_progressbar_acceleration_color "0.5 0.75 1" diff --git a/hud_luminos_minimal_xhair.cfg b/hud_luminos_minimal_xhair.cfg index 3bfd694b1..db0fc51c6 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -22,6 +22,7 @@ seta hud_progressbar_shield_color "0.6 0 0.6" seta hud_progressbar_health_color "0.6 0 0" seta hud_progressbar_armor_color "0 0.6 0" seta hud_progressbar_fuel_color "0.6 0.6 0" +seta hud_progressbar_oxygen_color "0 1 1" seta hud_progressbar_nexball_color "0.7 0.1 0" seta hud_progressbar_speed_color "1 0.75 0" seta hud_progressbar_acceleration_color "0.5 0.75 1" diff --git a/hud_luminos_old.cfg b/hud_luminos_old.cfg index c808f62fb..4baea4852 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -22,6 +22,7 @@ seta hud_progressbar_shield_color "0.6 0 0.6" seta hud_progressbar_health_color "0.6 0 0" seta hud_progressbar_armor_color "0 0.6 0" seta hud_progressbar_fuel_color "0.6 0.6 0" +seta hud_progressbar_oxygen_color "0 1 1" seta hud_progressbar_nexball_color "0.7 0.1 0" seta hud_progressbar_speed_color "1 0.75 0" seta hud_progressbar_acceleration_color "0.5 0.75 1" diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index b0b02d080..726620501 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -22,6 +22,7 @@ seta hud_progressbar_shield_color "0.6 0 0.6" seta hud_progressbar_health_color "0.6 0 0" seta hud_progressbar_armor_color "0 0.6 0" seta hud_progressbar_fuel_color "0.6 0.6 0" +seta hud_progressbar_oxygen_color "0 1 1" seta hud_progressbar_nexball_color "0.7 0.1 0" seta hud_progressbar_speed_color "1 0.75 0" seta hud_progressbar_acceleration_color "0.5 0.75 1" diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index f87b94e8e..6759c8078 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -363,6 +363,7 @@ vector autocvar_hud_progressbar_acceleration_neg_color; float autocvar_hud_progressbar_alpha; vector autocvar_hud_progressbar_armor_color; vector autocvar_hud_progressbar_fuel_color; +vector autocvar_hud_progressbar_oxygen_color = '0.1 1 1'; vector autocvar_hud_progressbar_health_color; vector autocvar_hud_progressbar_nexball_color; vector autocvar_hud_progressbar_shield_color; diff --git a/qcsrc/client/hud/hud_config.qc b/qcsrc/client/hud/hud_config.qc index a6c22c74e..27a33c408 100644 --- a/qcsrc/client/hud/hud_config.qc +++ b/qcsrc/client/hud/hud_config.qc @@ -45,6 +45,7 @@ void HUD_Panel_ExportCfg(string cfgname) HUD_Write_Cvar("hud_progressbar_health_color"); HUD_Write_Cvar("hud_progressbar_armor_color"); HUD_Write_Cvar("hud_progressbar_fuel_color"); + HUD_Write_Cvar("hud_progressbar_oxygen_color"); HUD_Write_Cvar("hud_progressbar_nexball_color"); HUD_Write_Cvar("hud_progressbar_speed_color"); HUD_Write_Cvar("hud_progressbar_acceleration_color"); diff --git a/qcsrc/client/hud/panel/healtharmor.qc b/qcsrc/client/hud/panel/healtharmor.qc index 1e124dd94..36e3a8d90 100644 --- a/qcsrc/client/hud/panel/healtharmor.qc +++ b/qcsrc/client/hud/panel/healtharmor.qc @@ -9,7 +9,7 @@ void HUD_HealthArmor() { - int armor, health, fuel; + int armor, health, fuel, air_time; if(!autocvar__hud_configure) { if((!autocvar_hud_panel_healtharmor) || (spectatee_status == -1)) @@ -52,12 +52,14 @@ void HUD_HealthArmor() prev_armor = 0; } fuel = STAT(FUEL); + air_time = bound(0, STAT(AIR_FINISHED) - time, 10); } else { health = 150; armor = 75; fuel = 20; + air_time = 6; } HUD_Panel_LoadCvars(); @@ -112,6 +114,8 @@ void HUD_HealthArmor() if(fuel) HUD_Panel_DrawProgressBar(pos, vec2(mySize.x, 0.2 * mySize.y), "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); + if(air_time) + HUD_Panel_DrawProgressBar(pos + eY * 0.8 * mySize.y, vec2(mySize.x, 0.2 * mySize.y), "progressbar", air_time / 10, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_oxygen_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); } else { @@ -135,13 +139,13 @@ void HUD_HealthArmor() armor_offset.y = mySize.y; } - bool health_baralign, armor_baralign, fuel_baralign; + bool health_baralign, armor_baralign, fuel_baralign, air_align; bool health_iconalign, armor_iconalign; if (autocvar_hud_panel_healtharmor_flip) { armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1); health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1); - fuel_baralign = health_baralign; + air_align = fuel_baralign = health_baralign; armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1); health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1); } @@ -149,7 +153,7 @@ void HUD_HealthArmor() { health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1); armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1); - fuel_baralign = armor_baralign; + air_align = fuel_baralign = armor_baralign; health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1); armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1); } @@ -256,7 +260,8 @@ void HUD_HealthArmor() DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1); } - if(fuel) + vector cell_size = mySize; + if (fuel || air_time) { if (is_vertical) mySize.x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits @@ -266,7 +271,20 @@ void HUD_HealthArmor() mySize.x *= 2; //restore full panel size else if (panel_ar < 1/4) mySize.y *= 2; //restore full panel size - HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); + if (fuel) + HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); + if (air_time) + { + if (panel_ar > 1 && panel_ar < 4) + pos.y += cell_size.y; + else if (panel_ar > 1/4 && panel_ar <= 1) + pos.x += cell_size.x; + if (is_vertical) + pos.x += cell_size.x - mySize.x; + else + pos.y += cell_size.y - mySize.y; + HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", air_time / 10, is_vertical, air_align, autocvar_hud_progressbar_oxygen_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); + } } } diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index ed37073fb..612e5b6cd 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -92,6 +92,7 @@ REGISTER_STAT(HIT_TIME, float) REGISTER_STAT(DAMAGE_DEALT_TOTAL, int) REGISTER_STAT(TYPEHIT_TIME, float) REGISTER_STAT(SUPERWEAPONS_FINISHED, float) +REGISTER_STAT(AIR_FINISHED, float) REGISTER_STAT(VEHICLESTAT_HEALTH, int) REGISTER_STAT(VEHICLESTAT_SHIELD, int) REGISTER_STAT(VEHICLESTAT_ENERGY, int) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 70b0e4ed0..120f4c92b 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -2617,6 +2617,7 @@ void DrownPlayer(entity this) if(this.air_finished < time) PlayerSound(this, playersound_gasp, CH_PLAYER, VOL_BASE, VOICETYPE_PLAYERSOUND); this.air_finished = time + autocvar_g_balance_contents_drowndelay; + this.air_finished_stat = 0; } else if (this.air_finished < time) { // drown! @@ -2625,7 +2626,10 @@ void DrownPlayer(entity this) Damage (this, NULL, NULL, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN.m_id, DMG_NOWEP, this.origin, '0 0 0'); this.pain_finished = time + 0.5; } + this.air_finished_stat = this.air_finished; } + else + this.air_finished_stat = this.air_finished; } .bool move_qcphysics; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 29621f61d..9036ee222 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -51,6 +51,7 @@ float server_is_dedicated; .float crouch; // Crouching or not? const .float superweapons_finished = _STAT(SUPERWEAPONS_FINISHED); +const .float air_finished_stat = _STAT(AIR_FINISHED); .float cnt; // used in too many places .float count;