]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Implement #2393 "Oxygen bar"
authorterencehill <piuntn@gmail.com>
Fri, 20 Mar 2020 19:16:24 +0000 (20:16 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 20 Mar 2020 19:24:26 +0000 (20:24 +0100)
13 files changed:
_hud_descriptions.cfg
hud_luma.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud/hud_config.qc
qcsrc/client/hud/panel/healtharmor.qc
qcsrc/common/stats.qh
qcsrc/server/client.qc
qcsrc/server/defs.qh

index 30e5a8bee9a8756fe9fafe883306260e1e4025aa..9bb1b84a620f61cc2672d4d85a52817d384b21a1 100644 (file)
@@ -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"
index 813ecbaef0df64396789d8115bce2c758deaec4d..84e73404d078d1daef56af39b2bbb46661081975 100644 (file)
@@ -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"
index c5cfe4ac548fdc62e070ac1cda9ed08d4a9c3524..2b0d14a2735052c1d61a690b9a72963dc460a947 100644 (file)
@@ -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"
index b7282584637aba28087bec61f8c071f5ac97df68..be4a87ae29967cb03d7ed11664abb48f161617a4 100644 (file)
@@ -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"
index 3bfd694b19cf2f0977c36c437ed7ee5c8220d5f9..db0fc51c6e18bbd47eb8d8ccab963150668b1cdd 100644 (file)
@@ -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"
index c808f62fb5b10ca9f430153f3260821fc0280ff9..4baea48523d4579afcd2cd94f39afb06f14ceefe 100644 (file)
@@ -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"
index b0b02d080c6e6517407ca8706a8315bca9160f46..726620501f0635cca1e0384257bac0bf274069dd 100644 (file)
@@ -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"
index f87b94e8e37fc132f02d81be3d33075c1ac6e9a9..6759c80782484fbd786c0e1e6b070231541ea88b 100644 (file)
@@ -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;
index a6c22c74eee9bf113f4d71570b90ec57f7a33938..27a33c408b50de484b40dbbd9722b47972756e4e 100644 (file)
@@ -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");
index 1e124dd94243fa63af52906cd410d927933d83f8..36e3a8d907656a3ef28489cc324c9e303b70ec7e 100644 (file)
@@ -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);
+                       }
                }
        }
 
index ed37073fbeec0867b2b54e587204ca693ecb7126..612e5b6cde29b84add48892088141f3a636544d3 100644 (file)
@@ -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)
index 70b0e4ed0430a3acd776c5a5c706ffc1436136af..120f4c92b3368705ecf246bc58d1d3297209fdfc 100644 (file)
@@ -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;
index 29621f61d83ff80fc73163281d1a9bd0c33da6f8..9036ee22219f46aa4baf8724c5d2faee709a818a 100644 (file)
@@ -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;