]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Started working on antiwalls
authorPenguinum <penguinum@gmail.com>
Thu, 23 Apr 2015 09:38:40 +0000 (12:38 +0300)
committerPenguinum <penguinum@gmail.com>
Thu, 23 Apr 2015 09:38:40 +0000 (12:38 +0300)
qcsrc/client/antiwall.qc [new file with mode: 0644]
qcsrc/client/antiwall.qh [new file with mode: 0644]
qcsrc/client/progs.src
qcsrc/common/constants.qh

diff --git a/qcsrc/client/antiwall.qc b/qcsrc/client/antiwall.qc
new file mode 100644 (file)
index 0000000..87300b7
--- /dev/null
@@ -0,0 +1,200 @@
+#include "antiwall.qh"
+
+void Ent_Antiwall_PreDraw()
+{
+    if (self.inactive) {
+        self.alpha = 0;
+    } else {
+        vector org;
+        org = getpropertyvec(VF_ORIGIN);
+        if(!checkpvs(org, self))
+            self.alpha = 0;
+        else if(self.fade_start) {
+            self.alpha = self.alpha_max / 100.0 * bound(0,
+                               (self.fade_end - vlen(org - self.origin - 0.5 * (self.mins + self.maxs)))
+                               / (self.fade_end - self.fade_start), 1);
+        } else {
+            self.alpha = 1;
+        }
+    }
+    if(self.alpha <= 0)
+        self.drawmask = 0;
+    else
+        self.drawmask = MASK_NORMAL;
+}
+
+void Ent_Antiwall_Draw()
+{
+       float f;
+       var .vector fld;
+
+       if(self.bgmscriptangular)
+               fld = angles;
+       else
+               fld = origin;
+       self.fld = self.saved;
+
+       if(self.lodmodelindex1)
+       {
+               if(autocvar_cl_modeldetailreduction <= 0)
+               {
+                       if(self.lodmodelindex2 && autocvar_cl_modeldetailreduction <= -2)
+                               self.modelindex = self.lodmodelindex2;
+                       else if(autocvar_cl_modeldetailreduction <= -1)
+                               self.modelindex = self.lodmodelindex1;
+                       else
+                               self.modelindex = self.lodmodelindex0;
+               }
+               else
+               {
+                       float distance = vlen(NearestPointOnBox(self, view_origin) - view_origin);
+                       f = (distance * current_viewzoom + 100.0) * autocvar_cl_modeldetailreduction;
+                       f *= 1.0 / bound(0.01, view_quality, 1);
+                       if(self.lodmodelindex2 && f > self.loddistance2)
+                               self.modelindex = self.lodmodelindex2;
+                       else if(f > self.loddistance1)
+                               self.modelindex = self.lodmodelindex1;
+                       else
+                               self.modelindex = self.lodmodelindex0;
+               }
+       }
+
+       InterpolateOrigin_Do();
+
+       self.saved = self.fld;
+
+       f = BGMScript(self);
+       if(f >= 0)
+       {
+               if(self.lip < 0) // < 0: alpha goes from 1 to 1-|lip| when toggled (toggling subtracts lip)
+                       self.alpha = 1 + self.lip * f;
+               else // > 0: alpha goes from 1-|lip| to 1 when toggled (toggling adds lip)
+                       self.alpha = 1 - self.lip * (1 - f);
+               self.fld = self.fld + self.movedir * f;
+       }
+       else
+               self.alpha = 1;
+
+       if(self.alpha >= ALPHA_MIN_VISIBLE)
+               self.drawmask = MASK_NORMAL;
+       else
+               self.drawmask = 0;
+}
+
+void Ent_Antiwall_Remove()
+{
+       if(self.bgmscript)
+               strunzone(self.bgmscript);
+       self.bgmscript = string_null;
+}
+
+void Ent_Antiwall()
+{
+       int f;
+       var .vector fld;
+
+       InterpolateOrigin_Undo();
+       self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
+
+       if(self.bgmscriptangular)
+               fld = angles;
+       else
+               fld = origin;
+       self.fld = self.saved;
+
+       f = ReadByte();
+
+       if(f & 1)
+       {
+               if(f & 0x40)
+                       self.colormap = ReadShort();
+               else
+                       self.colormap = 0;
+       }
+
+       if(f & 2)
+       {
+               self.origin_x = ReadCoord();
+               self.origin_y = ReadCoord();
+               self.origin_z = ReadCoord();
+               setorigin(self, self.origin);
+       }
+
+       if(f & 4)
+       {
+               if(f & 0x10)
+               {
+                       self.angles_x = ReadAngle();
+                       self.angles_y = ReadAngle();
+                       self.angles_z = ReadAngle();
+               }
+               else
+                       self.angles = '0 0 0';
+       }
+
+       if(f & 8)
+       {
+               if(f & 0x80)
+               {
+                       self.lodmodelindex0 = ReadShort();
+                       self.loddistance1 = ReadShort();
+                       self.lodmodelindex1 = ReadShort();
+                       self.loddistance2 = ReadShort();
+                       self.lodmodelindex2 = ReadShort();
+               }
+               else
+               {
+                       self.modelindex = ReadShort();
+                       self.loddistance1 = 0;
+                       self.loddistance2 = 0;
+               }
+               self.solid = ReadByte();
+               self.scale = ReadShort() / 256.0;
+               if(f & 0x20)
+               {
+                       self.mins_x = ReadCoord();
+                       self.mins_y = ReadCoord();
+                       self.mins_z = ReadCoord();
+                       self.maxs_x = ReadCoord();
+                       self.maxs_y = ReadCoord();
+                       self.maxs_z = ReadCoord();
+               }
+               else
+                       self.mins = self.maxs = '0 0 0';
+               setsize(self, self.mins, self.maxs);
+
+               if(self.bgmscript)
+                       strunzone(self.bgmscript);
+               self.bgmscript = ReadString();
+               if(substring(self.bgmscript, 0, 1) == "<")
+               {
+                       self.bgmscript = strzone(substring(self.bgmscript, 1, -1));
+                       self.bgmscriptangular = 1;
+               }
+               else
+               {
+                       self.bgmscript = strzone(self.bgmscript);
+                       self.bgmscriptangular = 0;
+               }
+               if(self.bgmscript != "")
+               {
+                       self.bgmscriptattack = ReadByte() / 64.0;
+                       self.bgmscriptdecay = ReadByte() / 64.0;
+                       self.bgmscriptsustain = ReadByte() / 255.0;
+                       self.bgmscriptrelease = ReadByte() / 64.0;
+                       self.movedir_x = ReadCoord();
+                       self.movedir_y = ReadCoord();
+                       self.movedir_z = ReadCoord();
+                       self.lip = ReadByte() / 255.0;
+               }
+               BGMScript_InitEntity(self);
+       }
+
+       InterpolateOrigin_Note();
+
+       self.saved = self.fld;
+
+       self.entremove = Ent_Antiwall_Remove;
+       self.draw = Ent_Antiwall_Draw;
+}
+
diff --git a/qcsrc/client/antiwall.qh b/qcsrc/client/antiwall.qh
new file mode 100644 (file)
index 0000000..9d96c70
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef ANTIWALL_H
+#define ANTIWALL_H
+
+.float lip;
+.float bgmscriptangular;
+.int lodmodelindex0, lodmodelindex1, lodmodelindex2;
+.float loddistance1, loddistance2;
+.vector saved;
+.float inactive, alpha_max;
+.float fade_start, fade_end;
+
+void Ent_Antiwall_Draw();
+
+void Ent_Antiwall_Remove();
+
+void Ent_Antiwall();
+#endif
+
index f80da18d67309ace7482be0dd4ac37ac784cd1c0..535f5084c50d5d6d29d306d0227124ab5af289de 100644 (file)
@@ -35,6 +35,7 @@ vehicles/vehicles.qc
 view.qc
 wall.qc
 waypointsprites.qc
+antiwall.qc
 
 command/cl_cmd.qc
 
index 45a65abbe96bd904bae1c3e93007637ba5d8b581..d83e6262a48502293e4ea49acfff21a1665ff3af 100644 (file)
@@ -78,6 +78,7 @@ const int ENT_CLIENT_ELIMINATEDPLAYERS = 39;
 const int ENT_CLIENT_TURRET = 40;
 const int ENT_CLIENT_AUXILIARYXHAIR = 50;
 const int ENT_CLIENT_VEHICLE = 60;
+const int ENT_CLIENT_ANTIWALL = 61;
 
 const int ENT_CLIENT_HEALING_ORB = 80;