]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/platforms.qc
Introduce touch accessors
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / platforms.qc
index 11f0bd0024a25b407cb320659cea75114d937916..ba8a817ef8388f1fe4293c11c0210678f34417b4 100644 (file)
@@ -1,6 +1,7 @@
 void generic_plat_blocked()
-{SELFPARAM();
+{
 #ifdef SVQC
+    SELFPARAM();
        if(self.dmg && other.takedamage != DAMAGE_NO)
        {
                if(self.dmgtime2 < time)
@@ -10,7 +11,7 @@ void generic_plat_blocked()
                }
 
                // Gib dead/dying stuff
-               if(other.deadflag != DEAD_NO)
+               if(IS_DEAD(other))
                        Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0');
        }
 #endif
@@ -22,7 +23,7 @@ void plat_spawn_inside_trigger()
        vector tmin, tmax;
 
        trigger = spawn();
-       trigger.touch = plat_center_touch;
+       settouch(trigger, plat_center_touch);
        trigger.movetype = MOVETYPE_NONE;
        trigger.solid = SOLID_TRIGGER;
        trigger.enemy = self;
@@ -103,15 +104,14 @@ void plat_center_touch()
 #elif defined(CSQC)
        if (!IS_PLAYER(other))
                return;
-       if(PHYS_DEAD(other))
+       if(IS_DEAD(other))
                return;
 #endif
 
-       setself(self.enemy);
-       if (self.state == 2)
-               plat_go_up ();
-       else if (self.state == 1)
-               self.SUB_NEXTTHINK = self.SUB_LTIME + 1;
+       if (self.enemy.state == 2)
+               WITHSELF(self.enemy, plat_go_up());
+       else if (self.enemy.state == 1)
+               self.enemy.SUB_NEXTTHINK = self.enemy.SUB_LTIME + 1;
 }
 
 void plat_outside_touch()
@@ -127,21 +127,20 @@ void plat_outside_touch()
                return;
 #endif
 
-       setself(self.enemy);
-       if (self.state == 1)
-               plat_go_down ();
+       if (self.enemy.state == 1)
+               WITHSELF(self.enemy, plat_go_down());
 }
 
-void plat_trigger_use()
-{SELFPARAM();
+void plat_trigger_use(entity this, entity actor, entity trigger)
+{
 #ifdef SVQC
-       if (self.think)
+       if (this.think)
                return;         // already activated
 #elif defined(CSQC)
-       if(self.move_think)
+       if(this.move_think)
                return;
 #endif
-       plat_go_down();
+       WITHSELF(this, plat_go_down());
 }
 
 
@@ -160,7 +159,7 @@ void plat_crush()
                {   // Shall we bite?
                        Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0');
                        // Gib dead/dying stuff
-                       if(other.deadflag != DEAD_NO)
+                       if(IS_DEAD(other))
                                Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0');
                }
 #endif
@@ -175,12 +174,12 @@ void plat_crush()
        }
 }
 
-void plat_use()
-{SELFPARAM();
-       self.use = func_null;
-       if (self.state != 4)
+void plat_use(entity this, entity actor, entity trigger)
+{
+       this.use = func_null;
+       if (this.state != 4)
                objerror ("plat_use: not in up state");
-       plat_go_down();
+       WITHSELF(this, plat_go_down());
 }
 
 .string sound1, sound2;