]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/triggers.qc
Nasty fix for drag cheat
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / triggers.qc
index 8e94b5170a986b0eaa9c03e04f03aa721b8d92c1..1e7715a91b58a70ef8472f980ea8a9a094c16214 100644 (file)
@@ -20,15 +20,103 @@ void FixSize(entity e)
        e.maxs_z = rint(e.maxs_z);
 }
 
-void trigger_setnextthink(entity e, float dtime)
+#ifdef SVQC
+void trigger_common_write(bool withtarget)
 {
-#ifdef CSQC
-       e.nextthink = time + dtime;
-#else
-       e.nextthink = dtime;
-#endif
+       WriteByte(MSG_ENTITY, self.warpzone_isboxy);
+       WriteByte(MSG_ENTITY, self.scale);
+
+       if(withtarget)
+       {
+               WriteString(MSG_ENTITY, self.target);
+               WriteString(MSG_ENTITY, self.target2);
+               WriteString(MSG_ENTITY, self.target3);
+               WriteString(MSG_ENTITY, self.target4);
+               WriteString(MSG_ENTITY, self.targetname);
+               WriteString(MSG_ENTITY, self.killtarget);
+       }
+
+       WriteCoord(MSG_ENTITY, self.origin_x);
+       WriteCoord(MSG_ENTITY, self.origin_y);
+       WriteCoord(MSG_ENTITY, self.origin_z);
+
+       WriteCoord(MSG_ENTITY, self.mins_x);
+       WriteCoord(MSG_ENTITY, self.mins_y);
+       WriteCoord(MSG_ENTITY, self.mins_z);
+       WriteCoord(MSG_ENTITY, self.maxs_x);
+       WriteCoord(MSG_ENTITY, self.maxs_y);
+       WriteCoord(MSG_ENTITY, self.maxs_z);
+
+       WriteCoord(MSG_ENTITY, self.movedir_x);
+       WriteCoord(MSG_ENTITY, self.movedir_y);
+       WriteCoord(MSG_ENTITY, self.movedir_z);
+
+       WriteCoord(MSG_ENTITY, self.angles_x);
+       WriteCoord(MSG_ENTITY, self.angles_y);
+       WriteCoord(MSG_ENTITY, self.angles_z);
 }
 
+#elif defined(CSQC)
+
+void trigger_common_read(bool withtarget)
+{
+       self.warpzone_isboxy = ReadByte();
+       self.scale = ReadByte();
+
+       if(withtarget)
+       {
+               self.target = strzone(ReadString());
+               self.target2 = strzone(ReadString());
+               self.target3 = strzone(ReadString());
+               self.target4 = strzone(ReadString());
+               self.targetname = strzone(ReadString());
+               self.killtarget = strzone(ReadString());
+       }
+
+       self.origin_x = ReadCoord();
+       self.origin_y = ReadCoord();
+       self.origin_z = ReadCoord();
+       setorigin(self, self.origin);
+
+       self.mins_x = ReadCoord();
+       self.mins_y = ReadCoord();
+       self.mins_z = ReadCoord();
+       self.maxs_x = ReadCoord();
+       self.maxs_y = ReadCoord();
+       self.maxs_z = ReadCoord();
+       setsize(self, self.mins, self.maxs);
+
+       self.movedir_x = ReadCoord();
+       self.movedir_y = ReadCoord();
+       self.movedir_z = ReadCoord();
+
+       self.angles_x = ReadCoord();
+       self.angles_y = ReadCoord();
+       self.angles_z = ReadCoord();
+}
+
+void trigger_remove_generic()
+{
+       if(self.target) { strunzone(self.target); }
+       self.target = string_null;
+
+       if(self.target2) { strunzone(self.target2); }
+       self.target2 = string_null;
+
+       if(self.target3) { strunzone(self.target3); }
+       self.target3 = string_null;
+
+       if(self.target4) { strunzone(self.target4); }
+       self.target4 = string_null;
+
+       if(self.targetname) { strunzone(self.targetname); }
+       self.target = string_null;
+
+       if(self.killtarget) { strunzone(self.killtarget); }
+       self.killtarget = string_null;
+}
+#endif
+
 /*
 ==============================
 SUB_UseTargets
@@ -121,6 +209,9 @@ void SUB_UseTargets()
                }
                if (s != "")
                {
+                       // Flag to set func_clientwall state
+                       // 1 == deactivate, 2 == activate, 0 == do nothing
+                       float aw_flag = self.antiwall_flag;
                        for(t = world; (t = find(t, targetname, s)); )
                        if(t.use)
                        {
@@ -130,6 +221,8 @@ void SUB_UseTargets()
                                }
                                else
                                {
+                                       if (t.classname == "func_clientwall" || t.classname == "func_clientillusionary")
+                                               t.antiwall_flag = aw_flag;
                                        self = t;
                                        other = stemp;
                                        activator = act;
@@ -157,7 +250,7 @@ void trigger_touch_generic(void() touchfunc)
 {
        entity e;
        for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
-       if(e.isplayermodel)
+       if(e.isplayermodel || e.classname == "csqcprojectile")
        {
                vector emin = e.absmin, emax = e.absmax;
                if(self.solid == SOLID_BSP)
@@ -179,8 +272,6 @@ void trigger_draw_generic()
        self.move_time = time;
        if(dt <= 0) { return; }
 
-       setorigin(self, self.origin + self.velocity * frametime);
-
        if(self.trigger_touch) { trigger_touch_generic(self.trigger_touch); }
 }
 #endif