5 void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float alpha, float drawflag)
7 // I want to draw a quad...
8 // from and to are MIDPOINTS.
10 vector axis, thickdir, A, B, C, D;
13 axis = normalize(to - from);
14 length_tex = aspect * vlen(to - from) / thickness;
16 // direction is perpendicular to the view normal, and perpendicular to the axis
17 thickdir = normalize(cross(axis, view_origin - from));
19 A = from - thickdir * (thickness / 2);
20 B = from + thickdir * (thickness / 2);
21 C = to + thickdir * (thickness / 2);
22 D = to - thickdir * (thickness / 2);
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);
32 string Draw_GrapplingHook_trace_callback_tex;
33 float Draw_GrapplingHook_trace_callback_rnd;
34 void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
36 Draw_CylindricLine(hit, start, 8, Draw_GrapplingHook_trace_callback_tex, 0.25, Draw_GrapplingHook_trace_callback_rnd, '1 1 1', 1, DRAWFLAG_NORMAL);
37 Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
40 void Draw_GrapplingHook()
47 if(time >= self.HookKillTime)
49 if(self.sv_entnum == player_localentnum - 1)
50 a = view_origin + view_forward * hook_shotorigin_x + view_right * hook_shotorigin_y + view_up * hook_shotorigin_z;
55 t = GetPlayerColorForce(self.sv_entnum);
59 tex = "particles/hook_red";
62 else if(t == COLOR_TEAM2)
64 tex = "particles/hook_blue";
67 else if(t == COLOR_TEAM3)
69 tex = "particles/hook_yellow";
72 else if(t == COLOR_TEAM4)
74 tex = "particles/hook_pink";
79 tex = "particles/hook_green";
83 Draw_GrapplingHook_trace_callback_tex = tex;
84 Draw_GrapplingHook_trace_callback_rnd = random();
85 WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NOMONSTERS, world, world, Draw_GrapplingHook_trace_callback);
86 Draw_GrapplingHook_trace_callback_tex = string_null;
89 void Net_GrapplingHook()
99 start_x = ReadCoord();
100 start_y = ReadCoord();
101 start_z = ReadCoord();
103 if(i <= 0 || i >= 256) // not owned by a client
111 p.HookKillTime = time + 0.1;
114 p.draw = Draw_GrapplingHook;