9 .vector GauntletBeamStart;
10 .vector GauntletBeamEnd;
11 .float GauntletBeamKillTime;
12 .float GauntletBeamSound;
13 .float GauntletBeamSilent;
16 void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float alpha, float drawflag)
18 // I want to draw a quad...
19 // from and to are MIDPOINTS.
21 vector axis, thickdir, A, B, C, D;
24 axis = normalize(to - from);
25 length_tex = aspect * vlen(to - from) / thickness;
27 // direction is perpendicular to the view normal, and perpendicular to the axis
28 thickdir = normalize(cross(axis, view_origin - from));
31 print("from ", vtos(from), "\n");
32 print("to ", vtos(to), "\n");
33 print("org ", vtos(view_origin), "\n");
34 print("dir ", vtos(thickdir), "\n");
37 A = from - thickdir * (thickness / 2);
38 B = from + thickdir * (thickness / 2);
39 C = to + thickdir * (thickness / 2);
40 D = to - thickdir * (thickness / 2);
42 R_BeginPolygon(texture, drawflag);
43 R_PolygonVertex(A, '0 0 0' + shift * '1 0 0', rgb, alpha);
44 R_PolygonVertex(B, '0 1 0' + shift * '1 0 0', rgb, alpha);
45 R_PolygonVertex(C, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
46 R_PolygonVertex(D, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
50 string Draw_GrapplingHook_trace_callback_tex;
51 float Draw_GrapplingHook_trace_callback_rnd;
52 void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
54 Draw_CylindricLine(hit, start, 8, Draw_GrapplingHook_trace_callback_tex, 0.25, Draw_GrapplingHook_trace_callback_rnd, '1 1 1', 1, DRAWFLAG_NORMAL);
55 Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
58 void Draw_GrapplingHook()
67 if(time < self.HookKillTime)
69 s = cvar("cl_gunalign");
70 if(s != 1 && s != 2 && s != 4)
71 s = 3; // default value
73 vs = hook_shotorigin[s];
75 if(self.sv_entnum == player_localentnum - 1)
76 a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z;
81 t = GetPlayerColorForce(self.sv_entnum);
85 tex = "particles/hook_red";
88 else if(t == COLOR_TEAM2)
90 tex = "particles/hook_blue";
93 else if(t == COLOR_TEAM3)
95 tex = "particles/hook_yellow";
98 else if(t == COLOR_TEAM4)
100 tex = "particles/hook_pink";
105 tex = "particles/hook_green";
109 Draw_GrapplingHook_trace_callback_tex = tex;
110 Draw_GrapplingHook_trace_callback_rnd = random();
111 WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NOMONSTERS, world, world, Draw_GrapplingHook_trace_callback);
112 Draw_GrapplingHook_trace_callback_tex = string_null;
115 if(time < self.LGBeamKillTime)
117 s = cvar("cl_gunalign");
118 if(s != 1 && s != 2 && s != 4)
119 s = 3; // default value
121 vs = electro_shotorigin[s];
123 if(self.sv_entnum == player_localentnum - 1)
125 b = view_origin + view_forward * MAX_SHOT_DISTANCE;
126 WarpZone_TraceLine(view_origin, b, MOVE_NORMAL, world);
127 a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z;
131 a = self.LGBeamStart;
135 tex = "particles/lgbeam";
138 Draw_GrapplingHook_trace_callback_tex = tex;
139 Draw_GrapplingHook_trace_callback_rnd = random();
140 WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NORMAL, world, world, Draw_GrapplingHook_trace_callback);
141 Draw_GrapplingHook_trace_callback_tex = string_null;
147 if(time < self.GauntletBeamKillTime)
149 s = cvar("cl_gunalign");
150 if(s != 1 && s != 2 && s != 4)
151 s = 3; // default value
153 vs = gauntlet_shotorigin[s];
155 if(self.sv_entnum == player_localentnum - 1)
157 b = view_origin + view_forward * MAX_SHOT_DISTANCE;
158 WarpZone_TraceLine(view_origin, b, MOVE_NORMAL, world);
159 a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z;
163 a = self.GauntletBeamStart;
164 b = self.GauntletBeamEnd;
167 tex = "particles/gauntletbeam";
170 Draw_GrapplingHook_trace_callback_tex = tex;
171 Draw_GrapplingHook_trace_callback_rnd = random();
172 WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NORMAL, world, world, Draw_GrapplingHook_trace_callback);
173 Draw_GrapplingHook_trace_callback_tex = string_null;
179 if(time < self.LGBeamKillTime && !self.LGBeamSilent)
181 if(!self.LGBeamSound)
183 sound (self, CHAN_PROJECTILE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTN_NORM);
184 self.LGBeamSound = 1;
191 sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
192 self.LGBeamSound = 0;
196 if(time < self.GauntletBeamKillTime && !self.GauntletBeamSilent)
198 if(!self.GauntletBeamSound)
200 sound (self, CHAN_PROJECTILE, "weapons/gauntletbeam_fly.wav", VOL_BASE, ATTN_NORM);
201 self.GauntletBeamSound = 1;
206 if(self.GauntletBeamSound)
208 sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
209 self.GauntletBeamSound = 0;
214 void Net_GrapplingHook()
225 start_x = ReadCoord();
226 start_y = ReadCoord();
227 start_z = ReadCoord();
229 if(i <= 0 || i >= 256) // not owned by a client
240 p.HookKillTime = time + 0.1;
243 p.draw = Draw_GrapplingHook;
245 case 1: // electro lgbeam
246 p.LGBeamKillTime = time + 0.1;
247 p.LGBeamStart = start;
250 p.draw = Draw_GrapplingHook;
252 case 2: // silent electro lgbeam
253 p.LGBeamKillTime = time + 0.1;
254 p.LGBeamStart = start;
257 p.draw = Draw_GrapplingHook;
259 case 3: // gauntlet beam
260 p.GauntletBeamKillTime = time + 0.1;
261 p.GauntletBeamStart = start;
262 p.GauntletBeamEnd = end;
263 p.GauntletBeamSilent = 0;
264 p.draw = Draw_GrapplingHook;
271 precache_sound("weapons/lgbeam_fly.wav");
272 precache_sound("weapons/gauntletbeam_fly.wav");