]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
send max/minvelocity, make the circle drawing code a function, allow some customizati...
authorFruitieX <rasse@rasse-laptop.(none)>
Sun, 3 Oct 2010 18:48:12 +0000 (21:48 +0300)
committerFruitieX <rasse@rasse-laptop.(none)>
Sun, 3 Oct 2010 18:48:12 +0000 (21:48 +0300)
defaultXonotic.cfg
gfx/nex_ring.tga
qcsrc/client/Defs.qc
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/miscfunctions.qc
qcsrc/common/constants.qh
qcsrc/server/cl_client.qc

index 2e535c3955e0fce1447afe3d4cb7db238ebaf014..8a23a83e6d38031eb2260fd1aeb561e6fb1b5f2e 100644 (file)
@@ -198,6 +198,10 @@ seta crosshair_fireball_color_green 1.0    "crosshair color green component to disp
 seta crosshair_fireball_color_blue 0.2 "crosshair color blue component to display when wielding the fireball"
 seta crosshair_fireball_color_alpha 1  "crosshair alpha value to display when wielding the fireball"
 seta crosshair_fireball_size 1 "crosshair size when wielding the fireball"
+seta crosshair_nexvelocity_color_red 0.8
+seta crosshair_nexvelocity_color_green 0
+seta crosshair_nexvelocity_color_blue 0
+seta crosshair_nexvelocity_alpha 0.25
 seta cl_reticle_stretch 0 "whether to stretch reticles so they fit the screen (brakes image proportions)"
 seta cl_reticle_item_nex 1 "draw aiming recticle for the nex weapon's zoom, 0 disables and values between 0 and 1 change alpha"
 seta cl_reticle_item_normal 1 "draw recticle when zooming with the zoom button, 0 disables and values between 0 and 1 change alpha"
index c082c62432f4a82e38146b652d11a8ee1526b79a..22e3514cf68748eb87acf0c638244c167a8a3148 100644 (file)
Binary files a/gfx/nex_ring.tga and b/gfx/nex_ring.tga differ
index fbed63fc40b671ffb09f0d43d11eb5a9eecf5bad..1bd911aafb12b890f30152d8a1e17ead239fd11c 100644 (file)
@@ -260,3 +260,6 @@ vector w_org, w_backoff;
 
 float campingrifle_scope;
 float nex_scope;
+
+float nex_minvelocity;
+float nex_maxvelocity;
index 2fc1ce308bee3c0d7fd49907249f8dbd25dc205b..27b9284cd1e903e181490fa20470569bf62aa546 100644 (file)
@@ -1351,6 +1351,11 @@ float CSQC_Parse_TempEntity()
                        Net_WeaponComplain();
                        bHandled = true;
                        break;
+               case TE_CSQC_NEX_VELOCITY:
+                       nex_minvelocity = ReadShort();
+                       nex_maxvelocity = ReadShort();
+                       bHandled = true;
+                       break;
                default:
                        // No special logic for this temporary entity; return 0 so the engine can handle it
                        bHandled = false;
