]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
hook: move to common
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 24 Dec 2015 09:24:59 +0000 (20:24 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 24 Dec 2015 09:24:59 +0000 (20:24 +1100)
qcsrc/client/hook.qc [deleted file]
qcsrc/client/hook.qh [deleted file]
qcsrc/client/main.qc
qcsrc/client/progs.inc
qcsrc/client/view.qc
qcsrc/common/weapons/weapon/hook.qc

diff --git a/qcsrc/client/hook.qc b/qcsrc/client/hook.qc
deleted file mode 100644 (file)
index 818e737..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-#include "hook.qh"
-
-#include "../lib/csqcmodel/interpolate.qh"
-#include "../lib/warpzone/common.qh"
-
-entityclass(Hook);
-class(Hook) .entity HookType; // ENT_CLIENT_*
-class(Hook) .vector origin;
-class(Hook) .vector velocity;
-class(Hook) .float HookSilent;
-class(Hook) .float HookRange;
-
-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)
-{
-       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;
-}
-
-class(Hook) .float teleport_time;
-void Draw_GrapplingHook(entity this)
-{
-       vector a, b, atrans;
-       string tex;
-       vector rgb;
-       float t;
-       vector vs;
-       float intensity, offset;
-
-       if(self.teleport_time)
-       if(time > self.teleport_time)
-       {
-               sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); // safeguard
-               self.teleport_time = 0;
-       }
-
-       InterpolateOrigin_Do(this);
-
-       int s = W_GetGunAlignment(world);
-
-       switch(self.HookType)
-       {
-               default:
-               case NET_ENT_CLIENT_HOOK:
-                       vs = hook_shotorigin[s];
-                       break;
-               case NET_ENT_CLIENT_ARC_BEAM:
-                       vs = lightning_shotorigin[s];
-                       break;
-       }
-
-       if((self.owner.sv_entnum == player_localentnum - 1) && autocvar_chase_active <= 0)
-       {
-               switch(self.HookType)
-               {
-                       default:
-                       case NET_ENT_CLIENT_HOOK:
-                               a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z;
-                               b = self.origin;
-                               break;
-                       case NET_ENT_CLIENT_ARC_BEAM:
-                               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
-       {
-               switch(self.HookType)
-               {
-                       default:
-                       case NET_ENT_CLIENT_HOOK:
-                               a = self.velocity;
-                               b = self.origin;
-                               break;
-                       case NET_ENT_CLIENT_ARC_BEAM:
-                               a = self.origin;
-                               b = self.velocity;
-                               break;
-               }
-       }
-
-       t = entcs_GetTeamColor(self.owner.sv_entnum);
-
-       switch(self.HookType)
-       {
-               default:
-               case NET_ENT_CLIENT_HOOK:
-                       intensity = 1;
-                       offset = 0;
-                       switch(t)
-                       {
-                               case NUM_TEAM_1: tex = "particles/hook_red"; rgb = '1 0.3 0.3'; break;
-                               case NUM_TEAM_2: tex = "particles/hook_blue"; rgb = '0.3 0.3 1'; break;
-                               case NUM_TEAM_3: tex = "particles/hook_yellow"; rgb = '1 1 0.3'; break;
-                               case NUM_TEAM_4: tex = "particles/hook_pink"; rgb = '1 0.3 1'; break;
-                               default: tex = "particles/hook_white"; rgb = entcs_GetColor(self.sv_entnum - 1); break;
-                       }
-                       break;
-               case NET_ENT_CLIENT_ARC_BEAM: // todo
-                       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;
-       }
-
-       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 == NET_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 NET_ENT_CLIENT_HOOK:
-                       if(vlen(trace_endpos - atrans) > 0.5)
-                       {
-                               setorigin(self, trace_endpos); // hook endpoint!
-                               self.angles = vectoangles(trace_endpos - atrans);
-                               self.drawmask = MASK_NORMAL;
-                       }
-                       else
-                       {
-                               self.drawmask = 0;
-                       }
-                       break;
-               case NET_ENT_CLIENT_ARC_BEAM:
-                       setorigin(self, a); // beam origin!
-                       break;
-       }
-
-       switch(self.HookType)
-       {
-               default:
-               case NET_ENT_CLIENT_HOOK:
-                       break;
-               case NET_ENT_CLIENT_ARC_BEAM:
-                       pointparticles(EFFECT_ARC_LIGHTNING2, trace_endpos, normalize(atrans - trace_endpos), frametime * intensity); // todo: new effect
-                       break;
-       }
-}
-
-void Remove_GrapplingHook()
-{SELFPARAM();
-       sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
-}
-
-NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew)
-{
-       self.HookType = NET_ENT_CLIENT_HOOK;
-
-       int sf = ReadByte();
-
-       self.HookSilent = (sf & 0x80);
-       self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
-
-       InterpolateOrigin_Undo(self);
-
-       if(sf & 1)
-       {
-               int myowner = ReadByte();
-               self.owner = playerslots[myowner - 1];
-               self.sv_entnum = myowner;
-               switch(self.HookType)
-               {
-                       default:
-                       case NET_ENT_CLIENT_HOOK:
-                               self.HookRange = 0;
-                               break;
-                       case NET_ENT_CLIENT_ARC_BEAM:
-                               self.HookRange = ReadCoord();
-                               break;
-               }
-       }
-       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(this);
-
-       if(bIsNew || !self.teleport_time)
-       {
-               self.draw = Draw_GrapplingHook;
-               self.entremove = Remove_GrapplingHook;
-
-               switch(self.HookType)
-               {
-                       default:
-                       case NET_ENT_CLIENT_HOOK:
-                               // for the model
-                               setmodel(self, MDL_HOOK);
-                               self.drawmask = MASK_NORMAL;
-                               break;
-                       case NET_ENT_CLIENT_ARC_BEAM:
-                               sound (self, CH_SHOTS_SINGLE, SND_LGBEAM_FLY, VOL_BASE, ATTEN_NORM);
-                               break;
-               }
-       }
-
-       self.teleport_time = time + 10;
-       return true;
-}
-
-// TODO: hook: temporarily transform self.origin for drawing the model along warpzones!
diff --git a/qcsrc/client/hook.qh b/qcsrc/client/hook.qh
deleted file mode 100644 (file)
index 3662425..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef CLIENT_HOOK_H
-#define CLIENT_HOOK_H
-
-void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg);
-
-#endif
index fad35276cda39659ed8e34c0361f4cf1f32704e4..2665f4ed1b8bb28cc453aa0e8bd99480fde78144 100644 (file)
@@ -1,7 +1,6 @@
 #include "main.qh"
 
 #include "../common/effects/qc/all.qh"
