]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'morphed/armor'
authorRudolf Polzer <divverent@alientrap.org>
Sun, 26 Sep 2010 16:45:48 +0000 (18:45 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 26 Sep 2010 16:45:48 +0000 (18:45 +0200)
qcsrc/warpzonelib/client.qc
qcsrc/warpzonelib/common.qh
qcsrc/warpzonelib/server.qc

index d084e08084ce854d08b723911a97b63185610937..725f84ffbd24a8f09150431c7aa44e1c2f2860d2 100644 (file)
@@ -1,5 +1,20 @@
+void WarpZone_Fade_PreDraw()
+{
+       if(self.warpzone_fadestart)
+               self.alpha = bound(0, (self.warpzone_fadeend - vlen(view_origin - self.origin - 0.5 * (self.mins + self.maxs))) / (self.warpzone_fadeend - self.warpzone_fadestart), 1);
+       else
+               self.alpha = 1;
+       //print(sprintf("%v <-> %v\n", view_origin, self.origin + 0.5 * (self.mins + self.maxs)));
+       if(self.alpha <= 0)
+               self.drawmask = 0;
+       else
+               self.drawmask = MASK_NORMAL;
+}
+
 void WarpZone_Read(float isnew)
 {
+       float f;
+
        ++warpzone_warpzones_exist;
        if not(self.enemy)
        {
@@ -8,10 +23,16 @@ void WarpZone_Read(float isnew)
        }
        self.classname = "trigger_warpzone";
 
-       self.warpzone_isboxy = ReadByte();
-       self.origin_x = ReadCoord();
-       self.origin_y = ReadCoord();
-       self.origin_z = ReadCoord();
+       f = ReadByte();
+       self.warpzone_isboxy = (f & 1);
+       if(f & 4)
+       {
+               self.origin_x = ReadCoord();
+               self.origin_y = ReadCoord();
+               self.origin_z = ReadCoord();
+       }
+       else
+               self.origin = '0 0 0';
        self.modelindex = ReadShort();
        self.mins_x = ReadCoord();
        self.mins_y = ReadCoord();
@@ -33,25 +54,48 @@ void WarpZone_Read(float isnew)
        self.avelocity_y = ReadCoord();
        self.avelocity_z = ReadCoord();
 
+       if(f & 2)
+       {
+               self.warpzone_fadestart = ReadShort();
+               self.warpzone_fadeend = max(self.warpzone_fadestart + 1, ReadShort());
+       }
+       else
+       {
+               self.warpzone_fadestart = 0;
+               self.warpzone_fadeend = 0;
+       }
+
        // common stuff
        WarpZone_SetUp(self, self.enemy.oldorigin, self.enemy.avelocity, self.oldorigin, self.avelocity);
 
-       // engine currently wants this
-       self.drawmask = MASK_NORMAL;
-
        // link me
        //setmodel(self, self.model);
        setorigin(self, self.origin);
        setsize(self, self.mins, self.maxs);
+
+       // how to draw
+       // engine currently wants this
+       if(self.warpzone_fadestart)
+               self.predraw = WarpZone_Fade_PreDraw;
+       else
+               self.drawmask = MASK_NORMAL;
 }
 
 void WarpZone_Camera_Read(float isnew)
 {
+       float f;
        ++warpzone_cameras_exist;
        self.classname = "func_warpzone_camera";
-       self.origin_x = ReadCoord();
-       self.origin_y = ReadCoord();
-       self.origin_z = ReadCoord();
+
+       f = ReadByte();
+       if(f & 4)
+       {
+               self.origin_x = ReadCoord();
+               self.origin_y = ReadCoord();
+               self.origin_z = ReadCoord();
+       }
+       else
+               self.origin = '0 0 0';
        self.modelindex = ReadShort();
        self.mins_x = ReadCoord();
        self.mins_y = ReadCoord();
@@ -67,6 +111,17 @@ void WarpZone_Camera_Read(float isnew)
        self.avelocity_y = ReadCoord();
        self.avelocity_z = ReadCoord();
 
+       if(f & 2)
+       {
+               self.warpzone_fadestart = ReadShort();
+               self.warpzone_fadeend = max(self.warpzone_fadestart + 1, ReadShort());
+       }
+       else
+       {
+               self.warpzone_fadestart = 0;
+               self.warpzone_fadeend = 0;
+       }
+
        // common stuff
        WarpZone_Camera_SetUp(self, self.oldorigin, self.avelocity);
 
@@ -77,6 +132,13 @@ void WarpZone_Camera_Read(float isnew)
        //setmodel(self, self.model);
        setorigin(self, self.origin);
        setsize(self, self.mins, self.maxs);
+
+       // how to draw
+       // engine currently wants this
+       if(self.warpzone_fadestart)
+               self.predraw = WarpZone_Fade_PreDraw;
+       else
+               self.drawmask = MASK_NORMAL;
 }
 
 float warpzone_fixingview;
index 8405ce6d3c5febbbd4050c127f3c0a3b62df4b78..9ccd5216a63186ad15da4c573cd368d8db51d481 100644 (file)
@@ -15,6 +15,8 @@ const void func_null(void); // never assign to this one please
 .vector warpzone_targetangles;
 .vector warpzone_targetforward;
 .vector warpzone_transform;
+.float warpzone_fadestart;
+.float warpzone_fadeend;
 void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, vector other_ang);
 
 float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig);
