]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/platforms.qc
Merge branch 'master' into TimePath/deathtypes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / platforms.qc
index 7dff8429e3e83077d6dc42366e57d701f2d7ed22..1c8a8bbad45766a10538139667d0bf5061077eaa 100644 (file)
@@ -1,20 +1,23 @@
-#ifdef SVQC
 void generic_plat_blocked()
-{
-    if(self.dmg && other.takedamage != DAMAGE_NO) {
-        if(self.dmgtime2 < time) {
-            Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
-            self.dmgtime2 = time + self.dmgtime;
-        }
-
-        // Gib dead/dying stuff
-        if(other.deadflag != DEAD_NO)
-            Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
-    }
+{SELFPARAM();
+#ifdef SVQC
+       if(self.dmg && other.takedamage != DAMAGE_NO)
+       {
+               if(self.dmgtime2 < time)
+               {
+                       Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0');
+                       self.dmgtime2 = time + self.dmgtime;
+               }
+
+               // Gib dead/dying stuff
+               if(other.deadflag != DEAD_NO)
+                       Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0');
+       }
+#endif
 }
 
 void plat_spawn_inside_trigger()
-{
+{SELFPARAM();
        entity trigger;
        vector tmin, tmax;
 
@@ -24,6 +27,12 @@ void plat_spawn_inside_trigger()
        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);
@@ -55,93 +64,119 @@ void plat_spawn_inside_trigger()
 }
 
 void plat_hit_top()
-{
-       sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+{SELFPARAM();
+       _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = 1;
-       self.think = plat_go_down;
-       self.nextthink = self.ltime + 3;
+
+       self.SUB_THINK = plat_go_down;
+       self.SUB_NEXTTHINK = self.SUB_LTIME + 3;
 }
 
 void plat_hit_bottom()
-{
-       sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+{SELFPARAM();
+       _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = 2;
 }
 
 void plat_go_down()
-{
-       sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
+{SELFPARAM();
+       _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);
 }
 
 void plat_go_up()
-{
-       sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
+{SELFPARAM();
+       _sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
        self.state = 4;
        SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, plat_hit_top);
 }
 
 void plat_center_touch()
-{
+{SELFPARAM();
+#ifdef SVQC
        if (!other.iscreature)
                return;
 
        if (other.health <= 0)
                return;
+#elif defined(CSQC)
+       if (!IS_PLAYER(other))
+               return;
+       if(PHYS_DEAD(other))
+               return;
+#endif
 
-       self = self.enemy;
+       setself(self.enemy);
        if (self.state == 2)
                plat_go_up ();
        else if (self.state == 1)
-               self.nextthink = self.ltime + 1;        // delay going down
+               self.SUB_NEXTTHINK = self.SUB_LTIME + 1;
 }
 
 void plat_outside_touch()
-{
+{SELFPARAM();
+#ifdef SVQC
        if (!other.iscreature)
                return;
 
        if (other.health <= 0)
                return;
+#elif defined(CSQC)
+       if (!IS_PLAYER(other))
+               return;
+#endif
 
-       self = self.enemy;
+       setself(self.enemy);
        if (self.state == 1)
                plat_go_down ();
 }
 
 void plat_trigger_use()
-{
+{SELFPARAM();
+#ifdef SVQC
        if (self.think)
                return;         // already activated
+#elif defined(CSQC)
+       if(self.move_think)
+               return;
+#endif
        plat_go_down();
 }
 
 
 void plat_crush()
-{
-    if((self.spawnflags & 4) && (other.takedamage != DAMAGE_NO)) { // KIll Kill Kill!!
-        Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
-    } else {
-        if((self.dmg) && (other.takedamage != DAMAGE_NO)) {   // Shall we bite?
-            Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
-            // Gib dead/dying stuff
-            if(other.deadflag != DEAD_NO)
-                Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
-        }
-
-        if (self.state == 4)
-            plat_go_down ();
-        else if (self.state == 3)
-            plat_go_up ();
+{SELFPARAM();
+       if((self.spawnflags & 4) && (other.takedamage != DAMAGE_NO))
+       { // KIll Kill Kill!!
+#ifdef SVQC
+               Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0');
+#endif
+       }
+       else
+       {
+#ifdef SVQC
+               if((self.dmg) && (other.takedamage != DAMAGE_NO))
+               {   // 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)
+                               Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0');
+               }
+#endif
+
+               if (self.state == 4)
+                       plat_go_down ();
+               else if (self.state == 3)
+                       plat_go_up ();
        // when in other states, then the plat_crush event came delayed after
        // plat state already had changed
        // this isn't a bug per se!
-    }
+       }
 }
 
 void plat_use()
-{
+{SELFPARAM();
        self.use = func_null;
        if (self.state != 4)
                objerror ("plat_use: not in up state");
@@ -151,7 +186,7 @@ void plat_use()
 .string sound1, sound2;
 
 void plat_reset()
-{
+{SELFPARAM();
        IFTARGETED
        {
                setorigin (self, self.pos1);
@@ -164,15 +199,18 @@ void plat_reset()
                self.state = 2;
                self.use = plat_trigger_use;
        }
+
+#ifdef SVQC
+       self.SendFlags |= SF_TRIGGER_RESET;
+#endif
 }
 
 .float platmovetype_start_default, platmovetype_end_default;
-float set_platmovetype(entity e, string s)
+bool set_platmovetype(entity e, string s)
 {
        // sets platmovetype_start and platmovetype_end based on a string consisting of two values
 
-       float n;
-       n = tokenize_console(s);
+       int n = tokenize_console(s);
        if(n > 0)
                e.platmovetype_start = stof(argv(0));
        else
@@ -185,14 +223,13 @@ float set_platmovetype(entity e, string s)
 
        if(n > 2)
                if(argv(2) == "force")
-                       return TRUE; // no checking, return immediately
+                       return true; // no checking, return immediately
 
        if(!cubic_speedfunc_is_sane(e.platmovetype_start, e.platmovetype_end))
        {
                objerror("Invalid platform move type; platform would go in reverse, which is not allowed.");
-               return FALSE;
+               return false;
        }
 
-       return TRUE;
+       return true;
 }
-#endif