-#include "hook.qh"
 #include "hud/all.qh"
 #include "mapvoting.qh"
 #include "mutators/events.qh"
index 0f95ad580395c9d17dc16c46375cf4fcc73fbefb..ca0078cdb8c50fdc75d7b3ed196944f516819cac 100644 (file)
@@ -6,7 +6,6 @@
 #include "announcer.qc"
 #include "bgmscript.qc"
 #include "csqcmodel_hooks.qc"
-#include "hook.qc"
 #include "hud/all.qc"
 #include "main.qc"
 #include "mapvoting.qc"
index cdeb247e77a412b2ac5c4ddea89a849118a10ab0..3d6af6f2caf164d8fe0e41950bbe8426186b15e3 100644 (file)
@@ -1,6 +1,5 @@
 
 #include "announcer.qh"
-#include "hook.qh"
 #include "hud/all.qh"
 #include "mapvoting.qh"
 #include "scoreboard.qh"
index a8a76cfd6e5783056a0760bb401a3586bcb95ff0..216a82074f391048f50b2a4cbca05ef51f71b3af 100644 (file)
@@ -317,4 +317,239 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
                }
 
 #endif
+
+#ifdef CSQC
+#include "../../../lib/csqcmodel/interpolate.qh"
+#include "../../../lib/warpzone/common.qh"
+
+void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg);
+
+entityclass(Hook);
+class(Hook) .entity HookType; // ENT_CLIENT_*
+class(Hook) .vector origin;
+class(Hook) .vector velocity;
+class(Hook) .float HookSilent;
+class(Hook) .float HookRange;
+
+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)
+{
+       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;
+}
+
+class(Hook) .float teleport_time;
+void Draw_GrapplingHook(entity this)
+{
+       vector a, b, atrans;
+       string tex;
+       vector rgb;
+       float t;
+       vector vs;
+       float intensity, offset;
+
+       if(self.teleport_time)
+       if(time > self.teleport_time)
+       {
+               sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); // safeguard
+               self.teleport_time = 0;
+       }
+
+       InterpolateOrigin_Do(this);
+
+       int s = W_GetGunAlignment(world);
+
+       switch(self.HookType)
+       {
+               default:
+               case NET_ENT_CLIENT_HOOK:
+                       vs = hook_shotorigin[s];
+                       break;
+               case NET_ENT_CLIENT_ARC_BEAM:
+                       vs = lightning_shotorigin[s];
+                       break;
+       }
+
+       if((self.owner.sv_entnum == player_localentnum - 1) && autocvar_chase_active <= 0)
+       {
+               switch(self.HookType)
+               {
+                       default:
+                       case NET_ENT_CLIENT_HOOK:
+                               a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z;
+                               b = self.origin;
+                               break;
+                       case NET_ENT_CLIENT_ARC_BEAM:
+                               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
+       {
+               switch(self.HookType)
+               {
+                       default:
+                       case NET_ENT_CLIENT_HOOK:
+                               a = self.velocity;
+                               b = self.origin;
+                               break;
+                       case NET_ENT_CLIENT_ARC_BEAM:
+                               a = self.origin;
+                               b = self.velocity;
+                               break;
+               }
+       }
+
+       t = entcs_GetTeamColor(self.owner.sv_entnum);
+
+       switch(self.HookType)
+       {
+               default:
+               case NET_ENT_CLIENT_HOOK:
+                       intensity = 1;
+                       offset = 0;
+                       switch(t)
+                       {
+                               case NUM_TEAM_1: tex = "particles/hook_red"; rgb = '1 0.3 0.3'; break;
+                               case NUM_TEAM_2: tex = "particles/hook_blue"; rgb = '0.3 0.3 1'; break;
+                               case NUM_TEAM_3: tex = "particles/hook_yellow"; rgb = '1 1 0.3'; break;
+                               case NUM_TEAM_4: tex = "particles/hook_pink"; rgb = '1 0.3 1'; break;
+                               default: tex = "particles/hook_white"; rgb = entcs_GetColor(self.sv_entnum - 1); break;
+                       }
+                       break;
+               case NET_ENT_CLIENT_ARC_BEAM: // todo
+                       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;
+       }
+
+       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 == NET_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 NET_ENT_CLIENT_HOOK:
+                       if(vlen(trace_endpos - atrans) > 0.5)
+                       {
+                               setorigin(self, trace_endpos); // hook endpoint!
+                               self.angles = vectoangles(trace_endpos - atrans);
+                               self.drawmask = MASK_NORMAL;
+                       }
+                       else
+                       {
+                               self.drawmask = 0;
+                       }
+                       break;
+               case NET_ENT_CLIENT_ARC_BEAM:
+                       setorigin(self, a); // beam origin!
+                       break;
+       }
+
+       switch(self.HookType)
+       {
+               default:
+               case NET_ENT_CLIENT_HOOK:
+                       break;
+               case NET_ENT_CLIENT_ARC_BEAM:
+                       pointparticles(EFFECT_ARC_LIGHTNING2, trace_endpos, normalize(atrans - trace_endpos), frametime * intensity); // todo: new effect
+                       break;
+       }
+}
+
+void Remove_GrapplingHook()
+{SELFPARAM();
+       sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
+}
+
+NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew)
+{
+       self.HookType = NET_ENT_CLIENT_HOOK;
+
+       int sf = ReadByte();
+
+       self.HookSilent = (sf & 0x80);
+       self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
+
+       InterpolateOrigin_Undo(self);
+
+       if(sf & 1)
+       {
+               int myowner = ReadByte();
+               self.owner = playerslots[myowner - 1];
+               self.sv_entnum = myowner;
+               switch(self.HookType)
+               {
+                       default:
+                       case NET_ENT_CLIENT_HOOK:
+                               self.HookRange = 0;
+                               break;
+                       case NET_ENT_CLIENT_ARC_BEAM:
+                               self.HookRange = ReadCoord();
+                               break;
+               }
+       }
+       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(this);
+
+       if(bIsNew || !self.teleport_time)
+       {
+               self.draw = Draw_GrapplingHook;
+               self.entremove = Remove_GrapplingHook;
+
+               switch(self.HookType)
+               {
+                       default:
+                       case NET_ENT_CLIENT_HOOK:
+                               // for the model
+                               setmodel(self, MDL_HOOK);
+                               self.drawmask = MASK_NORMAL;
+                               break;
+                       case NET_ENT_CLIENT_ARC_BEAM:
+                               sound (self, CH_SHOTS_SINGLE, SND_LGBEAM_FLY, VOL_BASE, ATTEN_NORM);
+                               break;
+               }
+       }
+
+       self.teleport_time = time + 10;
+       return true;
+}
+
+// TODO: hook: temporarily transform self.origin for drawing the model along warpzones!
+#endif
+
 #endif