]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge branch 'master' into fruitiex/gamemode_freezetag
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 2d7d8732b269468156b4470e0934756af371a779..93d435924454a9812bf348349f3e512916182d83 100644 (file)
@@ -1706,7 +1706,7 @@ void HUD_Weapons(void)
                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("hud_panel_weapons_accuracy_color", ftos(i))));
+                               acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
        }
 
        float weapons_st = getstati(STAT_WEAPONS);
@@ -2610,34 +2610,27 @@ string Weapon_KillMessage(float deathtype)
        return w_deathtypestring;
 }
 
-float killnotify_times[10];
-float killnotify_deathtype[10];
-float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
-string killnotify_attackers[10];
-string killnotify_victims[10];
+#define KN_MAX_ENTRIES 10
+float kn_index;
+float killnotify_times[KN_MAX_ENTRIES];
+float killnotify_deathtype[KN_MAX_ENTRIES];
+float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
+string killnotify_attackers[KN_MAX_ENTRIES];
+string killnotify_victims[KN_MAX_ENTRIES];
 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
 {
-       float i;
-       for (i = 9; i > 0; --i) {
-               killnotify_times[i] = killnotify_times[i-1];
-               killnotify_deathtype[i] = killnotify_deathtype[i-1];
-               killnotify_actiontype[i] = killnotify_actiontype[i-1];
-               if(killnotify_attackers[i])
-                       strunzone(killnotify_attackers[i]);
-               killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
-               if(killnotify_victims[i])
-                       strunzone(killnotify_victims[i]);
-               killnotify_victims[i] = strzone(killnotify_victims[i-1]);
-       }
-       killnotify_times[0] = time;
-       killnotify_deathtype[0] = wpn;
-       killnotify_actiontype[0] = actiontype;
-       if(killnotify_attackers[0])
-               strunzone(killnotify_attackers[0]);
-       killnotify_attackers[0] = strzone(attacker);
-       if(killnotify_victims[0])
-               strunzone(killnotify_victims[0]);
-       killnotify_victims[0] = strzone(victim);
+       --kn_index;
+       if (kn_index == -1)
+               kn_index = KN_MAX_ENTRIES-1;
+       killnotify_times[kn_index] = time;
+       killnotify_deathtype[kn_index] = wpn;
+       killnotify_actiontype[kn_index] = actiontype;
+       if(killnotify_attackers[kn_index])
+               strunzone(killnotify_attackers[kn_index]);
+       killnotify_attackers[kn_index] = strzone(attacker);
+       if(killnotify_victims[kn_index])
+               strunzone(killnotify_victims[kn_index]);
+       killnotify_victims[kn_index] = strzone(victim);
 }
 
 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
@@ -2695,7 +2688,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
                }
@@ -3100,7 +3097,7 @@ void HUD_Notify (void)
        }
 
        float entries, height;
-       entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
+       entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
        height = mySize_y/entries;
        
        vector fontsize;
@@ -3119,43 +3116,63 @@ void HUD_Notify (void)
        float width_attacker;
        string attacker, victim;
 
-       float i, j, w;
-       float flip = cvar("hud_panel_notify_flip");
-       for(j = 0; j < entries; ++j)
+       float i, j, w, step, limit;
+       if(cvar("hud_panel_notify_flip")) //order items from the top down
        {
-               s = "";
-               if(flip)
-                       i = j;
-               else // rather nasty hack for ordering items from the bottom up
-                       i = entries - j - 1;
+               i = 0;
+               step = +1;
+               limit = entries;
+       }
+       else //order items from the bottom up
+       {
+               i = entries - 1;
+               step = -1;
+               limit = -1;
+       }
 
-               if(fadetime)
+       for(j = kn_index;  i != limit;  i += step, ++j)
+       {
+               if(autocvar__hud_configure)
                {
-                       if(killnotify_times[j] + when > time)
-                               a = 1;
-                       else
-                               a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
+                       if (step == +1)
+                               a = i;
+                       else // inverse order
+                               a = entries - 1 - i;
+                       attacker = textShortenToWidth(strcat("Player", ftos(a+1)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
+                       victim = textShortenToWidth(strcat("Player", ftos(a+2)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
+                       s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
+                       a = bound(0, (when - a) / 4, 1);
+                       goto hud_config_notifyprint;
+               }
+
+               if (j == KN_MAX_ENTRIES)
+                       j = 0;
+
+               if(killnotify_times[j] + when > time)
+                       a = 1;
+               else if(fadetime)
+               {
+                       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;
                }
 
+               s = "";
+
                w = -1;
                w = DEATH_WEAPONOF(killnotify_deathtype[j]);
 
                // TODO: maybe print in team colors?
                //
                // Y [used by] X
-               if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure
+               if(killnotify_actiontype[j] == 0) 
                {
-                       attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
-                       pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
-                       weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
-
                        if(killnotify_deathtype[j] == DEATH_GENERIC)
                        {
                                s = "notify_death";
@@ -3248,7 +3265,11 @@ void HUD_Notify (void)
                                        s = "notify_blue_captured";
                                }
                        }
-                       if(s != "" && a)
+                       attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
+                       pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
+                       weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
+
+                       if(s != "")
                        {
                                drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
                                drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
@@ -3257,27 +3278,7 @@ void HUD_Notify (void)
                // X [did action to] Y
                else
                {
-                       if(autocvar__hud_configure)
-                       {
-                               attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
-                               victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
-                               a = bound(0, (when - j) / 4, 1);
-                       }
-                       else
-                       {
-                               attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
-                               victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
-                       }
-                       width_attacker = stringwidth(attacker, TRUE, fontsize);
-                       pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
-                       pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
-                       weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
-
-                       if(autocvar__hud_configure) // example actions for config mode
-                       {
-                               s = "weaponelectro";
-                       }
-                       else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
+                       if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
                        {
                                s = "notify_melee_laser";
                        }
@@ -3326,6 +3327,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";
@@ -3342,7 +3347,16 @@ void HUD_Notify (void)
                        {
                                s = "race_newfail";
                        }
-                       if(s != "" && a)
+
+                       attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
+                       victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
+:hud_config_notifyprint
+                       width_attacker = stringwidth(attacker, TRUE, fontsize);
+                       pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
+                       pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
+                       weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
+
+                       if(s != "")
                        {
                                drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
                                drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
@@ -3950,11 +3964,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();
 
@@ -4495,7 +4515,7 @@ void HUD_ModIcons(void)
        if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
                return;
 
-       if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && !autocvar__hud_configure)
+       if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && gametype != GAME_FREEZETAG && !autocvar__hud_configure)
                return;
 
        active_panel = HUD_PANEL_MODICONS;
@@ -4532,7 +4552,7 @@ void HUD_ModIcons(void)
                HUD_Mod_NexBall(pos, mySize);
        else if(gametype == GAME_CTS || gametype == GAME_RACE)
                HUD_Mod_Race(pos, mySize);
-       else if(gametype == GAME_CA)
+       else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
                HUD_Mod_CA(pos, mySize);
 }