]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add 2 nice effects to health and armor progressbars when spawning and when being...
authorterencehill <terencehill@gmail.com>
Sun, 26 Dec 2010 23:57:33 +0000 (00:57 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 30 Dec 2010 19:18:59 +0000 (20:18 +0100)
defaultXonotic.cfg
qcsrc/client/Defs.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc

index de61fd32787a255f8f0aa105fd6c815bbc23e974..126efc41e5aacfe73d5d97c29e2cb2cfd4aa576f 100644 (file)
@@ -1400,6 +1400,7 @@ seta hud_panel_ammo_maxammo "40" "when you have this much ammo, the ammo status
 
 seta hud_panel_healtharmor_maxhealth "250" "when you have this much health, the health status bar is full"
 seta hud_panel_healtharmor_maxarmor "150" "when you have this much armor, the armor status bar is full"
+seta hud_panel_healtharmor_progressbar_gfx 1 "add graphic effects to the progressbars when spawning and when being damaged"
 
 seta hud_panel_notify_time 10 "time that a new entry stays until it fades out"
 seta hud_panel_notify_fadetime 3 "fade out time"
index 88f0a51b0673e17f6984e4b27bf673ad0b5f3a5b..48442b7561e3287575c362bc031cac6ddaf99082 100644 (file)
@@ -221,6 +221,7 @@ float nb_pb_period;
 
 // Spectating
 float spectatee_status;
+float prev_spectatee_status;
 
 // short mapname
 string shortmapname;
index 121488d57d1225313c23a92601e27a15bf89b4fb..6f2bb6e025b3270abade4b3b3f2b77b1559f799b 100644 (file)
@@ -1078,6 +1078,8 @@ void CSQC_UpdateView(float w, float h)
                cvar_set("vid_conheight", h0);
        }
 
+       prev_spectatee_status = spectatee_status;
+
        if(autocvar__hud_configure)
                HUD_Panel_Mouse();
 
index 64b6e33fa0bb91502aba5c7657bb48f4d8911a67..5002a2e3356ae4f03e1cc53acc5a674a4a241b99 100644 (file)
@@ -177,6 +177,7 @@ float autocvar_hud_panel_healtharmor_maxhealth;
 float autocvar_hud_panel_healtharmor_progressbar;
 string autocvar_hud_panel_healtharmor_progressbar_armor;
 string autocvar_hud_panel_healtharmor_progressbar_health;
+string autocvar_hud_panel_healtharmor_progressbar_gfx;
 float autocvar_hud_panel_healtharmor_text;
 float autocvar_hud_panel_infomessages;
 float autocvar_hud_panel_infomessages_flip;
index 72c387b1b27ee6a5dddd72fe72695b565fff148d..14cf376c75d0aa924756f6f6d7996b191dae47fc 100644 (file)
@@ -1266,6 +1266,10 @@ void HUD_Powerups(void)
 
 // Health/armor (#3)
 //
+float health_time, prev_health;
+float armor_time, prev_armor;
+var float saved_health = -2;
+var float saved_armor = -2;
 void HUD_HealthArmor(void)
 {
        float armor, health, fuel;
@@ -1276,7 +1280,36 @@ void HUD_HealthArmor(void)
 
                health = getstati(STAT_HEALTH);
                if(health <= 0)
+               {
+                       health_time = -1;
                        return;
+               }
+               if (autocvar_hud_panel_healtharmor_progressbar_gfx)
+               {
+                       if ( (prev_spectatee_status == -1 && spectatee_status > 0) //before observing, now spectating
+                         || (prev_spectatee_status > 0 && spectatee_status > 0 && prev_spectatee_status != spectatee_status) //changed spectated player
+                       )
+                       {
+                               //no effect
+                               saved_health = 0;
+                               saved_armor = 0;
+                               health_time = 0;
+                               armor_time = 0;
+                       }
+                       else if(prev_spectatee_status == -1 || (prev_spectatee_status > 0 && !spectatee_status)) //before spectating/observing, now playing
+                               health_time = -1;
+
+                       if (health_time == -1)
+                       {
+                               //start the load effect
+                               saved_health = -2;
+                               saved_armor = -2;
+                               health_time = time;
+                               armor_time = time;
+                               prev_health = 0;
+                               prev_armor = 0;
+                       }
+               }
                armor = getstati(STAT_ARMOR);
                fuel = getstati(STAT_FUEL);
        }
@@ -1395,7 +1428,38 @@ void HUD_HealthArmor(void)
                        if(autocvar_hud_panel_healtharmor_progressbar)
                        {
                                HUD_Panel_GetProgressBarColor(health);
-                               HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               float p_health;
+                               p_health = health;
+                               if (autocvar_hud_panel_healtharmor_progressbar_gfx)
+                               {
+                                       if (saved_health == -1)
+                                       {
+                                               if (prev_health == 0 || prev_health - health >= 3)
+                                               {
+                                                       health_time = time;
+                                                       saved_health = prev_health;
+                                               }
+                                       }
+                                       if (saved_health != -1)
+                                       {
+                                               float d = time - health_time;
+                                               if (d < 1)
+                                               {
+                                                       if (saved_health == -2)
+                                                               p_health *= sqrt(d);
+                                                       else
+                                                       {
+                                                               HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, saved_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * (1 - d * d), DRAWFLAG_NORMAL);
+                                                               if (prev_health - health >= 1) //refresh the effect if repeatedly damaged
+                                                                       health_time = time;
+                                                       }
+                                               }
+                                               else
+                                                       saved_health = -1; //damage effect ended
+                                       }
+                                       prev_health = health;
+                               }
+                               HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        if(autocvar_hud_panel_healtharmor_text)
                                DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
@@ -1406,7 +1470,38 @@ void HUD_HealthArmor(void)
                        if(autocvar_hud_panel_healtharmor_progressbar)
                        {
                                HUD_Panel_GetProgressBarColor(armor);
-                               HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               float p_armor;
+                               p_armor = armor;
+                               if (autocvar_hud_panel_healtharmor_progressbar_gfx)
+                               {
+                                       if (saved_armor == -1)
+                                       {
+                                               if (prev_armor == 0 || prev_armor - armor >= 3)
+                                               {
+                                                       armor_time = time;
+                                                       saved_armor = prev_armor;
+                                               }
+                                       }
+                                       if (saved_armor != -1)
+                                       {
+                                               float d = time - armor_time;
+                                               if (d < 1)
+                                               {
+                                                       if (saved_armor == -2)
+                                                               p_armor *= sqrt(d);
+                                                       else
+                                                       {
+                                                               HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, saved_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * (1 - d * d), DRAWFLAG_NORMAL);
+                                                               if (prev_armor - armor >= 1) //refresh the effect if repeatedly damaged
+                                                                       armor_time = time;
+                                                       }
+                                               }
+                                               else
+                                                       saved_armor = -1; //damage effect ended
+                                       }
+                                       prev_armor = armor;
+                               }
+                               HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, p_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        if(autocvar_hud_panel_healtharmor_text)
                                DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);