]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hook.qc
Draw: purge SELFPARAM
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hook.qc
index 8b2ffca19cdb6e9997edddd5f6c566d93a7b104a..07123f06b5ec278b9bb1d609a7e9e8d195032836 100644 (file)
@@ -1,35 +1,20 @@
-.float HookType; // ENT_CLIENT_*
-.vector origin;
-.vector velocity;
-.float HookSilent;
-.float HookRange;
+#include "hook.qh"
+#include "_all.qh"
 
-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;
+#include "hud.qh"
 
-       axis = normalize(to - from);
-       length_tex = aspect * vlen(to - from) / thickness;
+#include "../common/teams.qh"
 
-       // direction is perpendicular to the view normal, and perpendicular to the axis
-       thickdir = normalize(cross(axis, vieworg - from));
+#include "../csqcmodellib/interpolate.qh"
 
-       A = from - thickdir * (thickness / 2);
-       B = from + thickdir * (thickness / 2);
-       C = to + thickdir * (thickness / 2);
-       D = to - thickdir * (thickness / 2);
+#include "../warpzonelib/common.qh"
 
-       R_BeginPolygon(texture, drawflag);
-       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();
-}
+entityclass(Hook);
+class(Hook) .float 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;
@@ -45,21 +30,21 @@ void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
        Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
 }
 
-.float teleport_time;
-void Draw_GrapplingHook()
+class(Hook) .float teleport_time;
+void Draw_GrapplingHook(entity this)
 {
        vector a, b, atrans;
        string tex;
        vector rgb;
        float t;
-       float s;
+       int s;
        vector vs;
        float intensity, offset;
 
        if(self.teleport_time)
        if(time > self.teleport_time)
        {
-               sound (self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM); // safeguard
+               sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); // safeguard
                self.teleport_time = 0;
        }
 
@@ -86,7 +71,7 @@ void Draw_GrapplingHook()
                {
                        default:
                        case ENT_CLIENT_HOOK:
-                               a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z;
+                               a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z;
                                b = self.origin;
                                break;
                        case ENT_CLIENT_ARC_BEAM:
@@ -96,7 +81,7 @@ void Draw_GrapplingHook()
                                        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;
+                               a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z;
                                break;
                }
        }
@@ -176,22 +161,21 @@ void Draw_GrapplingHook()
                case ENT_CLIENT_HOOK:
                        break;
                case ENT_CLIENT_ARC_BEAM:
-                       pointparticles(particleeffectnum("electro_lightning"), trace_endpos, normalize(atrans - trace_endpos), frametime * intensity); // todo: new effect
+                       pointparticles(particleeffectnum(EFFECT_ARC_LIGHTNING2), trace_endpos, normalize(atrans - trace_endpos), frametime * intensity); // todo: new effect
                        break;
        }
 }
 
 void Remove_GrapplingHook()
-{
-       sound (self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM);
+{SELFPARAM();
+       sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
 }
 
 void Ent_ReadHook(float bIsNew, float type)
-{
+{SELFPARAM();
        self.HookType = type;
 
-       float sf;
-       sf = ReadByte();
+       int sf = ReadByte();
 
        self.HookSilent = (sf & 0x80);
        self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
@@ -200,7 +184,7 @@ void Ent_ReadHook(float bIsNew, float type)
 
        if(sf & 1)
        {
-               float myowner = ReadByte();
+               int myowner = ReadByte();
                self.owner = playerslots[myowner - 1];
                self.sv_entnum = myowner;
                switch(self.HookType)
@@ -240,11 +224,11 @@ void Ent_ReadHook(float bIsNew, float type)
                        default:
                        case ENT_CLIENT_HOOK:
                                // for the model
-                               setmodel(self, "models/hook.md3");
+                               setmodel(self, MDL_HOOK);
                                self.drawmask = MASK_NORMAL;
                                break;
                        case ENT_CLIENT_ARC_BEAM:
-                               sound (self, CH_SHOTS_SINGLE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTEN_NORM);
+                               sound (self, CH_SHOTS_SINGLE, SND_LGBEAM_FLY, VOL_BASE, ATTEN_NORM);
                                break;
                }
        }
@@ -252,10 +236,4 @@ void Ent_ReadHook(float bIsNew, float type)
        self.teleport_time = time + 10;
 }
 
-void Hook_Precache()
-{
-       precache_sound("weapons/lgbeam_fly.wav");
-       precache_model("models/hook.md3");
-}
-
 // TODO: hook: temporarily transform self.origin for drawing the model along warpzones!