And lastly, implement the client side part.
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 28 Feb 2011 15:25:17 +0000 (17:25 +0200)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 28 Feb 2011 15:25:17 +0000 (17:25 +0200)
data/defaultVoretournament.cfg
data/qcsrc/client/View.qc
data/qcsrc/client/miscfunctions.qc

index aece24e..d0ccbde 100644 (file)
@@ -110,6 +110,8 @@ _cl_playerskin 0
 crosshair 1\r
 seta crosshair_pickup 1\r
 seta crosshair_pickup_speed 4\r
+seta crosshair_ring_alpha 0.5\r
+seta crosshair_ring_size 3\r
 seta crosshair_effect_speed 0.25 "how fast (in seconds) some crosshair effects should take place, 0 = instant, -1 = 2x weapon switch time"\r
 seta crosshair_effect_scalefade 1 "use scaling and fading for crosshair effects"\r
 seta crosshair_hittest 1.25 "do a crosshair hit evaluation; also, the crosshair is scaled by the given number when aiming at an enemy, and blurred when aiming at a team mate"\r
index f68adaa..bdfb160 100644 (file)
@@ -270,6 +270,7 @@ void CSQC_UpdateView(float w, float h)
        float fov;\r
        float f, i, j;\r
        vector v, vo;\r
+       float a;\r
 \r
        vector artwork_pos, artwork_size;\r
 \r
@@ -926,6 +927,8 @@ void CSQC_UpdateView(float w, float h)
                        else\r
                                shottype = SHOTTYPE_HITWORLD;\r
 \r
+                       float weapon_clipload, weapon_clipsize, ring_scale;\r
+\r
                        string wcross_style;\r
                        wcross_style = cvar_string("crosshair");\r
 \r
@@ -1057,6 +1060,17 @@ void CSQC_UpdateView(float w, float h)
                                wcross_size = drawgetimagesize(wcross_name) * wcross_scale;\r
                                CROSSHAIR_DRAW(wcross_resolution, wcross_name, wcross_alpha * f);\r
                                wcross_name_alpha_goal_prev = f;\r
+\r
+                               // ring around crosshair representing bullets left in weapon clip\r
+                               weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);\r
+                               if (weapon_clipload)\r
+                               {\r
+                                       weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);\r
+                                       f = bound(0, weapon_clipload / weapon_clipsize, 1);\r
+                                       ring_scale = cvar("crosshair_ring_size");\r
+                                       a = cvar("crosshair_ring_alpha");\r
+                                       DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, "gfx/crosshair_ring.tga", f, wcross_color, wcross_alpha * a, DRAWFLAG_ADDITIVE);\r
+                               }\r
                        }\r
                }\r
                else\r
index 226a964..0d72bfe 100644 (file)
@@ -541,3 +541,153 @@ void PolyDrawModel(entity e)
                }\r
        }\r
 }\r
+\r
+void DrawCircleClippedPic(vector centre, float radius, string pic, float f, vector rgb, float a, float drawflag)\r
+{\r
+       float x, y, q, d;\r
+       vector ringsize, v, t;\r
+       ringsize = radius * '1 1 0';\r
+\r
+       x = cos(f * 2 * M_PI);\r
+       y = sin(f * 2 * M_PI);\r
+       q = fabs(x) + fabs(y);\r
+       x /= q;\r
+       y /= q;\r
+\r
+       if(f >= 1)\r
+       {\r
+               // draw full rectangle\r
+               R_BeginPolygon(pic, drawflag);\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_y -= 0.5 * ringsize_y;        t -= '0.5 -0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+               R_EndPolygon();\r
+\r
+               d = q - 1;\r
+               if(d > 0)\r
+               {\r
+                       R_BeginPolygon(pic, drawflag);\r
+                               v = centre;                     t = '0.5 0.5 0';\r
+                               R_PolygonVertex(v, t, rgb, a);\r
+\r
+                               v = centre;                     t = '0.5 0.5 0';\r
+                               v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';\r
+                               R_PolygonVertex(v, t, rgb, a);\r
+               }\r
+       }\r
+       else if(f > 0.75)\r
+       {\r
+               // draw upper and first triangle\r
+               R_BeginPolygon(pic, drawflag);\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+               R_EndPolygon();\r
+               R_BeginPolygon(pic, drawflag);\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_y -= 0.5 * ringsize_y;        t -= '0.5 -0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+               d = q - 0.75;\r
+               if(d <= 0)\r
+                       R_EndPolygon();\r
+       }\r
+       else if(f > 0.5)\r
+       {\r
+               // draw upper triangle\r
+               R_BeginPolygon(pic, drawflag);\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+               R_EndPolygon();\r
+\r
+               d = q - 0.5;\r
+               if(d > 0)\r
+               {\r
+                       R_BeginPolygon(pic, drawflag);\r
+                               v = centre;                     t = '0.5 0.5 0';\r
+                               R_PolygonVertex(v, t, rgb, a);\r
+\r
+                               v = centre;                     t = '0.5 0.5 0';\r
+                               v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';\r
+                               R_PolygonVertex(v, t, rgb, a);\r
+               }\r
+       }\r
+       else if(f > 0.25)\r
+       {\r
+               // draw first triangle\r
+               R_BeginPolygon(pic, drawflag);\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+\r
+               d = q - 0.25;\r
+               if(d <= 0)\r
+                       R_EndPolygon();\r
+       }\r
+       else\r
+       {\r
+               d = q;\r
+               if(d > 0)\r
+               {\r
+                       R_BeginPolygon(pic, drawflag);\r
+                               v = centre;                     t = '0.5 0.5 0';\r
+                               R_PolygonVertex(v, t, rgb, a);\r
+\r
+                               v = centre;                     t = '0.5 0.5 0';\r
+                               v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';\r
+                               R_PolygonVertex(v, t, rgb, a);\r
+               }\r
+       }\r
+\r
+       if(d > 0)\r
+       {\r
+                       v = centre;                     t = '0.5 0.5 0';\r
+                       v_x += x * 0.5 * ringsize_x;    t += x * '0.5 0.5 0';\r
+                       v_y += y * 0.5 * ringsize_y;    t += y * '0.5 -0.5 0';\r
+                       R_PolygonVertex(v, t, rgb, a);\r
+               R_EndPolygon();\r
+       }\r
+}\r