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()
59 if(time < self.HookKillTime)
61 if(self.sv_entnum == player_localentnum - 1)
62 a = view_origin + view_forward * hook_shotorigin_x + view_right * hook_shotorigin_y + view_up * hook_shotorigin_z;
67 t = GetPlayerColorForce(self.sv_entnum);
71 tex = "particles/hook_red";
74 else if(t == COLOR_TEAM2)
76 tex = "particles/hook_blue";
79 else if(t == COLOR_TEAM3)
81 tex = "particles/hook_yellow";
84 else if(t == COLOR_TEAM4)
86 tex = "particles/hook_pink";
91 tex = "particles/hook_green";
95 Draw_GrapplingHook_trace_callback_tex = tex;
96 Draw_GrapplingHook_trace_callback_rnd = random();
97 WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NOMONSTERS, world, world, Draw_GrapplingHook_trace_callback);
98 Draw_GrapplingHook_trace_callback_tex = string_null;
101 if(time < self.LGBeamKillTime)
103 if(self.sv_entnum == player_localentnum - 1)
104 a = view_origin + view_forward * electro_shotorigin_x + view_right * electro_shotorigin_y + view_up * electro_shotorigin_z;
106 a = self.LGBeamStart;
109 tex = "particles/lgbeam";
112 Draw_GrapplingHook_trace_callback_tex = tex;
113 Draw_GrapplingHook_trace_callback_rnd = random();
114 WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NOMONSTERS, world, world, Draw_GrapplingHook_trace_callback);
115 Draw_GrapplingHook_trace_callback_tex = string_null;
118 if(time < self.LGBeamKillTime && !self.LGBeamSilent)
120 if(!self.LGBeamSound)
122 sound (self, CHAN_PROJECTILE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTN_NORM);
123 self.LGBeamSound = 1;
130 sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
131 self.LGBeamSound = 0;
136 void Net_GrapplingHook()
147 start_x = ReadCoord();
148 start_y = ReadCoord();
149 start_z = ReadCoord();
151 if(i <= 0 || i >= 256) // not owned by a client
162 p.HookKillTime = time + 0.1;
165 p.draw = Draw_GrapplingHook;
167 case 1: // electro lgbeam
168 p.LGBeamKillTime = time + 0.1;
169 p.LGBeamStart = start;
172 p.draw = Draw_GrapplingHook;
174 case 2: // silent electro lgbeam
175 p.LGBeamKillTime = time + 0.1;
176 p.LGBeamStart = start;
179 p.draw = Draw_GrapplingHook;