]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
increase headshot damage on rifle, use the headshot image in the notify panel if...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 3d2ba9f2b5230b6733232ac72d663dbcad5119dd..9a203c72b54ac738d58346a4ffc2f38861985eae 100644 (file)
@@ -596,8 +596,6 @@ vector HUD_Panel_CheckMove(vector myPos, vector mySize)
        vector myTarget;
        myTarget = myPos;
 
-       vector targPos;
-       vector targSize;
        vector myCenter;
        vector targCenter;
        myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
@@ -697,12 +695,9 @@ void HUD_Panel_SetPos(vector pos)
 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
        float i;
 
-       float targBorder;
-       vector targPos;
-       vector targSize;
        vector targEndPos;
 
-       vector dist;
+       float dist_x, dist_y;
        float ratio;
        ratio = mySize_x/mySize_y;
 
@@ -1415,7 +1410,6 @@ void HUD_Panel_Mouse()
                highlightcheck = HUD_Panel_HighlightCheck();
        }
        // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
-       string cursor;
        vector cursorsize;
        cursorsize = '32 32 0';
 
@@ -1448,7 +1442,6 @@ void weaponorder_swap(float i, float j, entity pass)
        weaponorder[j] = h;
 }
 
-string weaponorder_cmp_str_save;
 string weaponorder_cmp_str;
 float weaponorder_cmp(float i, float j, entity pass)
 {
@@ -1477,7 +1470,6 @@ float GetAmmoTypeForWep(float i)
        {
                case WEP_SHOTGUN: return 0;
                case WEP_UZI: return 1;
-               case WEP_CAMPINGRIFLE: return 1;
                case WEP_GRENADE_LAUNCHER: return 2;
                case WEP_MINE_LAYER: return 2;
                case WEP_ELECTRO: return 3;
@@ -1485,6 +1477,7 @@ float GetAmmoTypeForWep(float i)
                case WEP_HLAC: return 3;
                case WEP_MINSTANEX: return 3;
                case WEP_NEX: return 3;
+               case WEP_CAMPINGRIFLE: return 1;
                case WEP_HAGAR: return 2;
                case WEP_ROCKET_LAUNCHER: return 2;
                case WEP_SEEKER: return 2;
@@ -1497,7 +1490,7 @@ float GetAmmoTypeForWep(float i)
 void HUD_Weapons(void)
 {
        float f, screen_ar;
-       vector center;
+       float center_x, center_y;
 
        if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
                return;
@@ -1597,13 +1590,17 @@ void HUD_Weapons(void)
        }
 
        // TODO make this configurable
-       weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
-
-       if(weaponorder_cmp_str != weaponorder_cmp_str_save)
+       if(weaponorder_bypriority != cvar_string("cl_weaponpriority"))
        {
-               if(weaponorder_cmp_str_save)
-                       strunzone(weaponorder_cmp_str_save);
-               weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
+               if(weaponorder_bypriority)
+                       strunzone(weaponorder_bypriority);
+               if(weaponorder_byimpulse)
+                       strunzone(weaponorder_byimpulse);
+
+               weaponorder_bypriority = strzone(cvar_string("cl_weaponpriority"));
+               weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
+               weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
+
                weapon_cnt = 0;
                for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                {
@@ -1615,6 +1612,8 @@ void HUD_Weapons(void)
                        }
                }
                heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
+
+               weaponorder_cmp_str = string_null;
        }
 
        HUD_Panel_DrawBg(1);
@@ -1732,8 +1731,7 @@ void HUD_Weapons(void)
                                                default: fullammo = 60;
                                        }
 