index 5e194821532b1cd76928ab3e6a462fbb6494e353..6fc94ca4346d1ebfa395510f9270ad9234ad841b 100644 (file)
@@ -701,160 +701,18 @@ void CSQC_UpdateView(float w, float h)
                // ring around crosshair representing velocity-dependent damage for the nex
                if (activeweapon == WEP_NEX)
                {
-                       float x, y, q, d;
-                       vector ringorigin, ringsize, t;
-                       ringorigin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
-                       ringsize = 64 * '1 -1 0'; // testing only
-
-                       // TODO send from server
-                       float maxvel, minvel, curvel;
-                       minvel = 400;
-                       maxvel = 1000;
-                       curvel = vlen('1 0 0' * pmove_vel_x + '0 1 0' * pmove_vel_y);
-
-                       f = bound(0, (curvel - minvel) / (maxvel - minvel), 1);
-                       x = cos(f * 2 * M_PI);
-                       y = sin(f * 2 * M_PI);
-                       q = fabs(x) + fabs(y);
-                       x /= q;
-                       y /= q;
-
-                       if(f >= 1)
-                       {
-                               // draw full rectangle
-                               R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y -= 0.5 * ringsize_y;        t -= '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-                               R_EndPolygon();
-
-                               d = q - 1;
-                               if(d > 0)
-                               {
-                                       R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                               v = ringorigin;                 t = '0.5 0.5 0';
-                                               R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                               v = ringorigin;                 t = '0.5 0.5 0';
-                                               v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
-                                               R_PolygonVertex(v, t, '1 1 1', 1);
-                               }
-                       }
-                       else if(f > 0.75)
-                       {
-                               // draw upper and first triangle
-                               R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-                               R_EndPolygon();
-                               R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y -= 0.5 * ringsize_y;        t -= '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                               d = q - 0.75;
-                               if(d <= 0)
-                                       R_EndPolygon();
-                       }
-                       else if(f > 0.5)
-                       {
-                               // draw upper triangle
-                               R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-                               R_EndPolygon();
-
-                               d = q - 0.5;
-                               if(d > 0)
-                               {
-                                       R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                               v = ringorigin;                 t = '0.5 0.5 0';
-                                               R_PolygonVertex(v, t, '1 1 1', 1);
+                       float f, a, curvel;
+                       vector rgb;
 
-                                               v = ringorigin;                 t = '0.5 0.5 0';
-                                               v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';
-                                               R_PolygonVertex(v, t, '1 1 1', 1);
-                               }
-                       }
-                       else if(f > 0.25)
-                       {
-                               // draw first triangle
-                               R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                               d = q - 0.25;
-                               if(d <= 0)
-                                       R_EndPolygon();
-                       }
-                       else
-                       {
-                               d = q;
-                               if(d > 0)
-                               {
-                                       R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                               v = ringorigin;                 t = '0.5 0.5 0';
-                                               R_PolygonVertex(v, t, '1 1 1', 1);
+                       rgb_x = cvar("crosshair_nexvelocity_color_red");
+                       rgb_y = cvar("crosshair_nexvelocity_color_green");
+                       rgb_z = cvar("crosshair_nexvelocity_color_blue");
+                       a = cvar("crosshair_nexvelocity_alpha");
 
-                                               v = ringorigin;                 t = '0.5 0.5 0';
-                                               v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
-                                               R_PolygonVertex(v, t, '1 1 1', 1);
-                               }
-                       }
+                       curvel = vlen('1 0 0' * pmove_vel_x + '0 1 0' * pmove_vel_y);
+                       f = bound(0, (curvel - nex_minvelocity) / (nex_maxvelocity - nex_minvelocity), 1);
 
-                       if(d > 0)
-                       {
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x += x * 0.5 * ringsize_x;    t += x * '0.5 0.5 0';
-                                       v_y += y * 0.5 * ringsize_y;    t += y * '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-                               R_EndPolygon();
-                       }
+                       DrawCircleClippedPic('0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight, 0.1 * vid_conheight, "gfx/nex_ring.tga", f, rgb, a, DRAWFLAG_ADDITIVE);
                }
 
                // crosshair goes VERY LAST
index ed8f84fc28bf128c3b2e340cb0e9c2233bb5307f..5c377bffadb8ade59c381071def85021d3181ba8 100644 (file)
@@ -650,3 +650,153 @@ void PolyDrawModel(entity e)
                }
        }
 }
