X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fhook.qc;h=06858d597aa917a126e1e46cc50354458973afa0;hp=e30b7d905d4729cc18032e829d9eb4119bebaf7b;hb=02bf8667ee9686ba129b305a263fcd704bb1d8c1;hpb=591308c7b3ef684394fb6cade9931d9c7107560c diff --git a/qcsrc/client/hook.qc b/qcsrc/client/hook.qc index e30b7d905d..06858d597a 100644 --- a/qcsrc/client/hook.qc +++ b/qcsrc/client/hook.qc @@ -1,13 +1,11 @@ -.vector HookStart; -.vector HookEnd; -.float HookKillTime; -.vector LGBeamStart; -.vector LGBeamEnd; -.float LGBeamKillTime; -.float LGBeamSound; -.float LGBeamSilent; - -void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float alpha, float drawflag) +.float HookType; // ENT_CLIENT_* +.vector origin; +.vector velocity; +.float HookSound; +.float HookSilent; +.float HookRange; + +void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float alpha, float drawflag, vector vieworg) { // I want to draw a quad... // from and to are MIDPOINTS. @@ -19,7 +17,7 @@ void Draw_CylindricLine(vector from, vector to, float thickness, string texture, length_tex = aspect * vlen(to - from) / thickness; // direction is perpendicular to the view normal, and perpendicular to the axis - thickdir = normalize(cross(axis, view_origin - from)); + thickdir = normalize(cross(axis, vieworg - from)); /* print("from ", vtos(from), "\n"); @@ -43,140 +41,246 @@ void Draw_CylindricLine(vector from, vector to, float thickness, string texture, string Draw_GrapplingHook_trace_callback_tex; float Draw_GrapplingHook_trace_callback_rnd; +vector Draw_GrapplingHook_trace_callback_rgb; +float Draw_GrapplingHook_trace_callback_a; void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end) { - Draw_CylindricLine(hit, start, 8, Draw_GrapplingHook_trace_callback_tex, 0.25, Draw_GrapplingHook_trace_callback_rnd, '1 1 1', 1, DRAWFLAG_NORMAL); + float i; + vector vorg; + vorg = WarpZone_TransformOrigin(WarpZone_trace_transform, view_origin); + for(i = 0; i < Draw_GrapplingHook_trace_callback_a; ++i) + Draw_CylindricLine(hit, start, 8, Draw_GrapplingHook_trace_callback_tex, 0.25, Draw_GrapplingHook_trace_callback_rnd, Draw_GrapplingHook_trace_callback_rgb, min(1, Draw_GrapplingHook_trace_callback_a - i), DRAWFLAG_NORMAL, vorg); Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8; } void Draw_GrapplingHook() { - vector a, b; - string tex; + vector a, b, atrans; + string tex, snd; vector rgb; float t; + float s; + vector vs; + float intensity, offset; - if(time < self.HookKillTime) - { - if(self.sv_entnum == player_localentnum - 1) - a = view_origin + view_forward * hook_shotorigin_x + view_right * hook_shotorigin_y + view_up * hook_shotorigin_z; - else - a = self.HookStart; - b = self.HookEnd; + InterpolateOrigin_Do(); - t = GetPlayerColorForce(self.sv_entnum); + s = cvar("cl_gunalign"); + if(s != 1 && s != 2 && s != 4) + s = 3; // default value + --s; + switch(self.HookType) + { + default: + case ENT_CLIENT_HOOK: + vs = hook_shotorigin[s]; + break; + case ENT_CLIENT_LGBEAM: + vs = electro_shotorigin[s]; + break; + case ENT_CLIENT_GAUNTLET: + vs = gauntlet_shotorigin[s]; + break; + } - if(t == COLOR_TEAM1) - { - tex = "particles/hook_red"; - rgb = '1 .3 .3'; - } - else if(t == COLOR_TEAM2) - { - tex = "particles/hook_blue"; - rgb = '.3 .3 1'; - } - else if(t == COLOR_TEAM3) - { - tex = "particles/hook_yellow"; - rgb = '1 1 .3'; - } - else if(t == COLOR_TEAM4) + if((self.owner.sv_entnum == player_localentnum - 1)) + { + switch(self.HookType) { - tex = "particles/hook_pink"; - rgb = '1 .3 1'; + default: + case ENT_CLIENT_HOOK: + a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z; + b = self.origin; + break; + case ENT_CLIENT_LGBEAM: + case ENT_CLIENT_GAUNTLET: + if(self.HookRange) + b = view_origin + view_forward * self.HookRange; + else + b = view_origin + view_forward * vlen(self.velocity - self.origin); // honor original length of beam! + WarpZone_TraceLine(view_origin, b, MOVE_NORMAL, world); + b = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos); + a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z; + break; } - else + } + else + { + switch(self.HookType) { - tex = "particles/hook_green"; - rgb = '.3 1 .3'; + default: + case ENT_CLIENT_HOOK: + a = self.velocity; + b = self.origin; + break; + case ENT_CLIENT_LGBEAM: + case ENT_CLIENT_GAUNTLET: + a = self.origin; + b = self.velocity; + break; } + } + + t = GetPlayerColorForce(self.owner.sv_entnum); + + switch(self.HookType) + { + default: + case ENT_CLIENT_HOOK: + intensity = 1; + offset = 0; + if(t == COLOR_TEAM1) + { + tex = "particles/hook_red"; + rgb = '1 .3 .3'; + } + else if(t == COLOR_TEAM2) + { + tex = "particles/hook_blue"; + rgb = '.3 .3 1'; + } + else if(t == COLOR_TEAM3) + { + tex = "particles/hook_yellow"; + rgb = '1 1 .3'; + } + else if(t == COLOR_TEAM4) + { + tex = "particles/hook_pink"; + rgb = '1 .3 1'; + } + else + { + tex = "particles/hook_green"; + rgb = '.3 1 .3'; + } + break; + case ENT_CLIENT_LGBEAM: + intensity = bound(0.2, 1 + Noise_Pink(self, frametime) * 1 + Noise_Burst(self, frametime, 0.03) * 0.3, 2); + offset = Noise_Brown(self, frametime) * 10; + tex = "particles/lgbeam"; + rgb = '1 1 1'; + break; + case ENT_CLIENT_GAUNTLET: + intensity = 1; + offset = Noise_White(self, frametime); + tex = "particles/gauntletbeam"; + rgb = '1 1 1'; + break; + } - Draw_GrapplingHook_trace_callback_tex = tex; - Draw_GrapplingHook_trace_callback_rnd = random(); - WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NOMONSTERS, world, world, Draw_GrapplingHook_trace_callback); - Draw_GrapplingHook_trace_callback_tex = string_null; + Draw_GrapplingHook_trace_callback_tex = tex; + Draw_GrapplingHook_trace_callback_rnd = offset; + Draw_GrapplingHook_trace_callback_rgb = rgb; + Draw_GrapplingHook_trace_callback_a = intensity; + 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); + Draw_GrapplingHook_trace_callback_tex = string_null; + + atrans = WarpZone_TransformOrigin(WarpZone_trace_transform, a); + + switch(self.HookType) + { + default: + case ENT_CLIENT_HOOK: + setorigin(self, trace_endpos); // hook endpoint! + self.angles = vectoangles(trace_endpos - atrans); + break; + case ENT_CLIENT_LGBEAM: + case ENT_CLIENT_GAUNTLET: + setorigin(self, a); // beam origin! + break; } - if(time < self.LGBeamKillTime) + switch(self.HookType) { - if(self.sv_entnum == player_localentnum - 1) - a = view_origin + view_forward * electro_shotorigin_x + view_right * electro_shotorigin_y + view_up * electro_shotorigin_z; - else - a = self.LGBeamStart; - b = self.LGBeamEnd; - - tex = "particles/lgbeam"; - rgb = '1 1 1'; - - Draw_GrapplingHook_trace_callback_tex = tex; - Draw_GrapplingHook_trace_callback_rnd = random(); - WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NOMONSTERS, world, world, Draw_GrapplingHook_trace_callback); - Draw_GrapplingHook_trace_callback_tex = string_null; + default: + case ENT_CLIENT_HOOK: + break; + case ENT_CLIENT_LGBEAM: + pointparticles(particleeffectnum("electro_lightning"), trace_endpos, normalize(atrans - trace_endpos), frametime * intensity); + break; + case ENT_CLIENT_GAUNTLET: + pointparticles(particleeffectnum("gauntlet_lightning"), b, normalize(a - b), frametime * intensity); + break; } +} + +void Remove_GrapplingHook() +{ + sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM); +} + +void Ent_ReadHook(float bIsNew, float type) +{ + self.HookType = type; + + float sf; + sf = ReadByte(); + + self.HookSilent = (sf & 0x80); + self.iflags = IFLAG_VELOCITY; + + InterpolateOrigin_Undo(); - if(time < self.LGBeamKillTime && !self.LGBeamSilent) + if(sf & 1) { - if(!self.LGBeamSound) + self.owner = playerslots[ReadByte() - 1]; + switch(self.HookType) { - sound (self, CHAN_PROJECTILE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTN_NORM); - self.LGBeamSound = 1; + default: + case ENT_CLIENT_HOOK: + case ENT_CLIENT_GAUNTLET: + self.HookRange = 0; + break; + case ENT_CLIENT_LGBEAM: + self.HookRange = ReadCoord(); + break; } } - else + if(sf & 2) + { + self.origin_x = ReadCoord(); + self.origin_y = ReadCoord(); + self.origin_z = ReadCoord(); + setorigin(self, self.origin); + } + if(sf & 4) + { + self.velocity_x = ReadCoord(); + self.velocity_y = ReadCoord(); + self.velocity_z = ReadCoord(); + } + + InterpolateOrigin_Note(); + + if(bIsNew) { - if(self.LGBeamSound) + self.draw = Draw_GrapplingHook; + self.entremove = Remove_GrapplingHook; + + switch(self.HookType) { - sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM); - self.LGBeamSound = 0; + default: + case ENT_CLIENT_HOOK: + // for the model + setmodel(self, "models/hook.md3"); + self.drawmask = MASK_NORMAL; + break; + case ENT_CLIENT_LGBEAM: + sound (self, CHAN_PROJECTILE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTN_NORM); + break; + case ENT_CLIENT_GAUNTLET: + sound (self, CHAN_PROJECTILE, "weapons/gauntletbeam_fly.wav", VOL_BASE, ATTN_NORM); + break; } } } -void Net_GrapplingHook() +void Hook_Precache() { - float i, t; - vector start, end; - entity p; - - i = ReadByte(); - t = ReadByte(); - end_x = ReadCoord(); - end_y = ReadCoord(); - end_z = ReadCoord(); - start_x = ReadCoord(); - start_y = ReadCoord(); - start_z = ReadCoord(); - - if(i <= 0 || i >= 256) // not owned by a client - return; - --i; - - p = playerslots[i]; - if(!p) - return; - - switch(t) - { - case 0: // hook beam - p.HookKillTime = time + 0.1; - p.HookStart = start; - p.HookEnd = end; - p.draw = Draw_GrapplingHook; - break; - case 1: // electro lgbeam - p.LGBeamKillTime = time + 0.1; - p.LGBeamStart = start; - p.LGBeamEnd = end; - p.LGBeamSilent = 0; - p.draw = Draw_GrapplingHook; - break; - case 2: // silent electro lgbeam - p.LGBeamKillTime = time + 0.1; - p.LGBeamStart = start; - p.LGBeamEnd = end; - p.LGBeamSilent = 1; - p.draw = Draw_GrapplingHook; - break; - } + precache_sound("weapons/lgbeam_fly.wav"); + precache_sound("weapons/gauntletbeam_fly.wav"); + precache_model("models/hook.md3"); } + +// TODO: hook: temporarily transform self.origin for drawing the model along warpzones!