]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hook.qc
Merge branch 'master' into Mario/mutators2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hook.qc
index c1e8383aa6daf415356034b8b2bda1bc13193e7c..889e75d2679dc65cb7bfd18726479fd38fd8f97f 100644 (file)
@@ -1,15 +1,14 @@
 .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)
+void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg)
 {
        // I want to draw a quad...
        // from and to are MIDPOINTS.
-       
+
        vector axis, thickdir, A, B, C, D;
        float length_tex;
 
@@ -19,23 +18,16 @@ void Draw_CylindricLine(vector from, vector to, float thickness, string texture,
        // direction is perpendicular to the view normal, and perpendicular to the axis
        thickdir = normalize(cross(axis, vieworg - from));
 
-/*
-       print("from ", vtos(from), "\n");
-       print("to ", vtos(to), "\n");
-       print("org ", vtos(view_origin), "\n");
-       print("dir ", vtos(thickdir), "\n");
-*/
-
        A = from - thickdir * (thickness / 2);
        B = from + thickdir * (thickness / 2);
        C = to + thickdir * (thickness / 2);
        D = to - thickdir * (thickness / 2);
 
        R_BeginPolygon(texture, drawflag);
-       R_PolygonVertex(A, '0 0 0' + shift * '1 0 0', rgb, alpha);
-       R_PolygonVertex(B, '0 1 0' + shift * '1 0 0', rgb, alpha);
-       R_PolygonVertex(C, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
-       R_PolygonVertex(D, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, alpha);
+       R_PolygonVertex(A, '0 0 0' + shift * '1 0 0', rgb, theAlpha);
+       R_PolygonVertex(B, '0 1 0' + shift * '1 0 0', rgb, theAlpha);
+       R_PolygonVertex(C, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha);
+       R_PolygonVertex(D, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha);
        R_EndPolygon();
 }
 
@@ -57,7 +49,7 @@ void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
 void Draw_GrapplingHook()
 {
        vector a, b, atrans;
-       string tex, snd;
+       string tex;
        vector rgb;
        float t;
        float s;
@@ -67,13 +59,13 @@ void Draw_GrapplingHook()
        if(self.teleport_time)
        if(time > self.teleport_time)
        {
-               sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM); // safeguard
+               sound (self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM); // safeguard
                self.teleport_time = 0;
        }
 
        InterpolateOrigin_Do();
 
-       s = cvar("cl_gunalign");
+       s = autocvar_cl_gunalign;
        if(s != 1 && s != 2 && s != 4)
                s = 3; // default value
        --s;
@@ -91,7 +83,7 @@ void Draw_GrapplingHook()
                        break;
        }
 
-       if((self.owner.sv_entnum == player_localentnum - 1))
+       if((self.owner.sv_entnum == player_localentnum - 1) && autocvar_chase_active <= 0)
        {
                switch(self.HookType)
                {
@@ -137,30 +129,13 @@ void Draw_GrapplingHook()
                case ENT_CLIENT_HOOK:
                        intensity = 1;
                        offset = 0;
-                       if(t == COLOR_TEAM1)
+                       switch(t)
                        {
-                               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';
+                               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 = getcsqcplayercolor(self.sv_entnum); break;
                        }
                        break;
                case ENT_CLIENT_LGBEAM:
@@ -190,8 +165,16 @@ void Draw_GrapplingHook()
        {
                default:
                case ENT_CLIENT_HOOK:
-                       setorigin(self, trace_endpos); // hook endpoint!
-                       self.angles = vectoangles(trace_endpos - atrans);
+                       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 ENT_CLIENT_LGBEAM:
                case ENT_CLIENT_GAUNTLET:
@@ -215,7 +198,7 @@ void Draw_GrapplingHook()
 
 void Remove_GrapplingHook()
 {
-       sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
+       sound (self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM);
 }
 
 void Ent_ReadHook(float bIsNew, float type)
@@ -226,13 +209,15 @@ void Ent_ReadHook(float bIsNew, float type)
        sf = ReadByte();
 
        self.HookSilent = (sf & 0x80);
-       self.iflags = IFLAG_VELOCITY;
+       self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
 
        InterpolateOrigin_Undo();
 
        if(sf & 1)
        {
-               self.owner = playerslots[ReadByte() - 1];
+               float myowner = ReadByte();
+               self.owner = playerslots[myowner - 1];
+               self.sv_entnum = myowner;
                switch(self.HookType)
                {
                        default:
@@ -275,10 +260,10 @@ void Ent_ReadHook(float bIsNew, float type)
                                self.drawmask = MASK_NORMAL;
                                break;
                        case ENT_CLIENT_LGBEAM:
-                               sound (self, CHAN_PROJECTILE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTN_NORM);
+                               sound (self, CH_SHOTS_SINGLE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTEN_NORM);
                                break;
                        case ENT_CLIENT_GAUNTLET:
-                               sound (self, CHAN_PROJECTILE, "weapons/gauntletbeam_fly.wav", VOL_BASE, ATTN_NORM);
+                               sound (self, CH_SHOTS_SINGLE, "weapons/gauntletbeam_fly.wav", VOL_BASE, ATTEN_NORM);
                                break;
                }
        }