[comp.sources.games] v12i058: larn2 - dungeon type adventure game

billr@saab.CNA.TEK.COM (Bill Randle) (04/24/91)

Submitted-by: routley@tle.ENET.DEC.COM (Kevin Routley)
Posting-number: Volume 12, Issue 58
Archive-name: larn2/Part05
Supersedes: larn: Volume 11, Issue 84-94
Environment: Unix, VMS, MS-DOS, OS/2, termcap



#! /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 5 (of 12)."
# Contents:  display.c os2larn.def store.c termcap.pc
# Wrapped by billr@saab on Tue Apr 23 13:50:30 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'display.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'display.c'\"
else
echo shar: Extracting \"'display.c'\" \(21096 characters\)
sed "s/^X//" >'display.c' <<'END_OF_FILE'
X/* display.c */
X#include "header.h"
X#include "larndefs.h"
X#include "objects.h"
X#include "player.h"
X
X#define botsub( _idx, _x, _y, _str )        \
X    if ( c[(_idx)] != cbak[(_idx)] )        \
X    {                                   \
X    cbak[(_idx)] = c[(_idx)];           \
X    cursor( (_x), (_y) );               \
X    lprintf( (_str), (long)c[(_idx)] ); \
X    }
X
Xstatic int  minx,maxx,miny,maxy,k;
Xstatic char bot1f=0,bot2f=0,bot3f=0;
Xstatic char always=0;
X       char regen_bottom = 0;
X
X/*
X    bottomline()
X
X    now for the bottom line of the display
X */
Xbottomline()
X    {   recalc();   bot1f=1;    }
Xbottomhp()
X    {   bot2f=1;    }
Xbottomspell()
X    {   bot3f=1;    }
Xbottomdo()
X    {
X    if (bot1f) { bot3f=bot1f=bot2f=0; bot_linex(); return; }
X    if (bot2f) { bot2f=0; bot_hpx(); }
X    if (bot3f) { bot3f=0; bot_spellx(); }
X    }
X
Xbot_linex()
X    {
X    register int i;
X    if ( regen_bottom || (always))
X        {
X        regen_bottom = FALSE ;
X        cursor( 1,18);
X        if (c[SPELLMAX]>99)  lprintf("Spells:%3d(%3d)",(long)c[SPELLS],(long)c[SPELLMAX]);
X                        else lprintf("Spells:%3d(%2d) ",(long)c[SPELLS],(long)c[SPELLMAX]);
X        lprintf(" AC: %-3d  WC: %-3d  Level",(long)c[AC],(long)c[WCLASS]);
X        if (c[LEVEL]>99) lprintf("%3d",(long)c[LEVEL]);
X                    else lprintf(" %-2d",(long)c[LEVEL]);
X        lprintf(" Exp: %-9d %s\n",(long)c[EXPERIENCE],class[c[LEVEL]-1]);
X        lprintf("HP: %3d(%3d) STR=%-2d INT=%-2d ",
X            (long)c[HP],(long)c[HPMAX],(long)(c[STRENGTH]+c[STREXTRA]),(long)c[INTELLIGENCE]);
X        lprintf("WIS=%-2d CON=%-2d DEX=%-2d CHA=%-2d LV:",
X            (long)c[WISDOM],(long)c[CONSTITUTION],(long)c[DEXTERITY],(long)c[CHARISMA]);
X
X        if ((level==0) || (wizard))  c[TELEFLAG]=0;
X        if (c[TELEFLAG])  lprcat(" ?");  else  lprcat(levelname[level]);
X        lprintf("  Gold: %-6d",(long)c[GOLD]);
X        always=1;  botside();
X        c[TMP] = c[STRENGTH]+c[STREXTRA];
X        for (i=0; i<100; i++) cbak[i]=c[i];
X        return;
X        }
X
X    botsub(SPELLS,8,18,"%3d");
X    if (c[SPELLMAX]>99)
X        {
X        botsub(SPELLMAX,12,18,"%3d)");
X        }
X    else
X        botsub(SPELLMAX,12,18,"%2d) ");
X    botsub(HP,5,19,"%3d");
X    botsub(HPMAX,9,19,"%3d");
X    botsub(AC,21,18,"%-3d");
X    botsub(WCLASS,30,18,"%-3d");
X    botsub(EXPERIENCE,49,18,"%-9d");
X    if (c[LEVEL] != cbak[LEVEL])
X        {
X        cursor(59,18);
X        lprcat(class[c[LEVEL]-1]);
X        }
X    if (c[LEVEL]>99)
X        {
X        botsub(LEVEL,40,18,"%3d");
X        }
X    else
X        botsub(LEVEL,40,18," %-2d");
X    c[TMP] = c[STRENGTH]+c[STREXTRA];
X    botsub(TMP,18,19,"%-2d");
X    botsub(INTELLIGENCE,25,19,"%-2d");
X    botsub(WISDOM,32,19,"%-2d");
X    botsub(CONSTITUTION,39,19,"%-2d");
X    botsub(DEXTERITY,46,19,"%-2d");
X    botsub(CHARISMA,53,19,"%-2d");
X    if ((level != cbak[CAVELEVEL]) || (c[TELEFLAG] != cbak[TELEFLAG]))
X        {
X        if ((level==0) || (wizard))
X            c[TELEFLAG]=0;
X        cbak[TELEFLAG] = c[TELEFLAG];
X        cbak[CAVELEVEL] = level;
X        cursor(59,19);
X        if (c[TELEFLAG])
X            lprcat(" ?");
X        else
X            lprcat(levelname[level]);
X        }
X    botsub(GOLD,69,19,"%-6d");
X    botside();
X    }
X
X/*
X    special subroutine to update only the gold number on the bottomlines
X    called from ogold()
X */
Xbottomgold()
X    {
X    botsub(GOLD,69,19,"%-6d");
X    }
X
X/*
X    special routine to update hp and level fields on bottom lines
X    called in monster.c hitplayer() and spattack()
X */
Xstatic bot_hpx()
X    {
X    if (c[EXPERIENCE] != cbak[EXPERIENCE])
X        {
X        recalc();
X        bot_linex();
X        }
X    else
X        botsub(HP,5,19,"%3d");
X    }
X
X/*
X    special routine to update number of spells called from regen()
X */
Xstatic bot_spellx()
X    {
X    botsub(SPELLS,9,18,"%2d");
X    }
X
X/*
X    common subroutine for a more economical bottomline()
X */
Xstatic struct bot_side_def
X    {
X    int typ;
X    char *string;
X    }
X    bot_data[] =
X    {
X    STEALTH,"stealth",      UNDEADPRO,"undead pro",     SPIRITPRO,"spirit pro",
X    CHARMCOUNT,"Charm",     TIMESTOP,"Time Stop",       HOLDMONST,"Hold Monst",
X    GIANTSTR,"Giant Str",   FIRERESISTANCE,"Fire Resit", DEXCOUNT,"Dexterity",
X    STRCOUNT,"Strength",    SCAREMONST,"Scare",         HASTESELF,"Haste Self",
X    CANCELLATION,"Cancel",  INVISIBILITY,"Invisible",   ALTPRO,"Protect 3",
X    PROTECTIONTIME,"Protect 2", WTW,"Wall-Walk"
X    };
X
Xstatic botside()
X    {
X    register int i,idx;
X    for (i=0; i<17; i++)
X        {
X        idx = bot_data[i].typ;
X        if ((always) || (c[idx] != cbak[idx]))
X           {
X           if ((always) || (cbak[idx] == 0))
X                { if (c[idx]) { cursor(70,i+1); lprcat(bot_data[i].string); } }  else
X           if (c[idx]==0)     { cursor(70,i+1); lprcat("          "); }
X           cbak[idx]=c[idx];
X           }
X        }
X    always=0;
X    }
X
X/*
X *  subroutine to draw only a section of the screen
X *  only the top section of the screen is updated.  If entire lines are being
X *  drawn, then they will be cleared first.
X */
Xstatic int d_xmin=0,d_xmax=MAXX,d_ymin=0,d_ymax=MAXY;  /* for limited screen drawing */
Xdraws(xmin,xmax,ymin,ymax)
X    int xmin,xmax,ymin,ymax;
X    {
X    register int i,idx;
X    if (xmin==0 && xmax==MAXX) /* clear section of screen as needed */
X        {
X        if (ymin==0) cl_up(79,ymax);
X        else for (i=ymin; i<ymin; i++)  cl_line(1,i+1);
X        xmin = -1;
X        }
X    d_xmin=xmin;    d_xmax=xmax;    d_ymin=ymin;    d_ymax=ymax;    /* for limited screen drawing */
X    drawscreen();
X    if (xmin<=0 && xmax==MAXX) /* draw stuff on right side of screen as needed*/
X        {
X        for (i=ymin; i<ymax; i++)
X            {
X            idx = bot_data[i].typ;
X            if (c[idx])
X                {
X                cursor(70,i+1); lprcat(bot_data[i].string);
X                }
X            cbak[idx]=c[idx];
X            }
X        }
X    }
X
X#ifdef DECRainbow
X static int DECgraphics;     /* The graphics mode toggle */
X
X# define DECgraphicsON() if (!DECgraphics) lprc('\16'), DECgraphics = 1
X# define DECgraphicsOFF() if (DECgraphics) lprc('\17'), DECgraphics = 0
X
X/* For debugging on a non-DEC
X# define DECgraphicsON() if (!DECgraphics) lprcat("\33[4m"), DECgraphics = 1
X# define DECgraphicsOFF() if (DECgraphics) lprcat("\33[0m"), DECgraphics = 0
X*/
X
X# define DEClprc(ch)    if (ch & 0x80) {\
X                            DECgraphicsON();\
X                            lprc(ch ^ 0x80);\
X                        } else {\
X                            DECgraphicsOFF();\
X                            lprc(ch);\
X                        }
X#define nlprc(_ch) DEClprc(_ch)
X# else
X#define nlprc(_ch) lprc(_ch)
X#endif DECRainbow
X
X/*
X    drawscreen()
X
X    subroutine to redraw the whole screen as the player knows it
X */
Xstatic char d_flag;
Xdrawscreen()
X    {
X    register int i,j,k,ileft,iright;
X
X    if (d_xmin==0 && d_xmax==MAXX && d_ymin==0 && d_ymax==MAXY)
X        {
X        d_flag=1;  clear(); /* clear the screen */
X        }
X    else
X        {
X        d_flag=0;  cursor(1,1);
X        }
X    if (d_xmin<0)
X        d_xmin=0; /* d_xmin=-1 means display all without bottomline */
X
X    /* display lines of the screen
X    */
X    for ( j = d_ymin ; j < d_ymax ; j++ )
X        {
X        /* When we show a spot of the dungeon, we have 4 cases:
X            squares we know nothing about
X                - know == 0
X            squares we've been at and still know whats there
X                - know == KNOWALL (== KNOWHERE | HAVESEEN)
X            squares we've been at, but don't still recall because
X            something else happened there.
X                - know == HAVESEEN
X            squares we recall, but haven't been at (an error condition)
X                - know == KNOWHERE
X
X           to minimize printing of spaces, scan from left of line until
X           we reach a location that the user knows.
X        */
X        ileft = d_xmin - 1;
X        while ( ++ileft < d_xmax )
X            if (know[ileft][j])     /* instead of know[i][j] != 0 */
X                break;              /* exitloop while */
X
X        /* if not a blank line ... */
X        if ( ileft < d_xmax )
X            {
X            /* scan from right of line until we reach a location that the
X               user knows.
X            */
X            iright = d_xmax ;
X            while ( --iright > ileft )
X                if (know[iright][j])
X                    break ;    /* exitloop while */
X
X            /* now print the line, after positioning the cursor.
X               print the line with bold objects in a different
X               loop for effeciency
X            */
X            cursor( ileft+1, j+1 );
X            if (boldobjects)
X                for ( i=ileft ; i <= iright ; i++ )
X
X                    /* we still need to check for the location being known,
X                       for we might have an unknown spot in the middle of
X                       an otherwise known line.
X                    */
X                    if ( know[i][j] == 0 )
X                        nlprc( ' ' );
X                    else if ( know[i][j] & HAVESEEN )
X                        {
X                        /* if monster there and the user still knows the place,
X                           then show the monster.  Otherwise, show what was
X                           there before.
X                        */
X                        if (( i == playerx ) &&
X                            ( j == playery ))
X                            nlprc('@');
X                        else if (( k = mitem[i][j] ) &&
X                            ( know[i][j] & KNOWHERE ))
X                            nlprc( monstnamelist[k] );
X                        else if (((k=item[i][j]) == OWALL ) ||
X                                 (objnamelist[k] == floorc))
X                            nlprc( objnamelist[k] );
X                        else
X                            {
X                            setbold();
X                            nlprc( objnamelist[k] );
X                            resetbold();
X                            }
X                        }
X                    else
X                        /* error condition.  recover by resetting location
X                           to an 'unknown' state.
X                        */
X                        {
X                        nlprc( ' ' );
X                        mitem[i][j] = item[i][j] = 0 ;
X                        }
X            else /* non-bold objects here */
X                for ( i=ileft ; i <= iright ; i++ )
X
X                    /* we still need to check for the location being known,
X                       for we might have an unknown spot in the middle of
X                       an otherwise known line.
X                    */
X                    if ( know[i][j] == 0 )
X                        nlprc( ' ' );
X                    else if ( know[i][j] & HAVESEEN )
X                        {
X                        /* if monster there and the user still knows the place,
X                           then show the monster.  Otherwise, show what was
X                           there before.
X                        */
X                        if (( i == playerx ) &&
X                            ( j == playery ))
X                            nlprc('@');
X                        else if (( k = mitem[i][j] ) &&
X                            ( know[i][j] & KNOWHERE ))
X                            nlprc( monstnamelist[k] );
X                        else
X                            nlprc( objnamelist[item[i][j]] );
X                        }
X                    else
X                        /* error condition.  recover by resetting location
X                           to an 'unknown' state.
X                        */
X                        {
X                        nlprc( ' ' );
X                        mitem[i][j] = item[i][j] = 0 ;
X                        }
X            }   /* if (ileft < d_xmax ) */
X        }       /* for (j) */
X
X#ifdef DECRainbow
X    if (DECRainbow)
X        DECgraphicsOFF();
X#endif DECRainbow
X    resetbold();
X    if (d_flag)  { always=1; botside(); always=1; bot_linex(); }
X/*
X    oldx=99;
X*/
X    d_xmin = d_ymin = 0; d_xmax = MAXX; d_ymax = MAXY; /* for limited screen drawing */
X    }
X
X/*
X    showcell(x,y)
X
X    subroutine to display a cell location on the screen
X */
Xshowcell(x,y)
X    int x,y;
X    {
X    register int i,j,k,m;
X    if (c[BLINDCOUNT])  return; /* see nothing if blind     */
X    if (c[AWARENESS]) { minx = x-3; maxx = x+3; miny = y-3; maxy = y+3; }
X            else      { minx = x-1; maxx = x+1; miny = y-1; maxy = y+1; }
X
X    if (minx < 0) minx=0;       if (maxx > MAXX-1) maxx = MAXX-1;
X    if (miny < 0) miny=0;       if (maxy > MAXY-1) maxy = MAXY-1;
X
X    for (j=miny; j<=maxy; j++)
X      for (m=minx; m<=maxx; m++)
X        if ((know[m][j] & KNOWHERE) == 0)
X            {
X            cursor(m+1,j+1);
X        x=maxx;
X        while (know[x][j] & KNOWHERE)
X        --x;
X            for (i=m; i<=x; i++)
X                {
X                if ((k=mitem[i][j]) != 0)  lprc(monstnamelist[k]);
X                else switch(k=item[i][j])
X                    {
X                    case OWALL:  case 0: case OIVTELETRAP:  case OTRAPARROWIV:
X                    case OIVDARTRAP: case OIVTRAPDOOR:
X#ifdef DECRainbow
X                        if (DECRainbow) {
X                            DEClprc(objnamelist[k]);
X                        } else
X#endif DECRainbow
X                        lprc(objnamelist[k]);   
X                        break;
X                    default:
X                        if (boldobjects)
X                            setbold();
X                        lprc(objnamelist[k]);
X                        if (boldobjects)
X                            resetbold();
X                        break;
X                    };
X                know[i][j] = KNOWALL;
X                }
X            m = maxx;
X#ifdef DECRainbow
X            if (DECRainbow)
X                DECgraphicsOFF();
X#endif DECRainbow
X            }
X    }
X
X/*
X    this routine shows only the spot that is given it.  the spaces around
X    these coordinated are not shown
X    used in godirect() in monster.c for missile weapons display
X */
Xshow1cell(x,y)
X    int x,y;
X    {
X    cursor(x+1,y+1);
X
X    /* see nothing if blind, but clear previous player position
X    */
X    if (c[BLINDCOUNT])
X        {
X        if ((x == oldx) && (y == oldy))
X            lprc(' ');
X        return;
X        }
X
X    if ((k=mitem[x][y]))
X        lprc(monstnamelist[k]);
X    else switch(k=item[x][y])
X        {
X        case OWALL:  case 0:  case OIVTELETRAP:  case OTRAPARROWIV:
X        case OIVDARTRAP: case OIVTRAPDOOR:
X# ifdef DECRainbow
X            if (DECRainbow) {
X                DEClprc(objnamelist[k]);
X                DECgraphicsOFF();
X            } else
X# endif
X                lprc(objnamelist[k]);
X                break;
X
X        default:
X            if (boldobjects)
X                setbold();
X            lprc(objnamelist[k]);
X            if (boldobjects)
X                resetbold();
X            break;
X        };
X    know[x][y] = KNOWALL;   /* we end up knowing about it */
X    }
X
X/*
X    showplayer()
X
X    subroutine to show where the player is on the screen
X    cursor values start from 1 up
X */
Xshowplayer()
X    {
X    show1cell( oldx, oldy );
X    cursor(playerx+1,playery+1);
X    lprc('@');
X    cursor(playerx+1,playery+1);
X    oldx=playerx;  oldy=playery;
X    }
X
X/*
X    moveplayer(dir)
X
X    subroutine to move the player from one room to another
X    returns 0 if can't move in that direction or hit a monster or on an object
X    else returns 1
X    nomove is set to 1 to stop the next move (inadvertent monsters hitting
X    players when walking into walls) if player walks off screen or into wall
X */
Xshort diroffx[] = { 0,  0, 1,  0, -1,  1, -1, 1, -1 };
Xshort diroffy[] = { 0,  1, 0, -1,  0, -1, -1, 1,  1 };
Xmoveplayer(dir)
X    int dir;            /*  from = present room #  direction = [1-north]
X                            [2-east] [3-south] [4-west] [5-northeast]
X                            [6-northwest] [7-southeast] [8-southwest]
X                        if direction=0, don't move--just show where he is */
X    {
X    register int k,m,i,j;
X    extern char prayed ;
X
X    if (c[CONFUSE]) if (c[LEVEL]<rnd(30)) dir=rund(9); /*if confused any dir*/
X    k = playerx + diroffx[dir];     m = playery + diroffy[dir];
X    if (k<0 || k>=MAXX || m<0 || m>=MAXY) { nomove=1; return(yrepcount = 0); }
X    i = item[k][m];         j = mitem[k][m];
X
X    /* prevent the player from moving onto a wall, or a closed door when
X       in command mode, unless the character has Walk-Through-Walls.
X    */
X    if ((i==OCLOSEDDOOR && !prompt_mode) || (i==OWALL) && c[WTW]==0)
X        { 
X        nomove=1;  
X        return(yrepcount = 0); 
X        }
X    if (k==33 && m==MAXY-1 && level==1)
X        {
X        newcavelevel(0); 
X        for (k=0; k<MAXX; k++) 
X            for (m=0; m<MAXY; m++)
X                if (item[k][m]==OENTRANCE)
X                    { 
X                    playerx=k; 
X                    playery=m; 
X                    positionplayer();  
X                    drawscreen(); 
X                    return(0); 
X                    }
X        }
X    /* hit a monster
X    */    
X    if (j>0)     
X        { hitmonster(k,m); return(yrepcount = 0); } 
X
X    /* check for the player ignoring an altar when in command mode.
X    */
X    if ((!prompt_mode) &&
X        (item[playerx][playery] == OALTAR) &&
X        (!prayed))
X        {
X    cursors();
X    lprcat("\nYou have ignored the altar!");
X    act_ignore_altar();
X    }
X    prayed = 0 ;
X
X    lastpx = playerx;   lastpy = playery;
X    playerx = k;        playery = m;
X    if (i && i!=OTRAPARROWIV && i!=OIVTELETRAP && i!=OIVDARTRAP && i!=OIVTRAPDOOR) 
X        return(yrepcount = 0);  
X    else 
X        return(1);
X    }
X
X/*
X *  function to show what magic items have been discovered thus far
X *  enter with -1 for just spells, anything else will give scrolls & potions
X */
Xstatic int lincount,count;
Xseemagic(arg)
X    int arg;
X    {
X    register int i,j,k,number;
X    char sort[SPNUM+1]; /* OK as long as SPNUM > MAXSCROLL,MAXPOTION */
X
X    count = lincount = 0;
X    nosignal=1;
X
X    /* count and sort the known spell codes
X    */
X    for (j=0; j <= SPNUM ; j++ )
X        sort[j] = SPNUM ;
X    for (number = i = 0 ; i < SPNUM ; i++ )
X        if (spelknow[i])
X            {
X            number++;
X            j = 0 ;
X            while ( strncmp( spelcode[ sort[j] ], spelcode[ i ], 3 ) < 0 )
X                j++ ;
X            k = number - 1;
X            while ( k > j )
X                sort[k] = sort[ k-1 ], k-- ;
X            sort[j] = i ;
X            }
X
X    if (arg == -1) /* if display spells while casting one */
X        {
X        cl_up(79, ((number + 2) / 3 + 4 )); /* lines needed for display */
X        cursor(1,1);
X        }
X    else
X        {
X        resetscroll();
X        clear();
X        }
X
X    lprcat("The magic spells you have discovered thus far:\n\n");
X    for (i=0; i<number; i++)
X        {
X        lprintf("%s %-20s ",spelcode[sort[i]],spelname[sort[i]]);
X        seepage();
X        }
X
X    if (arg== -1)
X        {
X        seepage();
X        more(FALSE);
X        nosignal=0;
X        draws(0,MAXX,0, (( number + 2 ) / 3 + 4 ));
X        return;
X        }
X
X    lincount += 3;
X    if (count!=0)
X        {
X        count=2;
X        seepage();
X        }
X
X    /* count and sort the known scrolls
X    */
X    for (j=0; j <= MAXSCROLL ; j++ )
X        sort[j] = MAXSCROLL ;
X    for (number = i = 0 ; i < MAXSCROLL ; i++ )
X        if (scrollname[i][0])
X            {
X            number++;
X            j = 0 ;
X            while ( strcmp( &scrollname[sort[j]][1], &scrollname[i][1] ) < 0 )
X                j++ ;
X            k = number - 1;
X            while ( k > j )
X                sort[k] = sort[ k-1 ], k-- ;
X            sort[j] = i ;
X            }
X
X    lprcat("\nThe magic scrolls you have found to date are:\n\n");
X    count=0;
X    for (i=0; i < number; i++ )
X        {
X        lprintf("%-26s", &scrollname[sort[i]][1]);
X        seepage();
X        }
X
X    lincount += 3;
X    if ( count != 0 )
X        {
X        count=2;
X        seepage();
X        }
X
X    /* count and sort the known potions
X    */
X    for (j=0; j <= MAXPOTION ; j++ )
X        sort[j] = MAXPOTION ;
X    for (number = i = 0 ; i < MAXPOTION ; i++ )
X        if (potionname[i][0])
X            {
X            number++;
X            j = 0 ;
X            while ( strcmp( &potionname[sort[j]][1], &potionname[i][1] ) < 0 )
X                j++ ;
X            k = number - 1;
X            while ( k > j )
X                sort[k] = sort[ k-1 ], k-- ;
X            sort[j] = i ;
X            }
X
X    lprcat("\nThe magic potions you have found to date are:\n\n");
X    count=0;
X    for (i=0; i < number; i++)
X        {
X        lprintf("%-26s",&potionname[sort[i]][1]);
X        seepage();
X        }
X
X    if (lincount!=0)
X        more(FALSE);
X    nosignal=0;
X    setscroll();
X    drawscreen();
X    }
X
X/*
X *  subroutine to paginate the seemagic function
X */
Xstatic seepage()
X    {
X    if (++count==3)
X        {
X        lincount++; count=0;    lprc('\n');
X        if (lincount>17) {  lincount=0;  more(FALSE);  clear();  }
X        }
X    }
END_OF_FILE
if test 21096 -ne `wc -c <'display.c'`; then
    echo shar: \"'display.c'\" unpacked with wrong size!
