]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/client/hook.qc
Patch by Spaceman: Allow viewing the accuracy stats of spectated players (client...
[divverent/nexuiz.git] / data / qcsrc / client / hook.qc
1 .vector HookStart;
2 .vector HookEnd;
3 .float HookKillTime;
4
5 void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float alpha, float drawflag)
6 {
7         // I want to draw a quad...
8         // from and to are MIDPOINTS.
9         
10         vector axis, thickdir, A, B, C, D;
11         float length_tex;
12
13         axis = normalize(to - from);
14         length_tex = aspect * vlen(to - from) / thickness;
15
16         // direction is perpendicular to the view normal, and perpendicular to the axis
17         thickdir = normalize(cross(axis, view_origin - from));
18
19         A = from - thickdir * (thickness / 2);
20         B = from + thickdir * (thickness / 2);
21         C = to + thickdir * (thickness / 2);
22         D = to - thickdir * (thickness / 2);
23
24         R_BeginPolygon(texture, drawflag);
25         R_PolygonVertex(A, '0 0 0' + shift * '1 0 0', rgb, alpha);
26         R_PolygonVertex(B, '0 1 0' + shift * '1 0 0', rgb, alpha);
27         R_PolygonVertex(C, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
28         R_PolygonVertex(D, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
29         R_EndPolygon();
30 }
31
32 void Draw_GrapplingHook()
33 {
34         vector a, b;
35         string tex;
36         vector rgb;
37         float t;
38
39         if(time >= self.HookKillTime)
40                 return;
41         if(self.sv_entnum == player_localentnum - 1)
42                 a = view_origin + view_forward * hook_shotorigin_x + view_right * hook_shotorigin_y + view_up * hook_shotorigin_z;
43         else
44                 a = self.HookStart;
45         b = self.HookEnd;
46
47         t = GetPlayerColorForce(self.sv_entnum);
48
49         if(t == COLOR_TEAM1)
50         {
51                 tex = "particles/hook_red";
52                 rgb = '1 .3 .3';
53         }
54         else if(t == COLOR_TEAM2)
55         {
56                 tex = "particles/hook_blue";
57                 rgb = '.3 .3 1';
58         }
59         else if(t == COLOR_TEAM3)
60         {
61                 tex = "particles/hook_yellow";
62                 rgb = '1 1 .3';
63         }
64         else if(t == COLOR_TEAM4)
65         {
66                 tex = "particles/hook_pink";
67                 rgb = '1 .3 1';
68         }
69         else
70         {
71                 tex = "particles/hook_green";
72                 rgb = '.3 1 .3';
73         }
74         Draw_CylindricLine(b, a, 8, tex, 0.25, random(), '1 1 1', 1, DRAWFLAG_NORMAL);
75 }
76
77 void Net_GrapplingHook()
78 {
79         float i;
80         vector start, end;
81         entity p;
82
83         i = ReadShort();
84         end_x = ReadCoord();
85         end_y = ReadCoord();
86         end_z = ReadCoord();
87         start_x = ReadCoord();
88         start_y = ReadCoord();
89         start_z = ReadCoord();
90
91         if(i <= 0 || i >= 256) // not owned by a client
92                 return;
93         --i;
94
95         p = playerslots[i];
96         if(!p)
97                 return;
98
99         p.HookKillTime = time + 0.1;
100         p.HookStart = start;
101         p.HookEnd = end;
102         p.draw = Draw_GrapplingHook;
103 }