home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 159_01 / turn.c < prev    next >
C/C++ Source or Header  |  1990-05-17  |  17KB  |  933 lines

  1.  
  2.  /* TURN.C  no mods for V 1.43 
  3.   *
  4.   * Modified all calls of rand() to irand() for Eco-C88 (BW)
  5.   */
  6.  
  7. #include "advent.h"
  8.  
  9.  
  10. /*
  11.         Routine to take 1 turn
  12. */
  13. VOID PASCAL turn(VOID)
  14. {
  15.     auto     SHORT      i;
  16.  
  17.     /* if closing, then he can't leave except via the main office. */
  18.     if (newloc < 9 && newloc != 0 && closing)
  19.     {
  20.     rspeak(130);
  21.     newloc = loc;
  22.     if (!panic)
  23.         clock2 = 15;
  24.     panic = 1;
  25.     }
  26.     /* see if a dwarf has seen him and has come from where he wants to go. */
  27.     if (newloc != loc && !forced(loc) && cond[loc] & NOPIRAT == 0)
  28.     {
  29.     for (i = 1; i < (DWARFMAX - 1); ++i)
  30.         if (odloc[i] == newloc && dseen[i])
  31.         {
  32.         newloc = loc;
  33.         rspeak(2);
  34.         break;
  35.         }
  36.     }
  37.  
  38.     dwarves();
  39.  
  40.     /* on to the regular move. */
  41.     if (loc != newloc)
  42.     {
  43.     ++turns;
  44.     loc = newloc;
  45.     /* check for death */
  46.     if (loc == 0)
  47.     {
  48.         death();
  49.         return;
  50.     }
  51.     /* check for forced move */
  52.     if (forced(loc))
  53.     {
  54.         describe();
  55.         domove();
  56.         return;
  57.     }
  58.     /* check for wandering in dark */
  59.     if (wzdark && dark() && pct(35))
  60.     {
  61.         rspeak(23);
  62.         oldloc2 = loc;
  63.         death();
  64.         return;
  65.     }
  66.     /* describe his situation */
  67.     describe();
  68.     if (!dark())
  69.     {
  70.         ++visited[loc];
  71.         descitem();
  72.     }
  73.     }
  74.     if (closed)
  75.     {
  76.     if (prop[OYSTER] < 0 && toting(OYSTER))
  77.         pspeak(OYSTER, 1);
  78.     for (i = 1; i <= MAXOBJ; ++i)
  79.     {
  80.         if (toting(i) && prop[i] < 0)
  81.         prop[i] = -1 - prop[i];
  82.     }
  83.     }
  84.     wzdark = dark();
  85.     if (knfloc > 0 && knfloc != loc)
  86.     knfloc = 0;
  87.     /* run the timer routine */
  88.     if (stimer())
  89.     return;
  90.     /* ask what he wants to do */
  91.     /* debug */
  92.     if (dbgflg)
  93.     printf("Your current location is %d\n", loc);
  94.     while (!english())
  95.     ;
  96.  
  97.     /* act on his instructions */
  98.     if (motion)
  99.     domove();
  100.     else
  101.     {
  102.     if (object)
  103.         doobj();
  104.     else
  105.         itverb();
  106.     }
  107.  
  108.     return;
  109. }
  110.  
  111. /*
  112.         Routine to describe current location
  113. */
  114. VOID PASCAL describe(VOID)
  115. {
  116.     if (toting(BEAR))
  117.     rspeak(141);
  118.     if (dark())
  119.     rspeak(16);
  120.     else
  121.     {
  122.     if (visited[loc] && brief_sw)
  123.         descsh(loc);
  124.     else
  125.         desclg(loc);
  126.     }
  127.     if (loc == 33 && pct(25) && !closing)
  128.     rspeak(8);
  129.  
  130.     return;
  131. }
  132.  
  133. /*
  134.         Routine to describe visible items
  135. */
  136. VOID PASCAL descitem(VOID)
  137. {
  138.     auto     SHORT      i, state;
  139.  
  140.     for (i = 1; i < MAXOBJ; ++i)
  141.     {
  142.     if (at(i))
  143.     {
  144.         if (i == STEPS && toting(NUGGET))
  145.         continue;
  146.         if (prop[i] < 0)
  147.         {
  148.         if (closed)
  149.             continue;
  150.         else
  151.         {
  152.             prop[i] = 0;
  153.             if (i == RUG || i == CHAIN)
  154.             ++prop[i];
  155.             --tally;
  156.         }
  157.         }
  158.         if (i == STEPS && loc == fixed[STEPS])
  159.         state = 1;
  160.         else
  161.         state = prop[i];
  162.         pspeak(i, state);
  163.     }
  164.     }
  165.     if (tally == tally2 && tally != 0 && limit > 35)
  166.     limit = 35;
  167.  
  168.     return;
  169. }
  170.  
  171. /*
  172.         Routine to handle motion requests
  173. */
  174. VOID PASCAL domove(VOID)
  175. {
  176.     gettrav(loc);
  177.     switch (motion)
  178.     {
  179.     case NULLX:
  180.         break;
  181.     case BACK:
  182.         goback();
  183.         break;
  184.     case LOOK:
  185.         if (detail++ < 3)
  186.         rspeak(15);
  187.         wzdark = 0;
  188.         visited[loc] = 0;
  189.         newloc = loc;
  190.         loc = 0;
  191.         break;
  192.     case CAVE:
  193.         if (loc < 8)
  194.         rspeak(57);
  195.         else
  196.         rspeak(58);
  197.         break;
  198.     default:
  199.         oldloc2 = oldloc;
  200.         oldloc = loc;
  201.         dotrav();
  202.         loc = 0;        /* Modified BW 09/28/85   */
  203.     }
  204.  
  205.     return;
  206. }
  207.  
  208. /*
  209.         Routine to handle request to return
  210.         from whence we came!
  211. */
  212. VOID PASCAL goback(VOID)
  213. {
  214.     auto     SHORT          kk, k2, want, temp;
  215.     auto     TRAV         *pSavTrav;
  216.     auto     SHORT          sSavCnt;
  217.  
  218.     if (forced(oldloc))
  219.     want = oldloc2;
  220.     else
  221.     want = oldloc;
  222.     oldloc2 = oldloc;
  223.     oldloc = loc;
  224.     k2 = 0;
  225.     if (want == loc)
  226.     {
  227.     rspeak(91);
  228.     return;
  229.     }
  230.  
  231.     pSavTrav = pTravel;
  232.     sSavCnt  = sTravCnt;
  233.  
  234.     for (kk = 0; kk < sTravCnt; ++kk)
  235.     {
  236.     if (!pTravel[kk].tcond && pTravel[kk].tdest == want)
  237.     {
  238.         motion = pTravel[kk].tverb;
  239.         dotrav();
  240.         return;
  241.     }
  242.     if (!pTravel[kk].tcond)
  243.     {
  244.         k2     = kk;
  245.         temp = pTravel[kk].tdest;
  246.         gettrav(temp);
  247.         if (forced(temp) && pTravel[0].tdest == want)
  248.         k2 = temp;
  249.         pTravel  = pSavTrav;
  250.         sTravCnt = sSavCnt;
  251.     }
  252.     }
  253.  
  254.     if (k2)
  255.     {
  256.     motion = pTravel[k2].tverb;
  257.     dotrav();
  258.     }
  259.     else
  260.     rspeak(140);
  261.  
  262.     return;
  263. }
  264.  
  265. /*
  266.         Routine to figure out a new location
  267.         given current location and a motion.
  268. */
  269. VOID PASCAL dotrav(VOID)
  270. {
  271.     auto     SHORT     mvflag, hitflag, kk;
  272.     auto     SHORT     rdest, rverb, rcond, robject;
  273.     auto     SHORT     pctt;
  274.  
  275.     newloc = loc;
  276.     mvflag = hitflag = 0;
  277.     pctt   = rand() % 100;
  278.  
  279.     for (kk = 0; kk < sTravCnt && !mvflag; ++kk)
  280.     {
  281.     rdest    = pTravel[kk].tdest;
  282.     rverb    = pTravel[kk].tverb;
  283.     rcond    = pTravel[kk].tcond;
  284.     robject = rcond % 100;
  285.     if (rverb != 1 && rverb != motion && !hitflag)
  286.         continue;
  287.     ++hitflag;
  288.     switch (rcond / 100)
  289.     {
  290.         case 0:
  291.         if (rcond == 0 || pctt < rcond)
  292.             ++mvflag;
  293.         /* debug */
  294.         if (rcond && dbgflg)
  295.             printf("\% move %d %d\n",
  296.                pctt, mvflag);
  297.         break;
  298.         case 1:
  299.         if (robject == 0)
  300.             ++mvflag;
  301.         else
  302.         {
  303.             if (toting(robject))
  304.             ++mvflag;
  305.         }
  306.         break;
  307.         case 2:
  308.         if (toting(robject) || at(robject))
  309.             ++mvflag;
  310.         break;
  311.         case 3:
  312.         case 4:
  313.         case 5:
  314.         case 7:
  315.         if (prop[robject] != (rcond / 100) - 3)
  316.             ++mvflag;
  317.         break;
  318.         default:
  319.         bug(37);
  320.     }
  321.     }
  322.     if (!mvflag)
  323.     badmove();
  324.     else
  325.     {
  326.     if (rdest > 500)
  327.         rspeak(rdest - 500);
  328.     else
  329.     {
  330.         if (rdest > 300)
  331.         spcmove(rdest);
  332.         else
  333.         newloc = rdest;
  334.     }
  335.     }
  336.  
  337.     return;
  338. }
  339.  
  340. /*
  341.         The player tried a poor move option.
  342. */
  343. VOID PASCAL badmove(VOID)
  344. {
  345.     auto     SHORT      msg;
  346.  
  347.     msg = 12;
  348.     if (motion >= 43 && motion <= 50)
  349.     msg = 9;
  350.     if (motion == 29 || motion == 30)
  351.     msg = 9;
  352.     if (motion == 7 || motion == 36 || motion == 37)
  353.     msg = 10;
  354.     if (motion == 11 || motion == 19)
  355.     msg = 11;
  356.     if (verb == FIND || verb == INVENTORY)
  357.     msg = 59;
  358.     if (motion == 62 || motion == 65)
  359.     msg = 42;
  360.     if (motion == 17)
  361.     msg = 80;
  362.     rspeak(msg);
  363.  
  364.     return;
  365. }
  366.  
  367. /*
  368.         Routine to handle very special movement.
  369. */
  370. VOID PASCAL spcmove(SHORT rdest)
  371. {
  372.     switch (rdest - 300)
  373.     {
  374.     case 1:        /* plover movement via alcove */
  375.         if (!holding || (holding == 1 && toting(EMERALD)))
  376.         newloc = (99 + 100) - loc;
  377.         else
  378.         rspeak(117);
  379.         break;
  380.     case 2:        /* trying to remove plover, bad route */
  381.         drop(EMERALD, loc);
  382.         break;
  383.     case 3:        /* troll bridge */
  384.         if (prop[TROLL] == 1)
  385.         {
  386.         pspeak(TROLL, 1);
  387.         prop[TROLL] = 0;
  388.         move(TROLL2, 0);
  389.         move((TROLL2 + MAXOBJ), 0);
  390.         move(TROLL, 117);
  391.         move((TROLL + MAXOBJ), 122);
  392.         juggle(CHASM);
  393.         newloc = loc;
  394.         }
  395.         else
  396.         {
  397.         newloc = (loc == 117 ? 122 : 117);
  398.         if (prop[TROLL] == 0)
  399.             ++prop[TROLL];
  400.         if (!toting(BEAR))
  401.             return;
  402.         rspeak(162);
  403.         prop[CHASM] = 1;
  404.         prop[TROLL] = 2;
  405.         drop(BEAR, newloc);
  406.         fixed[BEAR] = -1;
  407.         prop[BEAR] = 3;
  408.         if (prop[SPICES] < 0)
  409.             ++tally2;
  410.         oldloc2 = newloc;
  411.         death();
  412.         }
  413.         break;
  414.     default:
  415.         bug(38);
  416.     }
  417.  
  418.     return;
  419. }
  420.  
  421.  
  422. /*
  423.         Routine to handle player's demise via
  424.         waking up the dwarves...
  425. */
  426. VOID PASCAL dwarfend(VOID)
  427. {
  428.     death();
  429.     normend();            /* no return from here */
  430. }
  431.  
  432. /*
  433.         normal end of game
  434. */
  435. VOID PASCAL normend(VOID)
  436. {
  437.     score();
  438.     exit(1);
  439. }
  440.  
  441. /*
  442.         scoring
  443. */
  444. VOID PASCAL score(VOID)
  445. {
  446.     auto     SHORT    t, i, k, s;
  447.  
  448.     s = t = 0;
  449.     for (i = 50; i <= MAXTRS; ++i)
  450.     {
  451.     if (i == CHEST)
  452.         k = 14;
  453.     else
  454.         k = i > CHEST ? 16 : 12;
  455.  
  456.     if (prop[i] >= 0)
  457.         t += 2;
  458.  
  459.     if (place[i] == 3 && prop[i] == 0)
  460.         t += k - 2;
  461.     }
  462.  
  463.     printf("%-20s%d\n", "Treasures:", s = t);
  464.     t = (MAXDIE - numdie) * 10;
  465.     if (t)
  466.     printf("%-20s%d\n", "Survival:", t);
  467.     s += t;
  468.     if (!gaveup)
  469.     s += 4;
  470.     t = dflag ? 25 : 0;
  471.     if (t)
  472.     printf("%-20s%d\n", "Getting well in:", t);
  473.     s += t;
  474.     t = closing ? 25 : 0;
  475.     if (t)
  476.     printf("%-20s%d\n", "Masters section:", t);
  477.     s += t;
  478.  
  479.     if (closed)
  480.     {
  481.     if (bonus == 0)
  482.         t = 10;
  483.     else
  484.     {
  485.         if (bonus == 135)
  486.         t = 25;
  487.         else
  488.         {
  489.         if (bonus == 134)
  490.             t = 30;
  491.         else
  492.         {
  493.             if (bonus == 133)
  494.             t = 45;
  495.         }
  496.         }
  497.     }
  498.     printf("%-20s%d\n", "Bonus:", t);
  499.     s += t;
  500.     }
  501.  
  502.     if (place[MAGAZINE] == 108)
  503.     s += 1;
  504.     s += 2;
  505.     printf("%-20s%d\n", "Score:", s);
  506.     return;
  507. }
  508.  
  509. /*
  510.         Routine to handle the passing on of one
  511.         of the player's incarnations...
  512. */
  513. VOID PASCAL death(VOID)
  514. {
  515.     auto     SHORT     yea, i, j;
  516.  
  517.     if (!closing)
  518.     {
  519.     yea = yes(81 + numdie * 2, 82 + numdie * 2, 54);
  520.     if (++numdie >= MAXDIE || !yea)
  521.         normend();
  522.     place[WATER] = 0;
  523.     place[OIL] = 0;
  524.     if (toting(LAMP))
  525.         prop[LAMP] = 0;
  526.     for (j = 1; j < 101; ++j)
  527.     {
  528.         i = 101 - j;
  529.         if (toting(i))
  530.         drop(i, i == LAMP ? 1 : oldloc2);
  531.     }
  532.     newloc = 3;
  533.     oldloc = loc;
  534.     return;
  535.     }
  536.  
  537.     /* closing -- no resurrection... */
  538.     rspeak(131);
  539.     ++numdie;
  540.     normend();                /* no return from here */
  541. }
  542.  
  543. /*
  544.         Routine to process an object.
  545. */
  546. VOID PASCAL doobj(VOID)
  547. {
  548.     /* is object here?  if so, transitive */
  549.     if (fixed[object] == loc || here(object))
  550.     trobj();
  551.     /* did he give grate as destination? */
  552.     else
  553.     {
  554.     if (object == GRATE)
  555.     {
  556.         if (loc == 1 || loc == 4 || loc == 7)
  557.         {
  558.         motion = DEPRESSION;
  559.         domove();
  560.         }
  561.         else
  562.         {
  563.         if (loc > 9 && loc < 15)
  564.         {
  565.             motion = ENTRANCE;
  566.             domove();
  567.         }
  568.         }
  569.     }
  570.     /* is it a dwarf he is after? */
  571.     else
  572.     {
  573.         if (dcheck() && dflag >= 2)
  574.         {
  575.         object = DWARF;
  576.         trobj();
  577.         }
  578.         /* is he trying to get/use a liquid? */
  579.         else
  580.         {
  581.         if ((liq() == object && here(BOTTLE)) || liqloc(loc) == object)
  582.             trobj();
  583.         else
  584.         {
  585.             if (object == PLANT && at(PLANT2) && prop[PLANT2] == 0)
  586.             {
  587.             object = PLANT2;
  588.             trobj();
  589.             }
  590.             /* is he trying to grab a knife? */
  591.             else
  592.             {
  593.             if (object == KNIFE && knfloc == loc)
  594.             {
  595.                 rspeak(116);
  596.                 knfloc = -1;
  597.             }
  598.             /* is he trying to get at dynamite? */
  599.             else
  600.             {
  601.                 if (object == ROD && here(ROD2))
  602.                 {
  603.                 object = ROD2;
  604.                 trobj();
  605.                 }
  606.                 else
  607.                 printf("I see no %s here.\n", probj(object));
  608.             }
  609.             }
  610.         }
  611.         }
  612.     }
  613.     }
  614.  
  615.     return;
  616. }
  617.  
  618. /*
  619.         Routine to process an object being
  620.         referred to.
  621. */
  622. VOID PASCAL trobj(VOID)
  623. {
  624.     if (verb)
  625.     trverb();
  626.     else
  627.     printf("What do you want to do with the %s?\n", probj(object));
  628.  
  629.     return;
  630. }
  631.  
  632. /*
  633.         Routine to print word corresponding to object
  634. */
  635. char * PASCAL probj(SHORT object)
  636. {
  637.     auto     SHORT      wtype, wval;
  638.  
  639.     object = object;                /* eliminate compiler warning */
  640.     analyze(word1, &wtype, &wval);
  641.     return((wtype == 1) ? word1 : word2);
  642. }
  643.  
  644. /*
  645.         dwarf stuff.
  646. */
  647. VOID PASCAL dwarves(VOID)
  648. {
  649.     auto     SHORT    i, j, k, try, attack, stick, dtotal;
  650.  
  651.     /* see if dwarves allowed here */
  652.     if (newloc == 0 || forced(newloc) || cond[newloc] & NOPIRAT)
  653.     return;
  654.     /* see if dwarves are active. */
  655.     if (!dflag)
  656.     {
  657.     if (newloc > 15)
  658.         ++dflag;
  659.     return;
  660.     }
  661.     /* if first close encounter (of 3rd kind) kill 0, 1 or 2 */
  662.     if (dflag == 1)
  663.     {
  664.     if (newloc < 15 || pct(95))
  665.         return;
  666.     ++dflag;
  667.     for (i = 1; i < 3; ++i)
  668.     {
  669.         if (pct(50))
  670.         dloc[rand() % 5 + 1] = 0;
  671.     }
  672.  
  673.     for (i = 1; i < (DWARFMAX - 1); ++i)
  674.     {
  675.         if (dloc[i] == newloc)
  676.         dloc[i] = daltloc;
  677.         odloc[i] = dloc[i];
  678.     }
  679.     rspeak(3);
  680.     drop(AXE, newloc);
  681.     return;
  682.     }
  683.  
  684.     dtotal = attack = stick = 0;
  685.     for (i = 1; i < DWARFMAX; ++i)
  686.     {
  687.     if (dloc[i] == 0)
  688.         continue;
  689.     /* move a dwarf at random.  we don't have a matrix around to do it as
  690.      * in the original version... */
  691.     for (try = 1; try < 20; ++try)
  692.     {
  693.         j = rand() % 106 + 15;    /* allowed area */
  694.         if (j != odloc[i] && j != dloc[i]
  695.                   &&
  696.         !(i == (DWARFMAX - 1) && cond[j] & NOPIRAT == 1))
  697.         break;
  698.     }
  699.     if (j == 0)
  700.         j = odloc[i];
  701.     odloc[i] = dloc[i];
  702.     dloc[i] = j;
  703.     if ((dseen[i] && newloc >= 15) ||
  704.         dloc[i] == newloc || odloc[i] == newloc)
  705.         dseen[i] = 1;
  706.     else
  707.         dseen[i] = 0;
  708.     if (!dseen[i])
  709.         continue;
  710.     dloc[i] = newloc;
  711.     if (i == 6)
  712.         dopirate();
  713.     else
  714.     {
  715.         ++dtotal;
  716.         if (odloc[i] == dloc[i])
  717.         {
  718.         ++attack;
  719.         if (knfloc >= 0)
  720.             knfloc = newloc;
  721.         if (rand() % 1000 < 30 * (dflag - 2))
  722.             ++stick;
  723.         }
  724.     }
  725.     }
  726.     if (dtotal == 0)
  727.     return;
  728.     if (dtotal > 1)
  729.     printf("There are %d threatening little dwarves in the room with you!\n", dtotal);
  730.     else
  731.     rspeak(4);
  732.     if (attack == 0)
  733.     return;
  734.     if (dflag == 2)
  735.     ++dflag;
  736.  
  737.     if (attack > 1)
  738.     {
  739.     printf("%d of them throw knives at you!!\n", attack);
  740.     k = 6;
  741.     }
  742.     else
  743.     {
  744.     rspeak(5);
  745.     k = 52;
  746.     }
  747.  
  748.     if (stick <= 1)
  749.     {
  750.     rspeak(stick + k);
  751.     if (stick == 0)
  752.         return;
  753.     }
  754.     else
  755.     printf("%d of them get you !!!\n", stick);
  756.  
  757.     oldloc2 = newloc;
  758.     death();
  759.  
  760.     return;
  761. }
  762.  
  763. /*
  764.         pirate stuff
  765. */
  766. VOID PASCAL dopirate(VOID)
  767. {
  768.     auto     SHORT      j, k;
  769.  
  770.     if (newloc == chloc || prop[CHEST] >= 0)
  771.     return;
  772.  
  773.     k = 0;
  774.     for (j = 50; j <= MAXTRS; ++j)
  775.     if (j != PYRAMID
  776.           ||
  777.         (newloc != place[PYRAMID] && newloc != place[EMERALD]))
  778.     {
  779.         if (toting(j))
  780.         goto stealit;
  781.         if (here(j))
  782.         ++k;
  783.     }
  784.     if (tally == tally2 + 1 && k == 0 && place[CHEST] == 0
  785.                 &&
  786.          here(LAMP) && prop[LAMP] == 1)
  787.     {
  788.     rspeak(186);
  789.     move(CHEST, chloc);
  790.     move(MESSAGE, chloc2);
  791.     dloc[6] = chloc;
  792.     odloc[6] = chloc;
  793.     dseen[6] = 0;
  794.     return;
  795.     }
  796.     if (odloc[6] != dloc[6] && pct(20))
  797.     {
  798.     rspeak(127);
  799.     return;
  800.     }
  801.     return;
  802.  
  803. stealit:
  804.     rspeak(128);
  805.     if (place[MESSAGE] == 0)
  806.     move(CHEST, chloc);
  807.     move(MESSAGE, chloc2);
  808.     for (j = 50; j <= MAXTRS; ++j)
  809.     {
  810.     if (j == PYRAMID &&
  811.         (newloc == place[PYRAMID] ||
  812.          newloc == place[EMERALD]))
  813.         continue;
  814.     if (at(j) && fixed[j] == 0)
  815.         carry(j, newloc);
  816.     if (toting(j))
  817.         drop(j, chloc);
  818.     }
  819.     dloc[6] = chloc;
  820.     odloc[6] = chloc;
  821.     dseen[6] = 0;
  822.  
  823.     return;
  824. }
  825.  
  826. /*
  827.         special time limit stuff...
  828. */
  829. BOOL PASCAL stimer(VOID)
  830. {
  831.     register SHORT      i;
  832.  
  833.     foobar = foobar > 0 ? -foobar : 0;
  834.     if (tally == 0 && loc >= 15 && loc != 33)
  835.     --clock1;
  836.     if (clock1 == 0)
  837.     {
  838.     /* start closing the cave */
  839.     prop[GRATE] = 0;
  840.     prop[FISSURE] = 0;
  841.     for (i = 1; i < DWARFMAX; ++i)
  842.         dseen[i] = 0;
  843.     move(TROLL, 0);
  844.     move((TROLL + MAXOBJ), 0);
  845.     move(TROLL2, 117);
  846.     move((TROLL2 + MAXOBJ), 122);
  847.     juggle(CHASM);
  848.     if (prop[BEAR] != 3)
  849.         dstroy(BEAR);
  850.     prop[CHAIN] = 0;
  851.     fixed[CHAIN] = 0;
  852.     prop[AXE] = 0;
  853.     fixed[AXE] = 0;
  854.     rspeak(129);
  855.     clock1    = -1;
  856.     closing = 1;
  857.     return(FALSE);
  858.     }
  859.     if (clock1 < 0)
  860.     --clock2;
  861.     if (clock2 == 0)
  862.     {
  863.     /* set up storage room... and close the cave... */
  864.     prop[BOTTLE] = put(BOTTLE, 115, 1);
  865.     prop[PLANT]  = put(PLANT, 115, 0);
  866.     prop[OYSTER] = put(OYSTER, 115, 0);
  867.     prop[LAMP]   = put(LAMP, 115, 0);
  868.     prop[ROD]    = put(ROD, 115, 0);
  869.     prop[DWARF]  = put(DWARF, 115, 0);
  870.     loc         = 115;
  871.     oldloc         = 115;
  872.     newloc         = 115;
  873.     put(GRATE, 116, 0);
  874.     prop[SNAKE]  = put(SNAKE, 116, 1);
  875.     prop[BIRD]   = put(BIRD, 116, 1);
  876.     prop[CAGE]   = put(CAGE, 116, 0);
  877.     prop[ROD2]   = put(ROD2, 116, 0);
  878.     prop[PILLOW] = put(PILLOW, 116, 0);
  879.     prop[MIRROR] = put(MIRROR, 115, 0);
  880.     fixed[MIRROR] = 116;
  881.     for (i = 1; i <= MAXOBJ; ++i)
  882.         if (toting(i))
  883.         dstroy(i);
  884.     rspeak(132);
  885.     closed = 1;
  886.     return(TRUE);
  887.     }
  888.     if (prop[LAMP] == 1)
  889.     --limit;
  890.     if (limit <= 30 &&
  891.     here(BATTERIES) && prop[BATTERIES] == 0 &&
  892.     here(LAMP))
  893.     {
  894.     rspeak(188);
  895.     prop[BATTERIES] = 1;
  896.     if (toting(BATTERIES))
  897.         drop(BATTERIES, loc);
  898.     limit += 2500;
  899.     lmwarn = 0;
  900.     return(FALSE);
  901.     }
  902.  
  903.     if (limit == 0)
  904.     {
  905.     --limit;
  906.     prop[LAMP] = 0;
  907.     if (here(LAMP))
  908.         rspeak(184);
  909.     return(FALSE);
  910.     }
  911.     if (limit < 0 && loc <= 8)
  912.     {
  913.     rspeak(185);
  914.     gaveup = 1;
  915.     normend();
  916.     }
  917.  
  918.     if (limit <= 30)
  919.     {
  920.     if (lmwarn || !here(LAMP))
  921.         return(FALSE);
  922.     lmwarn = 1;
  923.     i = 187;
  924.     if (place[BATTERIES] == 0)
  925.         i = 183;
  926.     if (prop[BATTERIES] == 1)
  927.         i = 189;
  928.     rspeak(i);
  929.     }
  930.  
  931.     return(FALSE);
  932. }
  933.