10 void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float alpha, float drawflag)
12 // I want to draw a quad...
13 // from and to are MIDPOINTS.
15 vector axis, thickdir, A, B, C, D;
18 axis = normalize(to - from);
19 length_tex = aspect * vlen(to - from) / thickness;
21 // direction is perpendicular to the view normal, and perpendicular to the axis
22 thickdir = normalize(cross(axis, view_origin - from));
25 print("from ", vtos(from), "\n");
26 print("to ", vtos(to), "\n");
27 print("org ", vtos(view_origin), "\n");
28 print("dir ", vtos(thickdir), "\n");
31 A = from - thickdir * (thickness / 2);
32 B = from + thickdir * (thickness / 2);
33 C = to + thickdir * (thickness / 2);
34 D = to - thickdir * (thickness / 2);
36 R_BeginPolygon(texture, drawflag);
37 R_PolygonVertex(A, '0 0 0' + shift * '1 0 0', rgb, alpha);
38 R_PolygonVertex(B, '0 1 0' + shift * '1 0 0', rgb, alpha);
39 R_PolygonVertex(C, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
40 R_PolygonVertex(D, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
44 string Draw_GrapplingHook_trace_callback_tex;
45 float Draw_GrapplingHook_trace_callback_rnd;
46 void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
48 Draw_CylindricLine(hit, start, 8, Draw_GrapplingHook_trace_callback_tex, 0.25, Draw_GrapplingHook_trace_callback_rnd, '1 1 1', 1, DRAWFLAG_NORMAL);
49 Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
52 void Draw_GrapplingHook()
61 if(time < self.HookKillTime)
63 s = cvar("cl_gunalign");
64 if(s != 1 && s != 2 && s != 4)
65 s = 3; // default value
67 vs = hook_shotorigin[s];
69 if(self.sv_entnum == player_localentnum - 1)
70 a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z;
75 t = GetPlayerColorForce(self.sv_entnum);
79 tex = "particles/hook_red";
82 else if(t == COLOR_TEAM2)
84 tex = "particles/hook_blue";
87 else if(t == COLOR_TEAM3)
89 tex = "particles/hook_yellow";
92 else if(t == COLOR_TEAM4)
94 tex = "particles/hook_pink";
99 tex = "particles/hook_green";
103 Draw_GrapplingHook_trace_callback_tex = tex;
104 Draw_GrapplingHook_trace_callback_rnd = random();
105 WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NOMONSTERS, world, world, Draw_GrapplingHook_trace_callback);
106 Draw_GrapplingHook_trace_callback_tex = string_null;
109 if(time < self.LGBeamKillTime)
111 s = cvar("cl_gunalign");
112 if(s != 1 && s != 2 && s != 4)
113 s = 3; // default value
115 vs = electro_shotorigin[s];
117 if(self.sv_entnum == player_localentnum - 1)
119 b = view_origin + view_forward * MAX_SHOT_DISTANCE;
120 WarpZone_TraceLine(view_origin, b, MOVE_NORMAL, world);
121 a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z;
125 a = self.LGBeamStart;
129 tex = "particles/lgbeam";
132 Draw_GrapplingHook_trace_callback_tex = tex;
133 Draw_GrapplingHook_trace_callback_rnd = random();
134 WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NORMAL, world, world, Draw_GrapplingHook_trace_callback);
135 Draw_GrapplingHook_trace_callback_tex = string_null;
141 if(time < self.LGBeamKillTime && !self.LGBeamSilent)
143 if(!self.LGBeamSound)
145 sound (self, CHAN_PROJECTILE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTN_NORM);
146 self.LGBeamSound = 1;
153 sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
154 self.LGBeamSound = 0;
159 void Net_GrapplingHook()
170 start_x = ReadCoord();
171 start_y = ReadCoord();
172 start_z = ReadCoord();
174 if(i <= 0 || i >= 256) // not owned by a client
185 p.HookKillTime = time + 0.1;
188 p.draw = Draw_GrapplingHook;
190 case 1: // electro lgbeam
191 p.LGBeamKillTime = time + 0.1;
192 p.LGBeamStart = start;
195 p.draw = Draw_GrapplingHook;
197 case 2: // silent electro lgbeam
198 p.LGBeamKillTime = time + 0.1;
199 p.LGBeamStart = start;
202 p.draw = Draw_GrapplingHook;
209 precache_sound("weapons/lgbeam_fly.wav");