]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/View.qc
Merge branch 'master' into mirceakitsune/universal_reload_system, with some VERY...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / View.qc
index 62ab6b6823400f58c835346e1419a379bf84870a..e95a01346fdae2b5d22b857c88db950cfdba4a10 100644 (file)
@@ -866,7 +866,9 @@ void CSQC_UpdateView(float w, float h)
 
                        // TrueAim check
                        float shottype;
+
                        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;
@@ -1064,51 +1066,68 @@ void CSQC_UpdateView(float w, float h)
 
                        wcross_scale *= 1 - autocvar__menu_alpha;
                        wcross_alpha *= 1 - autocvar__menu_alpha;
-
-                       ring_scale = autocvar_crosshair_ring_size;
-
                        wcross_size = drawgetimagesize(wcross_name) * wcross_scale;
 
-                       float nex_charge, nex_chargepool;
-                       nex_charge = getstatf(STAT_NEX_CHARGE);
-                       nex_chargepool = getstatf(STAT_NEX_CHARGEPOOL);
-
-                       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 ammo left in weapon clip
-                       weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);
-                       if (weapon_clipload)
+                       if (autocvar_crosshair_ring)
                        {
-                               weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);
-                               f = bound(0, weapon_clipload / weapon_clipsize, 1);
+                               float ring_value, ring_alpha, ring_inner_value, ring_inner_alpha;
+                               string ring_image, ring_inner_image;
+                               vector ring_rgb, ring_inner_rgb;
+                               
+                               float ring_scale = autocvar_crosshair_ring_size;
+                               
+                               float nex_charge, nex_chargepool;
+                               nex_charge = getstatf(STAT_NEX_CHARGE);
+                               nex_chargepool = getstatf(STAT_NEX_CHARGEPOOL);
+                               
+                               if(nex_charge_movingavg == 0) // this should only happen if we have just loaded up the game
+                                       nex_charge_movingavg = nex_charge;
 
-                               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);
-                       }
-                       if (activeweapon == WEP_NEX && nex_charge) // ring around crosshair representing velocity-dependent damage for the nex
-                       {
-                               if(nex_chargepool || use_nex_chargepool)
+                               weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);
+                               if (weapon_clipload) // ring around crosshair representing ammo left in weapon clip
                                {
-                                       use_nex_chargepool = 1;
-
-                                       a = autocvar_crosshair_ring_nex_inner_alpha;
-                                       rgb = eX * autocvar_crosshair_ring_nex_inner_color_red + eY * autocvar_crosshair_ring_nex_inner_color_green + eZ * autocvar_crosshair_ring_nex_inner_color_blue;
-                                       DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, "gfx/crosshair_ring_inner.tga", nex_chargepool, rgb, wcross_alpha * a, DRAWFLAG_ADDITIVE);
+                                       weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);
+                                       f = bound(0, weapon_clipload / weapon_clipsize, 1);
+                                       a = autocvar_crosshair_ring_sniperrifle_alpha;
+
+                                       ring_value = f;
+                                       ring_alpha = a;
+                                       ring_image = "gfx/crosshair_ring_sniperrifle.tga";
+                                       ring_rgb = wcross_color;
                                }
-                               else
+                               else if (activeweapon == WEP_NEX && nex_charge && autocvar_crosshair_ring_nex) // ring around crosshair representing velocity-dependent damage for the nex
                                {
-                                       // indicate how much we're charging right now with an inner circle
-                                       a = autocvar_crosshair_ring_nex_inner_alpha;
-                                       nex_charge_movingavg = (1 - autocvar_crosshair_ring_nex_currentcharge_movingavg_rate) * nex_charge_movingavg + autocvar_crosshair_ring_nex_currentcharge_movingavg_rate * nex_charge;
-
-                                       rgb = eX * autocvar_crosshair_ring_nex_inner_color_red + eY * autocvar_crosshair_ring_nex_inner_color_green + eZ * autocvar_crosshair_ring_nex_inner_color_blue;
-                                       DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, "gfx/crosshair_ring_inner.tga", bound(0, autocvar_crosshair_ring_nex_currentcharge_scale * (nex_charge - nex_charge_movingavg), 1), rgb, wcross_alpha * a, DRAWFLAG_ADDITIVE);
+                                       if (nex_chargepool || use_nex_chargepool) { 
+                                               use_nex_chargepool = 1; 
+                                               ring_inner_value = nex_chargepool;
+                                       } else { 
+                                               nex_charge_movingavg = (1 - autocvar_crosshair_ring_nex_currentcharge_movingavg_rate) * nex_charge_movingavg + autocvar_crosshair_ring_nex_currentcharge_movingavg_rate * nex_charge;
+                                               ring_inner_value = bound(0, autocvar_crosshair_ring_nex_currentcharge_scale * (nex_charge - nex_charge_movingavg), 1); 
+                                       }
+                                               
+                                       ring_inner_alpha = wcross_alpha * autocvar_crosshair_ring_nex_inner_alpha;
+                                       ring_inner_image = "gfx/crosshair_ring_inner.tga";
+                                       ring_inner_rgb = eX * autocvar_crosshair_ring_nex_inner_color_red + eY * autocvar_crosshair_ring_nex_inner_color_green + eZ * autocvar_crosshair_ring_nex_inner_color_blue;
+
+                                       // draw the outer ring to show the current charge of the weapon
+                                       ring_value = nex_charge;
+                                       ring_alpha = wcross_alpha * autocvar_crosshair_ring_nex_alpha;
+                                       ring_image = "gfx/crosshair_ring_nexgun.tga";
+                                       ring_rgb = wcross_color;
                                }
-
-                               // draw the charge
-                               a = autocvar_crosshair_ring_nex_outer_alpha;
-                               DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, "gfx/crosshair_ring.tga", nex_charge, wcross_color, wcross_alpha * a, DRAWFLAG_ADDITIVE);
+                               else if (activeweapon == WEP_MINE_LAYER && minelayer_maxmines && autocvar_crosshair_ring_minelayer) 
+                               {
+                                       ring_value = bound(0, getstati(STAT_LAYED_MINES) / minelayer_maxmines, 1); // if you later need to use the count of bullets in another place, then add a float for it. For now, no need to.
+                                       ring_alpha = wcross_alpha * autocvar_crosshair_ring_minelayer_alpha;
+                                       ring_image = "gfx/crosshair_ring.tga";
+                                       ring_rgb = wcross_color;
+                               }
+                               
+                               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, ring_inner_alpha, DRAWFLAG_ADDITIVE);
+                               
+                               if (ring_value)
+                                       DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, ring_image, ring_value, ring_rgb, ring_alpha, DRAWFLAG_ADDITIVE);
                        }
 
 #define CROSSHAIR_DO_BLUR(M,sz,wcross_name,wcross_alpha) \