]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/door_rotating.qc
Propagate this
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / door_rotating.qc
1 #ifdef SVQC
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.
4
5 TOGGLE causes the door to wait in both the start and end states for a trigger event.
6
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.
11
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).
13
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)
21 "sounds"
22 0)      no sound
23 1)      stone
24 2)      base
25 3)      stone chain
26 4)      screechy metal
27 FIXME: only one sound set available at the time being
28 */
29
30 void door_rotating_reset(entity this)
31 {
32         this.angles = this.pos1;
33         this.avelocity = '0 0 0';
34         this.state = STATE_BOTTOM;
35         this.think = func_null;
36         this.nextthink = 0;
37 }
38
39 void door_rotating_init_startopen(entity this)
40 {
41         self.angles = self.movedir;
42         self.pos2 = '0 0 0';
43         self.pos1 = self.movedir;
44 }
45
46
47 spawnfunc(func_door_rotating)
48 {
49
50         //if (!self.deathtype) // map makers can override this
51         //      self.deathtype = " got in the way";
52
53         // I abuse "movedir" for denoting the axis for now
54         if (self.spawnflags & 64) // X (untested)
55                 self.movedir = '0 0 1';
56         else if (self.spawnflags & 128) // Y (untested)
57                 self.movedir = '1 0 0';
58         else // Z
59                 self.movedir = '0 1 0';
60
61         if (self.angles_y==0) self.angles_y = 90;
62
63         self.movedir = self.movedir * self.angles_y;
64         self.angles = '0 0 0';
65
66         self.max_health = self.health;
67         self.avelocity = self.movedir;
68         if (!InitMovingBrushTrigger())
69                 return;
70         self.velocity = '0 0 0';
71         //self.effects |= EF_LOWPRECISION;
72         self.classname = "door_rotating";
73
74         self.blocked = door_blocked;
75         self.use = door_use;
76
77     if(self.spawnflags & 8)
78         self.dmg = 10000;
79
80     if(self.dmg && (self.message == ""))
81                 self.message = "was squished";
82     if(self.dmg && (self.message2 == ""))
83                 self.message2 = "was squished by";
84
85     if (self.sounds > 0)
86         {
87                 precache_sound ("plats/medplat1.wav");
88                 precache_sound ("plats/medplat2.wav");
89                 self.noise2 = "plats/medplat1.wav";
90                 self.noise1 = "plats/medplat2.wav";
91         }
92
93         if (!self.speed)
94                 self.speed = 50;
95         if (!self.wait)
96                 self.wait = 1;
97         self.lip = 0; // self.lip is used to remember reverse opening direction for door_rotating
98
99         self.pos1 = '0 0 0';
100         self.pos2 = self.movedir;
101
102 // DOOR_START_OPEN is to allow an entity to be lighted in the closed position
103 // but spawn in the open position
104         if (self.spawnflags & DOOR_START_OPEN)
105                 InitializeEntity(self, door_rotating_init_startopen, INITPRIO_SETLOCATION);
106
107         self.state = STATE_BOTTOM;
108
109         if (self.health)
110         {
111                 self.takedamage = DAMAGE_YES;
112                 self.event_damage = door_damage;
113         }
114
115         if (self.items)
116                 self.wait = -1;
117
118         self.touch = door_touch;
119
120 // LinkDoors can't be done until all of the doors have been spawned, so
121 // the sizes can be detected properly.
122         InitializeEntity(self, LinkDoors, INITPRIO_LINKDOORS);
123
124         self.reset = door_rotating_reset;
125 }
126 #endif