Path: news.larc.nasa.gov!amiga-request
From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
Subject: v91i157: Larn 12.3 - dungeon type adventure game, Part13/17
Reply-To: Sie <S.Raybould@fulcrum.bt.co.uk>
Newsgroups: comp.sources.amiga
Message-ID: <comp.sources.amiga.v91i157@ab20.larc.nasa.gov>
References: <comp.sources.amiga.v91i145@ab20.larc.nasa.gov>
Date: 29 Aug 91 10:10:54 GMT
Approved: tadguy@uunet.UU.NET (Tad Guy)
X-Mail-Submissions-To: amiga@uunet.uu.net
X-Post-Discussions-To: comp.sys.amiga.misc

Submitted-by: Sie <S.Raybould@fulcrum.bt.co.uk>
Posting-number: Volume 91, Issue 157
Archive-name: games/larn-12.3/part13

#!/bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 13 (of 17)."
# Contents:  store.c
# Wrapped by tadguy@ab20 on Mon Aug 26 21:51:54 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'store.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'store.c'\"
else
echo shar: Extracting \"'store.c'\" \(29004 characters\)
sed "s/^X//" >'store.c' <<'END_OF_FILE'
X/* store.c */
X/*
XThis module contains data and routines to handle buildings at the home level.
XRoutines:
X
X  dnd_2hed
X  dnd_hed
X  dndstore      The DND store main routine
X  handsfull     To tell the player he can carry no more
X  out_of_stock  To tell the player an item is out of stock
X  no_gold       To tell the player he has no gold
X  dnditem       Display DND store items
X  sch_head      print the school header
X  oschool       main school routine
X  obank         Larn National Bank
X  obank2        5th level branch of the bank
X  banktitle     bank header
X  ointerest     accrue interest to bank account
X  obanksub      bank main subroutine
X  otradhead     trading post header
X  otradepost    trading post main function
X  cnsitm
X  olrs          larn revenue service function
X*/
X
X#include "header.h"
X#include "larndefs.h"
X#include "objects.h"
X#include "player.h"
X
Xstatic int dndcount=0,dnditm=0;
X
X/* number of items in the dnd inventory table   */
X#define MAXITM 83
X
X/*  this is the data for the stuff in the dnd store */
Xstruct _itm itm[90] = {
X/*cost    memory    iven name   iven arg   how
X  gp     pointer      iven[]    ivenarg[]  many */
X
X{ 2,        0,      OLEATHER,       0,      3   },
X{ 10,       0,      OSTUDLEATHER,   0,      2   },
X{ 40,       0,      ORING,          0,      2   },
X{ 85,       0,      OCHAIN,         0,      2   },
X{ 220,      0,      OSPLINT,        0,      1   },
X{ 400,      0,      OPLATE,         0,      1   },
X{ 900,      0,      OPLATEARMOR,    0,      1   },
X{ 2600,     0,      OSSPLATE,       0,      1   },
X{ 150,      0,      OSHIELD,        0,      1   },
X
X/*cost    memory    iven name   iven arg   how
X  gp     pointer      iven[]    ivenarg[]  many */
X
X{ 2,        0,      ODAGGER,        0,      3   },
X{ 20,       0,      OSPEAR,         0,      3   },
X{ 80,       0,      OFLAIL,         0,      2   },
X{ 150,      0,      OBATTLEAXE,     0,      2   },
X{ 450,      0,      OLONGSWORD,     0,      2   },
X{ 1000,     0,      O2SWORD,        0,      2   },
X{ 5000,     0,      OSWORD,         0,      1   },
X{ 16500,    0,      OLANCE,         0,      1   },
X{ 6000,     0,   OSWORDofSLASHING,  0,      0   },
X{ 10000,    0,      OHAMMER,        0,      0   },
X
X/*cost    memory    iven name   iven arg   how
X  gp     pointer      iven[]    ivenarg[]  many */
X
X{ 150,      0,      OPROTRING,      1,      1   },
X{ 85,       0,      OSTRRING,       1,      1   },
X{ 120,      0,      ODEXRING,       1,      1   },
X{ 120,      0,      OCLEVERRING,    1,      1   },
X{ 180,      0,      OENERGYRING,    0,      1   },
X{ 125,      0,      ODAMRING,       0,      1   },
X{ 220,      0,      OREGENRING,     0,      1   },
X{ 1000,     0,      ORINGOFEXTRA,   0,      1   },
X
X{ 280,      0,      OBELT,          0,      1   },
X
X{ 400,      0,      OAMULET,        0,      1   },
X
X{ 6500,     0,      OORBOFDRAGON,   0,      0   },
X{ 5500,     0,      OSPIRITSCARAB,  0,      0   },
X{ 5000,     0,      OCUBEofUNDEAD,  0,      0   },
X{ 6000,     0,      ONOTHEFT,       0,      0   },
X
X{ 590,      0,      OCHEST,         6,      1   },
X{ 200,      0,      OBOOK,          8,      1   },
X{ 10,       0,      OCOOKIE,        0,      3   },
X
X/*cost    memory    iven name   iven arg   how
X  gp     pointer      iven[]    ivenarg[]  many */
X
X{   20,     potionname, OPOTION,    0,      6   },
X{   90,     potionname, OPOTION,    1,      5   },
X{   520,    potionname, OPOTION,    2,      1   },
X{   100,    potionname, OPOTION,    3,      2   },
X{   50,     potionname, OPOTION,    4,      2   },
X{   150,    potionname, OPOTION,    5,      2   },
X{   70,     potionname, OPOTION,    6,      1   },
X{   30,     potionname, OPOTION,    7,      7   },
X{   200,    potionname, OPOTION,    8,      1   },
X{   50,     potionname, OPOTION,    9,      1   },
X{   80,     potionname, OPOTION,    10,     1   },
X
X/*cost    memory    iven name   iven arg   how
X  gp     pointer      iven[]    ivenarg[]  many */
X
X{   30,     potionname, OPOTION,    11,     3   },
X{   20,     potionname, OPOTION,    12,     5   },
X{   40,     potionname, OPOTION,    13,     3   },
X{   35,     potionname, OPOTION,    14,     2   },
X{   520,    potionname, OPOTION,    15,     1   },
X{   90,     potionname, OPOTION,    16,     2   },
X{   200,    potionname, OPOTION,    17,     2   },
X{   220,    potionname, OPOTION,    18,     4   },
X{   80,     potionname, OPOTION,    19,     6   },
X{   370,    potionname, OPOTION,    20,     3   },
X{   50,     potionname, OPOTION,    22,     1   },
X{   150,    potionname, OPOTION,    23,     3   },
X
X/*cost    memory    iven name   iven arg   how
X  gp     pointer      iven[]    ivenarg[]  many */
X
X{ 100,  scrollname,     OSCROLL,    0,      2   },
X{ 125,  scrollname,     OSCROLL,    1,      2   },
X{ 60,   scrollname,     OSCROLL,    2,      4   },
X{ 10,   scrollname,     OSCROLL,    3,      4   },
X{ 100,  scrollname,     OSCROLL,    4,      3   },
X{ 200,  scrollname,     OSCROLL,    5,      2   },
X{ 110,  scrollname,     OSCROLL,    6,      1   },
X{ 500,  scrollname,     OSCROLL,    7,      2   },
X{ 200,  scrollname,     OSCROLL,    8,      2   },
X{ 250,  scrollname,     OSCROLL,    9,      4   },
X{ 20,   scrollname,     OSCROLL,    10,     5   },
X{ 30,   scrollname,     OSCROLL,    11,     3   },
X
X/*cost    memory    iven name   iven arg   how
X  gp     pointer      iven[]    ivenarg[]  many */
X
X{ 340,  scrollname,     OSCROLL,    12,     1   },
X{ 340,  scrollname,     OSCROLL,    13,     1   },
X{ 300,  scrollname,     OSCROLL,    14,     2   },
X{ 400,  scrollname,     OSCROLL,    15,     2   },
X{ 500,  scrollname,     OSCROLL,    16,     2   },
X{ 1000, scrollname,     OSCROLL,    17,     1   },
X{ 500,  scrollname,     OSCROLL,    18,     1   },
X{ 340,  scrollname,     OSCROLL,    19,     2   },
X{ 220,  scrollname,     OSCROLL,    20,     3   },
X{ 3900, scrollname,     OSCROLL,    21,     0   },
X{ 610,  scrollname,     OSCROLL,    22,     1   },
X{ 3000, scrollname,     OSCROLL,    23,     0   }
X };
X
X/*
X    for the college of larn
X */
Xchar course[26];    /*  the list of courses taken   */
Xstatic char coursetime[] = { 10, 15, 10, 20, 10, 10, 10, 5 };
X
X/*
X    function for the dnd store
X */
Xstatic dnd_2hed()
X    {
X    lprcat("Welcome to the Larn Thrift Shoppe.  We stock many items explorers find useful\n");
X    lprcat(" in their adventures.  Feel free to browse to your hearts content.\n");
X    lprcat("Also be advised, if you break 'em, you pay for 'em.");
X    }
X
Xstatic dnd_hed()
X    {
X    register int i;
X    for (i=dnditm; i<26+dnditm; i++)    dnditem(i);
X    cursor(50,18); lprcat("You have ");
X    }
X
Xdndstore()
X  {
X  register int i;
X  dnditm = 0;
X  nosignal = 1; /* disable signals */
X  clear();  dnd_2hed();
X  if (outstanding_taxes>0)
X    {
X    lprcat("\n\nThe Larn Revenue Service has ordered us to not do business with tax evaders.\n"); beep();
X    lprintf("They have also told us that you owe %d gp in back taxes, and as we must\n",(long)outstanding_taxes);
X    lprcat("comply with the law, we cannot serve you at this time.  Soo Sorry.\n");
X    cursors();
X    lprcat("\nPress "); standout("escape"); lprcat(" to leave: "); lflush();
X    i=0;
X    while (i!='\33') i=ttgetch();
X    drawscreen();  nosignal = 0; /* enable signals */ return;
X    }
X
X  dnd_hed();
X  while (1)
X    {
X    cursor(59,18); lprintf("%d gold pieces",(long)c[GOLD]);
X    cltoeoln(); cl_dn(1,20);    /* erase to eod */
X    lprcat("\nEnter your transaction ["); standout("space");
X    lprcat(" for more, "); standout("escape");
X    lprcat(" to leave]? ");
X    i=0;
X    while ((i<'a' || i>'z') && (i!=' ') && (i!='\33') && (i!=12))  i=ttgetch();
X    if (i==12) { clear();  dnd_2hed();  dnd_hed(); }
X    else if (i=='\33')
X        { drawscreen();  nosignal = 0; /* enable signals */ return; }
X    else if (i==' ')
X        {
X        cl_dn(1,4);
X    if ((dnditm += 26) >= MAXITM)
X            dnditm=0;
X        dnd_hed();
X        }
X    else
X        {  /* buy something */
X        lprc(i);    /* echo the byte */
X        i += dnditm - 'a';
X    if (i>=MAXITM) outofstock(); else
X        if (itm[i].qty <= 0) outofstock(); else
X        if (pocketfull()) handsfull(); else
X        if (c[GOLD] < (long) itm[i].price * 10) nogold(); else
X            {
X            if (itm[i].mem != 0) *itm[i].mem[itm[i].arg] = ' ';
X            c[GOLD] -= (long) itm[i].price * 10;
X            itm[i].qty--;  take(itm[i].obj,itm[i].arg);
X            if (itm[i].qty==0) dnditem(i);  nap(1001);
X            }
X        }
X
X    }
X  }
X
X/*
X    function for the players hands are full
X */
Xstatic handsfull()
X    { lprcat("\nYou can't carry anything more!"); lflush(); nap(2200); }
Xstatic outofstock()
X    { lprcat("\nSorry, but we are out of that item."); lflush(); nap(2200); }
Xstatic nogold()
X    { lprcat("\nYou don't have enough gold to pay for that!"); lflush(); nap(2200); }
X
X/*
X    dnditem(index)
X
X    to print the item list;  used in dndstore() enter with the index into itm
X */
Xstatic dnditem(i)
X    register int i;
X    {
X    register int j,k;
X    if (i >= MAXITM)  return;
X    cursor( (j=(i&1)*40+1) , (k=((i%26)>>1)+5) );
X    if (itm[i].qty == 0)  { lprintf("%39s","");  return; }
X    lprintf("%c) ",(i%26)+'a');
X    if (itm[i].obj == OPOTION)
X        { lprcat("potion of "); lprintf("%s",&potionname[itm[i].arg][1]); }
X    else if (itm[i].obj == OSCROLL)
X        { lprcat("scroll of "); lprintf("%s",&scrollname[itm[i].arg][1]); }
X    else lprintf("%s",objectname[itm[i].obj]);
X    cursor( j+31,k );  lprintf("%6d", (long) itm[i].price * 10);
X    }
X
X
X/*
X    function to display the header info for the school
X */
Xstatic sch_hed()
X    {
X    clear();
X    lprcat("The College of Larn offers the exciting opportunity of higher education to\n");
X    lprcat("all inhabitants of the caves.  Here is a list of the class schedule:\n\n\n");
X    lprcat("\t\t    Course Name \t       Time Needed\n\n");
X
X    if (course[0]==0) lprcat("\t\ta)  Fighters Training I         10 mobuls"); /*line 7 of crt*/
X    lprc('\n');
X    if (course[1]==0) lprcat("\t\tb)  Fighters Training II        15 mobuls");
X    lprc('\n');
X    if (course[2]==0) lprcat("\t\tc)  Introduction to Wizardry    10 mobuls");
X    lprc('\n');
X    if (course[3]==0) lprcat("\t\td)  Applied Wizardry            20 mobuls");
X    lprc('\n');
X    if (course[4]==0) lprcat("\t\te)  Behavioral Psychology       10 mobuls");
X    lprc('\n');
X    if (course[5]==0) lprcat("\t\tf)  Faith for Today             10 mobuls");
X    lprc('\n');
X    if (course[6]==0) lprcat("\t\tg)  Contemporary Dance          10 mobuls");
X    lprc('\n');
X    if (course[7]==0) lprcat("\t\th)  History of Larn              5 mobuls");
X
X    lprcat("\n\n\t\tAll courses cost 250 gold pieces.");
X    cursor(30,18);
X    lprcat("You are presently carrying ");
X    }
X
Xoschool()
X    {
X    register int i;
X    long time_used;
X    nosignal = 1; /* disable signals */
X    sch_hed();
X    while (1)
X        {
X        cursor(57,18); lprintf("%d gold pieces.   ",(long)c[GOLD]); cursors();
X        lprcat("\nWhat is your choice ["); standout("escape");
X        lprcat(" to leave] ? ");  yrepcount=0;
X        i=0;  while ((i<'a' || i>'h') && (i!='\33') && (i!=12)) i=ttgetch();
X        if (i==12) { sch_hed();  continue; }
X        else if (i=='\33')
X            { nosignal = 0; drawscreen();  /* enable signals */ return; }
X        lprc(i);
X        if (c[GOLD] < 250)  nogold();  else
X        if (course[i-'a'])
X            { lprcat("\nSorry, but that class is filled."); nap(1000); }
X        else
X        if (i <= 'h')
X            {
X            c[GOLD] -= 250; time_used=0;
X            switch(i)
X                {
X                case 'a':   c[STRENGTH] += 2;  c[CONSTITUTION]++;
X                            lprcat("\nYou feel stronger!");
X                            cl_line(16,7);
X                            break;
X
X                case 'b':   if (course[0]==0)
X                                {
X                                lprcat("\nSorry, but this class has a prerequisite of Fighters Training I");
X                                c[GOLD]+=250;  time_used= -10000;  break;
X                                }
X                            lprcat("\nYou feel much stronger!");
X                            cl_line(16,8);
X                            c[STRENGTH] += 2;  c[CONSTITUTION] += 2;  break;
X
X                case 'c':   c[INTELLIGENCE] += 2; 
X                            lprcat("\nThe task before you now seems more attainable!");
X                            cl_line(16,9);  break;
X
X                case 'd':   if (course[2]==0)
X                                {
X                                lprcat("\nSorry, but this class has a prerequisite of Introduction to Wizardry");
X                                c[GOLD]+=250;  time_used= -10000;  break;
X                                }
X                            lprcat("\nThe task before you now seems very attainable!");
X                            cl_line(16,10);
X                            c[INTELLIGENCE] += 2;  break;
X
X                case 'e':   c[CHARISMA] += 3;  
X                            lprcat("\nYou now feel like a born leader!");
X                            cl_line(16,11);  break;
X
X                case 'f':   c[WISDOM] += 2;  
X                            lprcat("\nYou now feel more confident that you can find the potion in time!");
X                            cl_line(16,12);  break;
X
X                case 'g':   c[DEXTERITY] += 3;  
X                            lprcat("\nYou feel like dancing!");
X                            cl_line(16,13);  break;
X
X                case 'h':   c[INTELLIGENCE]++;
X                            lprcat("\nYour instructor told you that the Eye of Larn is rumored to be guarded\n");
X                            lprcat("by a platinum dragon who possesses psionic abilities. ");
X                            cl_line(16,14);  break;
X                }
X            time_used += coursetime[i-'a']*100;
X            if (time_used > 0)
X              {
X              gtime += time_used;
X              course[i-'a']++;  /*  remember that he has taken that course  */
X              c[HP] = c[HPMAX];  c[SPELLS] = c[SPELLMAX]; /* he regenerated */
X
X              if (c[BLINDCOUNT])    c[BLINDCOUNT]=1;  /* cure blindness too!  */
X              if (c[CONFUSE])       c[CONFUSE]=1;   /*  end confusion   */
X              adjtime((long)time_used); /* adjust parameters for time change */
X              }
X            nap(1000);
X            }
X        }
X    }
X
X/*
X *  for the first national bank of Larn
X */
Xint lasttime=0; /* last time he was in bank */
Xobank()
X    {
X    banktitle("    Welcome to the First National Bank of Larn.");
X    }
Xobank2()
X    {
X    banktitle("Welcome to the 5th level branch office of the First National Bank of Larn.");
X    /* because we state the level in the title, clear the '?' in the
X       level display at the bottom, if the user teleported.
X    */
X    c[TELEFLAG] = 0;
X    }
Xstatic banktitle(str)
X    char *str;
X    {
X    nosignal = 1; /* disable signals */
X    clear();  lprcat(str);
X    if (outstanding_taxes>0)
X        {
X        register int i;
X        lprcat("\n\nThe Larn Revenue Service has ordered that your account be frozen until all\n"); beep();
X        lprintf("levied taxes have been paid.  They have also told us that you owe %d gp in\n",(long)outstanding_taxes);
X        lprcat("taxes, and we must comply with them. We cannot serve you at this time.  Sorry.\n");
X        lprcat("We suggest you go to the LRS office and pay your taxes.\n");
X        cursors();
X        lprcat("\nPress "); standout("escape"); lprcat(" to leave: "); lflush();
X        i=0;
X        while (i!='\33') i=ttgetch();
X        drawscreen();  nosignal = 0; /* enable signals */ return;
X        }
X    lprcat("\n\n\tGemstone\t      Appraisal\t\tGemstone\t      Appraisal");
X    obanksub();     nosignal = 0; /* enable signals */
X    drawscreen();
X    }
X
X/*
X *  function to put interest on your bank account
X */
Xointerest()
X    {
X    register int i;
X    if (c[BANKACCOUNT]<0) c[BANKACCOUNT] = 0;
X    else if ((c[BANKACCOUNT]>0) && (c[BANKACCOUNT]<500000))
X        {
X        i = (gtime-lasttime)/100; /* # mobuls elapsed */
X        while ((i-- > 0) && (c[BANKACCOUNT]<500000))
X            c[BANKACCOUNT] += c[BANKACCOUNT]/250;
X        if (c[BANKACCOUNT]>500000) c[BANKACCOUNT]=500000; /* interest limit */
X        }
X    lasttime = (gtime/100)*100;
X    }
X
Xstatic obanksub()
X    {
X    short gemorder[26];  /* the reference to screen location for each gem */
X    long gemvalue[26];   /* the appraisal of the gems */
X    unsigned long amt;
X    register int i,k,gems_sold=0;
X
X    ointerest();    /* credit any needed interest */
X
X    for (k=i=0; i<26; i++)
X        switch(iven[i])
X            {
X            case OLARNEYE: case ODIAMOND: case OEMERALD:
X            case ORUBY: case OSAPPHIRE:
X
X                    if (iven[i]==OLARNEYE)
X                        {
X                        gemvalue[i]=250000-((gtime*7)/100)*100;
X                        if (gemvalue[i]<50000) gemvalue[i]=50000;
X                        }
X                    else gemvalue[i] = (255&ivenarg[i])*100;
X                    gemorder[i]=k;
X                    cursor( (k%2)*40+1 , (k>>1)+4 );
X                    lprintf("%c) %s",i+'a',objectname[iven[i]]);
X                    cursor( (k%2)*40+33 , (k>>1)+4 );
X                    lprintf("%5d",(long)gemvalue[i]);  k++;
X                    break;
X
X            default:        /* make sure player can't sell non-existant gems */
X                gemvalue[i] = 0 ;
X                gemorder[i] = 0 ;
X            };
X    cursor(31,17); lprintf("You have %8d gold pieces in the bank.",(long)c[BANKACCOUNT]);
X    cursor(40,18); lprintf("You have %8d gold pieces",(long)c[GOLD]);
X    if (c[BANKACCOUNT]+c[GOLD] >= 500000)
X        lprcat("\nNote:  Larndom law states that only deposits under 500,000gp  can earn interest.");
X    while (1)
X        {
X        cl_dn(1,20);
X        lprcat("\nYour wish? [("); standout("d"); lprcat(") deposit, (");
X        standout("w"); lprcat(") withdraw, ("); standout("s");
X        lprcat(") sell a stone, or "); standout("escape"); lprcat("]  ");
X        yrepcount=0;
X        i=0; while (i!='d' && i!='w' && i!='s' && i!='\33') i=ttgetch();
X        switch(i)
X            {
X# ifdef MSDOS
X            case 'd':
X              lprcat("deposit\n");
X              cltoeoln();
X              lprcat("How much? "); amt = readnum((long)c[GOLD]);
X# else
X            case 'd':   lprcat("deposit\nHow much? ");  amt = readnum((long)c[GOLD]);
X# endif
X                        if (amt<0) { lprcat("\nSorry, but we can't take negative gold!"); nap(2000); amt=0; } else
X                        if (amt>c[GOLD])
X                          { lprcat("  You don't have that much.");  nap(2000); }
X                        else { c[GOLD] -= amt;  c[BANKACCOUNT] += amt; }
X                        break;
X
X            case 'w':   lprcat("withdraw\nHow much? "); amt = readnum((long)c[BANKACCOUNT]);
X                        if (amt<0) { lprcat("\nSorry, but we don't have any negative gold!");  nap(2000); amt=0; }
X                        else if (amt > c[BANKACCOUNT])
X                          { lprcat("\nYou don't have that much in the bank!"); nap(2000); }
X                        else { c[GOLD] += amt;  c[BANKACCOUNT] -= amt; }
X                        break;
X
X            case 's':   lprcat("\nWhich stone would you like to sell? ");
X            i=0; while ((i<'a' || i>'z') && i!='*' && i!='\33')
X                i=ttgetch();
X                        if (i=='*')
X              {
X              for (i=0; i<26; i++)
X                            {
X                            if (gemvalue[i])
X                                {
X                gems_sold = TRUE ;
X                c[GOLD]+=gemvalue[i];  iven[i]=0;
X                                gemvalue[i]=0;  k = gemorder[i];
X                                cursor( (k%2)*40+1 , (k>>1)+4 );
X                                lprintf("%39s","");
X                                }
X                            }
X              if (!gems_sold)
X                  {
X                  lprcat("\nYou have no gems to sell!");
X                  nap(2000);
X                  }
X              }
X            else if ( i != '\33' )
X                            {
X                            if (gemvalue[i=i-'a']==0)
X                                {
X                                lprintf("\nItem %c is not a gemstone!",i+'a');
X                                nap(2000); break;
X                                }
X                            c[GOLD]+=gemvalue[i];  iven[i]=0;
X                            gemvalue[i]=0;  k = gemorder[i];
X                            cursor( (k%2)*40+1 , (k>>1)+4 ); lprintf("%39s","");
X                            }
X                        break;
X
X            case '\33': return;
X            };
X        cursor(40,17); lprintf("%8d",(long)c[BANKACCOUNT]);
X        cursor(49,18); lprintf("%8d",(long)c[GOLD]);
X        }
X    }
X
X/*
X    function for the trading post
X */
Xstatic otradhead()
X    {
X    clear();
X    lprcat("Welcome to the Larn Trading Post.  We buy items that explorers no longer find\n");
X    lprcat("useful.  Since the condition of the items you bring in is not certain,\n");
X    lprcat("and we incur great expense in reconditioning the items, we usually pay\n");
X    lprcat("only 20% of their value were they to be new.  If the items are badly\n");
X    lprcat("damaged, we will pay only 10% of their new value.\n\n");
X
X    lprcat("Here are the items we would be willing to buy from you:\n");
X    }
X
Xstatic short tradorder[26];   /* screen locations for trading post inventory */
Xstatic otradiven()
X    {
X    int i,j ;
X
X  /* Print user's iventory like bank */
X  for (j=i=0 ; i<26 ; i++)
X      if (iven[i])
X          {
X      cursor( (j%2)*40+1, (j>>1)+8 );
X      tradorder[i] = 0 ;    /* init position on screen to zero */
X      switch (iven[i])
X              {
X              case OPOTION:
X          if ( potionname[ivenarg[i]][0] != 0 )
X              {
X              tradorder[i] = j++ ;   /* will display only if identified */
X              lprintf( "%c) %s", i+'a', objectname[iven[i]] );
X              lprintf(" of%s", potionname[ivenarg[i]] );
X              }
X                  break;
X              case OSCROLL:
X          if ( scrollname[ivenarg[i]][0] != 0 )
X              {
X              tradorder[i] = j++ ;   /* will display only if identified */
X              lprintf( "%c) %s", i+'a', objectname[iven[i]] );
X              lprintf(" of%s", scrollname[ivenarg[i]] );
X              }
X          break;
X          case OLARNEYE:
X          case OBOOK:
X          case OSPIRITSCARAB:
X          case ODIAMOND:
X          case ORUBY:
X          case OEMERALD:
X          case OCHEST:
X          case OSAPPHIRE:
X          case OCUBEofUNDEAD:
X          case OCOOKIE:
X          case ONOTHEFT:
X          tradorder[i] = j++ ;  /* put on screen */
X          lprintf( "%c) %s", i+'a', objectname[iven[i]] );
X          break;
X          default:
X          tradorder[i] = j++ ;  /* put on screen */
X          lprintf( "%c) %s", i+'a', objectname[iven[i]] );
X          if (ivenarg[i] > 0)
X              lprintf(" +%d", (long)ivenarg[i] );
X          else if (ivenarg[i] < 0)
X              lprintf(" %d",  (long)ivenarg[i] );
X          break;
X          }
X      }
X      else
X       tradorder[i] = 0;  /* make sure order array is clear */
X    }
X
Xstatic cleartradiven( i )
Xint i ;
X    {
X    int j;
X    j = tradorder[i] ;
X    cursor( (j%2)*40+1, (j>>1)+8 );
X    lprintf( "%39s", "" );
X    tradorder[i] = 0;
X    }
X
Xotradepost()
X    {
X    register int i,j,isub,izarg,found;
X    register long value;
X
X    dnditm = dndcount = 0;
X    nosignal = 1; /* disable signals */
X    otradhead();
X    otradiven();
X
X    while (1)
X       {
X       cl_dn(1,21);
X       lprcat("\nWhat item do you want to sell to us [");
X       standout("escape"); lprcat("] ? ");
X       i=0;
X       while ( i>'z' || i<'a' && i!=12 && i!='\33' )
X           i=ttgetch();
X       if (i == '\33')
X           {
X           recalc();
X           drawscreen();
X           nosignal=0; /* enable signals */
X           return;
X           }
X       while (1)   /* inner loop for simpler control */
X           {
X           if (i == 12)
X               {
X               clear();
X               otradhead();
X               otradiven();
X               break;      /* leave inner while */
X               }
X
X           isub = i - 'a' ;
X           if (iven[isub] == 0)
X               {
X               lprintf("\nYou don't have item %c!",isub+'a');
X               nap(2000);
X               break;      /* leave inner while */
X               }
X           if (iven[isub]==OSCROLL)
X               if (scrollname[ivenarg[isub]][0]==0)
X                   {
X                   cnsitm();
X                   break;      /* leave inner while */
X                   }
X           if (iven[isub]==OPOTION)
X               if (potionname[ivenarg[isub]][0]==0)
X                   {
X                   cnsitm();
X                   break;      /* leave inner while */
X                   }
X           if (iven[isub]==ODIAMOND ||
X               iven[isub]==ORUBY    ||
X               iven[isub]==OEMERALD ||
X           iven[isub]==OSAPPHIRE )
X           value = 20L * (ivenarg[isub] & 255);
X       else if (iven[isub]==OLARNEYE)
X           {
X           value = 50000 - (((gtime*7) / 100) * 20 );
X           if (value < 10000)
X           value = 10000;
X           }
X       else
X               {
X               /* find object in itm[] list for price info */
X               found = MAXITM ;
X               for (j=0; j<MAXITM; j++)
X                   if (itm[j].obj == iven[isub])
X                       {
X                       found = j ;
X                       break;      /* leave for loop */
X                       }
X               if (found == MAXITM)
X                   {
X                   lprcat("\nSo sorry, but we are not authorized to accept that item.");
X                   nap(2000);
X                   break;      /* leave inner while */
X                   }
X               if (iven[isub] == OSCROLL ||
X                   iven[isub] == OPOTION)
X                   value = 2 * (long)itm[ j + ivenarg[isub]].price ;
X               else
X                   {
X                   izarg=ivenarg[isub];
X                   value = itm[j].price;
X                   /* appreciate if a +n object */
X                   if (izarg >= 0) value *= 2;
X                   while ((izarg-- > 0) && ((value=14*(67+value)/10) < 500000));
X                   }
X               }
X           /* we have now found the value of the item, and dealt with any error
X              cases.  Print the object's value, let the user sell it.
X           */
X           lprintf("\nItem (%c) is worth %d gold pieces to us.  Do you want to sell it? ",i,(long)value);
X           yrepcount=0;
X           if (getyn()=='y')
X               {
X               lprcat("yes\n"); c[GOLD]+=value;
X               if (c[WEAR] == isub) c[WEAR] = -1;
X               if (c[WIELD] == isub) c[WIELD] = -1;
X               if (c[SHIELD] == isub) c[SHIELD] = -1;
X               adjustcvalues(iven[isub],ivenarg[isub]);
X               iven[isub]=0;
X               cleartradiven( isub );
X               }
X           else
X           {
X           lprcat("no thanks.\n");
X           nap(500);
X           }
X       break;          /* exit inner while */
X           }   /* end of inner while */
X        }       /* end of outer while */
X    }       /* end of routine */
X
Xstatic cnsitm()
X    {
X    lprcat("\nSorry, we can't accept unidentified objects.");
X    nap(2000);
X    }
X
X/*
X *  for the Larn Revenue Service
X */
Xolrs()
X    {
X    register int i,first;
X    unsigned long amt;
X    first = nosignal = 1; /* disable signals */
X    clear();  resetscroll(); cursor(1,4);
X    lprcat("Welcome to the Larn Revenue Service district office.  How can we help you?");
X    while (1)
X        {
X        if (first) { first=0; goto nxt; }
X        setscroll();
X        cursors();
X        lprcat("\n\nYour wish? [(");
X        standout("p");
X        lprcat(") pay taxes, or ");
X        standout("escape");
X        lprcat("]  ");  yrepcount=0;
X        i=0; while (i!='p' && i!='\33') i=ttgetch();
X        switch(i)
X            {
X            case 'p':   lprcat("pay taxes\nHow much? "); amt = readnum((long)c[GOLD]);
X                        if (amt<0) { lprcat("\nSorry, but we can't take negative gold\n"); amt=0; } else
X                        if (amt>c[GOLD])    lprcat("  You don't have that much.\n");
X                        else  c[GOLD] -= paytaxes((long)amt);
X                        break;
X
X            case '\33': nosignal = 0; /* enable signals */
X                        setscroll(); drawscreen();  return;
X            };
X
Xnxt:    cursor(1,6);
X        if (outstanding_taxes>0)
X            lprintf("You presently owe %d gp in taxes.  ",(long)outstanding_taxes);
X        else
X            lprcat("You do not owe us any taxes.           ");
X        cursor(1,8);
X        if (c[GOLD]>0)
X            lprintf("You have %6d gp.    ",(long)c[GOLD]);
X        else
X            lprcat("You have no gold pieces.  ");
X        }
X    }
END_OF_FILE
if test 29004 -ne `wc -c <'store.c'`; then
    echo shar: \"'store.c'\" unpacked with wrong size!
fi
# end of 'store.c'
fi
echo shar: End of archive 13 \(of 17\).
cp /dev/null ark13isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 17 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
Mail comments to the moderator at <amiga-request@uunet.uu.net>.
Post requests for sources, and general discussion to comp.sys.amiga.misc.
