]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/func/door_secret.qc
Move an assault constant into the assault file
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / door_secret.qc
index f0472fadc4b2d71f4110fccee7f05a71c66e299c..78e0dd64e9cafc275eb55c1a6d1302cdcde2cdd5 100644 (file)
@@ -1,3 +1,4 @@
+#include "door_secret.qh"
 #ifdef SVQC
 void fd_secret_move1(entity this);
 void fd_secret_move2(entity this);
@@ -7,18 +8,14 @@ void fd_secret_move5(entity this);
 void fd_secret_move6(entity this);
 void fd_secret_done(entity this);
 
-const float SECRET_OPEN_ONCE = 1;              // stays open
-const float SECRET_1ST_LEFT = 2;               // 1st move is left of arrow
-const float SECRET_1ST_DOWN = 4;               // 1st move is down from arrow
-const float SECRET_NO_SHOOT = 8;               // only opened by trigger
-const float SECRET_YES_SHOOT = 16;     // shootable even if targeted
-
 void fd_secret_use(entity this, entity actor, entity trigger)
 {
        float temp;
        string message_save;
 
        this.health = 10000;
+       if(!this.bot_attack)
+               IL_PUSH(g_bot_targets, this);
        this.bot_attack = true;
 
        // exit if still moving around...
@@ -36,14 +33,14 @@ void fd_secret_use(entity this, entity actor, entity trigger)
 
        if (this.noise1 != "")
                _sound(this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM);
-       this.SUB_NEXTTHINK = this.SUB_LTIME + 0.1;
+       this.nextthink = this.ltime + 0.1;
 
-       temp = 1 - (this.spawnflags & SECRET_1ST_LEFT); // 1 or -1
+       temp = 1 - (this.spawnflags & DOOR_SECRET_1ST_LEFT);    // 1 or -1
        makevectors(this.mangle);
 
        if (!this.t_width)
        {
-               if (this.spawnflags & SECRET_1ST_DOWN)
+               if (this.spawnflags & DOOR_SECRET_1ST_DOWN)
                        this.t_width = fabs(v_up * this.size);
                else
                        this.t_width = fabs(v_right * this.size);
@@ -52,18 +49,18 @@ void fd_secret_use(entity this, entity actor, entity trigger)
        if (!this.t_length)
                this.t_length = fabs(v_forward * this.size);
 
-       if (this.spawnflags & SECRET_1ST_DOWN)
+       if (this.spawnflags & DOOR_SECRET_1ST_DOWN)
                this.dest1 = this.origin - v_up * this.t_width;
        else
                this.dest1 = this.origin + v_right * (this.t_width * temp);
 
        this.dest2 = this.dest1 + v_forward * this.t_length;
-       WITHSELF(this, SUB_CalcMove(this, this.dest1, TSPEED_LINEAR, this.speed, fd_secret_move1));
+       SUB_CalcMove(this, this.dest1, TSPEED_LINEAR, this.speed, fd_secret_move1);
        if (this.noise2 != "")
                _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM);
 }
 
-void fd_secret_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+void fd_secret_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
 {
        fd_secret_use(this, NULL, NULL);
 }
