]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hook.qc
Merge branch 'terencehill/quickmenu_file_example' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hook.qc
index dd70c760c34534a1456165647e1fcc019b10754a..cee2a0cd83a1d6e64c8a9eb2b68807bc1bbf3c88 100644 (file)
@@ -1,16 +1,10 @@
 #include "hook.qh"
-#include "_all.qh"
 
-#include "hud.qh"
-
-#include "../common/teams.qh"
-
-#include "../csqcmodellib/interpolate.qh"
-
-#include "../warpzonelib/common.qh"
+#include "../lib/csqcmodel/interpolate.qh"
+#include "../lib/warpzone/common.qh"
 
 entityclass(Hook);
-class(Hook) .float HookType; // ENT_CLIENT_*
+class(Hook) .entity HookType; // ENT_CLIENT_*
 class(Hook) .vector origin;
 class(Hook) .vector velocity;
 class(Hook) .float HookSilent;
@@ -31,13 +25,12 @@ void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
 }
 
 class(Hook) .float teleport_time;
-void Draw_GrapplingHook()
-{SELFPARAM();
+void Draw_GrapplingHook(entity this)
+{
        vector a, b, atrans;
        string tex;
        vector rgb;
        float t;
-       int s;
        vector vs;
        float intensity, offset;
 
@@ -50,17 +43,15 @@ void Draw_GrapplingHook()
 
        InterpolateOrigin_Do();
 
-       s = autocvar_cl_gunalign;
-       if(s != 1 && s != 2 && s != 4)
-               s = 3; // default value
-       --s;
+       int s = W_GetGunAlignment(world);
+
        switch(self.HookType)
        {
                default:
-               case ENT_CLIENT_HOOK:
+               case NET_ENT_CLIENT_HOOK:
                        vs = hook_shotorigin[s];
                        break;
-               case ENT_CLIENT_ARC_BEAM:
+               case NET_ENT_CLIENT_ARC_BEAM:
                        vs = lightning_shotorigin[s];
                        break;
        }
@@ -70,11 +61,11 @@ void Draw_GrapplingHook()
                switch(self.HookType)
                {
                        default:
-                       case ENT_CLIENT_HOOK:
+                       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 ENT_CLIENT_ARC_BEAM:
+                       case NET_ENT_CLIENT_ARC_BEAM:
                                if(self.HookRange)
                                        b = view_origin + view_forward * self.HookRange;
                                else
@@ -90,11 +81,11 @@ void Draw_GrapplingHook()
                switch(self.HookType)
                {
                        default:
-                       case ENT_CLIENT_HOOK:
+                       case NET_ENT_CLIENT_HOOK:
                                a = self.velocity;
                                b = self.origin;
                                break;
-                       case ENT_CLIENT_ARC_BEAM:
+                       case NET_ENT_CLIENT_ARC_BEAM:
                                a = self.origin;
                                b = self.velocity;
                                break;
@@ -106,7 +97,7 @@ void Draw_GrapplingHook()
        switch(self.HookType)
        {
                default:
-               case ENT_CLIENT_HOOK:
+               case NET_ENT_CLIENT_HOOK:
                        intensity = 1;
                        offset = 0;
                        switch(t)
@@ -118,7 +109,7 @@ void Draw_GrapplingHook()
                                default: tex = "particles/hook_white"; rgb = getcsqcplayercolor(self.sv_entnum); break;
                        }
                        break;
-               case ENT_CLIENT_ARC_BEAM: // todo
+               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";
@@ -130,7 +121,7 @@ void Draw_GrapplingHook()
        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);
+       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);
@@ -138,7 +129,7 @@ void Draw_GrapplingHook()
        switch(self.HookType)
        {
                default:
-               case ENT_CLIENT_HOOK:
+               case NET_ENT_CLIENT_HOOK:
                        if(vlen(trace_endpos - atrans) > 0.5)
                        {
                                setorigin(self, trace_endpos); // hook endpoint!
@@ -150,7 +141,7 @@ void Draw_GrapplingHook()
                                self.drawmask = 0;
                        }
                        break;
-               case ENT_CLIENT_ARC_BEAM:
+               case NET_ENT_CLIENT_ARC_BEAM:
                        setorigin(self, a); // beam origin!
                        break;
        }
@@ -158,10 +149,10 @@ void Draw_GrapplingHook()
        switch(self.HookType)
        {
                default:
-               case ENT_CLIENT_HOOK:
+               case NET_ENT_CLIENT_HOOK:
                        break;
-               case ENT_CLIENT_ARC_BEAM:
-                       pointparticles(particleeffectnum(EFFECT_ARC_LIGHTNING2), trace_endpos, normalize(atrans - trace_endpos), frametime * intensity); // todo: new effect
+               case NET_ENT_CLIENT_ARC_BEAM:
+                       pointparticles(EFFECT_ARC_LIGHTNING2, trace_endpos, normalize(atrans - trace_endpos), frametime * intensity); // todo: new effect
                        break;
        }
 }
@@ -171,9 +162,9 @@ void Remove_GrapplingHook()
        sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
 }
 
-void Ent_ReadHook(float bIsNew, float type)
-{SELFPARAM();
-       self.HookType = type;
+NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew)
+{
+       self.HookType = NET_ENT_CLIENT_HOOK;
 
        int sf = ReadByte();
 
@@ -190,10 +181,10 @@ void Ent_ReadHook(float bIsNew, float type)
                switch(self.HookType)
                {
                        default:
-                       case ENT_CLIENT_HOOK:
+                       case NET_ENT_CLIENT_HOOK:
                                self.HookRange = 0;
                                break;
-                       case ENT_CLIENT_ARC_BEAM:
+                       case NET_ENT_CLIENT_ARC_BEAM:
                                self.HookRange = ReadCoord();
                                break;
                }
@@ -222,18 +213,19 @@ void Ent_ReadHook(float bIsNew, float type)
                switch(self.HookType)
                {
                        default:
-                       case ENT_CLIENT_HOOK:
+                       case NET_ENT_CLIENT_HOOK:
                                // for the model
                                setmodel(self, MDL_HOOK);
                                self.drawmask = MASK_NORMAL;
                                break;
-                       case ENT_CLIENT_ARC_BEAM:
+                       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!