]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mapobjects/func/door.qc
Ensure that fast doors don't open slower with sv_doors_always_open
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapobjects / func / door.qc
index c19041aa0b1b7ad2269597caa1ea93040a26afa6..e9fd04b7263398217e507800c47261f50ab29696 100644 (file)
@@ -113,7 +113,7 @@ void door_go_down(entity this)
        if (this.max_health)
        {
                this.takedamage = DAMAGE_YES;
-               this.health = this.max_health;
+               SetResourceExplicit(this, RES_HEALTH, this.max_health);
        }
 
        this.state = STATE_DOWN;
@@ -265,7 +265,7 @@ void door_damage(entity this, entity inflictor, entity attacker, float damage, i
        if(this.spawnflags & NOSPLASH)
                if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
                        return;
-       this.health = this.health - damage;
+       TakeResource(this, RES_HEALTH, damage);
 
        if (this.itemkeys)
        {
@@ -273,11 +273,11 @@ void door_damage(entity this, entity inflictor, entity attacker, float damage, i
                return;
        }
 
-       if (this.health <= 0)
+       if (GetResource(this, RES_HEALTH) <= 0)
        {
-               this.owner.health = this.owner.max_health;
-               this.owner.takedamage = DAMAGE_NO;      // wil be reset upon return
-               door_use(this.owner, NULL, NULL);
+               SetResourceExplicit(this.owner, RES_HEALTH, this.owner.max_health);
+               this.owner.takedamage = DAMAGE_NO;      // will be reset upon return
+               door_use(this.owner, attacker, NULL);
        }
 }
 
@@ -357,7 +357,7 @@ Spawned if a door lacks a real activator
 
 void door_trigger_touch(entity this, entity toucher)
 {
-       if (toucher.health < 1)
+       if (GetResource(toucher, RES_HEALTH) < 1)
 #ifdef SVQC
                if (!((toucher.iscreature || (toucher.flags & FL_PROJECTILE)) && !IS_DEAD(toucher)))
 #elif defined(CSQC)
@@ -441,7 +441,7 @@ void LinkDoors(entity this)
        {
                this.owner = this.enemy = this;
 
-               if (this.health)
+               if (GetResource(this, RES_HEALTH))
                        return;
                IFTARGETED
                        return;
@@ -474,8 +474,8 @@ void LinkDoors(entity this)
        cmaxs = this.absmax;
        for(t = this; ; t = t.enemy)
        {
-               if(t.health && !this.health)
-                       this.health = t.health;
+               if(GetResource(t, RES_HEALTH) && !GetResource(this, RES_HEALTH))
+                       SetResourceExplicit(this, RES_HEALTH, GetResource(t, RES_HEALTH));
                if((t.targetname != "") && (this.targetname == ""))
                        this.targetname = t.targetname;
                if((t.message != "") && (this.message == ""))
@@ -499,7 +499,7 @@ void LinkDoors(entity this)
        // distribute health, targetname, message
        for(t = this; t; t = t.enemy)
        {
-               t.health = this.health;
+               SetResourceExplicit(t, RES_HEALTH, GetResource(this, RES_HEALTH));
                t.targetname = this.targetname;
                t.message = this.message;
                if(t.enemy == this)
@@ -509,7 +509,7 @@ void LinkDoors(entity this)
        // shootable, or triggered doors just needed the owner/enemy links,
        // they don't spawn a field
 
-       if (this.health)
+       if (GetResource(this, RES_HEALTH))
                return;
        IFTARGETED
                return;
@@ -595,8 +595,6 @@ float door_send(entity this, entity to, float sf)
 
 void door_link()
 {
-       // set size now, as everything is loaded
-       //FixSize(this);
        //Net_LinkEntity(this, false, 0, door_send);
 }
 #endif
@@ -630,7 +628,7 @@ void door_reset(entity this)
 // common code for func_door and func_door_rotating spawnfuncs
 void door_init_shared(entity this)
 {
-       this.max_health = this.health;
+       this.max_health = GetResource(this, RES_HEALTH);
 
        // unlock sound
        if(this.noise == "")
@@ -672,10 +670,15 @@ void door_init_shared(entity this)
                precache_sound(this.noise2);
        }
 
-       if (!this.wait)
-       {
-               this.wait = 3;
-       }
+        if(autocvar_sv_doors_always_open)
+        {
+                 this.wait = -1;
+        }
+        else if (!this.wait)
+        {
+               this.wait = 3;
+        }
+
        if (!this.lip)
        {
                this.lip = 8;
@@ -683,7 +686,7 @@ void door_init_shared(entity this)
 
        this.state = STATE_BOTTOM;
 
-       if (this.health)
+       if (GetResource(this, RES_HEALTH))
        {
                //this.canteamdamage = true; // TODO
                this.takedamage = DAMAGE_YES;
@@ -715,9 +718,6 @@ spawnfunc(func_door)
        setblocked(this, door_blocked);
        this.use = door_use;
 
-       this.pos1 = this.origin;
-       this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip);
-
        if(this.spawnflags & DOOR_NONSOLID)
                this.solid = SOLID_NOT;
 
@@ -728,10 +728,17 @@ spawnfunc(func_door)
 
        door_init_shared(this);
 
-       if (!this.speed)
-       {
-               this.speed = 100;
-       }
+       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)
+        {
+                this.speed = 100;
+        }
 
        settouch(this, door_touch);