]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mapobjects/func/door.qc
func_door: use Q3 default of 2s .wait time on Q3 maps
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapobjects / func / door.qc
index 173c9d9cdec4b23f949d1e44055be6b91a3a065f..4e081bfb70308d7ea88d04e87b6af6396e3501b6 100644 (file)
@@ -27,6 +27,7 @@ void door_go_up(entity this, entity actor, entity trigger);
 
 void door_blocked(entity this, entity blocker)
 {
+       bool reverse = false;
        if((this.spawnflags & DOOR_CRUSH)
 #ifdef SVQC
                && (blocker.takedamage != DAMAGE_NO)
@@ -69,6 +70,7 @@ void door_blocked(entity this, entity blocker)
                                        else
                                                door_rotating_go_down(this);
                                }
+                               reverse = true;
                        }
                }
 #ifdef SVQC
@@ -80,6 +82,8 @@ void door_blocked(entity this, entity blocker)
                }
 #endif
        }
+       if (!reverse && this.classname == "door")
+               SUB_CalcMovePause(this);
 }
 
 void door_hit_top(entity this)
@@ -361,18 +365,29 @@ void door_trigger_touch(entity this, entity toucher)
 #ifdef SVQC
                if (!((toucher.iscreature || (toucher.flags & FL_PROJECTILE)) && !IS_DEAD(toucher)))
 #elif defined(CSQC)
-               if(!((IS_CLIENT(toucher) || toucher.classname == "csqcprojectile") && !IS_DEAD(toucher)))
+               if(!((IS_CLIENT(toucher) || toucher.classname == "ENT_CLIENT_PROJECTILE") && !IS_DEAD(toucher)))
 #endif
                        return;
 
-       if (time < this.door_finished)
+       if (this.owner.state == STATE_UP)
                return;
 
        // check if door is locked
        if (!door_check_keys(this, toucher))
                return;
 
-       this.door_finished = time + 1;
+       if (this.owner.state == STATE_TOP)
+       {
+               if (this.owner.nextthink < this.owner.ltime + this.owner.wait)
+               {
+                       entity e = this.owner;
+                       do {
+                               e.nextthink = e.ltime + e.wait;
+                               e = e.enemy;
+                       } while (e != this.owner);
+               }
+               return;
+       }
 
        door_use(this.owner, toucher, NULL);
 }
@@ -655,7 +670,7 @@ void door_init_shared(entity this)
        // TODO: other soundpacks
        if (this.sounds > 0 || q3compat)
        {
-               // Doors in Q3 always have sounds (they're hard coded in Q3 engine)
+               // Doors in Q3 always have sounds (they're hard coded)
                this.noise2 = "plats/medplat1.wav";
                this.noise1 = "plats/medplat2.wav";
        }
@@ -683,14 +698,14 @@ void door_init_shared(entity this)
                precache_sound(this.noise2);
        }
 
-        if(autocvar_sv_doors_always_open)
-        {
-                 this.wait = -1;
-        }
-        else if (!this.wait)
-        {
-               this.wait = 3;
-        }
+       if(autocvar_sv_doors_always_open)
+       {
+               this.wait = -1;
+       }
+       else if (!this.wait)
+       {
+               this.wait = q3compat ? 2 : 3;
+       }
 
        if (!this.lip)
        {
@@ -699,7 +714,7 @@ void door_init_shared(entity this)
 
        this.state = STATE_BOTTOM;
 
-       if (GetResource(this, RES_HEALTH))
+       if (GetResource(this, RES_HEALTH) || (q3compat && this.targetname == ""))
        {
                //this.canteamdamage = true; // TODO
                this.takedamage = DAMAGE_YES;
@@ -742,19 +757,23 @@ spawnfunc(func_door)
        door_init_shared(this);
 
        this.pos1 = this.origin;
-       this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip);
-
-        if(autocvar_sv_doors_always_open)
-        {
-                this.speed = max(750, this.speed);
-        }
-        else if (!this.speed)
-        {
+       vector absmovedir;
+       absmovedir.x = fabs(this.movedir.x);
+       absmovedir.y = fabs(this.movedir.y);
+       absmovedir.z = fabs(this.movedir.z);
+       this.pos2 = this.pos1 + this.movedir * (absmovedir * this.size - this.lip);
+
+       if(autocvar_sv_doors_always_open)
+       {
+               this.speed = max(750, this.speed);
+       }
+       else if (!this.speed)
+       {
                if (q3compat)
                        this.speed = 400;
                else
-                       this.speed = 100;
-        }
+                       this.speed = 100;
+       }
 
        settouch(this, door_touch);