doors.qc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. /* Copyright (C) 1996-2022 id Software LLC
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  13. See file, 'COPYING', for details.
  14. */
  15. float DOOR_START_OPEN = 1;
  16. float DOOR_DONT_LINK = 4;
  17. float DOOR_GOLD_KEY = 8;
  18. float DOOR_SILVER_KEY = 16;
  19. float DOOR_TOGGLE = 32;
  20. /*
  21. Doors are similar to buttons, but can spawn a fat trigger field around them
  22. to open without a touch, and they link together to form simultanious
  23. double/quad doors.
  24. Door.owner is the master door. If there is only one door, it points to itself.
  25. If multiple doors, all will point to a single one.
  26. Door.enemy chains from the master door through all doors linked in the chain.
  27. */
  28. /*
  29. =============================================================================
  30. THINK FUNCTIONS
  31. =============================================================================
  32. */
  33. void() door_go_down;
  34. void() door_go_up;
  35. void() door_blocked =
  36. {
  37. T_Damage (other, self, self, self.dmg);
  38. // if a door has a negative wait, it would never come back if blocked,
  39. // so let it just squash the object to death real fast
  40. if (self.wait >= 0)
  41. {
  42. if (self.state == STATE_DOWN)
  43. door_go_up ();
  44. else
  45. door_go_down ();
  46. }
  47. };
  48. void() door_hit_top =
  49. {
  50. sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
  51. self.state = STATE_TOP;
  52. if (self.spawnflags & DOOR_TOGGLE)
  53. return; // don't come down automatically
  54. self.think = door_go_down;
  55. self.nextthink = self.ltime + self.wait;
  56. };
  57. void() door_hit_bottom =
  58. {
  59. sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
  60. self.state = STATE_BOTTOM;
  61. };
  62. void() door_go_down =
  63. {
  64. sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  65. if (self.max_health)
  66. {
  67. self.takedamage = DAMAGE_YES;
  68. self.health = self.max_health;
  69. }
  70. self.state = STATE_DOWN;
  71. SUB_CalcMove (self.pos1, self.speed, door_hit_bottom);
  72. };
  73. void() door_go_up =
  74. {
  75. if (self.state == STATE_UP)
  76. return; // allready going up
  77. if (self.state == STATE_TOP)
  78. { // reset top wait time
  79. self.nextthink = self.ltime + self.wait;
  80. return;
  81. }
  82. sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  83. self.state = STATE_UP;
  84. SUB_CalcMove (self.pos2, self.speed, door_hit_top);
  85. SUB_UseTargets();
  86. };
  87. /*
  88. =============================================================================
  89. ACTIVATION FUNCTIONS
  90. =============================================================================
  91. */
  92. void() door_fire =
  93. {
  94. local entity oself;
  95. local entity starte;
  96. if (self.owner != self)
  97. objerror ("door_fire: self.owner != self");
  98. // play use key sound
  99. if (self.items)
  100. sound (self, CHAN_ITEM, self.noise4, 1, ATTN_NORM); // door unlock sound bugfix
  101. self.message = string_null; // no more message
  102. oself = self;
  103. if (self.spawnflags & DOOR_TOGGLE)
  104. {
  105. if (self.state == STATE_UP || self.state == STATE_TOP)
  106. {
  107. starte = self;
  108. do
  109. {
  110. door_go_down ();
  111. self = self.enemy;
  112. } while ( (self != starte) && (self != world) );
  113. self = oself;
  114. return;
  115. }
  116. }
  117. // trigger all paired doors
  118. starte = self;
  119. do
  120. {
  121. door_go_up ();
  122. self = self.enemy;
  123. } while ( (self != starte) && (self != world) );
  124. self = oself;
  125. };
  126. void() door_use =
  127. {
  128. local entity oself;
  129. self.message = string_null; // door message are for touch only
  130. self.owner.message = string_null;
  131. self.enemy.message = string_null;
  132. oself = self;
  133. self = self.owner;
  134. door_fire ();
  135. self = oself;
  136. };
  137. void() door_trigger_touch =
  138. {
  139. if (other.health <= 0)
  140. return;
  141. if (time < self.attack_finished)
  142. return;
  143. self.attack_finished = time + 1;
  144. activator = other;
  145. self = self.owner;
  146. door_use ();
  147. };
  148. void() door_killed =
  149. {
  150. local entity oself;
  151. oself = self;
  152. self = self.owner;
  153. self.health = self.max_health;
  154. self.takedamage = DAMAGE_NO; // wil be reset upon return
  155. door_use ();
  156. self = oself;
  157. };
  158. /*
  159. ================
  160. door_touch
  161. Prints messages and opens key doors
  162. ================
  163. */
  164. void() door_touch =
  165. {
  166. if (other.classname != "player")
  167. return;
  168. if (self.owner.attack_finished > time)
  169. return;
  170. self.owner.attack_finished = time + 2;
  171. if (self.owner.message != string_null)
  172. {
  173. centerprint (other, self.owner.message);
  174. sound (other, CHAN_VOICE, "misc/talk.wav", 1, ATTN_NORM);
  175. }
  176. // key door stuff
  177. if (!self.items)
  178. return;
  179. // FIXME: blink key on player's status bar
  180. if ( (self.items & other.items) != self.items )
  181. {
  182. if (self.owner.items == IT_KEY1)
  183. {
  184. if (world.worldtype == WORLDTYPE_BASE)
  185. {
  186. centerprint (other, "$qc_need_silver_keycard");
  187. sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  188. }
  189. else if (world.worldtype == WORLDTYPE_METAL)
  190. {
  191. centerprint (other, "$qc_need_silver_runekey");
  192. sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  193. }
  194. else if (world.worldtype == WORLDTYPE_MEDIEVAL)
  195. {
  196. centerprint (other, "$qc_need_silver_key");
  197. sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  198. }
  199. }
  200. else
  201. {
  202. if (world.worldtype == WORLDTYPE_BASE)
  203. {
  204. centerprint (other, "$qc_need_gold_keycard");
  205. sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  206. }
  207. else if (world.worldtype == WORLDTYPE_METAL)
  208. {
  209. centerprint (other, "$qc_need_gold_runekey");
  210. sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  211. }
  212. else if (world.worldtype == WORLDTYPE_MEDIEVAL)
  213. {
  214. centerprint (other, "$qc_need_gold_key");
  215. sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  216. }
  217. }
  218. return;
  219. }
  220. other.items = other.items - self.items;
  221. self.touch = SUB_Null;
  222. if (self.enemy)
  223. self.enemy.touch = SUB_Null; // get paired door
  224. door_use ();
  225. };
  226. /*
  227. =============================================================================
  228. SPAWNING FUNCTIONS
  229. =============================================================================
  230. */
  231. entity(vector fmins, vector fmaxs) spawn_field =
  232. {
  233. local entity trigger;
  234. local vector t1, t2;
  235. trigger = spawn();
  236. trigger.movetype = MOVETYPE_NONE;
  237. trigger.solid = SOLID_TRIGGER;
  238. trigger.owner = self;
  239. trigger.touch = door_trigger_touch;
  240. t1 = fmins;
  241. t2 = fmaxs;
  242. setsize (trigger, t1 - '60 60 8', t2 + '60 60 8');
  243. return (trigger);
  244. };
  245. float (entity e1, entity e2) EntitiesTouching =
  246. {
  247. if (e1.mins_x > e2.maxs_x)
  248. return FALSE;
  249. if (e1.mins_y > e2.maxs_y)
  250. return FALSE;
  251. if (e1.mins_z > e2.maxs_z)
  252. return FALSE;
  253. if (e1.maxs_x < e2.mins_x)
  254. return FALSE;
  255. if (e1.maxs_y < e2.mins_y)
  256. return FALSE;
  257. if (e1.maxs_z < e2.mins_z)
  258. return FALSE;
  259. return TRUE;
  260. };
  261. /*
  262. =============
  263. LinkDoors
  264. =============
  265. */
  266. void() LinkDoors =
  267. {
  268. local entity t, starte;
  269. local vector cmins, cmaxs;
  270. if (self.enemy)
  271. return; // already linked by another door
  272. if (self.spawnflags & 4)
  273. {
  274. self.owner = self.enemy = self;
  275. return; // don't want to link this door
  276. }
  277. cmins = self.mins;
  278. cmaxs = self.maxs;
  279. starte = self;
  280. t = self;
  281. do
  282. {
  283. self.owner = starte; // master door
  284. if (self.health)
  285. starte.health = self.health;
  286. if (self.targetname != string_null)
  287. starte.targetname = self.targetname;
  288. if (self.message != string_null)
  289. starte.message = self.message;
  290. t = find (t, classname, self.classname);
  291. if (!t)
  292. {
  293. self.enemy = starte; // make the chain a loop
  294. // shootable, fired, or key doors just needed the owner/enemy links,
  295. // they don't spawn a field
  296. self = self.owner;
  297. if (self.health)
  298. return;
  299. if (self.targetname != string_null)
  300. return;
  301. if (self.items)
  302. return;
  303. self.owner.trigger_field = spawn_field(cmins, cmaxs);
  304. return;
  305. }
  306. if (EntitiesTouching(self,t))
  307. {
  308. if (t.enemy)
  309. objerror ("cross connected doors");
  310. self.enemy = t;
  311. self = t;
  312. if (t.mins_x < cmins_x)
  313. cmins_x = t.mins_x;
  314. if (t.mins_y < cmins_y)
  315. cmins_y = t.mins_y;
  316. if (t.mins_z < cmins_z)
  317. cmins_z = t.mins_z;
  318. if (t.maxs_x > cmaxs_x)
  319. cmaxs_x = t.maxs_x;
  320. if (t.maxs_y > cmaxs_y)
  321. cmaxs_y = t.maxs_y;
  322. if (t.maxs_z > cmaxs_z)
  323. cmaxs_z = t.maxs_z;
  324. }
  325. } while (1 );
  326. };
  327. /*QUAKED func_door (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK GOLD_KEY SILVER_KEY TOGGLE
  328. if two doors touch, they are assumed to be connected and operate as a unit.
  329. TOGGLE causes the door to wait in both the start and end states for a trigger event.
  330. 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).
  331. Key doors are allways wait -1.
  332. "message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet
  333. "angle" determines the opening direction
  334. "targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door.
  335. "health" if set, door must be shot open
  336. "speed" movement speed (100 default)
  337. "wait" wait before returning (3 default, -1 = never return)
  338. "lip" lip remaining at end of move (8 default)
  339. "dmg" damage to inflict when blocked (2 default)
  340. "sounds"
  341. 0) no sound
  342. 1) stone
  343. 2) base
  344. 3) stone chain
  345. 4) screechy metal
  346. */
  347. void() func_door =
  348. {
  349. if (world.worldtype == WORLDTYPE_MEDIEVAL)
  350. {
  351. precache_sound ("doors/medtry.wav");
  352. precache_sound ("doors/meduse.wav");
  353. self.noise3 = "doors/medtry.wav";
  354. self.noise4 = "doors/meduse.wav";
  355. }
  356. else if (world.worldtype == WORLDTYPE_METAL)
  357. {
  358. precache_sound ("doors/runetry.wav");
  359. precache_sound ("doors/runeuse.wav");
  360. self.noise3 = "doors/runetry.wav";
  361. self.noise4 = "doors/runeuse.wav";
  362. }
  363. else if (world.worldtype == WORLDTYPE_BASE)
  364. {
  365. precache_sound ("doors/basetry.wav");
  366. precache_sound ("doors/baseuse.wav");
  367. self.noise3 = "doors/basetry.wav";
  368. self.noise4 = "doors/baseuse.wav";
  369. }
  370. else
  371. {
  372. dprint ("no worldtype set!\n");
  373. }
  374. if (self.sounds == 0)
  375. {
  376. precache_sound ("misc/null.wav");
  377. precache_sound ("misc/null.wav");
  378. self.noise1 = "misc/null.wav";
  379. self.noise2 = "misc/null.wav";
  380. }
  381. if (self.sounds == 1)
  382. {
  383. precache_sound ("doors/drclos4.wav");
  384. precache_sound ("doors/doormv1.wav");
  385. self.noise1 = "doors/drclos4.wav";
  386. self.noise2 = "doors/doormv1.wav";
  387. }
  388. if (self.sounds == 2)
  389. {
  390. precache_sound ("doors/hydro1.wav");
  391. precache_sound ("doors/hydro2.wav");
  392. self.noise2 = "doors/hydro1.wav";
  393. self.noise1 = "doors/hydro2.wav";
  394. }
  395. if (self.sounds == 3)
  396. {
  397. precache_sound ("doors/stndr1.wav");
  398. precache_sound ("doors/stndr2.wav");
  399. self.noise2 = "doors/stndr1.wav";
  400. self.noise1 = "doors/stndr2.wav";
  401. }
  402. if (self.sounds == 4)
  403. {
  404. precache_sound ("doors/ddoor1.wav");
  405. precache_sound ("doors/ddoor2.wav");
  406. self.noise1 = "doors/ddoor2.wav";
  407. self.noise2 = "doors/ddoor1.wav";
  408. }
  409. SetMovedir ();
  410. self.max_health = self.health;
  411. self.solid = SOLID_BSP;
  412. self.movetype = MOVETYPE_PUSH;
  413. setorigin (self, self.origin);
  414. setmodel (self, self.model);
  415. self.classname = "func_door";
  416. self.blocked = door_blocked;
  417. self.use = door_use;
  418. if (self.spawnflags & DOOR_SILVER_KEY)
  419. self.items = IT_KEY1;
  420. if (self.spawnflags & DOOR_GOLD_KEY)
  421. self.items = IT_KEY2;
  422. if (!self.speed)
  423. self.speed = 100;
  424. if (!self.wait)
  425. self.wait = 3;
  426. if (!self.lip)
  427. self.lip = 8;
  428. if (!self.dmg)
  429. self.dmg = 2;
  430. self.pos1 = self.origin;
  431. vector movedir_fabs = { fabs(self.movedir[0]), fabs(self.movedir[1]), fabs(self.movedir[2]) };
  432. self.pos2 = self.pos1 + ((movedir_fabs * self.size) - self.lip) * self.movedir;
  433. // DOOR_START_OPEN is to allow an entity to be lighted in the closed position
  434. // but spawn in the open position
  435. if (self.spawnflags & DOOR_START_OPEN)
  436. {
  437. setorigin (self, self.pos2);
  438. self.pos2 = self.pos1;
  439. self.pos1 = self.origin;
  440. }
  441. self.state = STATE_BOTTOM;
  442. if (self.health)
  443. {
  444. self.takedamage = DAMAGE_YES;
  445. self.th_die = door_killed;
  446. }
  447. if (self.items)
  448. self.wait = -1;
  449. self.touch = door_touch;
  450. // LinkDoors can't be done until all of the doors have been spawned, so
  451. // the sizes can be detected properly.
  452. self.think = LinkDoors;
  453. self.nextthink = self.ltime + 0.1;
  454. };
  455. /*
  456. =============================================================================
  457. SECRET DOORS
  458. =============================================================================
  459. */
  460. void() fd_secret_move1;
  461. void() fd_secret_move2;
  462. void() fd_secret_move3;
  463. void() fd_secret_move4;
  464. void() fd_secret_move5;
  465. void() fd_secret_move6;
  466. void() fd_secret_done;
  467. float SECRET_OPEN_ONCE = 1; // stays open
  468. float SECRET_1ST_LEFT = 2; // 1st move is left of arrow
  469. float SECRET_1ST_DOWN = 4; // 1st move is down from arrow
  470. float SECRET_NO_SHOOT = 8; // only opened by trigger
  471. float SECRET_YES_SHOOT = 16; // shootable even if targeted
  472. void () fd_secret_use =
  473. {
  474. local float temp;
  475. self.health = 10000;
  476. // exit if still moving around...
  477. if (self.origin != self.oldorigin)
  478. return;
  479. self.message = string_null; // no more message
  480. SUB_UseTargets(); // fire all targets / killtargets
  481. if (!(self.spawnflags & SECRET_NO_SHOOT))
  482. {
  483. self.th_pain = SUB_Null;
  484. self.takedamage = DAMAGE_NO;
  485. }
  486. self.velocity = '0 0 0';
  487. // Make a sound, wait a little...
  488. sound(self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
  489. self.nextthink = self.ltime + 0.1;
  490. temp = 1 - (self.spawnflags & SECRET_1ST_LEFT); // 1 or -1
  491. makevectors(self.mangle);
  492. if (!self.t_width)
  493. {
  494. if (self.spawnflags & SECRET_1ST_DOWN)
  495. self. t_width = fabs(v_up * self.size);
  496. else
  497. self. t_width = fabs(v_right * self.size);
  498. }
  499. if (!self.t_length)
  500. self. t_length = fabs(v_forward * self.size);
  501. if (self.spawnflags & SECRET_1ST_DOWN)
  502. self.dest1 = self.origin - v_up * self.t_width;
  503. else
  504. self.dest1 = self.origin + v_right * (self.t_width * temp);
  505. self.dest2 = self.dest1 + v_forward * self.t_length;
  506. SUB_CalcMove(self.dest1, self.speed, fd_secret_move1);
  507. sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  508. };
  509. // Wait after first movement...
  510. void () fd_secret_move1 =
  511. {
  512. self.nextthink = self.ltime + 1.0;
  513. self.think = fd_secret_move2;
  514. sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  515. };
  516. // Start moving sideways w/sound...
  517. void () fd_secret_move2 =
  518. {
  519. sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  520. SUB_CalcMove(self.dest2, self.speed, fd_secret_move3);
  521. };
  522. // Wait here until time to go back...
  523. void () fd_secret_move3 =
  524. {
  525. sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  526. if (!(self.spawnflags & SECRET_OPEN_ONCE))
  527. {
  528. self.nextthink = self.ltime + self.wait;
  529. self.think = fd_secret_move4;
  530. }
  531. };
  532. // Move backward...
  533. void () fd_secret_move4 =
  534. {
  535. sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  536. SUB_CalcMove(self.dest1, self.speed, fd_secret_move5);
  537. };
  538. // Wait 1 second...
  539. void () fd_secret_move5 =
  540. {
  541. self.nextthink = self.ltime + 1.0;
  542. self.think = fd_secret_move6;
  543. sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  544. };
  545. void () fd_secret_move6 =
  546. {
  547. sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  548. SUB_CalcMove(self.oldorigin, self.speed, fd_secret_done);
  549. };
  550. void () fd_secret_done =
  551. {
  552. if (!self.targetname || self.spawnflags&SECRET_YES_SHOOT)
  553. {
  554. self.health = 10000;
  555. self.takedamage = DAMAGE_YES;
  556. self.th_pain = fd_secret_use;
  557. self.th_die = fd_secret_use; // secret door kill crash fix
  558. }
  559. sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  560. };
  561. void () secret_blocked =
  562. {
  563. if (time < self.attack_finished)
  564. return;
  565. self.attack_finished = time + 0.5;
  566. T_Damage (other, self, self, self.dmg);
  567. };
  568. /*
  569. ================
  570. secret_touch
  571. Prints messages
  572. ================
  573. */
  574. void() secret_touch =
  575. {
  576. if (other.classname != "player")
  577. return;
  578. if (self.attack_finished > time)
  579. return;
  580. self.attack_finished = time + 2;
  581. if (self.message != string_null)
  582. {
  583. centerprint (other, self.message);
  584. sound (other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM);
  585. }
  586. };
  587. /*QUAKED func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot
  588. Basic secret door. Slides back, then to the side. Angle determines direction.
  589. wait = # of seconds before coming back
  590. 1st_left = 1st move is left of arrow
  591. 1st_down = 1st move is down from arrow
  592. always_shoot = even if targeted, keep shootable
  593. t_width = override WIDTH to move back (or height if going down)
  594. t_length = override LENGTH to move sideways
  595. "dmg" damage to inflict when blocked (2 default)
  596. If a secret door has a targetname, it will only be opened by it's botton or trigger, not by damage.
  597. "sounds"
  598. 1) medieval
  599. 2) metal
  600. 3) base
  601. */
  602. void () func_door_secret =
  603. {
  604. if (self.sounds == 0)
  605. self.sounds = 3;
  606. if (self.sounds == 1)
  607. {
  608. precache_sound ("doors/latch2.wav");
  609. precache_sound ("doors/winch2.wav");
  610. precache_sound ("doors/drclos4.wav");
  611. self.noise1 = "doors/latch2.wav";
  612. self.noise2 = "doors/winch2.wav";
  613. self.noise3 = "doors/drclos4.wav";
  614. }
  615. if (self.sounds == 2)
  616. {
  617. precache_sound ("doors/airdoor1.wav");
  618. precache_sound ("doors/airdoor2.wav");
  619. self.noise2 = "doors/airdoor1.wav";
  620. self.noise1 = "doors/airdoor2.wav";
  621. self.noise3 = "doors/airdoor2.wav";
  622. }
  623. if (self.sounds == 3)
  624. {
  625. precache_sound ("doors/basesec1.wav");
  626. precache_sound ("doors/basesec2.wav");
  627. self.noise2 = "doors/basesec1.wav";
  628. self.noise1 = "doors/basesec2.wav";
  629. self.noise3 = "doors/basesec2.wav";
  630. }
  631. if (!self.dmg)
  632. self.dmg = 2;
  633. // Magic formula...
  634. self.mangle = self.angles;
  635. self.angles = '0 0 0';
  636. self.solid = SOLID_BSP;
  637. self.movetype = MOVETYPE_PUSH;
  638. self.classname = "func_door_secret";
  639. setmodel (self, self.model);
  640. setorigin (self, self.origin);
  641. self.touch = secret_touch;
  642. self.blocked = secret_blocked;
  643. self.speed = 50;
  644. self.use = fd_secret_use;
  645. if ( !self.targetname || self.spawnflags&SECRET_YES_SHOOT)
  646. {
  647. self.health = 10000;
  648. self.takedamage = DAMAGE_YES;
  649. self.th_pain = fd_secret_use;
  650. self.th_die = fd_secret_use;
  651. }
  652. self.oldorigin = self.origin;
  653. if (!self.wait)
  654. self.wait = 5; // 5 seconds before closing
  655. };