]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/wall.qc
Draw: purge SELFPARAM
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / wall.qc
index f591268d358919420adcbd57851bf6e98f8b0356..f17b54a5caa7bf0f877593c1cd1a811d148fcb46 100644 (file)
 .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;
@@ -70,14 +110,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;
 
@@ -175,6 +215,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);
        }
 
@@ -184,4 +230,5 @@ void Ent_Wall()
 
        self.entremove = Ent_Wall_Remove;
        self.draw = Ent_Wall_Draw;
+       self.predraw = Ent_Wall_PreDraw;
 }