home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / qplus10 / doors.qc < prev    next >
Encoding:
Text File  |  1996-08-18  |  17.0 KB  |  792 lines

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