]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/door_rotating.qc
Merge branch 'master' into Mirio/balance
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / door_rotating.qc
1 #include "door_rotating.qh"
2 #ifdef SVQC
3 /*QUAKED spawnfunc_func_door_rotating (0 .5 .8) ? START_OPEN BIDIR DOOR_DONT_LINK BIDIR_IN_DOWN x TOGGLE X_AXIS Y_AXIS
4 if two doors touch, they are assumed to be connected and operate as a unit.
5
6 TOGGLE causes the door to wait in both the start and end states for a trigger event.
7
8 BIDIR makes the door work bidirectional, so that the opening direction is always away from the requestor.
9 The usage of bidirectional doors requires two manually instantiated triggers (trigger_multiple), the one to open it in the other direction
10 must have set trigger_reverse to 1.
11 BIDIR_IN_DOWN will the door prevent from reopening while closing if it is triggered from the other side.
12
13 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
15 "message"       is printed when the door is touched if it is a trigger door and it hasn't been fired yet
16 "angle"         determines the destination angle for opening. negative values reverse the direction.
17 "targetname"    if set, no touch field will be spawned and a remote button or trigger field activates the door.
18 "health"        if set, door must be shot open
19 "speed"         movement speed (100 default)
20 "wait"          wait before returning (3 default, -1 = never return)
21 "dmg"           damage to inflict when blocked (2 default)
22 "sounds"
23 0)      no sound
24 1)      stone
25 2)      base
26 3)      stone chain
27 4)      screechy metal
28 FIXME: only one sound set available at the time being
29 */
30
31 void door_rotating_reset(entity this)
32 {
33         this.angles = this.pos1;
34         this.avelocity = '0 0 0';
35         this.state = STATE_BOTTOM;
36         setthink(this, func_null);
37         this.nextthink = 0;
38 }
39
40 void door_rotating_init_startopen(entity this)
41 {
42         this.angles = this.movedir;
43         this.pos2 = '0 0 0';
44         this.pos1 = this.movedir;
45 }
46
47
48 spawnfunc(func_door_rotating)
49 {
50
51         //if (!this.deathtype) // map makers can override this
52         //      this.deathtype = " got in the way";
53
54         // I abuse "movedir" for denoting the axis for now
55         if (this.spawnflags & 64) // X (untested)
56                 this.movedir = '0 0 1';
57         else if (this.spawnflags & 128) // Y (untested)
58                 this.movedir = '1 0 0';
59         else // Z
60                 this.movedir = '0 1 0';
61
62         if (this.angles_y==0) this.angles_y = 90;
63
64         this.movedir = this.movedir * this.angles_y;
65         this.angles = '0 0 0';
66
67         this.max_health = this.health;
68         this.avelocity = this.movedir;
69         if (!InitMovingBrushTrigger(this))
70                 return;
71         this.velocity = '0 0 0';
72         //this.effects |= EF_LOWPRECISION;
73         this.classname = "door_rotating";
74
75         setblocked(this, door_blocked);
76         this.use = door_use;
77
78     if(this.spawnflags & 8)
79         this.dmg = 10000;
80
81     if(this.dmg && (this.message == ""))
82                 this.message = "was squished";
83     if(this.dmg && (this.message2 == ""))
84                 this.message2 = "was squished by";
85
86     if (this.sounds > 0)
87         {
88                 precache_sound ("plats/medplat1.wav");
89                 precache_sound ("plats/medplat2.wav");
90                 this.noise2 = "plats/medplat1.wav";
91                 this.noise1 = "plats/medplat2.wav";
92         }
93
94         if (!this.speed)
95                 this.speed = 50;
96         if (!this.wait)
97                 this.wait = 1;
98         this.lip = 0; // this.lip is used to remember reverse opening direction for door_rotating
99
100         this.pos1 = '0 0 0';
101         this.pos2 = this.movedir;
102
103 // DOOR_START_OPEN is to allow an entity to be lighted in the closed position
104 // but spawn in the open position
105         if (this.spawnflags & DOOR_START_OPEN)
106                 InitializeEntity(this, door_rotating_init_startopen, INITPRIO_SETLOCATION);
107
108         this.state = STATE_BOTTOM;
109
110         if (this.health)
111         {
112                 this.takedamage = DAMAGE_YES;
113                 this.event_damage = door_damage;
114         }
115
116         if (this.items)
117                 this.wait = -1;
118
119         settouch(this, door_touch);
120
121 // LinkDoors can't be done until all of the doors have been spawned, so
122 // the sizes can be detected properly.
123         InitializeEntity(this, LinkDoors, INITPRIO_LINKDOORS);
124
125         this.reset = door_rotating_reset;
126 }
127 #endif