home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / TOP / USR / SRC / larn.t.Z / larn.t / store.c < prev    next >
Text File  |  1988-11-13  |  21KB  |  669 lines

  1. /*    store.c        Larn is copyrighted 1986 by Noah Morgan. */
  2. #include "header.h"
  3. static int dndcount=0,dnditm=0;
  4.  
  5. /*    this is the data for the stuff in the dnd store    */
  6. int maxitm=83;    /* number of items in the dnd inventory table    */
  7. # ifndef OSK
  8. struct _itm itm[90] = {
  9. # else OSK
  10. # define potionname    (char **)4
  11. # define scrollname    (char **)8
  12. struct _itm itm[90], __itm[90] = {
  13. # endif OSK
  14. /*cost      memory     iven name    iven arg   how
  15.   gp     pointer      iven[]    ivenarg[]  many */
  16.  
  17. { 2,        0,        OLEATHER,        0,        3    },
  18. { 10,        0,        OSTUDLEATHER,    0,        2    },
  19. { 40,        0,        ORING,            0,        2    },
  20. { 85,        0,        OCHAIN,            0,        2    },
  21. { 220,        0,        OSPLINT,        0,        1    },
  22. { 400,        0,        OPLATE,            0,        1    },
  23. { 900,        0,        OPLATEARMOR,    0,        1    },
  24. { 2600,        0,        OSSPLATE,        0,        1    },
  25. { 150,        0,        OSHIELD,        0,        1    },
  26.  
  27. /*cost      memory     iven name    iven arg   how
  28.   gp     pointer      iven[]    ivenarg[]  many */
  29.  
  30. { 2,        0,        ODAGGER,        0,        3    },
  31. { 20,        0,        OSPEAR,            0,        3    },
  32. { 80,        0,        OFLAIL,            0,        2    },
  33. { 150,        0,        OBATTLEAXE,        0,        2    },
  34. { 450,        0,        OLONGSWORD,        0,        2    },
  35. { 1000,        0,        O2SWORD,        0,        2    },
  36. { 5000,        0,        OSWORD,            0,        1    },
  37. { 16500,    0,        OLANCE,            0,        1    },
  38. { 6000,        0,     OSWORDofSLASHING,    0,        0    },
  39. { 10000,    0,        OHAMMER,        0,        0    },
  40.  
  41. /*cost      memory     iven name    iven arg   how
  42.   gp     pointer      iven[]    ivenarg[]  many */
  43.  
  44. { 150,        0,        OPROTRING,        1,        1    },
  45. { 85,        0,        OSTRRING,        1,        1    },
  46. { 120,        0,        ODEXRING,        1,        1    },
  47. { 120,        0,        OCLEVERRING,    1,        1    },
  48. { 180,        0,        OENERGYRING,    0,        1    },
  49. { 125,        0,        ODAMRING,        0,        1    },
  50. { 220,        0,        OREGENRING,        0,        1    },
  51. { 1000,        0,        ORINGOFEXTRA,    0,        1    },
  52.  
  53. { 280,        0,        OBELT,            0,        1    },
  54.  
  55. { 400,        0,        OAMULET,        0,        1    },
  56.  
  57. { 6500,        0,        OORBOFDRAGON,    0,        0    },
  58. { 5500,        0,        OSPIRITSCARAB,    0,        0    },
  59. { 5000,        0,        OCUBEofUNDEAD,    0,        0    },
  60. { 6000,        0,        ONOTHEFT,        0,        0    },
  61.  
  62. { 590,        0,        OCHEST,            6,        1    },
  63. { 200,        0,        OBOOK,            8,        1    },
  64. { 10,        0,        OCOOKIE,        0,        3    },
  65.  
  66. /*cost      memory     iven name    iven arg   how
  67.   gp     pointer      iven[]    ivenarg[]  many */
  68.  
  69. {    20,        potionname,    OPOTION,    0,        6    },
  70. {    90,        potionname,    OPOTION,    1,        5    },
  71. {    520,    potionname,    OPOTION,    2,        1    },
  72. {     100,    potionname,    OPOTION,    3,        2    },
  73. {    50,        potionname,    OPOTION,    4,        2    },
  74. {    150,    potionname,    OPOTION,    5,        2    },
  75. {    70,        potionname,    OPOTION,    6,        1    },
  76. {    30,        potionname,    OPOTION,    7,        7    },
  77. {    200,    potionname,    OPOTION,    8,        1    },
  78. {    50,        potionname,    OPOTION,    9,        1    },
  79. {    80,        potionname,    OPOTION,    10,        1    },
  80.  
  81. /*cost      memory     iven name    iven arg   how
  82.   gp     pointer      iven[]    ivenarg[]  many */
  83.  
  84. {    30,        potionname,    OPOTION,    11,        3    },
  85. {    20,        potionname,    OPOTION,    12,        5    },
  86. {    40,        potionname,    OPOTION,    13,        3    },
  87. {    35,        potionname,    OPOTION,    14,        2    },
  88. {    520,    potionname,    OPOTION,    15,        1    },
  89. {    90,        potionname,    OPOTION,    16,        2    },
  90. {    200,    potionname,    OPOTION,    17,        2    },
  91. {    220,    potionname,    OPOTION,    18,        4    },
  92. {    80,        potionname,    OPOTION,    19,        6    },
  93. {    370,    potionname,    OPOTION,    20,        3    },
  94. {    50,        potionname,    OPOTION,    22,        1    },
  95. {    150,    potionname,    OPOTION,    23,        3    },
  96.  
  97. /*cost      memory     iven name    iven arg   how
  98.   gp     pointer      iven[]    ivenarg[]  many */
  99.  
  100. { 100,    scrollname,        OSCROLL,    0,        2    },
  101. { 125,    scrollname,        OSCROLL,    1,        2    },
  102. { 60,    scrollname,        OSCROLL,    2,        4    },
  103. { 10,    scrollname,        OSCROLL,    3,        4    },
  104. { 100,    scrollname,        OSCROLL,    4,        3    },
  105. { 200,    scrollname,        OSCROLL,    5,        2    },
  106. { 110,    scrollname,        OSCROLL,    6,        1    },
  107. { 500,    scrollname,        OSCROLL,    7,        2    },
  108. { 200,    scrollname,        OSCROLL,    8,        2    },
  109. { 250,    scrollname,        OSCROLL,    9,        4    },
  110. { 20,    scrollname,        OSCROLL,    10,        5    },
  111. { 30,    scrollname,        OSCROLL,    11,        3    },
  112.  
  113. /*cost      memory     iven name    iven arg   how
  114.   gp     pointer      iven[]    ivenarg[]  many */
  115.  
  116. { 340,    scrollname,        OSCROLL,    12,        1    },
  117. { 340,    scrollname,        OSCROLL,    13,        1    },
  118. { 300,    scrollname,        OSCROLL,    14,        2    },
  119. { 400,    scrollname,        OSCROLL,    15,        2    },
  120. { 500,    scrollname,        OSCROLL,    16,        2    },
  121. { 1000,    scrollname,        OSCROLL,    17,        1    },
  122. { 500,    scrollname,        OSCROLL,    18,        1    },
  123. { 340,    scrollname,        OSCROLL,    19,        2    },
  124. { 220,    scrollname,        OSCROLL,    20,        3    },
  125. { 3900,    scrollname,        OSCROLL,    21,        0    },
  126. { 610,    scrollname,        OSCROLL,    22,        1    },
  127. { 3000,    scrollname,        OSCROLL,    23,        0    }
  128.  };
  129.  
  130. # ifdef OSK
  131. # undef potionname
  132. # undef scrollname
  133. # endif OSK
  134. /*
  135.     function for the dnd store
  136.  */
  137. dnd_2hed()
  138.     {
  139.     lprcat("Welcome to the Larn Thrift Shoppe.  We stock many items explorers find useful\n");
  140.     lprcat(" in their adventures.  Feel free to browse to your hearts content.\n");
  141.     lprcat("Also be advised, if you break 'em, you pay for 'em.");
  142.     }
  143.  
  144. dnd_hed()
  145.     {
  146.     register int i;
  147.     for (i=dnditm; i<26+dnditm; i++)    dnditem(i);
  148.     cursor(50,18); lprcat("You have ");
  149.     }
  150.  
  151. dndstore()
  152.   {
  153.   register int i;
  154.   dnditm = 0;
  155.   nosignal = 1; /* disable signals */
  156.   clear();  dnd_2hed();
  157.   if (outstanding_taxes>0)
  158.     {
  159.     lprcat("\n\nThe Larn Revenue Service has ordered us to not do business with tax evaders.\n"); beep();
  160.     lprintf("They have also told us that you owe %d gp in back taxes, and as we must\n",(long)outstanding_taxes);
  161.     lprcat("comply with the law, we cannot serve you at this time.  Soo Sorry.\n");
  162.     cursors();    
  163.     lprcat("\nPress "); standout("escape"); lprcat(" to leave: "); lflush();
  164.     i=0;
  165.     while (i!='\33') i=getchar();
  166.     drawscreen();  nosignal = 0; /* enable signals */ return;
  167.     }
  168.  
  169.   dnd_hed();
  170.   while (1)
  171.     {
  172.     cursor(59,18); lprintf("%d gold pieces",(long)c[GOLD]);
  173.     cltoeoln(); cl_dn(1,20);    /* erase to eod */
  174.     lprcat("\nEnter your transaction ["); standout("space");
  175.     lprcat(" for more, "); standout("escape");
  176.     lprcat(" to leave]? ");
  177.     i=0;
  178.     while ((i<'a' || i>'z') && (i!=' ') && (i!='\33') && (i!=12))  i=getchar();
  179.     if (i==12) { clear();  dnd_2hed();  dnd_hed(); }
  180.     else if (i=='\33')
  181.         { drawscreen();  nosignal = 0; /* enable signals */ return; }
  182.     else if (i==' ')
  183.         {
  184.         cl_dn(1,4);
  185.         if ((dnditm += 26) >= maxitm) dnditm=0; dnd_hed();
  186.         }
  187.     else
  188.         {  /* buy something */
  189.         lprc(i);    /* echo the byte */
  190.         i += dnditm - 'a';
  191.         if (i>=maxitm) outofstock(); else
  192.         if (itm[i].qty <= 0) outofstock(); else
  193.         if (pocketfull()) handsfull(); else
  194.         if (c[GOLD] < itm[i].price*10) nogold(); else
  195.             {
  196.             if (itm[i].mem != 0) *itm[i].mem[itm[i].arg] = ' ';
  197.             c[GOLD] -= itm[i].price*10;
  198.             itm[i].qty--;  take(itm[i].obj,itm[i].arg);
  199.             if (itm[i].qty==0) dnditem(i);  nap(1001);
  200.             }
  201.         }
  202.  
  203.     }
  204.   }
  205.  
  206. /*
  207.     function for the players hands are full
  208.  */
  209. static handsfull()
  210.     { lprcat("\nYou can't carry anything more!"); lflush(); nap(2200); }
  211. static outofstock()
  212.     { lprcat("\nSorry, but we are out of that item."); lflush(); nap(2200); }
  213. static nogold()
  214.     { lprcat("\nYou don't have enough gold to pay for that!"); lflush(); nap(2200); }
  215.  
  216. /*
  217.     dnditem(index)
  218.  
  219.     to print the item list;  used in dndstore() enter with the index into itm
  220.  */
  221. static dnditem(i)
  222.     register int i;
  223.     {
  224.     register int j,k;
  225.     if (i >= maxitm)  return;
  226.     cursor( (j=(i&1)*40+1) , (k=((i%26)>>1)+5) );
  227.     if (itm[i].qty == 0)  { lprintf("%39s","");  return; }
  228.     lprintf("%c) ",(i%26)+'a');
  229.     if (itm[i].obj == OPOTION)
  230.         { lprcat("potion of "); lprintf("%s",&potionname[itm[i].arg][1]); }
  231.     else if (itm[i].obj == OSCROLL)
  232.         { lprcat("scroll of "); lprintf("%s",&scrollname[itm[i].arg][1]); }
  233.     else lprintf("%s",objectname[itm[i].obj]);
  234.     cursor( j+31,k );  lprintf("%6d",(long)(itm[i].price*10));
  235.     }
  236.  
  237.  
  238. /*
  239.     for the college of larn
  240.  */
  241. char course[26]=0;    /*    the list of courses taken    */
  242. char coursetime[] = { 10, 15, 10, 20, 10, 10, 10, 5 };
  243. /*
  244.     function to display the header info for the school
  245.  */
  246. sch_hed()
  247.     {
  248.     clear();
  249.     lprcat("The College of Larn offers the exciting opportunity of higher education to\n");
  250.     lprcat("all inhabitants of the caves.  Here is a list of the class schedule:\n\n\n");
  251.     lprcat("\t\t    Course Name \t       Time Needed\n\n");
  252.  
  253.     if (course[0]==0) lprcat("\t\ta)  Fighters Training I         10 mobuls"); /*line 7 of crt*/
  254.     lprc('\n');
  255.     if (course[1]==0) lprcat("\t\tb)  Fighters Training II        15 mobuls");
  256.     lprc('\n');
  257.     if (course[2]==0) lprcat("\t\tc)  Introduction to Wizardry    10 mobuls");
  258.     lprc('\n');
  259.     if (course[3]==0) lprcat("\t\td)  Applied Wizardry            20 mobuls");
  260.     lprc('\n');
  261.     if (course[4]==0) lprcat("\t\te)  Behavioral Psychology       10 mobuls");
  262.     lprc('\n');
  263.     if (course[5]==0) lprcat("\t\tf)  Faith for Today             10 mobuls");
  264.     lprc('\n');
  265.     if (course[6]==0) lprcat("\t\tg)  Contemporary Dance          10 mobuls");
  266.     lprc('\n');
  267.     if (course[7]==0) lprcat("\t\th)  History of Larn              5 mobuls");
  268.  
  269.     lprcat("\n\n\t\tAll courses cost 250 gold pieces.");
  270.     cursor(30,18);
  271.     lprcat("You are presently carrying ");
  272.     }
  273.  
  274. oschool()
  275.     {
  276.     register int i;
  277.     long time_used;
  278.     nosignal = 1; /* disable signals */
  279.     sch_hed();
  280.     while (1)
  281.         {
  282.         cursor(57,18); lprintf("%d gold pieces.   ",(long)c[GOLD]); cursors();
  283.         lprcat("\nWhat is your choice ["); standout("escape");
  284.         lprcat(" to leave] ? ");  yrepcount=0;
  285.         i=0;  while ((i<'a' || i>'h') && (i!='\33') && (i!=12)) i=getchar();
  286.         if (i==12) { sch_hed();  continue; }
  287.         else if (i=='\33')
  288.             { nosignal = 0; drawscreen();  /* enable signals */ return; }
  289.         lprc(i);
  290.         if (c[GOLD] < 250)  nogold();  else
  291.         if (course[i-'a'])
  292.             { lprcat("\nSorry, but that class is filled."); nap(1000); }
  293.         else
  294.         if (i <= 'h')
  295.             {
  296.             c[GOLD] -= 250; time_used=0;
  297.             switch(i)
  298.                 {
  299.                 case 'a':    c[STRENGTH] += 2;  c[CONSTITUTION]++;
  300.                             lprcat("\nYou feel stronger!");
  301.                             cl_line(16,7);
  302.                             break;
  303.  
  304.                 case 'b':    if (course[0]==0)
  305.                                 {
  306.                                 lprcat("\nSorry, but this class has a prerequisite of Fighters Training I");
  307.                                 c[GOLD]+=250;  time_used= -10000;  break;
  308.                                 }
  309.                             lprcat("\nYou feel much stronger!");
  310.                             cl_line(16,8);
  311.                             c[STRENGTH] += 2;  c[CONSTITUTION] += 2;  break;
  312.  
  313.                 case 'c':    c[INTELLIGENCE] += 2; 
  314.                             lprcat("\nThe task before you now seems more attainable!");
  315.                             cl_line(16,9);  break;
  316.  
  317.                 case 'd':    if (course[2]==0)
  318.                                 {
  319.                                 lprcat("\nSorry, but this class has a prerequisite of Introduction to Wizardry");
  320.                                 c[GOLD]+=250;  time_used= -10000;  break;
  321.                                 }
  322.                             lprcat("\nThe task before you now seems very attainable!");
  323.                             cl_line(16,10);
  324.                             c[INTELLIGENCE] += 2;  break;
  325.  
  326.                 case 'e':    c[CHARISMA] += 3;  
  327.                             lprcat("\nYou now feel like a born leader!");
  328.                             cl_line(16,11);  break;
  329.  
  330.                 case 'f':    c[WISDOM] += 2;  
  331.                             lprcat("\nYou now feel more confident that you can find the potion in time!");
  332.                             cl_line(16,12);  break;
  333.  
  334.                 case 'g':    c[DEXTERITY] += 3;  
  335.                             lprcat("\nYou feel like dancing!");
  336.                             cl_line(16,13);  break;
  337.  
  338.                 case 'h':    c[INTELLIGENCE]++;
  339.                             lprcat("\nYour instructor told you that the Eye of Larn is rumored to be guarded\n");
  340.                             lprcat("by a platinum dragon who possesses psionic abilities. ");
  341.                             cl_line(16,14);  break;
  342.                 }
  343.             time_used += coursetime[i-'a']*100;
  344.             if (time_used > 0)
  345.               {
  346.               gtime += time_used;
  347.               course[i-'a']++;    /*    remember that he has taken that course    */
  348.               c[HP] = c[HPMAX];  c[SPELLS] = c[SPELLMAX]; /* he regenerated */ 
  349.  
  350.               if (c[BLINDCOUNT])    c[BLINDCOUNT]=1;  /* cure blindness too!  */
  351.               if (c[CONFUSE])        c[CONFUSE]=1;    /*    end confusion    */
  352.               adjtime((long)time_used);    /* adjust parameters for time change */
  353.               }
  354.             nap(1000);
  355.             }
  356.         }
  357.     }
  358.  
  359. /*
  360.  *    for the first national bank of Larn
  361.  */
  362. int lasttime=0;    /* last time he was in bank */
  363. obank()
  364.     {
  365.     banktitle("    Welcome to the First National Bank of Larn.");
  366.     }
  367. obank2()
  368.     {
  369.     banktitle("Welcome to the 5th level branch office of the First National Bank of Larn.");
  370.     }
  371. static banktitle(str)
  372.     char *str;
  373.     {
  374.     nosignal = 1; /* disable signals */
  375.     clear();  lprcat(str);
  376.     if (outstanding_taxes>0)
  377.         {
  378.         register int i;
  379.         lprcat("\n\nThe Larn Revenue Service has ordered that your account be frozen until all\n"); beep();
  380.         lprintf("levied taxes have been paid.  They have also told us that you owe %d gp in\n",(long)outstanding_taxes);
  381.         lprcat("taxes, and we must comply with them. We cannot serve you at this time.  Sorry.\n");
  382.         lprcat("We suggest you go to the LRS office and pay your taxes.\n");
  383.         cursors();    
  384.         lprcat("\nPress "); standout("escape"); lprcat(" to leave: "); lflush();
  385.         i=0;
  386.         while (i!='\33') i=getchar();
  387.         drawscreen();  nosignal = 0; /* enable signals */ return;
  388.         }
  389.     lprcat("\n\n\tGemstone\t      Appraisal\t\tGemstone\t      Appraisal");
  390.     obanksub();        nosignal = 0; /* enable signals */
  391.     drawscreen();
  392.     }
  393.  
  394. /*
  395.  *    function to put interest on your bank account
  396.  */
  397. ointerest()
  398.     {
  399.     register int i;
  400.     if (c[BANKACCOUNT]<0) c[BANKACCOUNT] = 0;
  401.     else if ((c[BANKACCOUNT]>0) && (c[BANKACCOUNT]<500000))
  402.         {
  403.         i = (gtime-lasttime)/100; /* # mobuls elapsed */
  404.         while ((i-- > 0) && (c[BANKACCOUNT]<500000))
  405.             c[BANKACCOUNT] += c[BANKACCOUNT]/250;
  406.         if (c[BANKACCOUNT]>500000) c[BANKACCOUNT]=500000; /* interest limit */
  407.         }
  408.     lasttime = (gtime/100)*100;
  409.     }
  410.  
  411. # ifndef OSK
  412. static short gemorder[26]=0;    /* the reference to screen location for each */
  413. static long gemvalue[26]=0;    /* the appraisal of the gems */
  414. # else OSK
  415. static short gemorder[26]= 
  416. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  417. static long gemvalue[26]=
  418. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  419. # endif OSK
  420. obanksub()
  421.     {
  422.     unsigned long amt;
  423.     register int i,k;
  424.     ointerest();    /* credit any needed interest */
  425.  
  426.     for (k=i=0; i<26; i++)
  427.         switch(iven[i])
  428.             {
  429.             case OLARNEYE: case ODIAMOND: case OEMERALD: 
  430.             case ORUBY: case OSAPPHIRE:
  431.  
  432.                     if (iven[i]==OLARNEYE)
  433.                         {
  434.                         gemvalue[i]=250000-((gtime*7)/100)*100;
  435.                         if (gemvalue[i]<50000) gemvalue[i]=50000;
  436.                         }
  437.                     else gemvalue[i] = (255&ivenarg[i])*100;
  438.                     gemorder[i]=k;
  439.                     cursor( (k%2)*40+1 , (k>>1)+4 );
  440.                     lprintf("%c) %s",i+'a',objectname[iven[i]]);
  441.                     cursor( (k%2)*40+33 , (k>>1)+4 );
  442.                     lprintf("%5d",(long)gemvalue[i]);  k++;
  443.             };
  444.     cursor(31,17); lprintf("You have %8d gold pieces in the bank.",(long)c[BANKACCOUNT]);
  445.     cursor(40,18); lprintf("You have %8d gold pieces",(long)c[GOLD]);
  446.     if (c[BANKACCOUNT]+c[GOLD] >= 500000)
  447.         lprcat("\nNote:  Larndom law states that only deposits under 500,000gp  can earn interest.");
  448.     while (1)
  449.         {
  450.         cl_dn(1,20);
  451.         lprcat("\nYour wish? [("); standout("d"); lprcat(") deposit, (");
  452.         standout("w"); lprcat(") withdraw, ("); standout("s");
  453.         lprcat(") sell a stone, or "); standout("escape"); lprcat("]  ");
  454.         yrepcount=0;
  455.         i=0; while (i!='d' && i!='w' && i!='s' && i!='\33') i=getchar();
  456.         switch(i)
  457.             {
  458.             case 'd':    lprcat("deposit\nHow much? ");    amt = readnum((long)c[GOLD]);
  459.                         if (amt<0) { lprcat("\nSorry, but we can't take negative gold!"); nap(2000); amt=0; } else
  460.                         if (amt>c[GOLD])
  461.                           { lprcat("  You don't have that much.");  nap(2000); }
  462.                         else { c[GOLD] -= amt;  c[BANKACCOUNT] += amt; }
  463.                         break;
  464.  
  465.             case 'w':    lprcat("withdraw\nHow much? ");    amt = readnum((long)c[BANKACCOUNT]);
  466.                         if (amt<0) { lprcat("\nSorry, but we don't have any negative gold!");  nap(2000); amt=0; }
  467.                         else if (amt > c[BANKACCOUNT])
  468.                           { lprcat("\nYou don't have that much in the bank!"); nap(2000); }
  469.                         else { c[GOLD] += amt;  c[BANKACCOUNT] -= amt; }        
  470.                         break;
  471.  
  472.             case 's':    lprcat("\nWhich stone would you like to sell? ");
  473.                         i=0; while ((i<'a' || i>'z') && i!='*') i=getchar();
  474.                         if (i=='*')
  475.                           for (i=0; i<26; i++)
  476.                             {
  477.                             if (gemvalue[i]) 
  478.                                 {
  479.                                 c[GOLD]+=gemvalue[i];  iven[i]=0;
  480.                                 gemvalue[i]=0;    k = gemorder[i];
  481.                                 cursor( (k%2)*40+1 , (k>>1)+4 );
  482.                                 lprintf("%39s","");
  483.                                 }
  484.                             }
  485.                         else
  486.                             {
  487.                             if (gemvalue[i=i-'a']==0) 
  488.                                 {
  489.                                 lprintf("\nItem %c is not a gemstone!",i+'a');
  490.                                 nap(2000); break;
  491.                                 }
  492.                             c[GOLD]+=gemvalue[i];  iven[i]=0;
  493.                             gemvalue[i]=0;    k = gemorder[i];
  494.                             cursor( (k%2)*40+1 , (k>>1)+4 ); lprintf("%39s","");
  495.                             }
  496.                         break;
  497.  
  498.             case '\33':    return;
  499.             };
  500.         cursor(40,17); lprintf("%8d",(long)c[BANKACCOUNT]);
  501.         cursor(49,18); lprintf("%8d",(long)c[GOLD]);
  502.         }
  503.     }
  504.  
  505. /*
  506.     subroutine to appraise any stone for the bank
  507.  */
  508. appraise(gemstone)
  509.     register int gemstone;
  510.     {
  511.     register int j,amt;
  512.     for (j=0; j<26; j++)
  513.       if (iven[j]==gemstone)
  514.         {
  515.         lprintf("\nI see you have %s",objectname[gemstone]);
  516.         if (gemstone==OLARNEYE) lprcat("  I must commend you.  I didn't think\nyou could get it.");
  517.         lprcat("  Shall I appraise it for you? ");  yrepcount=0;
  518.         if (getyn()=='y')
  519.             {
  520.             lprcat("yes.\n  Just one moment please \n");  nap(1000);
  521.             if (gemstone==OLARNEYE)
  522.                 {
  523.                 amt = 250000-((gtime*7)/100)*100;
  524.                 if (amt<50000) amt=50000;
  525.                 }
  526.             else amt = (255 & ivenarg[j]) * 100;
  527.             lprintf("\nI can see this is an excellent stone, It is worth %d",(long)amt);
  528.             lprcat("\nWould you like to sell it to us? ");  yrepcount=0;
  529.             if (getyn()=='y') { lprcat("yes\n"); c[GOLD]+=amt;  iven[j]=0; }
  530.             else lprcat("no thank you.\n");
  531.             if (gemstone==OLARNEYE) lprcat("It is, of course, your privilege to keep the stone\n"); 
  532.             }
  533.         else lprcat("no\nO. K.\n");
  534.         }
  535.     }
  536. /*
  537.     function for the trading post
  538.  */
  539. static otradhead()
  540.     {
  541.     clear();
  542.     lprcat("Welcome to the Larn Trading Post.  We buy items that explorers no longer find\n");
  543.     lprcat("useful.  Since the condition of the items you bring in is not certain,\n");
  544.     lprcat("and we incur great expense in reconditioning the items, we usually pay\n");
  545.     lprcat("only 20% of their value were they to be new.  If the items are badly\n");
  546.     lprcat("damaged, we will pay only 10% of their new value.\n\n");
  547.     }
  548.  
  549. otradepost()
  550.   {
  551.   register int i,j,value,isub,izarg;
  552.   dnditm = dndcount = 0;
  553.   nosignal = 1; /* disable signals */
  554.   resetscroll();    otradhead();
  555.   while (1)
  556.     {
  557.     lprcat("\nWhat item do you want to sell to us ["); standout("*");
  558.     lprcat(" for list, or "); standout("escape"); lprcat("] ? ");
  559.     i=0; while (i>'z' || (i<'a' && i!='*' && i!='\33' && i!='.')) i=getchar();
  560.     if (i == '\33')
  561.         { setscroll(); recalc(); drawscreen(); nosignal=0; /* enable signals */ return; }
  562.     isub = i - 'a';        j=0;
  563.     if (iven[isub]==OSCROLL) if (scrollname[ivenarg[isub]][0]==0)
  564.         { j=1; cnsitm(); }    /* can't sell unidentified item */
  565.     if (iven[isub]==OPOTION) if (potionname[ivenarg[isub]][0]==0)
  566.         { j=1; cnsitm(); }    /* can't sell unidentified item */
  567.     if (!j)
  568.       if (i=='*') { clear(); qshowstr(); otradhead(); }
  569.     else  if (iven[isub]==0)  lprintf("\nYou don't have item %c!",isub+'a');
  570.     else
  571.         {
  572.         for (j=0; j<maxitm; j++)
  573.           if ((itm[j].obj == iven[isub]) || (iven[isub] == ODIAMOND) || (iven[isub] == ORUBY) || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE))
  574.             {
  575.             srcount=0;  show3(isub);    /* show what the item was */
  576.             if ((iven[isub] == ODIAMOND) || (iven[isub] == ORUBY)
  577.                 || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE))
  578.                 value = 20*ivenarg[isub];
  579.             else
  580.             if ((itm[j].obj == OSCROLL) || (itm[j].obj == OPOTION))  value = 2*itm[j+ivenarg[isub]].price;
  581.             else
  582.                 {
  583.                 izarg=ivenarg[isub];  value = itm[j].price;    /* appreciate if a +n object */
  584.                 if (izarg >= 0) value *= 2;
  585.                 while ((izarg-- > 0) && ((value=14*(67+value)/10) < 500000));
  586.                 }
  587.             lprintf("\nItem (%c) is worth %d gold pieces to us.  Do you want to sell it? ",i,(long)value);
  588.             yrepcount=0;
  589.             if (getyn()=='y')
  590.                 {
  591.                 lprcat("yes\n"); c[GOLD]+=value;
  592.                 if (c[WEAR] == isub) c[WEAR] = -1;
  593.                 if (c[WIELD] == isub) c[WIELD] = -1;
  594.                 if (c[SHIELD] == isub) c[SHIELD] = -1;
  595.                 adjustcvalues(iven[isub],ivenarg[isub]);
  596.                 iven[isub]=0;
  597.                 }
  598.             else lprcat("no thanks.\n");
  599.             j = maxitm+100;    /* get out of the inner loop */
  600.             }
  601.         if (j <= maxitm+2) lprcat("\nSo sorry, but we are not authorized to accept that item.");
  602.         }
  603.     }
  604.   }
  605.  
  606. cnsitm()
  607.     { lprcat("\nSorry, we can't accept unidentified objects."); }
  608.  
  609. /*
  610.  *    for the Larn Revenue Service
  611.  */
  612. olrs()
  613.     {
  614.     register int i,first;
  615.     unsigned long amt;
  616.     first = nosignal = 1; /* disable signals */
  617.     clear();  resetscroll(); cursor(1,4);
  618.     lprcat("Welcome to the Larn Revenue Service district office.  How can we help you?");
  619.     while (1)
  620.         {
  621.         if (first) { first=0; goto nxt; }
  622.         cursors();
  623.         lprcat("\n\nYour wish? [(");
  624.         standout("p");
  625.         lprcat(") pay taxes, or ");
  626.         standout("escape");
  627.         lprcat("]  ");  yrepcount=0;
  628.         i=0; while (i!='p' && i!='\33') i=getchar();
  629.         switch(i)
  630.             {
  631.             case 'p':    lprcat("pay taxes\nHow much? "); amt = readnum((long)c[GOLD]);
  632.                         if (amt<0) { lprcat("\nSorry, but we can't take negative gold\n"); amt=0; } else
  633.                         if (amt>c[GOLD])    lprcat("  You don't have that much.\n");
  634.                         else  c[GOLD] -= paytaxes((long)amt);
  635.                         break;
  636.  
  637.             case '\33':    nosignal = 0; /* enable signals */
  638.                         setscroll(); drawscreen();    return;
  639.             };
  640.  
  641. nxt:    cursor(1,6);
  642.         if (outstanding_taxes>0)
  643.             lprintf("You presently owe %d gp in taxes.  ",(long)outstanding_taxes);
  644.         else
  645.             lprcat("You do not owe us any taxes.           ");
  646.         cursor(1,8);
  647.         if (c[GOLD]>0)
  648.             lprintf("You have %6d gp.    ",(long)c[GOLD]);
  649.         else
  650.             lprcat("You have no gold pieces.  ");
  651.         }
  652.     }
  653.     
  654. # ifdef OSK
  655. void
  656. do_store ()
  657. {
  658.     register int t;
  659.     
  660.     for (t=0;t<90;++t) {
  661.         itm[t] = __itm[t];
  662.         if (itm[t].mem == (char **) 4)
  663.             itm[t].mem = potionname;
  664.         else if (itm[t].mem == (char **) 8)
  665.             itm[t].mem = scrollname;
  666.     }
  667. }
  668. # endif OSK
  669.