fi
# end of 'display.c'
fi
if test -f 'os2larn.def' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'os2larn.def'\"
else
echo shar: Extracting \"'os2larn.def'\" \(70 characters\)
sed "s/^X//" >'os2larn.def' <<'END_OF_FILE'
XNAME LARN WINDOWCOMPAT LONGNAMES
X
XDESCRIPTION 'LARN for OS/2 V12.3.0'
END_OF_FILE
if test 70 -ne `wc -c <'os2larn.def'`; then
    echo shar: \"'os2larn.def'\" unpacked with wrong size!
fi
# end of 'os2larn.def'
fi
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
if test -f 'termcap.pc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'termcap.pc'\"
else
echo shar: Extracting \"'termcap.pc'\" \(439 characters\)
sed "s/^X//" >'termcap.pc' <<'END_OF_FILE'
X#
X# Monochrome IBMPC.
X#	This is a termcap for the NANSI.SYS device driver.
X#	It is the same as the ANSI termcap, except NANSI supports
X#	line insert (al) and delete (dl) while ANSI does not.
X#
Xibmpc-mono:\
X	:co#80:\
X	:li#24:\
X	:cl=\E[;H\E[2J:\
X	:bs:\
X	:ho=\E[H:\
X	:cm=\E[%i%2;%2H:\
X	:up=\E[A:\
X	:xd=\E[B:\
X	:nd=\E[C:\
X	:bc=\E[D:\
X	:ce=\E[K:\
X	:ti=\E[m:\
X	:te=\E[m:\
X	:so=\E[1m:\
X	:se=\E[m:\
X	:us=\E[4m:\
X	:ue=\E[m:\
X	:al=\E[L:\
X	:dl=\E[M:
END_OF_FILE
if test 439 -ne `wc -c <'termcap.pc'`; then
    echo shar: \"'termcap.pc'\" unpacked with wrong size!
fi
# end of 'termcap.pc'
fi
echo shar: End of archive 5 \(of 12\).
cp /dev/null ark5isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 12 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