]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/wall.qc
Merge branch 'master' into terencehill/hud_cleanups
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / wall.qc
index 11b851f8a70e6b395f439f9acfd7e2fe9cd0e908..9da9bb5b658338fdacca81cbc3e7ef2d7dafd90d 100644 (file)
@@ -1,16 +1,55 @@
 #include "wall.qh"
 
-#include "autocvars.qh"
 #include "bgmscript.qh"
-#include "main.qh"
-#include "../common/util.qh"
-#include "../csqcmodellib/interpolate.qh"
+
+
+#include "../lib/csqcmodel/interpolate.qh"
 
 .float alpha;
 .float scale;
 .vector movedir;
 
-void Ent_Wall_Draw()
+void Ent_Wall_PreDraw()
+{SELFPARAM();
+       if (self.inactive)
+       {
+               self.alpha = 0;
+       }
+       else
+       {
+               vector org = getpropertyvec(VF_ORIGIN);
+               if(!checkpvs(org, self))
+                       self.alpha = 0;
+               else if(self.fade_start || self.fade_end) {
+                       vector offset = '0 0 0';
+                       offset_z = self.fade_vertical_offset;
+                       float player_dist = vlen(org - self.origin - 0.5 * (self.mins + self.maxs) + offset);
+                       if (self.fade_end == self.fade_start)
+                       {
+                               if (player_dist >= self.fade_start)
+                                       self.alpha = 0;
+                               else
+                                       self.alpha = 1;
+                       }
+                       else
+                       {
+                               self.alpha = (self.alpha_min + self.alpha_max * bound(0,
+                                                          (self.fade_end - player_dist)
+                                                          / (self.fade_end - self.fade_start), 1)) / 100.0;
+                       }
+               }
+               else
+               {
+                       self.alpha = 1;
+               }
+       }
+       if(self.alpha <= 0)
+               self.drawmask = 0;
+       else
+               self.drawmask = MASK_NORMAL;
+}
+
+void Ent_Wall_Draw(entity this)
 {
        float f;
        var .vector fld;
@@ -50,7 +89,7 @@ void Ent_Wall_Draw()
 
        self.saved = self.(fld);
 
-       f = BGMScript(self);
+       f = doBGMScript(self);
        if(f >= 0)
        {
                if(self.lip < 0) // < 0: alpha goes from 1 to 1-|lip| when toggled (toggling subtracts lip)
@@ -69,14 +108,14 @@ void Ent_Wall_Draw()
 }
 
 void Ent_Wall_Remove()
-{
+{SELFPARAM();
        if(self.bgmscript)
                strunzone(self.bgmscript);
        self.bgmscript = string_null;
 }
 
 void Ent_Wall()
-{
+{SELFPARAM();
        int f;
        var .vector fld;
 
@@ -174,6 +213,12 @@ void Ent_Wall()
                        self.movedir_z = ReadCoord();
                        self.lip = ReadByte() / 255.0;
                }
+               self.fade_start = ReadShort();
+               self.fade_end = ReadShort();
+               self.alpha_max = ReadShort();
+               self.alpha_min = ReadShort();
+               self.inactive = ReadShort();
+               self.fade_vertical_offset = ReadShort();
                BGMScript_InitEntity(self);
        }
 
@@ -183,4 +228,5 @@ void Ent_Wall()
 
        self.entremove = Ent_Wall_Remove;
        self.draw = Ent_Wall_Draw;
+       self.predraw = Ent_Wall_PreDraw;
 }