]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/View.qc
If we drop a weapon that's loaded, give the ammo back to the player. The player will...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / View.qc
index adfdbf0bd50bc6c3d87bc33aadabf6e5005543b3..f91026cf0845cff97e82084ca255e99fd8aecf7e 100644 (file)
@@ -360,7 +360,8 @@ float myhealth_flash;
 
 vector myhealth_gentlergb;
 
-float contentavgalpha;
+float contentavgalpha, liquidalpha_prev;
+vector liquidcolor_prev;
 
 void CSQC_UpdateView(float w, float h)
 {
@@ -671,13 +672,12 @@ void CSQC_UpdateView(float w, float h)
                        drawpic(reticle_pos, "gfx/reticle_nex", reticle_size, '1 1 1', f * autocvar_cl_reticle_item_nex, DRAWFLAG_NORMAL);
        }
 
-       // improved polyblend with post processing effects
+
+       // improved polyblend
        vector rgb;
-       vector damage_blurpostprocess;
-       vector content_blurpostprocess;
        if(autocvar_hud_contents)
        {
-               float contentalpha_temp, incontent, liquidalpha;
+               float contentalpha_temp, incontent, liquidalpha, contentfadetime;
                vector liquidcolor;
                
                switch(pointcontents(view_origin))
@@ -707,28 +707,20 @@ void CSQC_UpdateView(float w, float h)
                                break;
                }
                
-               contentalpha_temp = bound(0, drawframetime / max(0.0001, autocvar_hud_contents_fadetime), 1);
+               if(incontent) // fade in/out at different speeds so you can do e.g. instant fade when entering water and slow when leaving it.
+               { // also lets delcare previous values for blending properties, this way it isn't reset until after you have entered a different content
+                       contentfadetime = autocvar_hud_contents_fadeintime;
+                       liquidalpha_prev = liquidalpha;
+                       liquidcolor_prev = liquidcolor;
+               }
+               else
+                       contentfadetime = autocvar_hud_contents_fadeouttime;
+                       
+               contentalpha_temp = bound(0, drawframetime / max(0.0001, contentfadetime), 1);
                contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp;
-               //contentalpha_temp = contentavgalpha;
-               
-               if(incontent)
-                       drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, liquidcolor, contentavgalpha * liquidalpha, DRAWFLAG_NORMAL);
                
-               if(autocvar_hud_postprocessing)
-               {
-                       if(autocvar_hud_contents_blur)
-                       {
-                               content_blurpostprocess_x = 1;
-                               content_blurpostprocess_y = contentavgalpha * autocvar_hud_contents_blur;
-                               content_blurpostprocess_z = contentavgalpha * autocvar_hud_contents_blur_alpha;
-                       }
-                       else
-                       {
-                               content_blurpostprocess_x = 0;
-                               content_blurpostprocess_y = 0;
-                               content_blurpostprocess_z = 0;
-                       }
-               }
+               if(contentavgalpha)
+                       drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, liquidcolor_prev, contentavgalpha * liquidalpha_prev, DRAWFLAG_NORMAL);
        }
        
        if(autocvar_hud_damage)
@@ -788,42 +780,9 @@ void CSQC_UpdateView(float w, float h)
 
                        drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, myhealth_gentlergb, autocvar_hud_damage_gentle_alpha_multiplier * bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
                }
-               else if(autocvar_hud_damage_image)
-                       drawpic(reticle_pos, "gfx/blood", reticle_size, stov(autocvar_hud_damage_color), bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
-                       
-               if(autocvar_hud_postprocessing)
-               {
-                       if(autocvar_hud_damage_blur)
-                       {
-                               damage_blurpostprocess_x = 1;
-                               damage_blurpostprocess_y = bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage_blur;
-                               damage_blurpostprocess_z = bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage_blur_alpha;
-                       }
-                       else
-                       {
-                               damage_blurpostprocess_x = 0;
-                               damage_blurpostprocess_y = 0;
-                               damage_blurpostprocess_z = 0;
-                       }
-               }
-       }
-       
-       if(autocvar_hud_postprocessing)
-       { // lets apply the postprocess effects from the previous two functions if needed
-               if(damage_blurpostprocess_x || content_blurpostprocess_x)
-               {
-                       float blurradius = bound(0, damage_blurpostprocess_y + content_blurpostprocess_y, autocvar_hud_postprocessing_maxblurradius);
-                       float bluralpha = bound(0, damage_blurpostprocess_z + content_blurpostprocess_z, autocvar_hud_postprocessing_maxbluralpha);
-                       cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0"));
-                       cvar_set("r_glsl_postprocess_uservec1_enable", "1");
-               }
                else
-               {
-                       cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
-                       cvar_set("r_glsl_postprocess_uservec1_enable", "0");
-               }
+                       drawpic(reticle_pos, "gfx/blood", reticle_size, stov(autocvar_hud_damage_color), bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
        }
-       
 
        // Draw the mouse cursor
        // NOTE: drawpic must happen after R_RenderScene for some reason
@@ -891,7 +850,7 @@ void CSQC_UpdateView(float w, float h)
 
                        // TrueAim check
                        float shottype;
-                       float bullets, ring_scale;
+                       float weapon_clipload, weapon_clipsize, ring_scale;
                        // wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
                        wcross_origin = project_3d_to_2d(view_origin + MAX_SHOT_DISTANCE * view_forward);
                        wcross_origin_z = 0;
@@ -940,6 +899,50 @@ void CSQC_UpdateView(float w, float h)
                        }
                        if(wcross_wep != "" && autocvar_crosshair_color_per_weapon)
                                wcross_color = stov(cvar_string(strcat("crosshair_", wcross_wep, "_color")));
