1 #include "door_rotating.qh"
2 /*QUAKED spawnfunc_func_door_rotating (0 .5 .8) ? START_OPEN BIDIR DOOR_DONT_LINK BIDIR_IN_DOWN x TOGGLE X_AXIS Y_AXIS
3 if two doors touch, they are assumed to be connected and operate as a unit.
5 TOGGLE causes the door to wait in both the start and end states for a trigger event.
7 BIDIR makes the door work bidirectional, so that the opening direction is always away from the requestor.
8 The usage of bidirectional doors requires two manually instantiated triggers (trigger_multiple), the one to open it in the other direction
9 must have set trigger_reverse to 1.
10 BIDIR_IN_DOWN will the door prevent from reopening while closing if it is triggered from the other side.
12 START_OPEN causes the door to move to its destination when spawned, and operate in reverse. It is used to temporarily or permanently close off an area when triggered (not usefull for touch or takedamage doors).
14 "message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet
15 "angle" determines the destination angle for opening. negative values reverse the direction.
16 "targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door.
17 "health" if set, door must be shot open
18 "speed" movement speed (100 default)
19 "wait" wait before returning (3 default, -1 = never return)
20 "dmg" damage to inflict when blocked (2 default)
27 FIXME: only one sound set available at the time being
31 void door_rotating_hit_top(entity this)
33 if (this.noise1 != "")
34 _sound (this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM);
35 this.state = STATE_TOP;
36 if (this.spawnflags & DOOR_TOGGLE)
37 return; // don't come down automatically
38 setthink(this, door_rotating_go_down);
39 this.nextthink = this.ltime + this.wait;
42 void door_rotating_hit_bottom(entity this)
44 if (this.noise1 != "")
45 _sound (this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM);
46 if (this.lip==666) // this.lip is used to remember reverse opening direction for door_rotating
48 this.pos2 = '0 0 0' - this.pos2;
51 this.state = STATE_BOTTOM;
54 void door_rotating_go_down(entity this)
56 if (this.noise2 != "")
57 _sound (this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM);
60 this.takedamage = DAMAGE_YES;
62 SetResourceAmountExplicit(this, RESOURCE_HEALTH, this.max_health);
64 this.health = this.max_health;
68 this.state = STATE_DOWN;
69 SUB_CalcAngleMove (this, this.pos1, TSPEED_LINEAR, this.speed, door_rotating_hit_bottom);
72 void door_rotating_go_up(entity this, entity oth)
74 if (this.state == STATE_UP)
75 return; // already going up
77 if (this.state == STATE_TOP)
78 { // reset top wait time
79 this.nextthink = this.ltime + this.wait;
82 if (this.noise2 != "")
83 _sound (this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM);
84 this.state = STATE_UP;
85 SUB_CalcAngleMove (this, this.pos2, TSPEED_LINEAR, this.speed, door_rotating_hit_top);
88 oldmessage = this.message;
90 SUB_UseTargets(this, NULL, oth); // TODO: is oth needed here?
91 this.message = oldmessage;
96 void door_rotating_reset(entity this)
98 this.angles = this.pos1;
99 this.avelocity = '0 0 0';
100 this.state = STATE_BOTTOM;
101 setthink(this, func_null);
105 void door_rotating_init_startopen(entity this)
107 this.angles = this.movedir;
109 this.pos1 = this.movedir;
112 spawnfunc(func_door_rotating)
114 //if (!this.deathtype) // map makers can override this
115 // this.deathtype = " got in the way";
117 // I abuse "movedir" for denoting the axis for now
118 if (this.spawnflags & DOOR_ROTATING_XAXIS)
119 this.movedir = '0 0 1';
120 else if (this.spawnflags & DOOR_ROTATING_YAXIS)
121 this.movedir = '1 0 0';
123 this.movedir = '0 1 0';
125 if (this.angles_y==0) this.angles_y = 90;
127 this.movedir = this.movedir * this.angles_y;
128 this.angles = '0 0 0';
130 this.avelocity = this.movedir;
131 if (!InitMovingBrushTrigger(this))
133 this.velocity = '0 0 0';
134 //this.effects |= EF_LOWPRECISION;
135 this.classname = "door_rotating";
137 setblocked(this, door_blocked);
141 this.pos2 = this.movedir;
143 // DOOR_START_OPEN is to allow an entity to be lighted in the closed position
144 // but spawn in the open position
145 if (this.spawnflags & DOOR_START_OPEN)
146 InitializeEntity(this, door_rotating_init_startopen, INITPRIO_SETLOCATION);
148 door_init_shared(this);
153 this.lip = 0; // this.lip is used to remember reverse opening direction for door_rotating
155 settouch(this, door_touch);
157 // LinkDoors can't be done until all of the doors have been spawned, so
158 // the sizes can be detected properly.
159 InitializeEntity(this, LinkDoors, INITPRIO_LINKDOORS);
161 this.reset = door_rotating_reset;