]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/platforms.qc
Fix func_pointparticles (draw function referencing self), solution found by Maddin
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / platforms.qc
index b9937f04d36bcaf7627717ca58582df14db1d56e..7b583f1d3d370545b900505b40167cadb966c2e3 100644 (file)
@@ -23,17 +23,11 @@ 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;
 
-#ifdef CSQC
-       trigger.drawmask = MASK_NORMAL;
-       trigger.trigger_touch = plat_center_touch;
-       trigger.draw = trigger_draw_generic;
-#endif
-
        tmin = self.absmin + '25 25 0';
        tmax = self.absmax - '25 25 -8';
        tmin_z = tmax_z - (self.pos1_z - self.pos2_z + 8);
@@ -64,23 +58,23 @@ void plat_spawn_inside_trigger()
        objerror("plat_spawn_inside_trigger: platform has odd size or lip, can't spawn");
 }
 
-void plat_hit_top()
-{SELFPARAM();
+void plat_hit_top(entity this)
+{
        _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = 1;
 
-       self.SUB_THINK = plat_go_down;
+       SUB_THINK(self, plat_go_down);
        self.SUB_NEXTTHINK = self.SUB_LTIME + 3;
 }
 
-void plat_hit_bottom()
-{SELFPARAM();
+void plat_hit_bottom(entity this)
+{
        _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = 2;
 }
 
-void plat_go_down()
-{SELFPARAM();
+void plat_go_down(entity this)
+{
        _sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
        self.state = 3;
        SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, plat_hit_bottom);
@@ -93,8 +87,8 @@ void plat_go_up()
        SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, plat_hit_top);
 }
 
-void plat_center_touch()
-{SELFPARAM();
+void plat_center_touch(entity this)
+{
 #ifdef SVQC
        if (!other.iscreature)
                return;
@@ -108,15 +102,14 @@ void plat_center_touch()
                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()
-{SELFPARAM();
+void plat_outside_touch(entity this)
+{
 #ifdef SVQC
        if (!other.iscreature)
                return;
@@ -128,21 +121,22 @@ void plat_outside_touch()
                return;
 #endif
 
-       setself(self.enemy);
-       if (self.state == 1)
-               plat_go_down ();
+       if (self.enemy.state == 1) {
+           entity e = self.enemy;
+               WITHSELF(e, plat_go_down(e));
+    }
 }
 
 void plat_trigger_use(entity this, entity actor, entity trigger)
 {
 #ifdef SVQC
-       if (this.think)
+       if (getthink(this))
                return;         // already activated
 #elif defined(CSQC)
        if(this.move_think)
                return;
 #endif
-       WITHSELF(this, plat_go_down());
+       WITHSELF(this, plat_go_down(this));
 }
 
 
@@ -167,7 +161,7 @@ void plat_crush()
 #endif
 
                if (self.state == 4)
-                       plat_go_down ();
+                       plat_go_down (self);
                else if (self.state == 3)
                        plat_go_up ();
        // when in other states, then the plat_crush event came delayed after
@@ -178,10 +172,10 @@ void plat_crush()
 
 void plat_use(entity this, entity actor, entity trigger)
 {
-       this.use1 = func_null;
+       this.use = func_null;
        if (this.state != 4)
                objerror ("plat_use: not in up state");
-       WITHSELF(this, plat_go_down());
+       WITHSELF(this, plat_go_down(this));
 }
 
 .string sound1, sound2;
@@ -192,13 +186,13 @@ void plat_reset(entity this)
        {
                setorigin (this, this.pos1);
                this.state = 4;
-               this.use1 = plat_use;
+               this.use = plat_use;
        }
        else
        {
                setorigin (this, this.pos2);
                this.state = 2;
-               this.use1 = plat_trigger_use;
+               this.use = plat_trigger_use;
        }
 
 #ifdef SVQC