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

  1. /* moreobj.c         Larn is copyrighted 1986 by Noah Morgan.
  2.  *
  3.  *    Routines in this file:
  4.  *
  5.  *    oaltar()
  6.  *    othrone()
  7.  *    ochest()
  8.  *    ofountain()
  9.  */
  10. #include "header.h"
  11.  
  12. /*
  13.  *    ******
  14.  *    OALTAR
  15.  *    ******
  16.  *
  17.  *    subroutine to process an altar object
  18.  */
  19. oaltar()
  20.     {
  21.     unsigned long k;
  22.  
  23.     lprcat("\nDo you (p) pray  (d) desecrate"); iopts();
  24.     while (1)
  25.       {
  26.       while (1) switch(getchar())
  27.         {
  28.         case 'p':    lprcat(" pray\nDo you (m) give money or (j) just pray? ");
  29.                     while (1) switch(getchar())
  30.                       {
  31.                       case 'j':    if (rnd(100)<75) 
  32.                                     lprcat("\nnothing happens");
  33.                                 else if (rnd(13)<4) ohear();
  34.                                 else if (rnd(43) == 10)
  35.                                     {
  36.                                     if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
  37.                                     enchantarmor(); return;
  38.                                     }
  39.                                 else if (rnd(43) == 10)
  40.                                     {
  41.                                     if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
  42.                                     enchweapon(); return;
  43.                                     }
  44.                                 else createmonster(makemonst(level+1));
  45.                                 return;
  46.  
  47.                       case 'm':    lprcat("\n\n");  cursor(1,24);  cltoeoln();
  48.                                   cursor(1,23);  cltoeoln();
  49.                                 lprcat("how much do you donate? ");
  50.                                 k = readnum((long)c[GOLD]);
  51.                                 if (c[GOLD]<k)
  52.                                     {
  53.                                     lprcat("\nYou don't have that much!");
  54.                                     return;
  55.                                     }
  56.                                 c[GOLD] -= k;
  57.                                 if (k < c[GOLD]/10 || k<rnd(50))
  58.                                     { createmonster(makemonst(level+1)); c[AGGRAVATE] += 200; }
  59.                                 else if (rnd(101) > 50)    { ohear(); return; }
  60.                                 else if (rnd(43) == 5)
  61.                                     {
  62.                                     if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
  63.                                     enchantarmor(); return;
  64.                                     }
  65.                                 else if (rnd(43) == 8)
  66.                                     {
  67.                                     if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
  68.                                     enchweapon(); return;
  69.                                     }
  70.                                 else    lprcat("\nThank You.");
  71.                                 bottomline();    return;
  72.  
  73.                       case '\33':    return;
  74.                       };
  75.  
  76.         case 'd': lprcat(" desecrate");
  77.                   if (rnd(100)<60)
  78.                         { createmonster(makemonst(level+2)+8); c[AGGRAVATE] += 2500; }
  79.                     else
  80.                     if (rnd(101)<30)
  81.                         {
  82.                         lprcat("\nThe altar crumbles into a pile of dust before your eyes");
  83.                         forget();    /*    remember to destroy the altar    */
  84.                         }
  85.                     else
  86.                         lprcat("\nnothing happens");
  87.                     return;
  88.  
  89.         case 'i':
  90.         case '\33': ignore();
  91.                   if (rnd(100)<30)    { createmonster(makemonst(level+1)); c[AGGRAVATE] += rnd(450); }
  92.                     else    lprcat("\nnothing happens");
  93.                     return;
  94.         };
  95.       }
  96.     }
  97.  
  98. /*
  99.     function to cast a +3 protection on the player
  100.  */
  101. static ohear()
  102.     {
  103.     lprcat("\nYou have been heard!");
  104.     if (c[ALTPRO]==0) c[MOREDEFENSES]+=3;
  105.     c[ALTPRO] += 500;    /* protection field */
  106.     bottomline();
  107.     }
  108.  
  109. /*
  110.     *******
  111.     OTHRONE
  112.     *******
  113.  
  114.     subroutine to process a throne object
  115.  */
  116. othrone(arg)
  117.     int arg;
  118.     {
  119.     register int i,k;
  120.  
  121.     lprcat("\nDo you (p) pry off jewels, (s) sit down"); iopts();
  122.     while (1)
  123.       {
  124.       while (1) switch(getchar())
  125.         {
  126.         case 'p':    lprcat(" pry off");  k=rnd(101);
  127.                     if (k<25)
  128.                         {
  129.                         for (i=0; i<rnd(4); i++) creategem(); /* gems pop off the throne */
  130.                         item[playerx][playery]=ODEADTHRONE;
  131.                         know[playerx][playery]=0;
  132.                         }
  133.                     else if (k<40 && arg==0)
  134.                         {
  135.                         createmonster(GNOMEKING);
  136.                         item[playerx][playery]=OTHRONE2;
  137.                         know[playerx][playery]=0;
  138.                         }
  139.                     else lprcat("\nnothing happens");
  140.                     return;
  141.  
  142.         case 's':     lprcat(" sit down");  k=rnd(101);
  143.                       if (k<30 && arg==0)
  144.                         {
  145.                         createmonster(GNOMEKING);
  146.                         item[playerx][playery]=OTHRONE2;
  147.                         know[playerx][playery]=0;
  148.                         }
  149.                       else if (k<35) { lprcat("\nZaaaappp!  You've been teleported!\n"); beep(); oteleport(0); }
  150.                     else lprcat("\nnothing happens");
  151.                     return;
  152.  
  153.         case 'i':
  154.         case '\33': ignore(); return;
  155.         };
  156.       }
  157.     }
  158.  
  159. odeadthrone()
  160.     {
  161.     register int k;
  162.  
  163.     lprcat("\nDo you (s) sit down"); iopts();
  164.     while (1)
  165.       {
  166.       while (1) switch(getchar())
  167.         {
  168.         case 's':     lprcat(" sit down");  k=rnd(101);
  169.                       if (k<35) { lprcat("\nZaaaappp!  You've been teleported!\n"); beep(); oteleport(0); }
  170.                     else lprcat("\nnothing happens");
  171.                     return;
  172.  
  173.         case 'i':
  174.         case '\33': ignore(); return;
  175.         };
  176.       }
  177.     }
  178.  
  179. /*
  180.     ******
  181.     OCHEST
  182.     ******
  183.  
  184.     subroutine to process a throne object
  185.  */
  186. ochest()
  187.     {
  188.     register int i,k;
  189.     lprcat("\nDo you (t) take it, (o) try to open it"); iopts();
  190.     while (1)
  191.       {
  192.       while (1) switch(getchar())
  193.         {
  194.         case 'o':    lprcat(" open it");  k=rnd(101);
  195.                     if (k<40)
  196.                         {
  197.                         lprcat("\nThe chest explodes as you open it"); beep();
  198.                         i = rnd(10);  lastnum=281;  /* in case he dies */
  199.                         lprintf("\nYou suffer %d hit points damage!",(long)i);
  200.                         checkloss(i);
  201.                         switch(rnd(10))    /* see if he gets a curse */
  202.                             {
  203.                             case 1:    c[ITCHING]+= rnd(1000)+100;
  204.                                     lprcat("\nYou feel an irritation spread over your skin!");
  205.                                     beep();
  206.                                     break;
  207.  
  208.                             case 2:    c[CLUMSINESS]+= rnd(1600)+200;
  209.                                     lprcat("\nYou begin to lose hand to eye coordination!");
  210.                                     beep();
  211.                                     break;
  212.                             
  213.                             case 3:    c[HALFDAM]+= rnd(1600)+200;
  214.                                     beep();
  215.                                     lprcat("\nA sickness engulfs you!");    break;
  216.                             };
  217.                         item[playerx][playery]=know[playerx][playery]=0;
  218.                         if (rnd(100)<69) creategem(); /* gems from the chest */
  219.                         dropgold(rnd(110*iarg[playerx][playery]+200));
  220.                         for (i=0; i<rnd(4); i++) something(iarg[playerx][playery]+2);
  221.                         }
  222.                     else lprcat("\nnothing happens");
  223.                     return;
  224.  
  225.         case 't':    lprcat(" take");
  226.                     if (take(OCHEST,iarg[playerx][playery])==0)
  227.                         item[playerx][playery]=know[playerx][playery]=0;
  228.                     return;
  229.  
  230.         case 'i':
  231.         case '\33': ignore(); return;
  232.         };
  233.       }
  234.     }
  235.  
  236. /*
  237.     *********
  238.     OFOUNTAIN
  239.     *********
  240.  */
  241.  
  242. ofountain()
  243.     {
  244.     register int x;
  245.     cursors();
  246.     lprcat("\nDo you (d) drink, (w) wash yourself"); iopts();
  247.     while (1) switch(getchar())
  248.         {
  249.         case 'd':    lprcat("drink");
  250.                     if (rnd(1501)<2)
  251.                         {
  252.                         lprcat("\nOops!  You seem to have caught the dreadful sleep!");
  253.                         beep(); lflush();  sleep(3);  died(280); return;
  254.                         }
  255.                     x = rnd(100);
  256.                     if (x<7)
  257.                         {
  258.                         c[HALFDAM] += 200+rnd(200);
  259.                         lprcat("\nYou feel a sickness coming on");
  260.                         }
  261.                     else if (x<13) quaffpotion(23); /* see invisible */
  262.                     else if (x < 45)
  263.                         lprcat("\nnothing seems to have happened");
  264.                     else if (rnd(3) != 2)
  265.                         fntchange(1);    /*    change char levels upward    */
  266.                     else
  267.                         fntchange(-1);    /*    change char levels downward    */
  268.                     if (rnd(12)<3)
  269.                         {
  270.                         lprcat("\nThe fountains bubbling slowly quiets");
  271.                         item[playerx][playery]=ODEADFOUNTAIN; /* dead fountain */
  272.                         know[playerx][playery]=0;
  273.                         }
  274.                     return;
  275.  
  276.         case '\33':
  277.         case 'i':    ignore();  return;
  278.  
  279.         case 'w':    lprcat("wash yourself");
  280.                     if (rnd(100) < 11)
  281.                         {
  282.                         x=rnd((level<<2)+2);
  283.                         lprintf("\nOh no!  The water was foul!  You suffer %d hit points!",(long)x);
  284.                         lastnum=273; losehp(x); bottomline();  cursors();
  285.                         }
  286.                     else
  287.                     if (rnd(100) < 29)
  288.                         lprcat("\nYou got the dirt off!");
  289.                     else
  290.                     if (rnd(100) < 31)
  291.                         lprcat("\nThis water seems to be hard water!  The dirt didn't come off!");
  292.                     else
  293.                     if (rnd(100) < 34)
  294.                         createmonster(WATERLORD); /*    make water lord        */
  295.                     else
  296.                     lprcat("\nnothing seems to have happened");
  297.                     return;
  298.         }
  299.     }
  300.  
  301. /*
  302.     a subroutine to raise or lower character levels
  303.     if x > 0 they are raised   if x < 0 they are lowered
  304.  */
  305. fntchange(how)
  306.     int how;
  307.     {
  308.     register long j;
  309.     lprc('\n');
  310.     switch(rnd(9))
  311.         {
  312.         case 1:    lprcat("Your strength");        fch(how,&c[0]);        break;
  313.         case 2:    lprcat("Your intelligence");    fch(how,&c[1]);        break;
  314.         case 3:    lprcat("Your wisdom");            fch(how,&c[2]);        break;
  315.         case 4:    lprcat("Your constitution");    fch(how,&c[3]);        break;
  316.         case 5:    lprcat("Your dexterity");        fch(how,&c[4]);        break;
  317.         case 6:    lprcat("Your charm");            fch(how,&c[5]);        break;
  318.         case 7:    j=rnd(level+1);
  319.                 if (how < 0)
  320.                     { lprintf("You lose %d hit point",(long)j);  if (j>1) lprcat("s!"); else lprc('!'); losemhp((int)j); }
  321.                 else
  322.                     { lprintf("You gain %d hit point",(long)j);  if (j>1) lprcat("s!"); else lprc('!'); raisemhp((int)j); }
  323.                 bottomline();        break;
  324.  
  325.         case 8:    j=rnd(level+1);
  326.                 if (how > 0)
  327.                     {
  328.                     lprintf("You just gained %d spell",(long)j);  raisemspells((int)j);
  329.                     if (j>1) lprcat("s!"); else lprc('!');
  330.                     }
  331.                 else
  332.                     {
  333.                     lprintf("You just lost %d spell",(long)j);    losemspells((int)j);
  334.                     if (j>1) lprcat("s!"); else lprc('!');
  335.                     }
  336.                 bottomline();        break;
  337.  
  338.         case 9:    j = 5*rnd((level+1)*(level+1));
  339.                 if (how < 0)
  340.                     {
  341.                     lprintf("You just lost %d experience point",(long)j);
  342.                     if (j>1) lprcat("s!"); else lprc('!'); loseexperience((long)j);
  343.                     }
  344.                 else
  345.                     {
  346.                     lprintf("You just gained %d experience point",(long)j);
  347.                     if (j>1) lprcat("s!"); else lprc('!'); raiseexperience((long)j);
  348.                     }
  349.                 break;
  350.         }
  351.     cursors();
  352.     }
  353.  
  354. /*
  355.     ***
  356.     FCH
  357.     ***
  358.  
  359.     subroutine to process an up/down of a character attribute for ofountain
  360.  */
  361. static fch(how,x)
  362.     int how;
  363.     long *x;
  364.     {
  365.     if (how < 0)     { lprcat(" went down by one!");    --(*x); }
  366.         else         { lprcat(" went up by one!");    (*x)++; }
  367.     bottomline();
  368.     }
  369.