-                                       vector barsize;
-                                       vector barpos;
+                                       float barsize_x, barsize_y, barpos_x, barpos_y;
                                        if(wpnsize_x/wpnsize_y > autocvar_hud_panel_weapons_aspect)
                                        {
                                                barsize_x = autocvar_hud_panel_weapons_aspect * wpnsize_y;
@@ -1959,7 +1957,8 @@ void HUD_Ammo(void)
 
 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
 {
-       vector newSize, newPos;
+       vector newPos;
+       float newSize_x, newSize_y;
        if(mySize_x/mySize_y > 3)
        {
                newSize_x = 3 * mySize_y;
@@ -2596,6 +2595,9 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
        alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
        gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
        
+       if ((msg == MSG_SUICIDE || msg == MSG_KILL || msg == MSG_KILL_ACTION) && gametype == GAME_CTS) // selfkill isn't interesting in CTS and only spams up the notify panel
+               return;
+
        if(msg == MSG_SUICIDE) {
                w = DEATH_WEAPONOF(type);
                if(WEP_VALID(w)) {
@@ -2641,9 +2643,14 @@ 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 (alsoprint)
-                               print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
+                       if(type & HITTYPE_HEADSHOT)
+                               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
+                       }
                }
                else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
                        HUD_KillNotify_Push(s1, s2, 1, type);
@@ -2922,6 +2929,19 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                        HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
                        print(s1, "^7 captured the ", s2, s3, "\n");
                }
+       } else if(msg == MSG_RACE) {
+               if(type == RACE_SERVER_RECORD) {
+                       HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
+               }
+               else if(type == RACE_NEW_RANK) {
+                       HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
+               }
+               else if(type == RACE_NEW_TIME) {
+                       HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
+               }
+               else if(type == RACE_FAIL) {
+                       HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
+               }
        }
 }
 
@@ -3258,6 +3278,26 @@ 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";
+                       }
+                       else if(killnotify_deathtype[j] == RACE_NEW_RANK)
+                       {
+                               s = "race_newrankyellow";
+                       }
+                       else if(killnotify_deathtype[j] == RACE_NEW_TIME)
+                       {
+                               s = "race_newtime";
+                       }
+                       else if(killnotify_deathtype[j] == RACE_FAIL)
+                       {
+                               s = "race_newfail";
+                       }
                        if(s != "" && a)
                        {
                                drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
@@ -3486,6 +3526,7 @@ void HUD_Score(void)
        }
 
        float score, distribution, leader;
+       string sign;
        vector distribution_color;
        entity tm, pl, me;
        me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
@@ -3507,15 +3548,17 @@ void HUD_Score(void)
                        // distribution display
                        distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
 
-                       distrtimer = ftos(distribution/pow(10, TIME_DECIMALS));
+                       distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
 
                        if (distribution <= 0) {
                                distribution_color = '0 1 0';
+                               sign = "-";
                        }
                        else {
                                distribution_color = '1 0 0';
+                               sign = "+";
                        }
-                       drawstring_aspect(pos + eX * 0.75 * mySize_x, distrtimer, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(pos + eX * 0.75 * mySize_x, strcat(sign, distrtimer), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
                }
                // race record display
                if (distribution <= 0)
@@ -3748,11 +3791,22 @@ float vote_change; // "time" when vote_active changed
 
 void HUD_VoteWindow(void) 
 {
+       if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
+       {
+               vote_active = 1;
+               vote_called_vote = strzone(strcat("^2Name ^7instead of \"^1Unregistered player\"", " ^7in stats"));
+       }
+
        if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
                return;
 
        active_panel = HUD_PANEL_VOTE;
        HUD_Panel_UpdateCvars(vote);
+       if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
+       {
+               panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
+               panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
+       }
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
@@ -3818,16 +3872,22 @@ void HUD_VoteWindow(void)
        mySize = newSize;
 
        s = "A vote has been called for:";
+       if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
+               s = "Allow servers to store and display your name?";
        drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
-       s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
+       s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
        if(autocvar__hud_configure)
                s = "^1Configure the HUD";
        drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
 
        // print the yes/no counts
        s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount));
+       if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
+               s = strcat("Yes: (press y)");
        drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a, DRAWFLAG_NORMAL);
        s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount));
+       if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
+               s = strcat("No: (press n)");
        drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a, DRAWFLAG_NORMAL);
 
        // draw the progress bar backgrounds
@@ -3844,11 +3904,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();
 
@@ -4949,6 +5015,8 @@ switch (id) {\
 
 void HUD_Main (void)
 {
+       float i;
+
        hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
 
        // global hud alpha fade
@@ -4975,7 +5043,6 @@ void HUD_Main (void)
        // HUD configure visible grid
        if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
        {
-               float i;
                // x-axis
                for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
                {