+                       else if(autocvar_crosshair_color_by_health)
+                       {
+                               local float x = getstati(STAT_HEALTH);
+                               
+                               //x = red
+                               //y = green
+                               //z = blue
+                               
+                               wcross_color_z = 0;
+                               
+                               if(x > 200)
+                               {
+                                       wcross_color_x = 0;
+                                       wcross_color_y = 1;
+                               }
+                               else if(x > 150)
+                               {
+                                       wcross_color_x = 0.4 - (x-150)*0.02 * 0.4;
+                                       wcross_color_y = 0.9 + (x-150)*0.02 * 0.1;
+                               }
+                               else if(x > 100)
+                               {
+                                       wcross_color_x = 1 - (x-100)*0.02 * 0.6;
+                                       wcross_color_y = 1 - (x-100)*0.02 * 0.1;
+                                       wcross_color_z = 1 - (x-100)*0.02;
+                               }
+                               else if(x > 50)
+                               {
+                                       wcross_color_x = 1;
+                                       wcross_color_y = 1;
+                                       wcross_color_z = 0.2 + (x-50)*0.02 * 0.8;  
+                               }
+                               else if(x > 20)
+                               {
+                                       wcross_color_x = 1;
+                                       wcross_color_y = (x-20)*90/27/100;
+                                       wcross_color_z = (x-20)*90/27/100 * 0.2;
+                               }
+                               else
+                               {
+                                       wcross_color_x = 1;
+                                       wcross_color_y = 0;
+                               }
+                       }
                        else
                                wcross_color = stov(autocvar_crosshair_color);
 
@@ -1036,16 +1039,17 @@ void CSQC_UpdateView(float w, float h)
                        if(nex_charge_movingavg == 0) // this should only happen if we have just loaded up the game
                                nex_charge_movingavg = nex_charge;
 
-                       // ring around crosshair representing bullets left in camping rifle clip
-                       if (activeweapon == WEP_SNIPERRIFLE && cr_maxbullets)
+                       // ring around crosshair representing bullets left in weapon clip
+                       weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);
+                       if (weapon_clipload)
                        {
-                               bullets = getstati(STAT_BULLETS_LOADED);
-                               f = bound(0, bullets / cr_maxbullets, 1);
+                               weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);
+                               f = bound(0, weapon_clipload / weapon_clipsize, 1);
 
                                a = autocvar_crosshair_ring_sniperrifle_alpha;
                                DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, "gfx/crosshair_ring.tga", f, wcross_color, wcross_alpha * a, DRAWFLAG_ADDITIVE);
                        }
-                       else if (activeweapon == WEP_NEX && nex_charge) // ring around crosshair representing velocity-dependent damage for the nex
+                       if (activeweapon == WEP_NEX && nex_charge) // ring around crosshair representing velocity-dependent damage for the nex
                        {
                                if(nex_chargepool || use_nex_chargepool)
                                {
@@ -1580,7 +1584,7 @@ void CSQC_Demo_Camera()
        else
        {
                tmp = getmousepos() * 0.1;
-               if(vlen(tmp)>autocvar_camera_mouse_treshold)
+               if(vlen(tmp)>autocvar_camera_mouse_threshold)
                {
                        mouse_angles_x += tmp_y * cos(mouse_angles_z * DEG2RAD) + (tmp_x * sin(mouse_angles_z * DEG2RAD));
                        mouse_angles_y -= tmp_x * cos(mouse_angles_z * DEG2RAD) + (tmp_y * -sin(mouse_angles_z * DEG2RAD));