]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/View.qc
fix an effectless statement - who put this there in the first place? TH of course...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / View.qc
index efe7be12f3d91cda379ea7750c6515fea707ad76..ade5155c46ff2e7c26e50070c05e31b269982085 100644 (file)
@@ -127,7 +127,7 @@ vector GetCurrentFov(float fov)
 
        zoomdir = button_zoom;
        if(hud == HUD_NORMAL)
-       if((getstati(STAT_ACTIVEWEAPON) == WEP_NEX && nex_scope) || (getstati(STAT_ACTIVEWEAPON) == WEP_RIFLE && rifle_scope)) // do NOT use switchweapon here
+       if((activeweapon == WEP_NEX && nex_scope) || (activeweapon == WEP_RIFLE && rifle_scope)) // do NOT use switchweapon here
                zoomdir += button_attack2;
        if(spectatee_status > 0 || isdemo())
        {
@@ -544,7 +544,16 @@ void CSQC_UpdateView(float w, float h)
        }
 
        ColorTranslateMode = autocvar_cl_stripcolorcodes;
-       activeweapon = getstati(STAT_SWITCHWEAPON);
+
+       // next WANTED weapon (for HUD)
+       switchweapon = getstati(STAT_SWITCHWEAPON);
+
+       // currently switching-to weapon (for crosshair)
+       switchingweapon = getstati(STAT_SWITCHINGWEAPON);
+
+       // actually active weapon (for zoom)
+       activeweapon = getstati(STAT_ACTIVEWEAPON);
+
        f = (serverflags & SERVERFLAG_TEAMPLAY);
        if(f != teamplay)
        {
@@ -552,9 +561,12 @@ void CSQC_UpdateView(float w, float h)
                HUD_InitScores();
        }
 
-       if(last_weapon != activeweapon) {
+       if(last_switchweapon != switchweapon) {
                weapontime = time;
-               last_weapon = activeweapon;
+               last_switchweapon = switchweapon;
+       }
+       if(last_activeweapon != activeweapon) {
+               last_activeweapon = activeweapon;
 
                e = get_weaponinfo(activeweapon);
                if(e.netname != "")
@@ -1030,7 +1042,7 @@ void CSQC_UpdateView(float w, float h)
                        float wcross_scale, wcross_blur;
 
                        if (autocvar_crosshair_per_weapon || autocvar_crosshair_color_per_weapon) {
-                               e = get_weaponinfo(activeweapon);
+                               e = get_weaponinfo(switchingweapon);
                                if (e && e.netname != "")
                                {
                                        wcross_wep = e.netname;
@@ -1159,7 +1171,7 @@ void CSQC_UpdateView(float w, float h)
 
                        f = autocvar_crosshair_effect_speed;
                        if(f < 0)
-                               f *= -2 * g_weaponswitchdelay;
+                               f *= -2 * g_weaponswitchdelay; // anim starts when weapon has been lowered and new weapon comes up
                        if(wcross_scale != wcross_scale_goal_prev || wcross_alpha != wcross_alpha_goal_prev || wcross_color != wcross_color_goal_prev)
                        {
                                wcross_changedonetime = time + f;
@@ -1282,6 +1294,14 @@ void CSQC_UpdateView(float w, float h)
                                                        ring_image = "gfx/crosshair_ring.tga";
                                        }
 
+                                       // if in weapon switch animation, fade ring out/in
+                                       if(g_weaponswitchdelay > 0)
+                                       {
+                                               f = (time - wcross_name_changestarttime) / g_weaponswitchdelay;
+                                               if(f > 0 && f < 2)
+                                                       ring_alpha *= fabs(1 - f);
+                                       }
+
                                        if (autocvar_crosshair_ring_inner && ring_inner_value) // lets draw a ring inside a ring so you can ring while you ring
                                                DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, ring_inner_image, ring_inner_value, ring_inner_rgb, wcross_alpha * ring_inner_alpha, DRAWFLAG_ADDITIVE);