@@ -71,7 +68,7 @@ void fd_secret_damage(entity this, entity inflictor, entity attacker, float dama
 // Wait after first movement...
 void fd_secret_move1(entity this)
 {
-       this.SUB_NEXTTHINK = this.SUB_LTIME + 1.0;
+       this.nextthink = this.ltime + 1.0;
        setthink(this, fd_secret_move2);
        if (this.noise3 != "")
                _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
@@ -90,9 +87,9 @@ void fd_secret_move3(entity this)
 {
        if (this.noise3 != "")
                _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
-       if (!(this.spawnflags & SECRET_OPEN_ONCE))
+       if (!(this.spawnflags & DOOR_SECRET_OPEN_ONCE) && this.wait >= 0)
        {
-               this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
+               this.nextthink = this.ltime + this.wait;
                setthink(this, fd_secret_move4);
        }
 }
@@ -108,7 +105,7 @@ void fd_secret_move4(entity this)
 // Wait 1 second...
 void fd_secret_move5(entity this)
 {
-       this.SUB_NEXTTHINK = this.SUB_LTIME + 1.0;
+       this.nextthink = this.ltime + 1.0;
        setthink(this, fd_secret_move6);
        if (this.noise3 != "")
                _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
@@ -123,7 +120,7 @@ void fd_secret_move6(entity this)
 
 void fd_secret_done(entity this)
 {
-       if (this.spawnflags&SECRET_YES_SHOOT)
+       if (this.spawnflags&DOOR_SECRET_YES_SHOOT)
        {
                this.health = 10000;
                this.takedamage = DAMAGE_YES;
@@ -135,8 +132,8 @@ void fd_secret_done(entity this)
 
 .float door_finished;
 
-void secret_blocked()
-{SELFPARAM();
+void secret_blocked(entity this, entity blocker)
+{
        if (time < this.door_finished)
                return;
        this.door_finished = time + 0.5;
@@ -150,9 +147,9 @@ secret_touch
 Prints messages
 ================
 */
-void secret_touch(entity this)
+void secret_touch(entity this, entity toucher)
 {
-       if (!other.iscreature)
+       if (!toucher.iscreature)
                return;
        if (this.door_finished > time)
                return;
@@ -161,22 +158,22 @@ void secret_touch(entity this)
 
        if (this.message)
        {
-               if (IS_CLIENT(other))
-                       centerprint(other, this.message);
-               play2(other, this.noise);
+               if (IS_CLIENT(toucher))
+                       centerprint(toucher, this.message);
+               play2(toucher, this.noise);
        }
 }
 
 void secret_reset(entity this)
 {
-       if (this.spawnflags & SECRET_YES_SHOOT)
+       if (this.spawnflags & DOOR_SECRET_YES_SHOOT)
        {
                this.health = 10000;
                this.takedamage = DAMAGE_YES;
        }
        setorigin(this, this.oldorigin);
        setthink(this, func_null);
-       this.SUB_NEXTTHINK = 0;
+       this.nextthink = 0;
 }
 
 /*QUAKED spawnfunc_func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot
@@ -201,7 +198,10 @@ spawnfunc(func_door_secret)
        /*if (!this.deathtype) // map makers can override this
                this.deathtype = " got in the way";*/
 
-       if (!this.dmg) this.dmg = 2;
+       if (!this.dmg)
+       {
+               this.dmg = 2;
+       }
 
        // Magic formula...
        this.mangle = this.angles;
@@ -210,21 +210,49 @@ spawnfunc(func_door_secret)
        if (!InitMovingBrushTrigger(this)) return;
        this.effects |= EF_LOWPRECISION;
 
-       if (this.noise == "") this.noise = "misc/talk.wav";
+       // TODO: other soundpacks
+       if (this.sounds > 0)
+       {
+               this.noise1 = "plats/medplat1.wav";
+               this.noise2 = "plats/medplat1.wav";
+               this.noise3 = "plats/medplat2.wav";
+       }
+
+       // sound on touch
+       if (this.noise == "")
+       {
+               this.noise = "misc/talk.wav";
+       }
        precache_sound(this.noise);
+       // sound while moving backwards
+       if (this.noise1 && this.noise1 != "")
+       {
+               precache_sound(this.noise1);
+       }
+       // sound while moving sideways
+       if (this.noise2 && this.noise2 != "")
+       {
+               precache_sound(this.noise2);
+       }
+       // sound when door stops moving
+       if (this.noise3 && this.noise3 != "")
+       {
+               precache_sound(this.noise3);
+       }
 
        settouch(this, secret_touch);
-       this.blocked = secret_blocked;
+       setblocked(this, secret_blocked);
        this.speed = 50;
        this.use = fd_secret_use;
        IFTARGETED
        {
        }
        else
-               this.spawnflags |= SECRET_YES_SHOOT;
+               this.spawnflags |= DOOR_SECRET_YES_SHOOT;
 
-       if (this.spawnflags & SECRET_YES_SHOOT)
+       if (this.spawnflags & DOOR_SECRET_YES_SHOOT)
        {
+               //this.canteamdamage = true; // TODO
                this.health = 10000;
                this.takedamage = DAMAGE_YES;
                this.event_damage = fd_secret_damage;