1 #include "door_secret.qh"
3 void fd_secret_move1(entity this);
4 void fd_secret_move2(entity this);
5 void fd_secret_move3(entity this);
6 void fd_secret_move4(entity this);
7 void fd_secret_move5(entity this);
8 void fd_secret_move6(entity this);
9 void fd_secret_done(entity this);
11 const float SECRET_OPEN_ONCE = 1; // stays open
12 const float SECRET_1ST_LEFT = 2; // 1st move is left of arrow
13 const float SECRET_1ST_DOWN = 4; // 1st move is down from arrow
14 const float SECRET_NO_SHOOT = 8; // only opened by trigger
15 const float SECRET_YES_SHOOT = 16; // shootable even if targeted
17 void fd_secret_use(entity this, entity actor, entity trigger)
23 this.bot_attack = true;
25 // exit if still moving around...
26 if (this.origin != this.oldorigin)
29 message_save = this.message;
30 this.message = ""; // no more message
31 SUB_UseTargets(this, actor, trigger); // fire all targets / killtargets
32 this.message = message_save;
34 this.velocity = '0 0 0';
36 // Make a sound, wait a little...
38 if (this.noise1 != "")
39 _sound(this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM);
40 this.SUB_NEXTTHINK = this.SUB_LTIME + 0.1;
42 temp = 1 - (this.spawnflags & SECRET_1ST_LEFT); // 1 or -1
43 makevectors(this.mangle);
47 if (this.spawnflags & SECRET_1ST_DOWN)
48 this.t_width = fabs(v_up * this.size);
50 this.t_width = fabs(v_right * this.size);
54 this.t_length = fabs(v_forward * this.size);
56 if (this.spawnflags & SECRET_1ST_DOWN)
57 this.dest1 = this.origin - v_up * this.t_width;
59 this.dest1 = this.origin + v_right * (this.t_width * temp);
61 this.dest2 = this.dest1 + v_forward * this.t_length;
62 SUB_CalcMove(this, this.dest1, TSPEED_LINEAR, this.speed, fd_secret_move1);
63 if (this.noise2 != "")
64 _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM);
67 void fd_secret_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
69 fd_secret_use(this, NULL, NULL);
72 // Wait after first movement...
73 void fd_secret_move1(entity this)
75 this.SUB_NEXTTHINK = this.SUB_LTIME + 1.0;
76 setthink(this, fd_secret_move2);
77 if (this.noise3 != "")
78 _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
81 // Start moving sideways w/sound...
82 void fd_secret_move2(entity this)
84 if (this.noise2 != "")
85 _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM);
86 SUB_CalcMove(this, this.dest2, TSPEED_LINEAR, this.speed, fd_secret_move3);
89 // Wait here until time to go back...
90 void fd_secret_move3(entity this)
92 if (this.noise3 != "")
93 _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
94 if (!(this.spawnflags & SECRET_OPEN_ONCE))
96 this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
97 setthink(this, fd_secret_move4);
102 void fd_secret_move4(entity this)
104 if (this.noise2 != "")
105 _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM);
106 SUB_CalcMove(this, this.dest1, TSPEED_LINEAR, this.speed, fd_secret_move5);
110 void fd_secret_move5(entity this)
112 this.SUB_NEXTTHINK = this.SUB_LTIME + 1.0;
113 setthink(this, fd_secret_move6);
114 if (this.noise3 != "")
115 _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
118 void fd_secret_move6(entity this)
120 if (this.noise2 != "")
121 _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM);
122 SUB_CalcMove(this, this.oldorigin, TSPEED_LINEAR, this.speed, fd_secret_done);
125 void fd_secret_done(entity this)
127 if (this.spawnflags&SECRET_YES_SHOOT)
130 this.takedamage = DAMAGE_YES;
131 //this.th_pain = fd_secret_use;
133 if (this.noise3 != "")
134 _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
137 .float door_finished;
139 void secret_blocked(entity this, entity blocker)
141 if (time < this.door_finished)
143 this.door_finished = time + 0.5;
144 //T_Damage (other, this, this, this.dmg, this.dmg, this.deathtype, DT_IMPACT, (this.absmin + this.absmax) * 0.5, '0 0 0', Obituary_Generic);
154 void secret_touch(entity this, entity toucher)
156 if (!toucher.iscreature)
158 if (this.door_finished > time)
161 this.door_finished = time + 2;
165 if (IS_CLIENT(toucher))
166 centerprint(toucher, this.message);
167 play2(toucher, this.noise);
171 void secret_reset(entity this)
173 if (this.spawnflags & SECRET_YES_SHOOT)
176 this.takedamage = DAMAGE_YES;
178 setorigin(this, this.oldorigin);
179 setthink(this, func_null);
180 this.SUB_NEXTTHINK = 0;
183 /*QUAKED spawnfunc_func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot
184 Basic secret door. Slides back, then to the side. Angle determines direction.
185 wait = # of seconds before coming back
186 1st_left = 1st move is left of arrow
187 1st_down = 1st move is down from arrow
188 always_shoot = even if targeted, keep shootable
189 t_width = override WIDTH to move back (or height if going down)
190 t_length = override LENGTH to move sideways
191 "dmg" damage to inflict when blocked (2 default)
193 If a secret door has a targetname, it will only be opened by it's botton or trigger, not by damage.
200 spawnfunc(func_door_secret)
202 /*if (!this.deathtype) // map makers can override this
203 this.deathtype = " got in the way";*/
205 if (!this.dmg) this.dmg = 2;
208 this.mangle = this.angles;
209 this.angles = '0 0 0';
210 this.classname = "door";
211 if (!InitMovingBrushTrigger(this)) return;
212 this.effects |= EF_LOWPRECISION;
214 if (this.noise == "") this.noise = "misc/talk.wav";
215 precache_sound(this.noise);
217 settouch(this, secret_touch);
218 setblocked(this, secret_blocked);
220 this.use = fd_secret_use;
225 this.spawnflags |= SECRET_YES_SHOOT;
227 if (this.spawnflags & SECRET_YES_SHOOT)
230 this.takedamage = DAMAGE_YES;
231 this.event_damage = fd_secret_damage;
233 this.oldorigin = this.origin;
234 if (!this.wait) this.wait = 5; // seconds before closing
236 this.reset = secret_reset;