home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Games / larn12s.arc / LARN.ARC / OBJECT.C < prev    next >
C/C++ Source or Header  |  1987-10-28  |  27KB  |  845 lines

  1. /*    object.c        Larn is copyrighted 1986 by Noah Morgan. */
  2. #include "header.h"
  3.  
  4. /*
  5.     ***************
  6.     LOOK_FOR_OBJECT
  7.     ***************
  8.  
  9.     subroutine to look for an object and give the player his options
  10.     if an object was found.
  11.  */
  12. lookforobject()
  13. {
  14. register int i,j;
  15. if (c[TIMESTOP])  return;    /* can't find objects is time is stopped    */
  16. i=item[playerx][playery];    if (i==0) return;
  17. showcell(playerx,playery);  cursors();  yrepcount=0;
  18. switch(i)
  19.     {
  20.     case OGOLDPILE:    case OMAXGOLD:
  21.     case OKGOLD:    case ODGOLD:    lprcat("\n\nYou have found some gold!");    ogold(i);    break;
  22.  
  23.     case OPOTION:    lprcat("\n\nYou have found a magic potion");
  24.                 i = iarg[playerx][playery];
  25.                 if (potionname[i][0]) lprintf(" of %s",&potionname[i][1]);  opotion(i);  break;
  26.  
  27.     case OSCROLL:    lprcat("\n\nYou have found a magic scroll");
  28.                 i = iarg[playerx][playery];
  29.                 if (scrollname[i][0])    lprintf(" of %s",&scrollname[i][1]);
  30.                 oscroll(i);  break;
  31.  
  32.     case OALTAR:    if (nearbymonst()) return;
  33.                     lprcat("\n\nThere is a Holy Altar here!"); oaltar(); break;
  34.  
  35.     case OBOOK:    lprcat("\n\nYou have found a book."); obook(); break;
  36.  
  37.     case OCOOKIE:    lprcat("\n\nYou have found a fortune cookie."); ocookie(); break;
  38.  
  39.     case OTHRONE:    if (nearbymonst()) return;
  40.                     lprintf("\n\nThere is %s here!",objectname[i]); othrone(0); break;
  41.  
  42.     case OTHRONE2:    if (nearbymonst()) return;
  43.                     lprintf("\n\nThere is %s here!",objectname[i]); othrone(1); break;
  44.  
  45.     case ODEADTHRONE: lprintf("\n\nThere is %s here!",objectname[i]); odeadthrone(); break;
  46.  
  47.     case OORB:        lprcat("\n\nYou have found the Orb!!!!!"); oorb(); break;
  48.  
  49.     case OPIT:        lprcat("\n\nYou're standing at the top of a pit."); opit(); break;
  50.  
  51.     case OSTAIRSUP:        lprcat("\n\nThere is a circular staircase here"); ostairs(1);  /* up */ break;
  52.  
  53.     case OELEVATORUP:    lprcat("\n\nYou feel heavy for a moment, but the feeling disappears");
  54.                 oelevator(1);  /*  up  */  break;
  55.  
  56.     case OFOUNTAIN:    if (nearbymonst()) return;
  57.                     lprcat("\n\nThere is a fountain here"); ofountain(); break;
  58.  
  59.     case OSTATUE:    if (nearbymonst()) return;
  60.                     lprcat("\n\nYou are standing in front of a statue"); ostatue(); break;
  61.  
  62.     case OCHEST:    lprcat("\n\nThere is a chest here");  ochest();  break;
  63.  
  64.     case OIVTELETRAP:    if (rnd(11)<6) return;
  65.                         item[playerx][playery] = OTELEPORTER;
  66. # ifdef DGK
  67.                         know[playerx][playery] = KNOWALL;
  68. # else
  69.                         know[playerx][playery] = 1;
  70. # endif
  71.  
  72.     case OTELEPORTER:    lprcat("\nZaaaappp!  You've been teleported!\n");
  73.                         beep(); nap(3000); oteleport(0);
  74.                         break; 
  75.  
  76.     case OSCHOOL:    if (nearbymonst()) return;
  77.                 lprcat("\n\nYou have found the College of Larn.");
  78.                 lprcat("\nDo you (g) go inside, or (i) stay here? ");
  79.                 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
  80.                 if (i == 'g') { oschool();  /*    the college of larn    */ }
  81.                 else    lprcat(" stay here");
  82.                 break;
  83.  
  84.     case OMIRROR:    if (nearbymonst()) return;
  85.                     lprcat("\n\nThere is a mirror here");    omirror();    break;
  86.  
  87.     case OBANK2:
  88.     case OBANK:    if (nearbymonst()) return;
  89.                 if (i==OBANK) lprcat("\n\nYou have found the bank of Larn.");
  90.                 else lprcat("\n\nYou have found a branch office of the bank of Larn.");
  91.                 lprcat("\nDo you (g) go inside, or (i) stay here? ");
  92.                 j=0; while ((j!='g') && (j!='i') && (j!='\33')) j=getchar();
  93.                 if (j == 'g') {  if (i==OBANK) obank(); else obank2(); /*  the bank of larn  */  }
  94.                 else   lprcat(" stay here");
  95.                 break;
  96.  
  97.     case ODEADFOUNTAIN:    if (nearbymonst()) return;
  98.                         lprcat("\n\nThere is a dead fountain here"); break;
  99.  
  100.     case ODNDSTORE:    if (nearbymonst()) return;
  101.                     lprcat("\n\nThere is a DND store here.");
  102.                     lprcat("\nDo you (g) go inside, or (i) stay here? ");
  103.                     i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
  104.                     if (i == 'g')
  105.                         dndstore();  /*  the dnd adventurers store  */
  106.                     else  lprcat(" stay here");
  107.                     break;
  108.  
  109.     case OSTAIRSDOWN:    lprcat("\n\nThere is a circular staircase here"); ostairs(-1); /* down */ break;
  110.  
  111.     case OELEVATORDOWN:    lprcat("\n\nYou feel light for a moment, but the feeling disappears");
  112.                 oelevator(-1);    /*    down    */
  113.                 break;
  114.  
  115.     case OOPENDOOR:        lprintf("\n\nYou have found %s",objectname[i]);
  116.                         lprcat("\nDo you (c) close it"); iopts();
  117.                         i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
  118.                         if ((i=='\33') || (i=='i')) { ignore();  break; }
  119.                         lprcat("close");  forget();
  120.                         item[playerx][playery]=OCLOSEDDOOR;
  121.                         iarg[playerx][playery]=0;
  122.                         playerx = lastpx;  playery = lastpy;
  123.                         break;
  124.  
  125.     case OCLOSEDDOOR:    lprintf("\n\nYou have found %s",objectname[i]);
  126.                         lprcat("\nDo you (o) try to open it"); iopts();
  127.                         i=0; while ((i!='o') && (i!='i') && (i!='\33')) i=getchar();
  128.                         if ((i=='\33') || (i=='i'))
  129.                             { ignore();  playerx = lastpx;
  130.                             playery = lastpy; break; }
  131.                         else
  132.                         {
  133.                         lprcat("open");
  134.                         if (rnd(11)<7)
  135.                           {
  136.                           switch(iarg[playerx][playery])
  137.                             {
  138.                             case 6: c[AGGRAVATE] += rnd(400);    break;
  139.  
  140.                             case 7:    lprcat("\nYou are jolted by an electric shock "); 
  141.                                     lastnum=274; losehp(rnd(20));  bottomline();  break;
  142.  
  143.                             case 8:    loselevel();  break;
  144.  
  145.                             case 9:    lprcat("\nYou suddenly feel weaker ");
  146.                                     if (c[STRENGTH]>3) c[STRENGTH]--;
  147.                                     bottomline();  break;
  148.  
  149.                             default:    break;
  150.                             }
  151.                           playerx = lastpx;  playery = lastpy;
  152.                           }
  153.                         else
  154.                           {
  155.                           forget();  item[playerx][playery]=OOPENDOOR;
  156.                           }
  157.                         }
  158.                         break;
  159.  
  160.     case OENTRANCE:    lprcat("\nYou have found "); lprcat(objectname[OENTRANCE]);
  161.                     lprcat("\nDo you (g) go inside"); iopts();
  162.                     i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
  163.                     if (i == 'g')
  164.                         {
  165.                         newcavelevel(1); playerx=33; playery=MAXY-2;
  166.                         item[33][MAXY-1]=know[33][MAXY-1]=mitem[33][MAXY-1]=0;
  167.                         draws(0,MAXX,0,MAXY); bot_linex(); return;
  168.                         }
  169.                     else   ignore();
  170.                     break;
  171.  
  172.     case OVOLDOWN:    lprcat("\nYou have found "); lprcat(objectname[OVOLDOWN]);
  173.                         lprcat("\nDo you (c) climb down"); iopts();
  174.                         i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
  175.                         if ((i=='\33') || (i=='i')) { ignore();  break; }
  176.                     if (level!=0) { lprcat("\nThe shaft only extends 5 feet downward!"); return; }
  177.                     if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep();
  178.                                               lastnum=275;  losehp(30+rnd(20)); bottomhp(); }
  179.                     
  180.                     else lprcat("climb down");  nap(3000);  newcavelevel(MAXLEVEL);
  181.                     for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++) /* put player near volcano shaft */
  182.                         if (item[j][i]==OVOLUP) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); }
  183.                     draws(0,MAXX,0,MAXY); bot_linex(); return;
  184.  
  185.     case OVOLUP:    lprcat("\nYou have found "); lprcat(objectname[OVOLUP]);
  186.                         lprcat("\nDo you (c) climb up"); iopts();
  187.                         i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
  188.                         if ((i=='\33') || (i=='i')) { ignore();  break; }
  189.                     if (level!=11) { lprcat("\nThe shaft only extends 8 feet upwards before you find a blockage!"); return; }
  190.                     if (packweight() > 45+5*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep();
  191.                                               lastnum=275; losehp(15+rnd(20)); bottomhp(); return; }
  192.                     lprcat("climb up"); lflush(); nap(3000); newcavelevel(0);
  193.                     for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++) /* put player near volcano shaft */
  194.                         if (item[j][i]==OVOLDOWN) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); }
  195.                     draws(0,MAXX,0,MAXY); bot_linex(); return;
  196.  
  197.     case OTRAPARROWIV:    if (rnd(17)<13) return;    /* for an arrow trap */
  198.                         item[playerx][playery] = OTRAPARROW;
  199.                         know[playerx][playery] = 0;
  200.  
  201.     case OTRAPARROW:    lprcat("\nYou are hit by an arrow"); beep();    /* for an arrow trap */
  202.                         lastnum=259;    losehp(rnd(10)+level);
  203.                         bottomhp();    return;
  204.  
  205.     case OIVDARTRAP:    if (rnd(17)<13) return;        /* for a dart trap */
  206.                         item[playerx][playery] = ODARTRAP;
  207.                         know[playerx][playery] = 0;
  208.  
  209.     case ODARTRAP:        lprcat("\nYou are hit by a dart"); beep();    /* for a dart trap */
  210.                         lastnum=260;    losehp(rnd(5));
  211.                         if ((--c[STRENGTH]) < 3) c[STRENGTH] = 3;
  212.                         bottomline();    return;
  213.  
  214.     case OIVTRAPDOOR:    if (rnd(17)<13) return;        /* for a trap door */
  215.                         item[playerx][playery] = OTRAPDOOR;
  216. # ifdef DGK
  217.                         know[playerx][playery] = KNOWALL;
  218. # else    
  219.                         know[playerx][playery] = 1;
  220. # endif
  221.  
  222.     case OTRAPDOOR:        lastnum = 272; /* a trap door */
  223.                         if ((level==MAXLEVEL-1) || (level==MAXLEVEL+MAXVLEVEL-1))
  224.                             { lprcat("\nYou fell through a bottomless trap door!"); beep();  nap(3000);  died(271); }
  225.                         lprcat("\nYou fall through a trap door!"); beep();    /* for a trap door */
  226.                         losehp(rnd(5+level));
  227.                         nap(2000);  newcavelevel(level+1);  draws(0,MAXX,0,MAXY); bot_linex();
  228.                         return;
  229.  
  230.  
  231.     case OTRADEPOST:    if (nearbymonst()) return;
  232.                 lprcat("\nYou have found the Larn trading Post.");
  233.                 lprcat("\nDo you (g) go inside, or (i) stay here? ");
  234.                 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
  235.                 if (i == 'g')  otradepost();  else  lprcat("stay here");
  236.                 return;
  237.  
  238.     case OHOME:    if (nearbymonst()) return;
  239.                 lprcat("\nYou have found your way home.");
  240.                 lprcat("\nDo you (g) go inside, or (i) stay here? ");
  241.                 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
  242.                 if (i == 'g')  ohome();  else  lprcat("stay here");
  243.                 return;
  244.  
  245.     case OWALL:    break;
  246.  
  247.     case OANNIHILATION:    died(283); return;     /* annihilated by sphere of annihilation */
  248.  
  249.     case OLRS:    if (nearbymonst()) return;
  250.                 lprcat("\n\nThere is an LRS office here.");
  251.                 lprcat("\nDo you (g) go inside, or (i) stay here? ");
  252.                 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
  253.                 if (i == 'g')
  254.                     olrs();  /*  the larn revenue service */
  255.                 else  lprcat(" stay here");
  256.                 break;
  257.  
  258.     default:    finditem(i); break;
  259.     };
  260. }
  261.  
  262. /*
  263.     function to say what object we found and ask if player wants to take it
  264.  */
  265. finditem(itm)
  266.     int itm;
  267.     {
  268.     int tmp,i;
  269.     lprintf("\n\nYou have found %s ",objectname[itm]);
  270.     tmp=iarg[playerx][playery];
  271.     switch(itm)
  272.         {
  273.         case ODIAMOND:        case ORUBY:            case OEMERALD:
  274.         case OSAPPHIRE:        case OSPIRITSCARAB:    case OORBOFDRAGON:
  275.         case OCUBEofUNDEAD:    case ONOTHEFT:    break;
  276.  
  277.         default:
  278.         if (tmp>0) lprintf("+ %d",(long)tmp); else if (tmp<0) lprintf(" %d",(long)tmp);
  279.         }
  280.     lprcat("\nDo you want to (t) take it"); iopts();
  281.     i=0; while (i!='t' && i!='i' && i!='\33') i=getchar();
  282.     if (i == 't')
  283.         {    lprcat("take");  if (take(itm,tmp)==0)  forget();    return;    }
  284.     ignore();
  285.     }
  286.  
  287.  
  288. /*
  289.     *******
  290.     OSTAIRS
  291.     *******
  292.  
  293.     subroutine to process the stair cases
  294.     if dir > 0 the up else down
  295.  */
  296. ostairs(dir)
  297.     int dir;
  298.     {
  299.     register int k;
  300.     lprcat("\nDo you (s) stay here  ");
  301.     if (dir > 0)    lprcat("(u) go up  ");    else    lprcat("(d) go down  ");
  302.     lprcat("or (f) kick stairs? ");
  303.  
  304.     while (1) switch(getchar())
  305.         {
  306.         case '\33':
  307.         case 's':    case 'i':    lprcat("stay here");    return;
  308.  
  309.         case 'f':    lprcat("kick stairs");
  310.                     if (rnd(2) == 1)
  311.                         lprcat("\nI hope you feel better.  Showing anger rids you of frustration.");
  312.                     else
  313.                         {
  314.                         k=rnd((level+1)<<1);
  315.                         lprintf("\nYou hurt your foot dumb dumb!  You suffer %d hit points",(long)k);
  316.                         lastnum=276;  losehp(k);  bottomline();
  317.                         }
  318.                     return;
  319.  
  320.         case 'u':    lprcat("go up");
  321.                     if (dir < 0)    lprcat("\nThe stairs don't go up!");
  322.                     else
  323.                       if (level>=2 && level!=11)
  324.                         {
  325.                         k = level;  newcavelevel(level-1);
  326.                         draws(0,MAXX,0,MAXY); bot_linex();
  327.                         }
  328.                       else lprcat("\nThe stairs lead to a dead end!");
  329.                     return;
  330.  
  331.         case 'd':    lprcat("go down");
  332.                     if (dir > 0)    lprcat("\nThe stairs don't go down!");
  333.                     else
  334.                       if (level!=0 && level!=10 && level!=13)
  335.                         {
  336.                         k = level;  newcavelevel(level+1);
  337.                         draws(0,MAXX,0,MAXY); bot_linex();
  338.                         }
  339.                       else lprcat("\nThe stairs lead to a dead end!");
  340.                     return;
  341.         };
  342.     }
  343.  
  344.  
  345. /*
  346.     *********
  347.     OTELEPORTER
  348.     *********
  349.  
  350.     subroutine to handle a teleport trap +/- 1 level maximum
  351.  */
  352. oteleport(err)
  353.     int err;
  354.     {
  355.     register int tmp;
  356.     if (err) if (rnd(151)<3)  died(264);  /*    stuck in a rock */
  357.     c[TELEFLAG]=1;    /*    show ?? on bottomline if been teleported    */
  358.     if (level==0) tmp=0;
  359.     else if (level < MAXLEVEL)
  360.         { tmp=rnd(5)+level-3; if (tmp>=MAXLEVEL) tmp=MAXLEVEL-1;
  361.             if (tmp<1) tmp=1; }
  362.     else
  363.         { tmp=rnd(3)+level-2; if (tmp>=MAXLEVEL+MAXVLEVEL) tmp=MAXLEVEL+MAXVLEVEL-1;
  364.             if (tmp<MAXLEVEL) tmp=MAXLEVEL; }
  365.     playerx = rnd(MAXX-2);    playery = rnd(MAXY-2);
  366.     if (level != tmp)    newcavelevel(tmp);  positionplayer();
  367.     draws(0,MAXX,0,MAXY); bot_linex();
  368.     }
  369.  
  370. /*
  371.     *******
  372.     OPOTION
  373.     *******
  374.  
  375.     function to process a potion
  376.  */
  377. opotion(pot)
  378.     int pot;
  379.     {
  380.     lprcat("\nDo you (d) drink it, (t) take it"); iopts();
  381.     while (1) switch(getchar())
  382.         {
  383.         case '\33':
  384.         case 'i':    ignore();  return;
  385.  
  386.         case 'd':    lprcat("drink\n");    forget();    /*    destroy potion    */
  387.                     quaffpotion(pot);        return;
  388.  
  389.         case 't':    lprcat("take\n");    if (take(OPOTION,pot)==0)  forget();
  390.                     return;
  391.         };
  392.     }
  393.         
  394. /*
  395.     function to drink a potion
  396.  */
  397. quaffpotion(pot)
  398.     int pot;
  399.     {
  400.     register int i,j,k;
  401.     if (pot<0 || pot>=MAXPOTION) return; /* check for within bounds */
  402.     potionname[pot][0] = ' ';
  403.     switch(pot)
  404.         {
  405.         case 9: lprcat("\nYou feel greedy . . .");   nap(2000);
  406.                 for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
  407.                   if ((item[j][i]==OGOLDPILE) || (item[j][i]==OMAXGOLD))
  408.                     {
  409.                     know[j][i]=1; show1cell(j,i);
  410.                     }
  411.                 showplayer();  return;
  412.  
  413.         case 19: lprcat("\nYou feel greedy . . .");   nap(2000);
  414.                 for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
  415.                     {
  416.                     k=item[j][i];
  417.                     if ((k==ODIAMOND) || (k==ORUBY) || (k==OEMERALD) || (k==OMAXGOLD)
  418.                          || (k==OSAPPHIRE) || (k==OLARNEYE) || (k==OGOLDPILE))
  419.                          {
  420.                          know[j][i]=1; show1cell(j,i);
  421.                          }
  422.                     }
  423.                 showplayer();  return;
  424.  
  425.         case 20: c[HP] = c[HPMAX]; break;    /* instant healing */
  426.  
  427.         case 1:    lprcat("\nYou feel better");
  428.                 if (c[HP] == c[HPMAX])  raisemhp(1);
  429.                 else if ((c[HP] += rnd(20)+20+c[LEVEL]) > c[HPMAX]) c[HP]=c[HPMAX];  break;
  430.  
  431.         case 2:    lprcat("\nSuddenly, you feel much more skillful!");
  432.                 raiselevel();  raisemhp(1); return;
  433.  
  434.         case 3:    lprcat("\nYou feel strange for a moment"); 
  435.                 c[rund(6)]++;  break;
  436.  
  437.         case 4:    lprcat("\nYou feel more self confident!");
  438.                 c[WISDOM] += rnd(2);  break;
  439.  
  440.         case 5:    lprcat("\nWow!  You feel great!");
  441.                 if (c[STRENGTH]<12) c[STRENGTH]=12; else c[STRENGTH]++;  break;
  442.  
  443.         case 6:    lprcat("\nYour charm went up by one!");  c[CHARISMA]++;  break;
  444.  
  445.         case 8:    lprcat("\nYour intelligence went up by one!");
  446.                 c[INTELLIGENCE]++;  break;
  447.  
  448.         case 10: for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
  449.                    if (mitem[j][i])
  450.                     {
  451.                     know[j][i]=1; show1cell(j,i);
  452.                     }
  453.                  /*    monster detection    */  return;
  454.  
  455.         case 12: lprcat("\nThis potion has no taste to it");  return;
  456.  
  457.         case 15: lprcat("\nWOW!!!  You feel Super-fantastic!!!");
  458.                  if (c[HERO]==0) for (i=0; i<6; i++) c[i] += 11;
  459.                     c[HERO] += 250;  break;
  460.  
  461.         case 16: lprcat("\nYou have a greater intestinal constitude!");
  462.                  c[CONSTITUTION]++;  break;
  463.  
  464.         case 17: lprcat("\nYou now have incredibly bulging muscles!!!");
  465.                  if (c[GIANTSTR]==0) c[STREXTRA] += 21;
  466.                  c[GIANTSTR] += 700;  break;
  467.  
  468.         case 18: lprcat("\nYou feel a chill run up your spine!");
  469.                  c[FIRERESISTANCE] += 1000;  break;
  470.  
  471.         case 0:    lprcat("\nYou fall asleep. . .");
  472.                 i=rnd(11)-(c[CONSTITUTION]>>2)+2;  while(--i>0) { parse2();  nap(1000); }
  473.                 cursors();  lprcat("\nYou woke up!");  return;
  474.  
  475.         case 7:    lprcat("\nYou become dizzy!");
  476.                 if (--c[STRENGTH] < 3) c[STRENGTH]=3;  break;
  477.  
  478.         case 11: lprcat("\nYou stagger for a moment . .");
  479.                  for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
  480.                     know[j][i]=0;
  481.                  nap(2000);    draws(0,MAXX,0,MAXY); /* potion of forgetfulness */  return;
  482.  
  483.         case 13: lprcat("\nYou can't see anything!");  /* blindness */
  484.                  c[BLINDCOUNT]+=500;  return;
  485.  
  486.         case 14: lprcat("\nYou feel confused"); c[CONFUSE]+= 20+rnd(9); return;
  487.  
  488.         case 21: lprcat("\nYou don't seem to be affected");  return; /* cure dianthroritis */
  489.  
  490.         case 22: lprcat("\nYou feel a sickness engulf you"); /* poison */
  491.                  c[HALFDAM] += 200 + rnd(200);  return;
  492.  
  493.         case 23: lprcat("\nYou feel your vision sharpen");    /* see invisible */
  494.                  c[SEEINVISIBLE] += rnd(1000)+400;
  495.                  monstnamelist[INVISIBLESTALKER] = 'I';  return;
  496.         };
  497.     bottomline();        /*    show new stats        */  return;
  498.     }
  499.  
  500. /*
  501.     *******
  502.     OSCROLL
  503.     *******
  504.  
  505.     function to process a magic scroll
  506.  */
  507. oscroll(typ)
  508.     int typ;
  509.     {
  510.     lprcat("\nDo you ");
  511.     if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); lprcat("(t) take it"); iopts();
  512.     while (1) switch(getchar())
  513.         {
  514.         case '\33':
  515.         case 'i':    ignore();  return;
  516.  
  517.         case 'r':    if (c[BLINDCOUNT]) break;
  518.                     lprcat("read"); forget();
  519.                     if (typ==2 || typ==15)  { show1cell(playerx,playery); cursors(); }
  520.                     /*    destroy it    */    read_scroll(typ);  return;
  521.  
  522.         case 't':    lprcat("take"); if (take(OSCROLL,typ)==0)    forget();    /*    destroy it    */
  523.                     return;
  524.         };
  525.     }
  526.  
  527. /*
  528.     data for the function to read a scroll
  529.  */
  530. static int xh,yh,yl,xl;
  531. static char curse[] = { BLINDCOUNT, CONFUSE, AGGRAVATE, HASTEMONST, ITCHING,
  532.     LAUGHING, DRAINSTRENGTH, CLUMSINESS, INFEEBLEMENT, HALFDAM };
  533. static char exten[] = { PROTECTIONTIME, DEXCOUNT, STRCOUNT, CHARMCOUNT,
  534.     INVISIBILITY, CANCELLATION, HASTESELF, GLOBE, SCAREMONST, HOLDMONST, TIMESTOP };
  535. char time_change[] = { HASTESELF,HERO,ALTPRO,PROTECTIONTIME,DEXCOUNT,
  536.     STRCOUNT,GIANTSTR,CHARMCOUNT,INVISIBILITY,CANCELLATION,
  537.     HASTESELF,AGGRAVATE,SCAREMONST,STEALTH,AWARENESS,HOLDMONST,HASTEMONST,
  538.     FIRERESISTANCE,GLOBE,SPIRITPRO,UNDEADPRO,HALFDAM,SEEINVISIBLE,
  539.     ITCHING,CLUMSINESS, WTW };
  540. /*
  541.  *    function to adjust time when time warping and taking courses in school
  542.  */
  543. adjtime(tim)
  544.     register long tim;
  545.     {
  546.     register int j;
  547.     for (j=0; j<26; j++)    /* adjust time related parameters */
  548.         if (c[time_change[j]])
  549.             if ((c[time_change[j]] -= tim) < 1) c[time_change[j]]=1;
  550.     regen();
  551.     }
  552.  
  553. /*
  554.     function to read a scroll
  555.  */
  556. read_scroll(typ)
  557.     int typ;
  558.     {
  559.     register int i,j;
  560.     if (typ<0 || typ>=MAXSCROLL) return;  /* be sure we are within bounds */
  561.     scrollname[typ][0] = ' ';
  562.     switch(typ)
  563.       {
  564.       case 0:    lprcat("\nYour armor glows for a moment");  enchantarmor(); return;
  565.  
  566.       case 1:    lprcat("\nYour weapon glows for a moment"); enchweapon(); return;  /* enchant weapon */
  567.  
  568.       case 2:    lprcat("\nYou have been granted enlightenment!");
  569.                 yh = min(playery+7,MAXY);    xh = min(playerx+25,MAXX);
  570.                 yl = max(playery-7,0);        xl = max(playerx-25,0);
  571. # ifdef DGK
  572.                 for (i=yl; i<yh; i++) for (j=xl; j<xh; j++)  know[j][i]=KNOWALL;
  573. # else
  574.                 for (i=yl; i<yh; i++) for (j=xl; j<xh; j++)  know[j][i]=1;
  575. # endif
  576.                 nap(2000);    draws(xl,xh,yl,yh);    return;
  577.  
  578.       case 3:    lprcat("\nThis scroll seems to be blank");    return;
  579.  
  580.       case 4:    createmonster(makemonst(level+1));  return;  /*  this one creates a monster  */
  581.  
  582.       case 5:    something(level);    /*    create artifact        */  return;
  583.  
  584.       case 6:    c[AGGRAVATE]+=800; return; /* aggravate monsters */
  585.  
  586.       case 7:    gtime += (i = rnd(1000) - 850); /* time warp */ 
  587.                 if (i>=0) lprintf("\nYou went forward in time by %d mobuls",(long)((i+99)/100));
  588.                 else lprintf("\nYou went backward in time by %d mobuls",(long)(-(i+99)/100));
  589.                 adjtime((long)i);    /* adjust time for time warping */
  590.                 return;
  591.  
  592.       case 8:    oteleport(0);      return;    /*    teleportation */
  593.  
  594.       case 9:    c[AWARENESS] += 1800;  return;    /* expanded awareness    */
  595.  
  596.       case 10:    c[HASTEMONST] += rnd(55)+12; return;    /* haste monster */
  597.  
  598.       case 11:    for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
  599.                     if (mitem[j][i])
  600.                         hitp[j][i] = monster[mitem[j][i]].hitpoints;
  601.                 return;    /* monster healing */
  602.       case 12:    c[SPIRITPRO] += 300 + rnd(200); bottomline(); return; /* spirit protection */
  603.  
  604.       case 13:    c[UNDEADPRO] += 300 + rnd(200); bottomline(); return; /* undead protection */
  605.  
  606.       case 14:    c[STEALTH] += 250 + rnd(250);  bottomline(); return; /* stealth */
  607.  
  608.       case 15:    lprcat("\nYou have been granted enlightenment!"); /* magic mapping */
  609. # ifdef DGK
  610.                 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++)  know[j][i]=KNOWALL;
  611. # else
  612.                 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++)  know[j][i]=1;
  613. # endif
  614.                 nap(2000);    draws(0,MAXX,0,MAXY);    return;
  615.  
  616.       case 16:    c[HOLDMONST] += 30; bottomline(); return; /* hold monster */
  617.  
  618.       case 17:    for (i=0; i<26; i++)    /* gem perfection */
  619.                     switch(iven[i])
  620.                         {
  621.                         case ODIAMOND:    case ORUBY:
  622.                         case OEMERALD:    case OSAPPHIRE:
  623.                             j = ivenarg[i];  j &= 255;  j <<= 1;
  624.                             if (j  > 255) j=255; /* double value */
  625.                             ivenarg[i] = j;    break;
  626.                         }
  627.                 break;
  628.  
  629.       case 18:    for (i=0; i<11; i++)    c[exten[i]] <<= 1; /* spell extension */
  630.                 break;
  631.  
  632.       case 19:    for (i=0; i<26; i++)    /* identify */
  633.                     {
  634.                     if (iven[i]==OPOTION)  potionname[ivenarg[i]][0] = ' ';
  635.                     if (iven[i]==OSCROLL)  scrollname[ivenarg[i]][0] = ' ';
  636.                     }
  637.                 break;
  638.  
  639.       case 20:    for (i=0; i<10; i++)    /* remove curse */
  640.                     if (c[curse[i]]) c[curse[i]] = 1;
  641.                 break;
  642.  
  643.       case 21:    annihilate();    break;    /* scroll of annihilation */
  644.  
  645.       case 22:    godirect(22,150,"The ray hits the %s",0,' ');    /* pulverization */
  646.                 break;
  647.       case 23:  c[LIFEPROT]++;  break; /* life protection */
  648.       };
  649.     }
  650.  
  651.  
  652. oorb()
  653.     {
  654.     }
  655.  
  656. opit()
  657.     {
  658.     register int i;
  659.     if (rnd(101)<81)
  660.       if (rnd(70) > 9*c[DEXTERITY]-packweight() || rnd(101)<5)
  661.         if (level==MAXLEVEL-1) obottomless(); else
  662.         if (level==MAXLEVEL+MAXVLEVEL-1) obottomless(); else
  663.             {
  664.             if (rnd(101)<20)
  665.                 {
  666.                 i=0; lprcat("\nYou fell into a pit!  Your fall is cushioned by an unknown force\n");
  667.                 }
  668.             else
  669.                 {
  670.                 i = rnd(level*3+3);
  671.                 lprintf("\nYou fell into a pit!  You suffer %d hit points damage",(long)i);
  672.                 lastnum=261;     /*    if he dies scoreboard will say so */
  673.                 }
  674.             losehp(i); nap(2000);  newcavelevel(level+1);  draws(0,MAXX,0,MAXY);
  675.             }
  676.     }
  677.  
  678. obottomless()
  679.     {
  680.     lprcat("\nYou fell into a bottomless pit!");  beep(); nap(3000);  died(262);
  681.     }
  682. oelevator(dir)
  683.     int dir;
  684.     {
  685. #ifdef lint
  686.     int x;
  687.     x=dir;
  688.     dir=x;
  689. #endif lint
  690.     }
  691.  
  692. ostatue()
  693.     {
  694.     }
  695.  
  696. omirror()
  697.     {
  698.     }
  699.  
  700. obook()
  701.     {
  702.     lprcat("\nDo you ");
  703.     if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); lprcat("(t) take it"); iopts();
  704.     while (1) switch(getchar())
  705.         {
  706.         case '\33':
  707.         case 'i':    ignore();    return;
  708.  
  709.         case 'r':    if (c[BLINDCOUNT]) break;
  710.                     lprcat("read");
  711.                     /* no more book    */    readbook(iarg[playerx][playery]);  forget(); return;
  712.  
  713.         case 't':    lprcat("take");  if (take(OBOOK,iarg[playerx][playery])==0)  forget();    /* no more book    */
  714.                     return;
  715.         };
  716.     }
  717.  
  718. /*
  719.     function to read a book
  720.  */
  721. readbook(lev)
  722.     register int lev;
  723.     {
  724.     register int i,tmp;
  725.     if (lev<=3) i = rund((tmp=splev[lev])?tmp:1); else
  726.         i = rnd((tmp=splev[lev]-9)?tmp:1) + 9;
  727.     spelknow[i]=1;
  728.     lprintf("\nSpell \"%s\":  %s\n%s",spelcode[i],spelname[i],speldescript[i]);
  729.     if (rnd(10)==4)
  730.      { lprcat("\nYour int went up by one!"); c[INTELLIGENCE]++; bottomline(); }
  731.     }
  732.  
  733. ocookie()
  734.     {
  735.     char *p;
  736.     lprcat("\nDo you (e) eat it, (t) take it"); iopts();
  737.     while (1) switch(getchar())
  738.         {
  739.         case '\33':
  740.         case 'i':    ignore();    return;
  741.  
  742.         case 'e':    lprcat("eat\nThe cookie tasted good.");
  743.                     forget(); /* no more cookie    */
  744.                     if (c[BLINDCOUNT]) return;
  745. # ifdef MSDOS
  746.                     outfortune();
  747. # else
  748.                     if (!(p=fortune(fortfile))) return;
  749.                     lprcat("  A message inside the cookie reads:\n"); lprcat(p);
  750. # endif
  751.                     return;
  752.  
  753.         case 't':    lprcat("take");  if (take(OCOOKIE,0)==0) forget();    /* no more book    */
  754.                     return;
  755.         };
  756.     }
  757.  
  758.  
  759. /* routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth 100* the argument */
  760. ogold(arg)
  761.     int arg;
  762.     {
  763.     register long i;
  764.     i = iarg[playerx][playery];
  765.     if (arg==OMAXGOLD) i *= 100;
  766.         else if (arg==OKGOLD) i *= 1000;
  767.             else if (arg==ODGOLD) i *= 10;
  768.     lprintf("\nIt is worth %d!",(long)i);    c[GOLD] += i;  bottomgold();
  769.     item[playerx][playery] = know[playerx][playery] = 0; /*    destroy gold    */
  770.     }
  771.  
  772. # ifdef DGK
  773. /* The original is a little too morbid for my taste.
  774.  */
  775. static shedied() {
  776.     lprcat("\nThe doctor has the sad duty to inform you that your daughter died");
  777.     lprcat("\nbefore your return.  There was nothing he could do without the potion.\n");
  778.     nap(5000); died(269);
  779. }
  780. # endif
  781.  
  782. ohome()
  783.     {
  784.     register int i;
  785.     nosignal = 1;    /* disable signals */
  786.     for (i=0; i<26; i++) if (iven[i]==OPOTION) if (ivenarg[i]==21)
  787.         {
  788.         iven[i]=0;    /* remove the potion of cure dianthroritis from inventory */
  789.         clear(); lprcat("Congratulations.  You found a potion of cure dianthroritis.\n");
  790.         lprcat("\nFrankly, No one thought you could do it.  Boy!  Did you surprise them!\n");
  791.         if (gtime>TIMELIMIT)
  792. # ifdef DGK
  793.              shedied();
  794. # else
  795.             {
  796.             lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
  797.             lprcat("You didn't make it in time.  In your agony, you kill the doctor,\nyour wife, and yourself!  Too bad!\n");
  798.             nap(5000); died(269);
  799.             }
  800. # endif
  801.         else
  802.             {
  803.             lprcat("\nThe doctor is now administering the potion, and in a few moments\n");
  804.             lprcat("your daughter should be well on her way to recovery.\n");
  805.             nap(6000);
  806.             lprcat("\nThe potion is"); nap(3000); lprcat(" working!  The doctor thinks that\n");
  807.             lprcat("your daughter will recover in a few days.  Congratulations!\n");
  808.             beep(); nap(5000); died(263);
  809.             }
  810.         }
  811.  
  812.     while (1)
  813.         {
  814.         clear(); lprintf("Welcome home %s.  Latest word from the doctor is not good.\n",logname);
  815.  
  816.         if (gtime>TIMELIMIT)
  817. # ifdef DGK
  818.             shedied();
  819. # else
  820.             {
  821.             lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
  822.             lprcat("You didn't make it in time.  In your agony, you kill the doctor,\nyour wife, and yourself!  Too bad!\n");
  823.             }
  824. # endif
  825.  
  826.         lprcat("\nThe diagnosis is confirmed as dianthroritis.  He guesses that\n");
  827.         lprintf("your daughter has only %d mobuls left in this world.  It's up to you,\n",(long)((TIMELIMIT-gtime+99)/100));
  828.         lprintf("%s, to find the only hope for your daughter, the very rare\n",logname);
  829.         lprcat("potion of cure dianthroritis.  It is rumored that only deep in the\n");
  830.         lprcat("depths of the caves can this potion be found.\n\n\n");
  831.         lprcat("\n     ----- press "); standout("return");
  832.         lprcat(" to continue, "); standout("escape");
  833.         lprcat(" to leave ----- ");
  834.         i=getchar();  while (i!='\33' && i!='\n') i=getchar();
  835.         if (i=='\33') { drawscreen(); nosignal = 0; /* enable signals */ return; }
  836.         }
  837.     }
  838.  
  839. /*    routine to save program space    */
  840. iopts()
  841.     {    lprcat(", or (i) ignore it? ");    }
  842. ignore()
  843.     {    lprcat("ignore\n");    }
  844.  
  845.