]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
custom max values for the health/armor status bars
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 3dd61ff8a70fddcd5d8f315095e89d0c8b13a628..cfcb369d7560bc75ac870bd762d89055e16c1b9b 100644 (file)
@@ -1692,18 +1692,10 @@ void HUD_Weapons(void)
        }
 
        float show_accuracy;
-       float weapon_stats, weapon_number;
+       float weapon_stats;
        if(cvar("hud_panel_weapons_accuracy") && acc_levels)
        {
                show_accuracy = true;
-               // hits
-               weapon_stats = getstati(STAT_DAMAGE_HITS);
-               weapon_number = weapon_stats & 63;
-               weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
-               // fired
-               weapon_stats = getstati(STAT_DAMAGE_FIRED);
-               weapon_number = weapon_stats & 63;
-               weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
                if (acc_col_x[0] == -1)
                        for (i = 0; i < acc_levels; ++i)
                                acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
@@ -1726,13 +1718,9 @@ void HUD_Weapons(void)
                // draw the weapon accuracy
                if(show_accuracy)
                {
-                       float weapon_hit, weapon_damage;
-                       weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
-                       if(weapon_damage)
+                       weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
+                       if(weapon_stats >= 0)
                        {
-                               weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
-                               weapon_stats = floor(100 * weapon_hit / weapon_damage);
-
                                // find the max level lower than weapon_stats
                                float j;
                                j = acc_levels-1;
@@ -2332,6 +2320,9 @@ void HUD_HealthArmor(void)
        float baralign = cvar("hud_panel_healtharmor_baralign");
        float iconalign = cvar("hud_panel_healtharmor_iconalign");
        float progressbar = cvar("hud_panel_healtharmor_progressbar");
+
+    float maxhealth = cvar("hud_panel_healtharmor_maxhealth");
+    float maxarmor = cvar("hud_panel_healtharmor_maxarmor");
        if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
        {
                vector v;
@@ -2340,12 +2331,14 @@ void HUD_HealthArmor(void)
                float x;
                x = floor(v_x + 1);
 
+        float maxtotal = maxhealth + maxarmor;
+
                if(baralign == 1 || baralign == 3) { // right align
-                       barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
-                       barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
+                       barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/maxtotal);
+                       barsize = eX * mySize_x * min(1, x/maxtotal) + eY * mySize_y;
                } else { // left align
                        barpos = pos;
-                       barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
+                       barsize = eX * mySize_x * min(1, x/maxtotal) + eY * mySize_y;
                }
 
                string biggercount;
@@ -2371,7 +2364,7 @@ void HUD_HealthArmor(void)
                        if(health)
                                drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                }
-               DrawNumIcon(iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
+               DrawNumIcon(iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, maxtotal), 1);
 
                // fuel
                if(fuel)
@@ -2391,6 +2384,7 @@ void HUD_HealthArmor(void)
        {
                string leftname, rightname;
                float leftcnt, rightcnt;
+               float leftmax, rightmax;
                float leftactive, rightactive;
                float leftalpha, rightalpha;
                float flip = cvar("hud_panel_healtharmor_flip");
@@ -2400,22 +2394,26 @@ void HUD_HealthArmor(void)
                        if(leftcnt)
                                leftactive = 1;
                        leftalpha = min((armor+10)/55, 1);
+            leftmax = maxarmor;
 
                        rightname = "health";
                        rightcnt = health;
                        rightactive = 1;
                        rightalpha = 1;
+            rightmax = maxhealth;
                } else {
                        leftname = "health";
                        leftcnt = health;
                        leftactive = 1;
                        leftalpha = 1;
+            leftmax = maxhealth;
 
                        rightname = "armor";
                        rightcnt = armor;
                        if(rightcnt)
                                rightactive = 1;
                        rightalpha = min((armor+10)/55, 1);
+            rightmax = maxarmor;
                }
 
                if (mySize_x/mySize_y > 4)
@@ -2423,11 +2421,11 @@ void HUD_HealthArmor(void)
                        if(leftactive)
                        {
                                if(baralign == 1 || baralign == 3) { // right align
-                                       barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
-                                       barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
+                                       barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/leftmax);
+                                       barsize = eX * 0.5 * mySize_x * min(1, leftcnt/leftmax) + eY * mySize_y;
                                } else { // left align
                                        barpos = pos;
-                                       barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
+                                       barsize = eX * 0.5 * mySize_x * min(1, leftcnt/leftmax) + eY * mySize_y;
                                }
 
                                if(progressbar)
@@ -2435,17 +2433,17 @@ void HUD_HealthArmor(void)
                                        HUD_Panel_GetProgressBarColorForString(leftname);
                                        HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
-                               DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
+                               DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, leftmax), 1);
                        }
 
                        if(rightactive)
                        {
                                if(baralign == 0 || baralign == 3) { // left align
                                        barpos = pos + eX * 0.5 * mySize_x;
-                                       barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
+                                       barsize = eX * 0.5 * mySize_x * min(1, rightcnt/rightmax) + eY * mySize_y;
                                } else { // right align
-                                       barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
-                                       barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
+                                       barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/rightmax);
+                                       barsize = eX * 0.5 * mySize_x * min(1, rightcnt/rightmax) + eY * mySize_y;
                                }
 
                                if(progressbar)
