From 5fe51fc3c89d42df0ea80e7a60059c0f270f4f4b Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 25 Sep 2010 21:21:38 +0200 Subject: [PATCH] warpzones: support new parameters warpzone_fadestart, warpzone_fadeend (distance parameters for fading out the effect at a distance) --- qcsrc/warpzonelib/client.qc | 59 ++++++++++++++++++++++++++++++++++--- qcsrc/warpzonelib/common.qh | 2 ++ qcsrc/warpzonelib/server.qc | 25 +++++++++++++++- 3 files changed, 81 insertions(+), 5 deletions(-) diff --git a/qcsrc/warpzonelib/client.qc b/qcsrc/warpzonelib/client.qc index d084e0808..cb2ac268a 100644 --- a/qcsrc/warpzonelib/client.qc +++ b/qcsrc/warpzonelib/client.qc @@ -1,5 +1,19 @@ +void WarpZone_Fade_PreDraw() +{ + if(self.warpzone_fadestart) + self.alpha = (self.warpzone_fadeend - vlen(view_origin - self.origin)) / (self.warpzone_fadeend - self.warpzone_fadestart); + else + self.alpha = 1; + 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,7 +22,8 @@ void WarpZone_Read(float isnew) } self.classname = "trigger_warpzone"; - self.warpzone_isboxy = ReadByte(); + f = ReadByte(); + self.warpzone_isboxy = (f & 1); self.origin_x = ReadCoord(); self.origin_y = ReadCoord(); self.origin_z = ReadCoord(); @@ -33,22 +48,40 @@ 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"; + + f = ReadByte(); self.origin_x = ReadCoord(); self.origin_y = ReadCoord(); self.origin_z = ReadCoord(); @@ -67,6 +100,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 +121,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; diff --git a/qcsrc/warpzonelib/common.qh b/qcsrc/warpzonelib/common.qh index 8405ce6d3..9ccd5216a 100644 --- a/qcsrc/warpzonelib/common.qh +++ b/qcsrc/warpzonelib/common.qh @@ -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); diff --git a/qcsrc/warpzonelib/server.qc b/qcsrc/warpzonelib/server.qc index ecfddff1a..8879d6f42 100644 --- a/qcsrc/warpzonelib/server.qc +++ b/qcsrc/warpzonelib/server.qc @@ -137,10 +137,16 @@ 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; + WriteByte(MSG_ENTITY, f); // we need THESE to render the warpzone (and cull properly)... WriteCoord(MSG_ENTITY, self.origin_x); @@ -170,13 +176,24 @@ 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; + 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); @@ -199,6 +216,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; } -- 2.39.2