]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hook.qc
Merge remote branch 'origin/fruitiex/fruitbalance'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hook.qc
index 89dd4a6e384f2831ad2da11bd9ac12e44202ea2f..c1e8383aa6daf415356034b8b2bda1bc13193e7c 100644 (file)
@@ -3,8 +3,9 @@
 .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)
+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.
@@ -16,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");
@@ -40,20 +41,35 @@ 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;
 }
 
+.float teleport_time;
 void Draw_GrapplingHook()
 {
-       vector a, b;
+       vector a, b, atrans;
        string tex, snd;
        vector rgb;
        float t;
        float s;
        vector vs;
+       float intensity, offset;
+
+       if(self.teleport_time)
+       if(time > self.teleport_time)
+       {
+               sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM); // safeguard
+               self.teleport_time = 0;
+       }
 
        InterpolateOrigin_Do();
 
@@ -86,7 +102,10 @@ void Draw_GrapplingHook()
                                break;
                        case ENT_CLIENT_LGBEAM:
                        case ENT_CLIENT_GAUNTLET:
-                               b = view_origin + view_forward * vlen(self.velocity - self.origin); // honor original length of 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;
@@ -116,6 +135,8 @@ void Draw_GrapplingHook()
        {
                default:
                case ENT_CLIENT_HOOK:
+                       intensity = 1;
+                       offset = 0;
                        if(t == COLOR_TEAM1)
                        {
                                tex = "particles/hook_red";
@@ -143,26 +164,34 @@ void Draw_GrapplingHook()
                        }
                        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();
+       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 - WarpZone_TransformOrigin(WarpZone_trace_transform, a));
+                       self.angles = vectoangles(trace_endpos - atrans);
                        break;
                case ENT_CLIENT_LGBEAM:
                case ENT_CLIENT_GAUNTLET:
@@ -176,9 +205,10 @@ void Draw_GrapplingHook()
                case ENT_CLIENT_HOOK:
                        break;
                case ENT_CLIENT_LGBEAM:
-                       pointparticles(particleeffectnum("electro_lightning"), b, normalize(a - b) * 1000, frametime);
+                       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;
        }
 }
@@ -203,6 +233,17 @@ void Ent_ReadHook(float bIsNew, float type)
        if(sf & 1)
        {
                self.owner = playerslots[ReadByte() - 1];
+               switch(self.HookType)
+               {
+                       default:
+                       case ENT_CLIENT_HOOK:
+                       case ENT_CLIENT_GAUNTLET:
+                               self.HookRange = 0;
+                               break;
+                       case ENT_CLIENT_LGBEAM:
+                               self.HookRange = ReadCoord();
+                               break;
+               }
        }
        if(sf & 2)
        {
@@ -220,7 +261,7 @@ void Ent_ReadHook(float bIsNew, float type)
 
        InterpolateOrigin_Note();
 
-       if(bIsNew)
+       if(bIsNew || !self.teleport_time)
        {
                self.draw = Draw_GrapplingHook;
                self.entremove = Remove_GrapplingHook;
@@ -241,6 +282,8 @@ void Ent_ReadHook(float bIsNew, float type)
                                break;
                }
        }
+
+       self.teleport_time = time + 10;
 }
 
 void Hook_Precache()