]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
move more of the weapon stuff to CSQC
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 0a83238503697e91330891be4055fdab4d998680..f2a5a34f31fec2574e689fde0e6e6fb1bfd6d2e6 100644 (file)
@@ -579,6 +579,7 @@ void HUD_Panel_ExportCfg(string cfgname)
                fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
+               fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
@@ -587,6 +588,7 @@ void HUD_Panel_ExportCfg(string cfgname)
 
                fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
                fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
+               fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
                fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
                fputs(fh, "\n");
 
@@ -608,6 +610,7 @@ void HUD_Panel_ExportCfg(string cfgname)
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
+                       fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
@@ -730,12 +733,24 @@ vector HUD_Panel_GetColor(float id)
        float f;
        vector color_vec;
        string color;
-       color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
+
+       // fetch per-panel color
+       if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
+               f = stof(getplayerkey(self.sv_entnum, "colors"));
+               color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
+       }
+       else
+               color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
        color_vec = stov(color);
-       if(color == "") {
+
+       if(color == "") { // fetch default color
                color = cvar_string("hud_bg_color");
                color_vec = stov(color);
-               if(color == "shirt") {
+               if(teamplay && cvar(strcat("hud_bg_color_team"))) {
+                       f = stof(getplayerkey(self.sv_entnum, "colors"));
+                       color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
+               }
+               else if(color == "shirt") {
                        f = stof(getplayerkey(self.sv_entnum, "colors"));
                        color_vec = colormapPaletteColor(floor(f / 16), 0);
                }
@@ -762,7 +777,11 @@ vector HUD_Panel_Dock_GetColor(void)
        string color;
        color = cvar_string("hud_dock_color");
        color_vec = stov(color);
-       if(color == "shirt") {
+       if(teamplay && cvar(strcat("hud_dock_color_team"))) {
+               f = stof(getplayerkey(self.sv_entnum, "colors"));
+               color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
+       }
+       else if(color == "shirt") {
                f = stof(getplayerkey(self.sv_entnum, "colors"));
                color_vec = colormapPaletteColor(floor(f / 16), 0);
        }
@@ -1980,9 +1999,12 @@ void HUD_HealthArmor(void)
 // Notification area (#4)
 //
 
-string Weapon_SuicideMessage(float id)
+string Weapon_SuicideMessage(float deathtype)
 {
-       switch (id)
+       float w;
+       w = DEATH_WEAPONOF(deathtype);
+
+       switch (w)
        {
                case 1:
                        return "lasered himself to hell";
@@ -1991,17 +2013,20 @@ string Weapon_SuicideMessage(float id)
                case 3:
                        return "did the impossible";
                case 4:
-                       if(id & HITTYPE_SECONDARY)
+                       if(deathtype & HITTYPE_SECONDARY)
                                return "tried out his own grenade";
                        return "detonated";
        }
        // TODO: was blasted by?
-       return strcat("[no kill message for weapon ", ftos(id), "!]");
+       return strcat("[no kill message for weapon ", ftos(w), "!]");
 }
 
-string Weapon_KillMessage(float id)
+string Weapon_KillMessage(float deathtype)
 {
-       switch (id)
+       float w;
+       w = DEATH_WEAPONOF(deathtype);
+
+       switch (w)
        {
                case 1:
                        return "was lasered to death by";
@@ -2016,7 +2041,7 @@ string Weapon_KillMessage(float id)
                                return "didn't see #'s grenade";
                        return "almost dodged #'s grenade";
        }
-       return strcat("[no suicide message for weapon ", ftos(id), "!]");
+       return strcat("[no suicide message for weapon ", ftos(w), "!]");
 }
 
 float killnotify_times[10];
@@ -2043,10 +2068,14 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
        if(msg == MSG_SUICIDE) {
                // TODO: cl_gentle
                // TODO: way of finding out secondary?
-               if(type == DEATH_WEAPON) {
-                       HUD_KillNotify_Push(s1, "", stof(s3));
+               print("deathtype: ", ftos(type), "\n");
+
+               float w;
+               w = DEATH_WEAPONOF(type);
+               if(WEP_VALID(w)) {
+                       HUD_KillNotify_Push(s1, "", w);
                        if (!HUD_Panel_CheckActive(4) || cvar("hud_notify_print"))
-                               print("^1", s1, "^1 ", Weapon_SuicideMessage(stof(s3)), "\n");
+                               print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
                }
                else if (type == DEATH_KILL)
                        print ("^1",s1, "^1 couldn't take it anymore\n");
@@ -2067,7 +2096,16 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
                if (stof(s2) > 2) // killcount > 2
                        print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
        } else if(msg == MSG_KILL) {
-               if(type == KILL_TEAM || type == KILL_TEAM_SPREE) {
+               print("deathtype: ", ftos(type), "\n");
+
+               float w;
+               w = DEATH_WEAPONOF(type);
+               if(WEP_VALID(w)) {
+                       HUD_KillNotify_Push(s1, s2, w);
+                       if (!HUD_Panel_CheckActive(4) || cvar("hud_notify_print"))
+                               print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
+               }
+               else if(type == KILL_TEAM || type == KILL_TEAM_SPREE) {
                                if(cvar("cl_gentle")) {
                                        print ("^1", s1, "^1 took action against a team mate\n");
                                } else {
@@ -2088,11 +2126,6 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
                }
                else if(type == KILL_FIRST_BLOOD)
                        print("^1",s1, "^1 drew first blood", "\n");
-               else if (type == DEATH_WEAPON) {
-                       HUD_KillNotify_Push(s1, s2, stof(s3));
-                       if (!HUD_Panel_CheckActive(4) || cvar("hud_notify_print"))
-                               print("^1", s1, "^1 ", Weapon_KillMessage(stof(s3)), "\n");
-               }
                else if (type == DEATH_TELEFRAG)
                        print ("^1",s1, "^1 was telefragged by ", s2, "\n");
                else if (type == DEATH_DROWN)
@@ -3577,6 +3610,23 @@ void HUD_Main (void)
        hud_configure = cvar("_hud_configure");
 
        // Drawing stuff
+
+       // HUD configure visible grid
+       if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
+       {
+               float i;
+               // x-axis
+               for(i = 0; i < vid_conwidth/cvar("hud_configure_grid_x"); ++i)
+               {
+                       drawfill(eX * i * cvar("hud_configure_grid_x"), eX + eY * vid_conheight, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
+               }
+               // y-axis
+               for(i = 0; i < vid_conheight/cvar("hud_configure_grid_y"); ++i)
+               {
+                       drawfill(eY * i * cvar("hud_configure_grid_y"), eY + eX * vid_conwidth, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
+               }
+       }
+
        if(cvar_string("hud_dock") != "")
                drawpic_skin('0 0 0', cvar_string("hud_dock"), eX * vid_conwidth + eY * vid_conheight, HUD_Panel_Dock_GetColor(), cvar("hud_dock_alpha"), DRAWFLAG_NORMAL);