]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/func/door.qc
Merge branch 'martin-t/angles' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / door.qc
index 2b3decf64ff3dcda89bf58bfeaaf8412de15e37f..dc0be6ae24a9822b67865e2c4a2cb0c6b0b32c6b 100644 (file)
@@ -1,3 +1,4 @@
+#include "door.qh"
 /*
 
 Doors are similar to buttons, but can spawn a fat trigger field around them
@@ -93,12 +94,12 @@ void door_hit_top(entity this)
                return;         // don't come down automatically
        if (this.classname == "door")
        {
-               SUB_THINK(this, door_go_down);
+               setthink(this, door_go_down);
        } else
        {
-               SUB_THINK(this, door_rotating_go_down);
+               setthink(this, door_rotating_go_down);
        }
-       this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
+       this.nextthink = this.ltime + this.wait;
 }
 
 void door_hit_bottom(entity this)
@@ -129,7 +130,7 @@ void door_go_up(entity this)
 
        if (this.state == STATE_TOP)
        {       // reset top wait time
-               this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
+               this.nextthink = this.ltime + this.wait;
                return;
        }
 
@@ -168,7 +169,11 @@ bool door_check_keys(entity door, entity player)
        if(!IS_PLAYER(player))
                return false;
 
-       int valid = (door.itemkeys & player.itemkeys);
+       entity store = player;
+#ifdef SVQC
+       store = PS(player);
+#endif
+       int valid = (door.itemkeys & store.itemkeys);
        door.itemkeys &= ~valid; // only some of the needed keys were given
 
        if(!door.itemkeys)
@@ -352,8 +357,8 @@ void door_rotating_hit_top(entity this)
        this.state = STATE_TOP;
        if (this.spawnflags & DOOR_TOGGLE)
                return;         // don't come down automatically
-       SUB_THINK(this, door_rotating_go_down);
-       this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
+       setthink(this, door_rotating_go_down);
+       this.nextthink = this.ltime + this.wait;
 }
 
 void door_rotating_hit_bottom(entity this)
@@ -389,7 +394,7 @@ void door_rotating_go_up(entity this, entity oth)
 
        if (this.state == STATE_TOP)
        {       // reset top wait time
-               this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
+               this.nextthink = this.ltime + this.wait;
                return;
        }
        if (this.noise2 != "")
@@ -441,7 +446,7 @@ void door_spawnfield(entity this, vector fmins, vector fmaxs)
        vector  t1 = fmins, t2 = fmaxs;
 
        trigger = new(doortriggerfield);
-       trigger.movetype = MOVETYPE_NONE;
+       set_movetype(trigger, MOVETYPE_NONE);
        trigger.solid = SOLID_TRIGGER;
        trigger.owner = this;
 #ifdef SVQC
@@ -525,7 +530,7 @@ void LinkDoors(entity this)
                        break;
                }
        }
-       LOG_TRACE("\n");
+       LOG_TRACE("");
 
        // collect health, targetname, message, size
        cmins = this.absmin;
@@ -638,7 +643,7 @@ float door_send(entity this, entity to, float sf)
                WriteShort(MSG_ENTITY, this.speed);
                WriteByte(MSG_ENTITY, this.lip);
                WriteByte(MSG_ENTITY, this.state);
-               WriteCoord(MSG_ENTITY, this.SUB_LTIME);
+               WriteCoord(MSG_ENTITY, this.ltime);
        }
 
        if(sf & SF_TRIGGER_RESET)
@@ -673,7 +678,7 @@ void door_link()
 
 void door_init_startopen(entity this)
 {
-       SUB_SETORIGIN(this, this.pos2);
+       setorigin(this, this.pos2);
        this.pos2 = this.pos1;
        this.pos1 = this.origin;
 
@@ -684,11 +689,11 @@ void door_init_startopen(entity this)
 
 void door_reset(entity this)
 {
-       SUB_SETORIGIN(this, this.pos1);
-       this.SUB_VELOCITY = '0 0 0';
+       setorigin(this, this.pos1);
+       this.velocity = '0 0 0';
        this.state = STATE_BOTTOM;
-       SUB_THINK(this, func_null);
-       this.SUB_NEXTTHINK = 0;
+       setthink(this, func_null);
+       this.nextthink = 0;
 
 #ifdef SVQC
        this.SendFlags |= SF_TRIGGER_RESET;
@@ -731,12 +736,13 @@ spawnfunc(func_door)
 
        if (this.sounds > 0)
        {
-               precache_sound ("plats/medplat1.wav");
-               precache_sound ("plats/medplat2.wav");
                this.noise2 = "plats/medplat1.wav";
                this.noise1 = "plats/medplat2.wav";
        }
 
+       if(this.noise1 && this.noise1 != "") { precache_sound(this.noise1); }
+       if(this.noise2 && this.noise2 != "") { precache_sound(this.noise2); }
+
        if (!this.speed)
                this.speed = 100;
        if (!this.wait)
@@ -744,7 +750,7 @@ spawnfunc(func_door)
        if (!this.lip)
                this.lip = 8;
 
-       this.pos1 = this.SUB_ORIGIN;
+       this.pos1 = this.origin;
        this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip);
 
        if(this.spawnflags & DOOR_NONSOLID)
@@ -812,10 +818,10 @@ NET_HANDLE(ENT_CLIENT_DOOR, bool isnew)
                this.speed = ReadShort();
                this.lip = ReadByte();
                this.state = ReadByte();
-               this.SUB_LTIME = ReadCoord();
+               this.ltime = ReadCoord();
 
                this.solid = SOLID_BSP;
-               this.movetype = MOVETYPE_PUSH;
+               set_movetype(this, MOVETYPE_PUSH);
                this.use = door_use;
 
                LinkDoors(this);
@@ -824,10 +830,7 @@ NET_HANDLE(ENT_CLIENT_DOOR, bool isnew)
                        door_init_startopen(this);
 
                this.move_time = time;
-               this.move_origin = this.origin;
-               this.move_movetype = MOVETYPE_PUSH;
-               this.move_angles = this.angles;
-               this.move_blocked = door_blocked;
+               set_movetype(this, MOVETYPE_PUSH);
        }
 
        if(sf & SF_TRIGGER_RESET)
@@ -841,7 +844,6 @@ NET_HANDLE(ENT_CLIENT_DOOR, bool isnew)
                this.origin_y = ReadCoord();
                this.origin_z = ReadCoord();
                setorigin(this, this.origin);
-               this.move_origin = this.origin;
 
                this.pos1_x = ReadCoord();
                this.pos1_y = ReadCoord();