@@ -2453,7 +2451,7 @@ void HUD_HealthArmor(void)
                                        HUD_Panel_GetProgressBarColorForString(rightname);
                                        HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
-                               DrawNumIcon(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
+                               DrawNumIcon(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, rightmax), 1);
                        }
 
                        if(fuel)
@@ -2474,11 +2472,11 @@ void HUD_HealthArmor(void)
                        if(leftactive)
                        {
                                if(baralign == 1 || baralign == 3) { // right align
-                                       barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
-                                       barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
+                                       barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/leftmax);
+                                       barsize = eX * mySize_x * min(1, leftcnt/leftmax) + eY * 0.5 * mySize_y;
                                } else { // left align
                                        barpos = pos;
-                                       barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
+                                       barsize = eX * mySize_x * min(1, leftcnt/leftmax) + eY * 0.5 * mySize_y;
                                }
 
                                if(progressbar)
@@ -2486,17 +2484,17 @@ void HUD_HealthArmor(void)
                                        HUD_Panel_GetProgressBarColorForString(leftname);
                                        HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
-                               DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
+                               DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, leftmax), 1);
                        }
 
                        if(rightactive)
                        {
                                if(baralign == 0 || baralign == 3) { // left align
                                        barpos = pos + eY * 0.5 * mySize_y;
-                                       barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
+                                       barsize = eX * mySize_x * min(1, rightcnt/rightmax) + eY * 0.5 * mySize_y;
                                } else { // right align
-                                       barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
-                                       barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
+                                       barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/rightmax) + eY * 0.5 * mySize_y;
+                                       barsize = eX * mySize_x * min(1, rightcnt/rightmax) + eY * 0.5 * mySize_y;
                                }
 
                                if(progressbar)
@@ -2504,7 +2502,7 @@ void HUD_HealthArmor(void)
                                        HUD_Panel_GetProgressBarColorForString(rightname);
                                        HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
-                               DrawNumIcon(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
+                               DrawNumIcon(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, rightmax), 1);
                        }
 
                        if(fuel)
@@ -2525,11 +2523,11 @@ void HUD_HealthArmor(void)
                        if(leftactive)
                        {
                                if(baralign == 1 || baralign == 3) { // down align
-                                       barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
-                                       barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
+                                       barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/leftmax);
+                                       barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/leftmax);
                                } else { // up align
                                        barpos = pos;
-                                       barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
+                                       barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/leftmax);
                                }
 
                                if(iconalign == 1 || iconalign == 3) { // down align
@@ -2546,17 +2544,17 @@ void HUD_HealthArmor(void)
                                        HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
                                drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, leftmax), panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
 
                        if(rightactive)
                        {
                                if(baralign == 0 || baralign == 3) { // up align
                                        barpos = pos + eX * 0.5 * mySize_x;
-                                       barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
+                                       barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/rightmax);
                                } else { // down align
-                                       barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
-                                       barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
+                                       barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/rightmax) + eX * 0.5 * mySize_x;
+                                       barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/rightmax);
                                }
 
                                if(iconalign == 0 || iconalign == 3) { // up align
@@ -2573,7 +2571,7 @@ void HUD_HealthArmor(void)
                                        HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
                                drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, rightmax), panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
 
                        if(fuel)
@@ -2688,7 +2686,11 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
        } else if(msg == MSG_KILL) {
                w = DEATH_WEAPONOF(type);
                if(WEP_VALID(w)) {
-                       HUD_KillNotify_Push(s1, s2, 1, type);
+                       if((w == WEP_CAMPINGRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
+                               HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
+                       else
+                               HUD_KillNotify_Push(s1, s2, 1, type);
+
                        if (alsoprint)
                                print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
                }
@@ -3144,22 +3146,20 @@ void HUD_Notify (void)
                if (j == KN_MAX_ENTRIES)
                        j = 0;
 
-               if(fadetime)
+               if(killnotify_times[j] + when > time)
+                       a = 1;
+               else if(fadetime)
                {
-                       if(killnotify_times[j] + when > time)
-                               a = 1;
-                       else
-                               a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
+                       a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
+                       if(!a)
+                       {
+                               break;
+                       }
                }
                else
                {
-                       if(killnotify_times[j] + when > time)
-                               a = 1;
-                       else
-                               a = 0;
+                       break;
                }
-               if(!a)
-                       continue;
 
                s = "";
 
@@ -3325,6 +3325,10 @@ void HUD_Notify (void)
                        {
                                s = "notify_void";
                        }
+                       else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
+                       {
+                               s = "notify_headshot";
+                       }
                        else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
                        {
                                s = "race_newrecordserver";
@@ -3958,11 +3962,17 @@ void HUD_VoteWindow(void)
        }
 
        // draw the progress bars
-       drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
-       drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+       if(vote_yescount && vote_needed)
+       {
+               drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
+               drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+       }
 
-       drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
-       drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+       if(vote_nocount && vote_needed)
+       {
+               drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
+               drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+       }
 
        drawresetcliparea();