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));
20 print("from ", vtos(from), "\n");
21 print("to ", vtos(to), "\n");
22 print("org ", vtos(view_origin), "\n");
23 print("dir ", vtos(thickdir), "\n");
26 A = from - thickdir * (thickness / 2);
27 B = from + thickdir * (thickness / 2);
28 C = to + thickdir * (thickness / 2);
29 D = to - thickdir * (thickness / 2);
31 R_BeginPolygon(texture, drawflag);
32 R_PolygonVertex(A, '0 0 0' + shift * '1 0 0', rgb, alpha);
33 R_PolygonVertex(B, '0 1 0' + shift * '1 0 0', rgb, alpha);
34 R_PolygonVertex(C, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
35 R_PolygonVertex(D, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
39 string Draw_GrapplingHook_trace_callback_tex;
40 float Draw_GrapplingHook_trace_callback_rnd;
41 void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
43 Draw_CylindricLine(hit, start, 8, Draw_GrapplingHook_trace_callback_tex, 0.25, Draw_GrapplingHook_trace_callback_rnd, '1 1 1', 1, DRAWFLAG_NORMAL);
44 Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
47 void Draw_GrapplingHook()
54 if(time >= self.HookKillTime)
56 if(self.sv_entnum == player_localentnum - 1)
57 a = view_origin + view_forward * hook_shotorigin_x + view_right * hook_shotorigin_y + view_up * hook_shotorigin_z;
62 t = GetPlayerColorForce(self.sv_entnum);
66 tex = "particles/hook_red";
69 else if(t == COLOR_TEAM2)
71 tex = "particles/hook_blue";
74 else if(t == COLOR_TEAM3)
76 tex = "particles/hook_yellow";
79 else if(t == COLOR_TEAM4)
81 tex = "particles/hook_pink";
86 tex = "particles/hook_green";
90 Draw_GrapplingHook_trace_callback_tex = tex;
91 Draw_GrapplingHook_trace_callback_rnd = random();
92 WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NOMONSTERS, world, world, Draw_GrapplingHook_trace_callback);
93 Draw_GrapplingHook_trace_callback_tex = string_null;
96 void Net_GrapplingHook()
106 start_x = ReadCoord();
107 start_y = ReadCoord();
108 start_z = ReadCoord();
110 if(i <= 0 || i >= 256) // not owned by a client
118 p.HookKillTime = time + 0.1;
121 p.draw = Draw_GrapplingHook;