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)
24 IL_PUSH(g_bot_targets, this);
25 this.bot_attack = true;
27 // exit if still moving around...
28 if (this.origin != this.oldorigin)
31 message_save = this.message;
32 this.message = ""; // no more message
33 SUB_UseTargets(this, actor, trigger); // fire all targets / killtargets
34 this.message = message_save;
36 this.velocity = '0 0 0';
38 // Make a sound, wait a little...
40 if (this.noise1 != "")
41 _sound(this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM);
42 this.nextthink = this.ltime + 0.1;
44 temp = 1 - (this.spawnflags & SECRET_1ST_LEFT); // 1 or -1
45 makevectors(this.mangle);
49 if (this.spawnflags & SECRET_1ST_DOWN)
50 this.t_width = fabs(v_up * this.size);
52 this.t_width = fabs(v_right * this.size);
56 this.t_length = fabs(v_forward * this.size);
58 if (this.spawnflags & SECRET_1ST_DOWN)
59 this.dest1 = this.origin - v_up * this.t_width;
61 this.dest1 = this.origin + v_right * (this.t_width * temp);
63 this.dest2 = this.dest1 + v_forward * this.t_length;
64 SUB_CalcMove(this, this.dest1, TSPEED_LINEAR, this.speed, fd_secret_move1);
65 if (this.noise2 != "")
66 _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM);
69 void fd_secret_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
71 fd_secret_use(this, NULL, NULL);
74 // Wait after first movement...
75 void fd_secret_move1(entity this)
77 this.nextthink = this.ltime + 1.0;
78 setthink(this, fd_secret_move2);
79 if (this.noise3 != "")
80 _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
83 // Start moving sideways w/sound...
84 void fd_secret_move2(entity this)
86 if (this.noise2 != "")
87 _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM);
88 SUB_CalcMove(this, this.dest2, TSPEED_LINEAR, this.speed, fd_secret_move3);
91 // Wait here until time to go back...
92 void fd_secret_move3(entity this)
94 if (this.noise3 != "")
95 _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
96 if (!(this.spawnflags & SECRET_OPEN_ONCE))
98 this.nextthink = this.ltime + this.wait;
99 setthink(this, fd_secret_move4);
104 void fd_secret_move4(entity this)
106 if (this.noise2 != "")
107 _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM);
108 SUB_CalcMove(this, this.dest1, TSPEED_LINEAR, this.speed, fd_secret_move5);
112 void fd_secret_move5(entity this)
114 this.nextthink = this.ltime + 1.0;
115 setthink(this, fd_secret_move6);
116 if (this.noise3 != "")
117 _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
120 void fd_secret_move6(entity this)
122 if (this.noise2 != "")
123 _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM);
124 SUB_CalcMove(this, this.oldorigin, TSPEED_LINEAR, this.speed, fd_secret_done);
127 void fd_secret_done(entity this)
129 if (this.spawnflags&SECRET_YES_SHOOT)
132 this.takedamage = DAMAGE_YES;
133 //this.th_pain = fd_secret_use;
135 if (this.noise3 != "")
136 _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
139 .float door_finished;
141 void secret_blocked(entity this, entity blocker)
143 if (time < this.door_finished)
145 this.door_finished = time + 0.5;
146 //T_Damage (other, this, this, this.dmg, this.dmg, this.deathtype, DT_IMPACT, (this.absmin + this.absmax) * 0.5, '0 0 0', Obituary_Generic);
156 void secret_touch(entity this, entity toucher)
158 if (!toucher.iscreature)
160 if (this.door_finished > time)
163 this.door_finished = time + 2;
167 if (IS_CLIENT(toucher))
168 centerprint(toucher, this.message);
169 play2(toucher, this.noise);
173 void secret_reset(entity this)
175 if (this.spawnflags & SECRET_YES_SHOOT)
178 this.takedamage = DAMAGE_YES;
180 setorigin(this, this.oldorigin);
181 setthink(this, func_null);
185 /*QUAKED spawnfunc_func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot
186 Basic secret door. Slides back, then to the side. Angle determines direction.
187 wait = # of seconds before coming back
188 1st_left = 1st move is left of arrow
189 1st_down = 1st move is down from arrow
190 always_shoot = even if targeted, keep shootable
191 t_width = override WIDTH to move back (or height if going down)
192 t_length = override LENGTH to move sideways
193 "dmg" damage to inflict when blocked (2 default)
195 If a secret door has a targetname, it will only be opened by it's botton or trigger, not by damage.
202 spawnfunc(func_door_secret)
204 /*if (!this.deathtype) // map makers can override this
205 this.deathtype = " got in the way";*/
207 if (!this.dmg) this.dmg = 2;
210 this.mangle = this.angles;
211 this.angles = '0 0 0';
212 this.classname = "door";
213 if (!InitMovingBrushTrigger(this)) return;
214 this.effects |= EF_LOWPRECISION;
216 if (this.noise == "") this.noise = "misc/talk.wav";
217 precache_sound(this.noise);
219 settouch(this, secret_touch);
220 setblocked(this, secret_blocked);
222 this.use = fd_secret_use;
227 this.spawnflags |= SECRET_YES_SHOOT;
229 if (this.spawnflags & SECRET_YES_SHOOT)
232 this.takedamage = DAMAGE_YES;
233 this.event_damage = fd_secret_damage;
235 this.oldorigin = this.origin;
236 if (!this.wait) this.wait = 5; // seconds before closing
238 this.reset = secret_reset;