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