2 void() fd_secret_move1;
3 void() fd_secret_move2;
4 void() fd_secret_move3;
5 void() fd_secret_move4;
6 void() fd_secret_move5;
7 void() fd_secret_move6;
10 const float SECRET_OPEN_ONCE = 1; // stays open
11 const float SECRET_1ST_LEFT = 2; // 1st move is left of arrow
12 const float SECRET_1ST_DOWN = 4; // 1st move is down from arrow
13 const float SECRET_NO_SHOOT = 8; // only opened by trigger
14 const float SECRET_YES_SHOOT = 16; // shootable even if targeted
22 self.bot_attack = true;
24 // exit if still moving around...
25 if (self.origin != self.oldorigin)
28 message_save = self.message;
29 self.message = ""; // no more message
30 SUB_UseTargets(); // fire all targets / killtargets
31 self.message = message_save;
33 self.velocity = '0 0 0';
35 // Make a sound, wait a little...
37 if (self.noise1 != "")
38 _sound(self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
39 self.SUB_NEXTTHINK = self.SUB_LTIME + 0.1;
41 temp = 1 - (self.spawnflags & SECRET_1ST_LEFT); // 1 or -1
42 makevectors(self.mangle);
46 if (self.spawnflags & SECRET_1ST_DOWN)
47 self.t_width = fabs(v_up * self.size);
49 self.t_width = fabs(v_right * self.size);
53 self.t_length = fabs(v_forward * self.size);
55 if (self.spawnflags & SECRET_1ST_DOWN)
56 self.dest1 = self.origin - v_up * self.t_width;
58 self.dest1 = self.origin + v_right * (self.t_width * temp);
60 self.dest2 = self.dest1 + v_forward * self.t_length;
61 SUB_CalcMove(self.dest1, TSPEED_LINEAR, self.speed, fd_secret_move1);
62 if (self.noise2 != "")
63 _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
66 void fd_secret_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
68 WITHSELF(this, fd_secret_use());
71 // Wait after first movement...
72 void fd_secret_move1()
74 self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0;
75 self.think = fd_secret_move2;
76 if (self.noise3 != "")
77 _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
80 // Start moving sideways w/sound...
81 void fd_secret_move2()
83 if (self.noise2 != "")
84 _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
85 SUB_CalcMove(self.dest2, TSPEED_LINEAR, self.speed, fd_secret_move3);
88 // Wait here until time to go back...
89 void fd_secret_move3()
91 if (self.noise3 != "")
92 _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
93 if (!(self.spawnflags & SECRET_OPEN_ONCE))
95 self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
96 self.think = fd_secret_move4;
101 void fd_secret_move4()
103 if (self.noise2 != "")
104 _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
105 SUB_CalcMove(self.dest1, TSPEED_LINEAR, self.speed, fd_secret_move5);
109 void fd_secret_move5()
111 self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0;
112 self.think = fd_secret_move6;
113 if (self.noise3 != "")
114 _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
117 void fd_secret_move6()
119 if (self.noise2 != "")
120 _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
121 SUB_CalcMove(self.oldorigin, TSPEED_LINEAR, self.speed, fd_secret_done);
124 void fd_secret_done()
126 if (self.spawnflags&SECRET_YES_SHOOT)
129 self.takedamage = DAMAGE_YES;
130 //self.th_pain = fd_secret_use;
132 if (self.noise3 != "")
133 _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
136 .float door_finished;
138 void secret_blocked()
140 if (time < self.door_finished)
142 self.door_finished = time + 0.5;
143 //T_Damage (other, self, self, self.dmg, self.dmg, self.deathtype, DT_IMPACT, (self.absmin + self.absmax) * 0.5, '0 0 0', Obituary_Generic);
155 if (!other.iscreature)
157 if (self.door_finished > time)
160 self.door_finished = time + 2;
164 if (IS_CLIENT(other))
165 centerprint(other, self.message);
166 play2(other, self.noise);
170 void secret_reset(entity this)
172 if (this.spawnflags & SECRET_YES_SHOOT)
175 this.takedamage = DAMAGE_YES;
177 setorigin(this, this.oldorigin);
178 this.think = func_null;
179 this.SUB_NEXTTHINK = 0;
182 /*QUAKED spawnfunc_func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot
183 Basic secret door. Slides back, then to the side. Angle determines direction.
184 wait = # of seconds before coming back
185 1st_left = 1st move is left of arrow
186 1st_down = 1st move is down from arrow
187 always_shoot = even if targeted, keep shootable
188 t_width = override WIDTH to move back (or height if going down)
189 t_length = override LENGTH to move sideways
190 "dmg" damage to inflict when blocked (2 default)
192 If a secret door has a targetname, it will only be opened by it's botton or trigger, not by damage.
199 spawnfunc(func_door_secret)
201 /*if (!this.deathtype) // map makers can override this
202 this.deathtype = " got in the way";*/
204 if (!this.dmg) this.dmg = 2;
207 this.mangle = this.angles;
208 this.angles = '0 0 0';
209 this.classname = "door";
210 if (!InitMovingBrushTrigger()) return;
211 this.effects |= EF_LOWPRECISION;
213 if (this.noise == "") this.noise = "misc/talk.wav";
214 precache_sound(this.noise);
216 this.touch = secret_touch;
217 this.blocked = secret_blocked;
219 this.use = fd_secret_use;
224 this.spawnflags |= SECRET_YES_SHOOT;
226 if (this.spawnflags & SECRET_YES_SHOOT)
229 this.takedamage = DAMAGE_YES;
230 this.event_damage = fd_secret_damage;
232 this.oldorigin = this.origin;
233 if (!this.wait) this.wait = 5; // seconds before closing
235 this.reset = secret_reset;