+
+void DrawCircleClippedPic(vector centre, float radius, string pic, float f, vector rgb, float a, float drawflag)
+{
+       float x, y, q, d;
+       vector ringsize, v, t;
+       ringsize = radius * '1 1 0';
+
+       x = cos(f * 2 * M_PI);
+       y = sin(f * 2 * M_PI);
+       q = fabs(x) + fabs(y);
+       x /= q;
+       y /= q;
+
+       if(f >= 1)
+       {
+               // draw full rectangle
+               R_BeginPolygon(pic, drawflag);
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_y -= 0.5 * ringsize_y;        t -= '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+               R_EndPolygon();
+
+               d = q - 1;
+               if(d > 0)
+               {
+                       R_BeginPolygon(pic, drawflag);
+                               v = centre;                     t = '0.5 0.5 0';
+                               R_PolygonVertex(v, t, rgb, a);
+
+                               v = centre;                     t = '0.5 0.5 0';
+                               v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
+                               R_PolygonVertex(v, t, rgb, a);
+               }
+       }
+       else if(f > 0.75)
+       {
+               // draw upper and first triangle
+               R_BeginPolygon(pic, drawflag);
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+               R_EndPolygon();
+               R_BeginPolygon(pic, drawflag);
+                       v = centre;                     t = '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_y -= 0.5 * ringsize_y;        t -= '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+               d = q - 0.75;
+               if(d <= 0)
+                       R_EndPolygon();
+       }
+       else if(f > 0.5)
+       {
+               // draw upper triangle
+               R_BeginPolygon(pic, drawflag);
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+               R_EndPolygon();
+
+               d = q - 0.5;
+               if(d > 0)
+               {
+                       R_BeginPolygon(pic, drawflag);
+                               v = centre;                     t = '0.5 0.5 0';
+                               R_PolygonVertex(v, t, rgb, a);
+
+                               v = centre;                     t = '0.5 0.5 0';
+                               v_x -= 0.5 * ringsize_x;        t -= '0.5 0.5 0';
+                               R_PolygonVertex(v, t, rgb, a);
+               }
+       }
+       else if(f > 0.25)
+       {
+               // draw first triangle
+               R_BeginPolygon(pic, drawflag);
+                       v = centre;                     t = '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+               d = q - 0.25;
+               if(d <= 0)
+                       R_EndPolygon();
+       }
+       else
+       {
+               d = q;
+               if(d > 0)
+               {
+                       R_BeginPolygon(pic, drawflag);
+                               v = centre;                     t = '0.5 0.5 0';
+                               R_PolygonVertex(v, t, rgb, a);
+
+                               v = centre;                     t = '0.5 0.5 0';
+                               v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
+                               R_PolygonVertex(v, t, rgb, a);
+               }
+       }
+
+       if(d > 0)
+       {
+                       v = centre;                     t = '0.5 0.5 0';
+                       v_x += x * 0.5 * ringsize_x;    t += x * '0.5 0.5 0';
+                       v_y += y * 0.5 * ringsize_y;    t += y * '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+               R_EndPolygon();
+       }
+}
index 5ebeb54659e4ba7e936c0666077f967fa5cd22b5..ddd24ed6bc887322941d6503ab314f0f9a0b7ab4 100644 (file)
@@ -61,6 +61,7 @@ const float TE_CSQC_NOTIFY = 112;
 const float TE_CSQC_WEAPONCOMPLAIN = 113;
 const float TE_CSQC_CAMPINGRIFLE_SCOPE = 115;
 const float TE_CSQC_NEX_SCOPE = 116;
+const float TE_CSQC_NEX_VELOCITY = 117;
 
 const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
 const float RACE_NET_CHECKPOINT_CLEAR = 1;
index c269ce50288ff4c6969aa51f4d795b674aae595a..d5ffae1e50d33f416fa9d05a30185107eb183e2b 100644 (file)
@@ -6,6 +6,14 @@ void send_CSQC_teamnagger() {
        WriteByte(0, TE_CSQC_TEAMNAGGER);
 }
 
+void send_CSQC_nexvelocity(entity e) {
+       msg_entity = e;
+       WriteByte(MSG_ONE, SVC_TEMPENTITY);
+       WriteByte(MSG_ONE, TE_CSQC_NEX_VELOCITY);
+       WriteShort(MSG_ONE, cvar("g_balance_nex_velocitydependent_minspeed"));
+       WriteShort(MSG_ONE, cvar("g_balance_nex_velocitydependent_maxspeed"));
+}
+
 void Announce(string snd) {
        WriteByte(MSG_ALL, SVC_TEMPENTITY);
        WriteByte(MSG_ALL, TE_CSQC_ANNOUNCE);
@@ -1598,6 +1606,8 @@ void ClientConnect (void)
        else if(cvar("sv_teamnagger") && !(cvar("bot_vs_human") && (c3==-1 && c4==-1)) && !g_ca) // teamnagger is currently bad for ca
                send_CSQC_teamnagger();
 
+       send_CSQC_nexvelocity(self);
+
        CheatInitClient();
 }