index ecfddff1ab5b4b1b9e56a5489b446b51a9f5d90a..cfa6ef965ec768949733736a165038d08555fd28 100644 (file)
@@ -137,15 +137,26 @@ void WarpZone_Touch (void)
 
 float WarpZone_Send(entity to, float sendflags)
 {
+       float f;
        WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE);
 
        // we must send this flag for clientside to match properly too
-       WriteByte(MSG_ENTITY, self.warpzone_isboxy);
+       f = 0;
+       if(self.warpzone_isboxy)
+               f |= 1;
+       if(self.warpzone_fadestart)
+               f |= 2;
+       if(self.origin != '0 0 0')
+               f |= 4;
+       WriteByte(MSG_ENTITY, f);
 
        // we need THESE to render the warpzone (and cull properly)...
-       WriteCoord(MSG_ENTITY, self.origin_x);
-       WriteCoord(MSG_ENTITY, self.origin_y);
-       WriteCoord(MSG_ENTITY, self.origin_z);
+       if(f & 4)
+       {
+               WriteCoord(MSG_ENTITY, self.origin_x);
+               WriteCoord(MSG_ENTITY, self.origin_y);
+               WriteCoord(MSG_ENTITY, self.origin_z);
+       }
 
        WriteShort(MSG_ENTITY, self.modelindex);
        WriteCoord(MSG_ENTITY, self.mins_x);
@@ -170,17 +181,33 @@ float WarpZone_Send(entity to, float sendflags)
        WriteCoord(MSG_ENTITY, self.warpzone_targetangles_y);
        WriteCoord(MSG_ENTITY, self.warpzone_targetangles_z);
 
+       if(f & 2)
+       {
+               WriteShort(MSG_ENTITY, self.warpzone_fadestart);
+               WriteShort(MSG_ENTITY, self.warpzone_fadeend);
+       }
+
        return TRUE;
 }
 
 float WarpZone_Camera_Send(entity to, float sendflags)
 {
+       float f;
        WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
 
+       if(self.warpzone_fadestart)
+               f |= 2;
+       if(self.origin != '0 0 0')
+               f |= 4;
+       WriteByte(MSG_ENTITY, f);
+
        // we need THESE to render the warpzone (and cull properly)...
-       WriteCoord(MSG_ENTITY, self.origin_x);
-       WriteCoord(MSG_ENTITY, self.origin_y);
-       WriteCoord(MSG_ENTITY, self.origin_z);
+       if(f & 4)
+       {
+               WriteCoord(MSG_ENTITY, self.origin_x);
+               WriteCoord(MSG_ENTITY, self.origin_y);
+               WriteCoord(MSG_ENTITY, self.origin_z);
+       }
 
        WriteShort(MSG_ENTITY, self.modelindex);
        WriteCoord(MSG_ENTITY, self.mins_x);
@@ -199,6 +226,12 @@ float WarpZone_Camera_Send(entity to, float sendflags)
        WriteCoord(MSG_ENTITY, self.enemy.angles_y);
        WriteCoord(MSG_ENTITY, self.enemy.angles_z);
 
+       if(f & 2)
+       {
+               WriteShort(MSG_ENTITY, self.warpzone_fadestart);
+               WriteShort(MSG_ENTITY, self.warpzone_fadeend);
+       }
+
        return TRUE;
 }
 
@@ -222,7 +255,7 @@ float WarpZone_CheckProjectileImpact()
        WarpZone_TraceBox_ThroughZone(self.warpzone_oldorigin, self.mins, self.maxs, self.warpzone_oldorigin + self.warpzone_oldvelocity * frametime, MOVE_NORMAL, self, wz, WarpZone_trace_callback_t_null); // this will get us through the warpzone
        setorigin(self, trace_endpos);
        self.angles = WarpZone_TransformAngles(WarpZone_trace_transform, self.angles);
-       self.velocity = WarpZone_TransformVelocity(WarpZone_trace_transform, self.velocity);
+       self.velocity = WarpZone_TransformVelocity(WarpZone_trace_transform, self.warpzone_oldvelocity);
        
        // in case we are in our warp zone post-teleport, shift the projectile forward a bit
        mpd = max(vlen(self.mins), vlen(self.maxs));