5 void Draw_GrapplingHookLine(vector from, vector to, float thickness, vector org, vector view_forward, string texture, float aspect, vector rgb)
7 // I want to draw a quad...
8 // from and to are MIDPOINTS.
11 vector axis, thickdir, A, B, C, D;
17 axis = normalize(to - from);
18 length_tex = aspect * vlen(to - from) / thickness;
20 // direction is perpendicular to the view normal, and perpendicular to the axis
21 thickdir = normalize(cross(axis, org - from));
23 A = from - thickdir * (thickness / 2);
24 B = from + thickdir * (thickness / 2);
25 C = to + thickdir * (thickness / 2);
26 D = to - thickdir * (thickness / 2);
28 R_BeginPolygon(texture, 0);
29 R_PolygonVertex(A, '0 0 0' + t * '1 0 0', rgb, 1);
30 R_PolygonVertex(B, '0 1 0' + t * '1 0 0', rgb, 1);
31 R_PolygonVertex(C, '0 1 0' + (t + length_tex) * '1 0 0', rgb, 1);
32 R_PolygonVertex(D, '0 0 0' + (t + length_tex) * '1 0 0', rgb, 1);
36 void Draw_GrapplingHook()
42 o = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
43 makevectors(input_angles);
45 if(time >= self.HookKillTime)
47 if(self.sv_entnum == player_localentnum - 1)
48 a = o + v_forward * 8 - v_right * 8 + v_up * -12;
52 if(self.team == COLOR_TEAM1)
54 tex = "particles/hook_red";
57 else if(self.team == COLOR_TEAM2)
59 tex = "particles/hook_blue";
62 else if(self.team == COLOR_TEAM3)
64 tex = "particles/hook_yellow";
67 else if(self.team == COLOR_TEAM4)
69 tex = "particles/hook_pink";
74 tex = "particles/hook_green";
77 if(checkextension("DP_SV_WRITEPICTURE"))
78 Draw_GrapplingHookLine(b, a, 8, o, v_forward, tex, 0.25, '1 1 1');
80 Draw_GrapplingHookLine(b, a, 1, o, v_forward, "", 0.25, rgb);
83 void Net_GrapplingHook()
93 start_x = ReadCoord();
94 start_y = ReadCoord();
95 start_z = ReadCoord();
97 if(i <= 0 || i >= 256) // not owned by a client
105 p.HookKillTime = time + 0.1;
108 p.draw = Draw_GrapplingHook;