1 .float HookType; // ENT_CLIENT_*
7 void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float alpha, float drawflag)
9 // I want to draw a quad...
10 // from and to are MIDPOINTS.
12 vector axis, thickdir, A, B, C, D;
15 axis = normalize(to - from);
16 length_tex = aspect * vlen(to - from) / thickness;
18 // direction is perpendicular to the view normal, and perpendicular to the axis
19 thickdir = normalize(cross(axis, view_origin - from));
22 print("from ", vtos(from), "\n");
23 print("to ", vtos(to), "\n");
24 print("org ", vtos(view_origin), "\n");
25 print("dir ", vtos(thickdir), "\n");
28 A = from - thickdir * (thickness / 2);
29 B = from + thickdir * (thickness / 2);
30 C = to + thickdir * (thickness / 2);
31 D = to - thickdir * (thickness / 2);
33 R_BeginPolygon(texture, drawflag);
34 R_PolygonVertex(A, '0 0 0' + shift * '1 0 0', rgb, alpha);
35 R_PolygonVertex(B, '0 1 0' + shift * '1 0 0', rgb, alpha);
36 R_PolygonVertex(C, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
37 R_PolygonVertex(D, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
41 string Draw_GrapplingHook_trace_callback_tex;
42 float Draw_GrapplingHook_trace_callback_rnd;
43 void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
45 Draw_CylindricLine(hit, start, 8, Draw_GrapplingHook_trace_callback_tex, 0.25, Draw_GrapplingHook_trace_callback_rnd, '1 1 1', 1, DRAWFLAG_NORMAL);
46 Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
49 void Draw_GrapplingHook()
58 InterpolateOrigin_Do();
60 s = cvar("cl_gunalign");
61 if(s != 1 && s != 2 && s != 4)
62 s = 3; // default value
68 vs = hook_shotorigin[s];
70 case ENT_CLIENT_LGBEAM:
71 vs = electro_shotorigin[s];
73 case ENT_CLIENT_GAUNTLET:
74 vs = gauntlet_shotorigin[s];
78 if((self.owner.sv_entnum == player_localentnum - 1))
84 a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z;
87 case ENT_CLIENT_LGBEAM:
88 case ENT_CLIENT_GAUNTLET:
89 b = view_origin + view_forward * vlen(self.velocity - self.origin); // honor original length of beam!
90 WarpZone_TraceLine(view_origin, b, MOVE_NORMAL, world);
91 b = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
92 a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z;
101 case ENT_CLIENT_HOOK:
105 case ENT_CLIENT_LGBEAM:
106 case ENT_CLIENT_GAUNTLET:
113 t = GetPlayerColorForce(self.owner.sv_entnum);
115 switch(self.HookType)
118 case ENT_CLIENT_HOOK:
121 tex = "particles/hook_red";
124 else if(t == COLOR_TEAM2)
126 tex = "particles/hook_blue";
129 else if(t == COLOR_TEAM3)
131 tex = "particles/hook_yellow";
134 else if(t == COLOR_TEAM4)
136 tex = "particles/hook_pink";
141 tex = "particles/hook_green";
145 case ENT_CLIENT_LGBEAM:
146 tex = "particles/lgbeam";
149 case ENT_CLIENT_GAUNTLET:
150 tex = "particles/gauntletbeam";
155 Draw_GrapplingHook_trace_callback_tex = tex;
156 Draw_GrapplingHook_trace_callback_rnd = random();
157 WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, ((self.HookType == ENT_CLIENT_HOOK) ? MOVE_NOTHING : MOVE_NORMAL), world, world, Draw_GrapplingHook_trace_callback);
158 Draw_GrapplingHook_trace_callback_tex = string_null;
160 switch(self.HookType)
163 case ENT_CLIENT_HOOK:
164 setorigin(self, trace_endpos); // hook endpoint!
165 self.angles = vectoangles(trace_endpos - WarpZone_TransformOrigin(WarpZone_trace_transform, a));
167 case ENT_CLIENT_LGBEAM:
168 case ENT_CLIENT_GAUNTLET:
169 setorigin(self, a); // beam origin!
173 switch(self.HookType)
176 case ENT_CLIENT_HOOK:
178 case ENT_CLIENT_LGBEAM:
179 pointparticles(particleeffectnum("electro_lightning"), b, normalize(a - b), frametime);
181 case ENT_CLIENT_GAUNTLET:
186 void Remove_GrapplingHook()
188 sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
191 void Ent_ReadHook(float bIsNew, float type)
193 self.HookType = type;
198 self.HookSilent = (sf & 0x80);
199 self.iflags = IFLAG_VELOCITY;
201 InterpolateOrigin_Undo();
205 self.owner = playerslots[ReadByte() - 1];
209 self.origin_x = ReadCoord();
210 self.origin_y = ReadCoord();
211 self.origin_z = ReadCoord();
212 setorigin(self, self.origin);
216 self.velocity_x = ReadCoord();
217 self.velocity_y = ReadCoord();
218 self.velocity_z = ReadCoord();
221 InterpolateOrigin_Note();
225 self.draw = Draw_GrapplingHook;
226 self.entremove = Remove_GrapplingHook;
228 switch(self.HookType)
231 case ENT_CLIENT_HOOK:
233 setmodel(self, "models/hook.md3");
234 self.drawmask = MASK_NORMAL;
236 case ENT_CLIENT_LGBEAM:
237 sound (self, CHAN_PROJECTILE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTN_NORM);
239 case ENT_CLIENT_GAUNTLET:
240 sound (self, CHAN_PROJECTILE, "weapons/gauntletbeam_fly.wav", VOL_BASE, ATTN_NORM);
248 precache_sound("weapons/lgbeam_fly.wav");
249 precache_sound("weapons/gauntletbeam_fly.wav");
250 precache_model("models/hook.md3");
253 // TODO: hook: temporarily transform self.origin for drawing the model along warpzones!