Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

v07i004: ularn - ultra-larn, an enhancement of the larn adventure game, Part04/08

10 views
Skip to first unread message

Bill Randle

unread,
Jul 6, 1989, 10:01:52 AM7/6/89
to
Submitted-by: "Philip A. Cordier" <ph...@sco.COM>
Posting-number: Volume 7, Issue 4
Archive-name: ularn/Part04

#! /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 4 (of 8)."
# Contents: Makefile scores.c store.c
# Wrapped by billr@saab on Thu Jun 29 08:10:19 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(2733 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# your favorite compiler
XCC = mcc
X
X# SYSV or BSD
XUNIX = SYSV
X#UNIX = BSD
X
X# location of data files
XHOME = /v/philc/games/Ularn/lib
X
X# final location of binary (for 'make install')
XBINDIR = .
X
X# user id of wizard (wizard password is defined in config.c)
XWIZID = 1060
X
X# name of program
XGAME = Ularn
X
X# termlib options
XTERMLIB = -ltermlib
X
X# program options
XOPTIONS = -DWIZID=$(WIZID) -D$(UNIX)
X
X# compile flags
XCFLAGS = -M3e -Ox -s $(OPTIONS) -DHOME=\"$(HOME)/\"
X#CFLAGS = -M3e -g $(OPTIONS) -DHOME=\"$(HOME)/\"
X
X# link flags
X#LDFLAGS= -s
XLDFLAGS =
X
X# the object files
XOBJ = bill.o config.o create.o data.o diag.o display.o fortune.o\
X global.o help.o io.o main.o monster.o moreobj.o movem.o object.o\
X regen.o savelev.o scores.o signal.o store.o tok.o nap.o
X
X# the source files
XSRC = bill.c config.c create.c data.c diag.c display.c fortune.c\
X global.c help.c io.c main.c monster.c moreobj.c movem.c object.c\
X regen.c savelev.c scores.c signal.c store.c tok.c nap.c
X
X# the header file
XHDR = header.h
X
XUTIL = to_ansi
XUTIL_OBJ = to_ansi.o
XUTIL_SRC = to_ansi.c
X
X##########################################################################
X
Xlove: $(GAME)
X
X$(GAME): $(OBJ)
X $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $(GAME) $(TERMLIB)
X @ls -ls $(GAME)
X @echo done
X
X.c.o:
X $(CC) -c $(CFLAGS) $<
X
X$(OBJ): header.h
X
X$(UTIL): $(UTIL_OBJ)
X $(CC) -o $(UTIL) $(UTIL_OBJ)
X
XUhelp: $(UTIL) Uhelp.no_control
X $(UTIL) <Uhelp.no_control >Uhelp
X
Xtags: tag
Xtag:
X rm -f Tags
X ctags -x $(SRC) $(HDR) > Tags
X ctags $(SRC) $(HDR)
X
Xlint: $(SRC)
X rm -f Lint.out
X lint $(SRC) $(TERMLIB) > Lint.out
X
Xinstall: $(GAME) Umaps Ufortune Uhelp
X touch Uscore
X chmod 644 Umaps Ufortune Uhelp
X chmod 666 Uscore
X -mkdir $(HOME)
X cp Uscore Umaps Ufortune Uhelp $(HOME)
X chmod 711 $(HOME)
X chmod 711 $(GAME)
X -mv $(GAME) $(BINDIR)
X
Xclean:
X rm -f core *.o $(GAME)
X#
X##########################################################################
X# shar the source
X##########################################################################
X#
XSHAR = /u/philc/bin/shar -a
XSHAR1 = bill.c config.c create.c diag.c fortune.c help.c io.c tok.c
XSHAR2 = data.c display.c regen.c savelev.c nap.c
XSHAR3 = global.c header.h moreobj.c signal.c Makefile
XSHAR4 = monster.c
XSHAR5 = main.c movem.c
XSHAR6 = object.c MANIFEST README
XSHAR7 = scores.c store.c
XSHAR8 = Ufortune Uhelp Umaps
Xshar:
X $(SHAR) -m 1 -n 8 $(SHAR1) > Ushar.1
X $(SHAR) -m 2 -n 8 $(SHAR2) > Ushar.2
X $(SHAR) -m 3 -n 8 $(SHAR3) > Ushar.3
X $(SHAR) -m 4 -n 8 $(SHAR4) > Ushar.4
X $(SHAR) -m 5 -n 8 $(SHAR5) > Ushar.5
X $(SHAR) -m 6 -n 8 $(SHAR6) > Ushar.6
X $(SHAR) -m 7 -n 8 $(SHAR7) > Ushar.7
X @cp $(HOME)/Ufortune .
X @cp $(HOME)/Uhelp .
X @cp $(HOME)/Umaps .
X $(SHAR) -m 8 -n 8 $(SHAR8) > Ushar.8
END_OF_FILE
if test 2733 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'scores.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'scores.c'\"
else
echo shar: Extracting \"'scores.c'\" \(19030 characters\)
sed "s/^X//" >'scores.c' <<'END_OF_FILE'
X/* scores.c
X *
X * Functions in this file are:
X *
X * readboard()
X * Function to read in the scoreboard into a static buffer
X * writeboard()
X * Function to write the scoreboard from readboard()'s buffer
X * makeboard()
X * Function to create a new scoreboard (wipe out old one)
X * hashewon()
X * Function to return 1 if player has won a game before, else 0
X * long paytaxes(x)
X * Function to pay taxes if any are due
X * winshou()
X * Subroutine to print out the winning scoreboard
X * shou(x)
X * Subroutine to print out the non-winners scoreboard
X * showscores()
X * Function to show the scoreboard on the terminal
X * showallscores()
X * Function to show scores and the iven lists that go with them
X * sortboard()
X * Function to sort the scoreboard
X * newscore(score, whoo, whyded, winner)
X * Function to add entry to scoreboard
X * new1sub(score,i,whoo,taxes)
X * Subroutine to put player into a
X * new2sub(score,i,whoo,whyded)
X * Subroutine to put player into a
X * died(x)
X * Subroutine to record who played larn, and what the score was
X * diedsub(x)
X * Subroutine to print out a line showing player when he is killed
X */
X#include "header.h"
X
Xstruct scofmt /*This is the structure for the scoreboard */
X{
X long score; /* the score of the player */
X long suid; /* the user id number of the player*/
X short what; /* the number of the monster that killedplayer*/
X short level; /* the level player was on when he died */
X short hardlev; /* the level of difficulty player played at*/
X short order; /* the relative ordering place of this entry*/
X char who[40]; /* the name of the character */
X char char_class[20]; /* the character class */
X char sciv[26][2]; /* this is the inventory list of the character*/
X};
X
X/* This is the structure for the winning scoreboard */
Xstruct wscofmt {
X long score; /* the score of the player */
X long timeused; /* the time used in mobuls to win the game*/
X long taxes; /* taxes he owes to LRS */
X long suid; /* the user id number of the player*/
X short hardlev; /* the level of difficulty player played at*/
X short order; /* the relative ordering place of this entry*/
X char who[40]; /* the name of the character */
X char char_class[20]; /* the character class */
X};
X
Xstatic struct scofmt sco[SCORESIZE]; /* the structure for the scoreboard */
Xstatic struct wscofmt winr[SCORESIZE]; /* struct for the winning scoreboard */
X
Xstatic char *whydead[] = {
X"quit", /* 0 */
X"suspended",
X"self - annihilated",
X"shot by an arrow",
X"hit by a dart",
X"fell into a pit", /* 5 */
X"fell into a pit to HELL",
X"a winner",
X"trapped in solid rock",
X"killed by a missing save file",
X"killed by an old save file", /* 10 */
X"caught by the greedy cheater checker trap",
X"killed by a protected save file",
X"killed his family and committed suicide", /* 13 */
X"erased by a wayward finger",
X"fell through a trap door to HELL", /* 15 */
X"fell through a trap door",
X"drank some poisonous water",
X"fried by an electric shock",
X"slipped on a volcano shaft",
X"killed by a stupid act of frustration", /* 20 */
X"attacked by a revolting demon",
X"hit by his own magic", /* 22 */
X"demolished by an unseen attacker",
X"fell into the dreadful sleep",
X"killed by an exploding chest", /* 25 */
X"killed by a missing maze data file",
X"annihilated in a sphere",
X"died a post mortem death",
X"wasted by a malloc() failure" /* 29 */
X};
X
X
X/*
X * readboard() Function to read in the scoreboard into a static buffer
X *
X * returns -1 if unable to read in the scoreboard, returns 0 if all is OK
X */
Xreadboard()
X{
X FILE *fp;
X
X if ((fp = fopen(scorefile, "r")) == (FILE *)NULL) {
X fprintf(stderr, "Can't open scorefile for reading\n");
X fflush(stderr);
X return(-1);
X }
X if (fread((char *)sco, sizeof(sco), 1, fp) != 1) {
X fprintf(stderr, "Can't read scoreboard\n");
X fflush(stderr);
X fclose(fp);
X return(-1);
X }
X if (fread((char *)winr, sizeof(winr), 1, fp) != 1) {
X fprintf(stderr, "Can't read scoreboard\n");
X fflush(stderr);
X fclose(fp);
X return(-1);
X }
X fflush(fp);
X fclose(fp);
X return(0);
X}
X
X
X/*
X * writeboard()
X * Function to write the scoreboard from readboard()'s buffer
X *
X * returns -1 if unable to write the scoreboard, returns 0 if all is OK
X */
Xwriteboard()
X{
X FILE *fp;
X
X if ((fp = fopen(scorefile, "w")) == (FILE *)NULL) {
X lprcat("Can't open scorefile for writing\n");
X lflush();
X return(-1);
X }
X if (fwrite((char * )sco, sizeof(sco), 1, fp) != 1) {
X lprcat("Can't write scorefile\n");
X lflush();
X fclose(fp);
X return(-1);
X }
X if (fwrite((char * )winr, sizeof(winr), 1, fp) != 1) {
X lprcat("Can't write scorefile\n");
X lflush();
X fclose(fp);
X return(-1);
X }
X fflush(fp);
X fclose(fp);
X return(0);
X}
X
X
X/*
X * Function to create a new scoreboard (wipe out old one)
X * makeboard()
X *
X * returns -1 if unable to write the scoreboard, returns 0 if all is OK
X */
Xmakeboard()
X{
X int i;
X
X for (i = 0; i < SCORESIZE; i++) {
X winr[i].taxes = winr[i].score = sco[i].score = 0;
X winr[i].order = sco[i].order = i;
X }
X if (writeboard())
X return(-1);
X chmod(scorefile, 0666);
X return(0);
X}
X
X
X/*
X * Function to return 1 if player has won a game before, else 0
X *
X * hashewon()
X *
X * This function also sets c[HARDGAME] to appropriate value -- 0 if not a
X * winner, otherwise the next level of difficulty listed in the winners
X * scoreboard. This function also sets outstanding_taxes to the value in
X * the winners scoreboard.
X */
Xhashewon()
X{
X register int i;
X
X c[HARDGAME] = 0;
X
X if (readboard() < 0)
X return(0); /* can't find scoreboard */
X
X for (i = 0; i < SCORESIZE; i++) /* search through winners scoreboard */
X if (winr[i].suid == userid)
X if (winr[i].score > 0) {
X c[HARDGAME] = winr[i].hardlev + 1;
X outstanding_taxes = winr[i].taxes;
X return(1);
X }
X return(0);
X}
X
X
X/*
X * long paytaxes(x) Function to pay taxes if any are due
X *
X * Enter with the amount (in gp) to pay on the taxes.
X * Returns amount actually paid.
X */
Xlong paytaxes(x)
Xlong x;
X{
X int i;
X long amt;
X
X if (x <= 0)
X return(0L);
X
X if (readboard() < 0)
X return(0L);
X
X for (i = 0; i < SCORESIZE; i++)
X
X /* look for players winning entry */
X if (winr[i].suid == userid)
X
X /* search for a winning entry for the player */ {
X if (winr[i].score > 0)
X amt = winr[i].taxes;
X if (x < amt)
X amt = x;
X winr[i].taxes -= amt;
X outstanding_taxes -= amt;
X if (writeboard() < 0)
X return(0);
X return(amt);
X }
X return(0L); /* couldn't find user on winning scoreboard */
X}
X
X
X/*
X * winshou() Subroutine to print out the winning scoreboard
X *
X * Returns the number of players on scoreboard that were shown
X */
Xwinshou()
X{
X struct wscofmt *p;
X register int i, j, count;
X
X /* is there anyone on the scoreboard? */
X for (count = j = i = 0; i < SCORESIZE; i++)
X if (winr[i].score != 0) {
X j++;
X break;
X }
X
X if (j) {
X
X /*12345678901234567890123456789012345678901234567890123*/
X puts("\n Score Diff Time Needed Ularn Winners List");
X
X /* needed to print out the */
X /* winners in order */
X for (i = 0; i < SCORESIZE; i++)
X for (j = 0; j < SCORESIZE; j++) {
X p = &winr[j];/*pointer to the scoreboard entry*/
X if (p->order == i) {
X if (p->score) {
X count++;
X printf("%-10ld%8d%8d Mobuls (%s) %s\n",
X (long)p->score,
X p->hardlev,
X p->timeused,
X p->char_class,
X p->who);
X fflush(stdout);
X }
X break;
X }
X }
X }
X return(count); /* return number of people on scoreboard */
X}
X
X
X/*
X * shou(x)
X * int x;
X * Subroutine to print out the non-winners scoreboard
X *
X * Enter with 0 to list the scores, enter with 1 to list inventories too
X * Returns the number of players on scoreboard that were shown
X */
Xshou(x)
Xint x;
X{
X int i, j, n;
X int count;
X
X /* is the scoreboard empty? */
X for (count = j = i = 0; i < SCORESIZE; i++)
X if (sco[i].score != 0) {
X j++;
X break;
X }
X
X if (j) {
X puts("\n Score Diff Ularn Visitor Log");
X for (i = 0; i < SCORESIZE; i++)
X for (j = 0; j < SCORESIZE; j++)
X if (sco[j].order == i) {
X if (sco[j].score) {
X count++;
X printf("%7ld %3ld (%s) %s ",
X (long)sco[j].score,
X (long)sco[j].hardlev,
X sco[j].char_class,
X sco[j].who);
X if (sco[j].what < 256)
X printf("killed by a %s",
X monster[sco[j].what].name);
X else {
X int foo = sco[j].what - 256;
X if (!sex && (foo == 13 || foo == 22))
X switch(foo) {
X case 13 :
X printf("killed her family and committed suicide");
X break;
X case 22 :
X printf("hit by her own magic");
X break;
X }
X else
X printf("%s", whydead[foo]);
X }
X if (x != 263)
X printf(" on %s",
X levelname[sco[j].level]);
X if (x) {
X for (n = 0; n < 26; n++) {
X iven[n] = sco[j].sciv[n][0];
X ivenarg[n] = sco[j].sciv[n][1];
X }
X for (n = 0; n < 26; n++)
X if (iven[n]) {
X srcount = 0;
X showscore3(n);
X }
X }
X putchar('\n');
X fflush(stdout);
X }
X j = SCORESIZE;
X }
X }
X return(count); /* return the number of players just shown */
X}
X
X
X/*
X * showscores() Function to show the scoreboard on the terminal
X *
X * Returns nothing of value
X */
Xstatic char esb[] = "The scoreboard is empty.\n";
X
Xshowscores()
X{
X int i, j;
X
X if (readboard() < 0)
X return;
X i = winshou();
X j = shou(0);
X
X if (i + j == 0)
X puts(esb);
X else
X putchar('\n');
X lflush();
X}
X
X
X/*
X * showallscores()
X * Function to show scores and the iven lists that go with them
X *
X * Returns nothing of value
X */
Xshowallscores()
X{
X int i, j;
X
X
X if (readboard() < 0)
X return;
X
X c[WEAR] = c[WIELD] = c[SHIELD] = -1;
X
X for (i = 0; i < MAXPOTION; i++)
X potionname[i][0] = ' ';
X for (i = 0; i < MAXSCROLL; i++)
X scrollname[i][0] = ' ';
X
X i = winshou();
X j = shou(1);
X
X if (i + j == 0)
X puts(esb);
X else
X putchar('\n');
X
X}
X
X
X/*
X * sortboard() Function to sort the scoreboard
X *
X * Returns 0 if no sorting done, else returns 1
X */
Xsortboard()
X{
X int i, j, pos;
X long jdat;
X
X for (i = 0; i < SCORESIZE; i++)
X sco[i].order = winr[i].order = -1;
X pos = 0;
X while (pos < SCORESIZE) {
X jdat = 0;
X for (i = 0; i < SCORESIZE; i++)
X if ((sco[i].order < 0) && (sco[i].score >= jdat)) {
X j = i;
X jdat = sco[i].score;
X }
X sco[j].order = pos++;
X }
X pos = 0;
X while (pos < SCORESIZE) {
X jdat = 0;
X for (i = 0; i < SCORESIZE; i++)
X if ((winr[i].order < 0) && (winr[i].score >= jdat)) {
X j = i;
X jdat = winr[i].score;
X }
X winr[j].order = pos++;
X }
X return(1);
X}
X
X
X/*
X * Function to add entry to scoreboard
X * newscore(score, whoo, whyded, winner)
X * int score, winner, whyded;
X * char *whoo;
X *
X * Enter with the total score in gp in score, players name in whoo,
X * died() reason # in whyded, and TRUE/FALSE in winner if a winner
X * ex. newscore(1000, "player 1", 32, 0);
X */
Xnewscore(score, whoo, whyded, winner)
Xlong score;
Xint winner, whyded;
Xchar *whoo;
X{
X int i;
X long taxes;
X
X if (readboard() < 0)
X return; /* do the scoreboard */
X
X /* if a winner then delete all non-winning scores */
X if (cheat)
X winner = 0; /* if he cheated, don't let him win */
X
X if (winner) {
X for (i = 0; i < SCORESIZE; i++)
X if (sco[i].suid == userid)
X sco[i].score = 0;
X taxes = score * TAXRATE;
X score += 100000 * c[HARDGAME]; /* bonus for winning */
X
X/* if he has a slot on the winning scoreboard update it if greater score*/
X for (i = 0; i < SCORESIZE; i++)
X if (winr[i].suid == userid) {
X new1sub(score, i, whoo, taxes);
X return;
X }
X
X/* he had no entry. look for last entry and see if he has a greater score */
X for (i = 0; i < SCORESIZE; i++)
X if (winr[i].order == SCORESIZE - 1) {
X new1sub(score, i, whoo, taxes);
X return;
X }
X } else if (!cheat) /* for not winning scoreboard */ {
X /* if he has a slot on the scoreboard update it if greater score */
X for (i = 0; i < SCORESIZE; i++)
X if (sco[i].suid == userid) {
X new2sub(score, i, whoo, whyded);
X return;
X }
X
X/* he had no entry. look for last entry and see if he has a greater score */
X for (i = 0; i < SCORESIZE; i++)
X if (sco[i].order == SCORESIZE - 1) {
X new2sub(score, i, whoo, whyded);
X return;
X }
X }
X}
X
X
X/*
X * new1sub(score,i,whoo,taxes) Subroutine to put player into a
X * int score,i,whyded,taxes; winning scoreboard entry if his score
X * char *whoo; is high enough
X *
X * Enter with the total score in gp in score, players name in whoo,
X * died() reason # in whyded, and TRUE/FALSE in winner if a winner
X * slot in scoreboard in i, and the tax bill in taxes.
X * Returns nothing of value
X */
Xnew1sub(score, i, whoo, taxes)
Xlong score, taxes;
Xint i;
Xchar *whoo;
X{
X struct wscofmt *p;
X
X p = &winr[i];
X p->taxes += taxes;
X if ((score >= p->score) || (c[HARDGAME] > p->hardlev)) {
X strcpy(p->who, whoo);
X strcpy(p->char_class, char_class);
X p->score = score;
X p->hardlev = c[HARDGAME];
X p->suid = userid;
X p->timeused = gtime / 100;
X }
X}
X
X
X/*
X * new2sub(score,i,whoo,whyded)
X * int score,i,whyded,taxes;
X * char *whoo;
X * Subroutine to put player into a
X * non-winning scoreboard entry if his
X * score is high enough
X *
X * Enter with the total score in gp in score, players name in whoo,
X * died() reason # in whyded, and slot in scoreboard in i.
X * Returns nothing of value
X */
Xnew2sub(score, i, whoo, whyded)
Xlong score;
Xint i, whyded;
Xchar *whoo;
X{
X int j;
X struct scofmt *p;
X
X p = &sco[i];
X if ((score >= p->score) || (c[HARDGAME] > p->hardlev)) {
X strcpy(p->who, whoo);
X strcpy(p->char_class, char_class);
X p->score = score;
X p->what = whyded;
X p->hardlev = c[HARDGAME];
X p->suid = userid;
X p->level = level;
X for (j = 0; j < 26; j++) {
X p->sciv[j][0] = iven[j];
X p->sciv[j][1] = ivenarg[j];
X }
X }
X}
X
X
X/*
X * Subroutine to record who played larn, and what the score was
X * died(x)
X * int x;
X *
X * if x < 0 then don't show scores
X * died() never returns! (unless c[LIFEPROT] and a reincarnatable death!)
X *
X * < 256 killed by the monster number
X * 256 quit
X * 257 suspended
X * 258 self - annihilated
X * 259 shot by an arrow
X * 260 hit by a dart
X * 261 fell into a pit
X * 262 fell into a bottomless pit
X * 263 a winner
X * 264 trapped in solid rock
X * 265 killed by a missing save file
X * 266 killed by an old save file
X * 267 caught by the greedy cheater checker trap
X * 268 killed by a protected save file
X * 269 killed his family and killed himself
X * 270 erased by a wayward finger
X * 271 fell through a bottomless trap door
X * 272 fell through a trap door
X * 273 drank some poisonous water
X * 274 fried by an electric shock
X * 275 slipped on a volcano shaft
X * 276 killed by a stupid act of frustration
X * 277 attacked by a revolting demon
X * 278 hit by his own magic
X * 279 demolished by an unseen attacker
X * 280 fell into the dreadful sleep
X * 281 killed by an exploding chest
X * 282 killed by a missing maze data file
X * 283 killed by a sphere of annihilation
X * 284 died a post mortem death
X * 285 malloc() failure
X * 300 quick quit -- don't put on scoreboard
X */
X
Xstatic int scorerror;
X
Xdied(x)
Xint x;
X{
X int f, win;
X
X if (c[LIFEPROT] > 0) /* if life protection */ {
X switch ((x > 0) ? x : -x) {
X case 256:
X case 257:
X case 262:
X case 263:
X case 265:
X case 266:
X case 267:
X case 268:
X case 269:
X case 271:
X case 282:
X case 284:
X case 285:
X case 300:
X goto invalid; /* can't be saved */
X };
X --c[LIFEPROT];
X c[HP] = 1;
X --c[CONSTITUTION];
X lprcat("\nYou feel wiiieeeeerrrrrd all over! ");
X lflush();
X beep();
X sleep(4);
X return; /* only case where died() returns */
X }
Xinvalid:
X sncbr();
X f = 0;
X if (ckpflag)
X unlink(ckpfile); /* remove checkpoint file if used */
X
X if (x < 0) {
X f++;
X x = -x;
X } /* if we are not to display the scores */
X
X if ((x == 300) || (x == 257)) {
X clear();
X lflush();
X putchar('\n');
X exit(0);/* for quick exit or saved game */
X }
X
X if (x == 263)
X win = 1;
X else
X win = 0;
X
X c[GOLD] += c[BANKACCOUNT];
X c[BANKACCOUNT] = 0;
X
X /* now enter the player at the end of the scoreboard */
X newscore(c[GOLD], logname, x, win);
X
X clear();
X lflush();
X diedsub(x); /* print out the score line */
X
X /* wizards can't score*/
X if ( !wizard ) {
X
X /*now for the scoreboard maintenance -- not for a suspended game*/
X if (x != 257) {
X if (sortboard())
X scorerror = writeboard();
X }
X }
X if ((x == 256) || (x == 257) || (f != 0)) {
X exit(0);
X }
X
X if (scorerror == 0)
X showscores(); /* if we updated the scoreboard*/
X
X if (x == 263)
X mailbill();
X
X putchar('\n');
X exit(0);
X}
X
X
X/*
X * Subroutine to print out the line showing the player when he is killed
X * diedsub(x)
X * int x;
X */
Xdiedsub(x)
Xint x;
X{
X char ch, *mod, *cls;
X
X cls = class[c[LEVEL]-1];
X puts("---------------------------------------------------------------");
X puts(" U L A R N S C O R E S");
X puts("---------------------------------------------------------------");
X printf("Score: %ld Diff: %d ", c[GOLD], c[HARDGAME]);
X printf("Level: %s Char: %s\n", cls, char_class);
X printf("\t%s", logname);
X if (wizard)
X printf(" (wizard)");
X if (x < 256) {
X ch = *monster[x].name;
X if(ch== 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
X mod = "an";
X else
X mod = "a";
X printf(" killed by %s %s", mod, monster[x].name);
X } else {
X int foo = x - 256;
X if (!sex && (foo == 13 || foo == 22))
X switch(foo) {
X case 13 :
X printf(" killed her family and committed suicide");
X break;
X case 22 :
X printf(" hit by her own magic");
X break;
X }
X else
X printf(" %s", whydead[foo]);
X }
X
X if (x != 263)
X printf(" on %s\n", levelname[level]);
X else
X putchar('\n');
X puts("---------------------------------------------------------------");
X fflush(stdout);
X}
X
Xshowscore3(index)
Xint index;
X{
X switch (iven[index]) {
X case OPOTION:
X showscore1(index, potionname);
X break;
X case OSCROLL:
X showscore1(index, scrollname);
X break;
X case OLARNEYE:
X case OBOOK:
X case OSPIRITSCARAB:
X case ODIAMOND:
X case ORUBY:
X case OCUBEofUNDEAD:
X case OEMERALD:
X case OCHEST:
X case OCOOKIE:
X case OSAPPHIRE:
X case OORB:
X case OHANDofFEAR:
X case OBRASSLAMP:
X case OURN:
X case OWWAND:
X case OSPHTALISMAN:
X case ONOTHEFT:
X showscore1(index, (char **)0);
X break;
X default:
X printf("\n%c) %s", index + 'a' , objectname[iven[index]]);
X if (ivenarg[index] > 0)
X printf(" + %d", (long)ivenarg[index]);
X else if (ivenarg[index] < 0)
X printf(" %d", (long)ivenarg[index]);
X break;
X }
X if (c[WIELD] == index)
X puts(" (weapon in hand)");
X if ((c[WEAR] == index) || (c[SHIELD] == index))
X puts(" (being worn)");
X fflush(stdout);
X}
X
Xshowscore1(idx, str2)
Xint idx;
Xchar *str2[];
X{
X if (str2 == 0)
X printf("\n%c) %s", idx + 'a' , objectname[iven[idx]]);
X else if (*str2[ivenarg[idx]] == 0)
X printf("\n%c) %s", idx + 'a' , objectname[iven[idx]]);
X else
X printf("\n%c) %s of%s", idx + 'a' ,
X objectname[iven[idx]], str2[ivenarg[idx]]);
X}
END_OF_FILE
if test 19030 -ne `wc -c <'scores.c'`; then
echo shar: \"'scores.c'\" unpacked with wrong size!
fi
# end of 'scores.c'
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'\" \(29301 characters\)
sed "s/^X//" >'store.c' <<'END_OF_FILE'
X/* store.c */
X#include "header.h"
X
Xstatic int dndcount=0,dnditm=0;
X
X/* this is the data for the stuff in the dnd store */
Xint maxitm=92; /* number of items in the dnd inventory table */
X
Xstruct _itm itm[92] = {
X/*cost memory iven name iven arg how
X gp pointer iven[] ivenarg[] many */
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{ 5000, 0, OELVENCHAIN, 0, 0 } ,
X{ 1000, 0, OORB, 0, 0 } ,
X{ 10000,0, OSLAYER, 0, 0 } ,
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{ 20000,0, OLANCE, 0, 1 } ,
X{ 2000, 0, OSWORDofSLASHING, 0, 0 } ,
X{ 7500, 0, OHAMMER, 0, 0 } ,
X
X/*cost memory iven name iven arg how
X gp pointer iven[] ivenarg[] many */
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{ 400, 0, OAMULET, 5, 1 } ,
X
X{ 500, 0, OCUBEofUNDEAD, 0, 0 } ,
X{ 600, 0, ONOTHEFT, 0, 0 } ,
X
X{ 590, 0, OCHEST, 3, 1 } ,
X{ 200, 0, OBOOK, 2, 1 } ,
X{ 10, 0, OCOOKIE, 0, 3 } ,
X{ 666, 0, OHANDofFEAR, 0, 0 } ,
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{ 850, 0, OORBOFDRAGON, 0, 0 } ,
X{ 750, 0, OSPIRITSCARAB, 0, 0 } ,
X{ 8000, 0, OVORPAL, 0, 0, } ,
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{ 300, 0, OSPHTALISMAN, 0, 0 } ,
X{ 150, 0, OWWAND, 0, 0 } ,
X{ 50, 0, OBRASSLAMP, 0, 0 } ,
X{ 9500, 0, OPSTAFF, 0, 0 }
X};
X
X/*
X function for the dnd store
X */
Xdnd_2hed()
X{
Xlprcat("Welcome to the Ularn Thrift Shoppe. We stock many items explorers find useful\n");
Xlprcat("in their adventures. Feel free to browse to your hearts content.\n");
Xlprcat("Also be advised, if you break 'em, you pay for 'em.");
X}
X
Xdnd_hed()
X{
X register int i;
X
X for (i=dnditm; i<26+dnditm; i++)
X dnditem(i);
X cursor(50,18);
X lprcat("You have ");
X}
X
Xdndstore()
X{
X register int i;
X
X dnditm = 0;
X nosignal = 1; /* disable signals */
X clear();
X dnd_2hed();
X if (outstanding_taxes>0)
X {
Xlprcat("\n\nThe Ularn Revenue Service has ordered us to not do business with tax evaders.\n");
X beep();
Xlprintf("They have also told us that you owe %d gp in back taxes, and as we must\n",(long)outstanding_taxes);
Xlprcat("comply with the law, we cannot serve you at this time. Soo Sorry.\n");
X cursors();
X lprcat("\nPress ");
X standout("escape");
X lprcat(" to leave: ");
X lflush();
X i=0;
X while (i!='\33') i=getcharacter();
X drawscreen();
X nosignal = 0; /* enable signals */
X return;
X }
X dnd_hed();
X while (1) {
X cursor(59,18);
X lprintf("%d gold pieces",(long)c[GOLD]);
X cltoeoln();
X cl_dn(1,20); /* erase to eod */
X lprcat("\nEnter your transaction [");
X standout("space");
X lprcat(" for more, ");
X standout("escape");
X lprcat(" to leave]? ");
X i=0;
X while ((i<'a' || i>'z') && (i!=' ') && (i!='\33') && (i!=12))
X i=getcharacter();
X if (i==12) {
X clear();
X dnd_2hed();
X dnd_hed();
X }
X else if (i=='\33') {
X drawscreen();
X nosignal = 0; /* enable signals */
X
X return;
X }
X else if (i==' ') {
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)
X outofstock();
X else if (itm[i].qty <= 0)
X outofstock();
X else if (pocketfull())
X handsfull();
X else if (c[GOLD] < itm[i].price*10)
X nogold();
X else {
X if (itm[i].mem != 0)
X *itm[i].mem[itm[i].arg] = ' ';
X c[GOLD] -= itm[i].price*10;
X itm[i].qty--;
X take(itm[i].obj,itm[i].arg);
X if (itm[i].qty==0)
X dnditem(i);
X nap(1001);
X }
X }
X
X }
X}
X
X/*
X function for the players hands are full
X */
Xhandsfull()
X{
X lprcat("\nYou can't carry anything more!");
X lflush();
X nap(2200);
X}
Xoutofstock()
X{
X lprcat("\nSorry, but we are out of that item.");
X lflush();
X nap(2200);
X}
Xnogold()
X{
X lprcat("\nYou don't have enough gold to pay for that!");
X lflush();
X nap(2200);
X}
X
X/*
X dnditem(index)
X
X to print the item list;
X used in dndstore() enter with the index into itm
X*/
Xdnditem(i)
Xregister int i;
X{
X register int j,k;
X
X if (i >= maxitm)
X return;
X cursor( (j=(i&1)*40+1) , (k=((i%26)>>1)+5) );
X if (itm[i].qty == 0) {
X lprintf("%39s","");
X return;
X }
X lprintf("%c) ",(i%26)+'a');
X if (itm[i].obj == OPOTION) {
X lprcat("potion of ");
X lprintf("%s",&potionname[itm[i].arg][1]);
X }
X else if (itm[i].obj == OSCROLL) {
X lprcat("scroll of ");
X lprintf("%s",&scrollname[itm[i].arg][1]);
X }
X else lprintf("%s",objectname[itm[i].obj]);
X cursor( j+31,k );
X lprintf("%6d",(long)(itm[i].price*10));
X}
X
X
X/*
X for the college of larn
X */
Xchar course[26]={0}; /* the list of courses taken */
Xchar coursetime[] = { 10, 15, 10, 20, 10, 10, 10, 5 };
X
X/*
X function to display the header info for the school
X */
Xsch_hed()
X{
X clear();
Xlprcat("The College of Ularn offers the exciting opportunity of higher education to\n");
Xlprcat("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 /*line 7 of crt*/
X if (course[0]==0)
X lprcat("\t\ta) Fighters Training I 10 mobuls");
X lprc('\n');
X if (course[1]==0)
X lprcat("\t\tb) Fighters Training II 15 mobuls");
X lprc('\n');
X if (course[2]==0)
X lprcat("\t\tc) Introduction to Wizardry 10 mobuls");
X lprc('\n');
X if (course[3]==0)
X lprcat("\t\td) Applied Wizardry 20 mobuls");
X lprc('\n');
X if (course[4]==0)
X lprcat("\t\te) Behavioral Psychology 10 mobuls");
X lprc('\n');
X if (course[5]==0)
X lprcat("\t\tf) Faith for Today 10 mobuls");
X lprc('\n');
X if (course[6]==0)
X lprcat("\t\tg) Contemporary Dance 10 mobuls");
X lprc('\n');
X if (course[7]==0)
X lprcat("\t\th) History of Ularn 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
X long time_used;
X nosignal = 1; /* disable signals */
X sch_hed();
X while (1) {
X cursor(57,18);
X lprintf("%d gold pieces. ",(long)c[GOLD]);
X cursors();
X lprcat("\nWhat is your choice [");
X standout("escape");
X lprcat(" to leave] ? ");
X yrepcount=0;
X i=0;
X while ((i<'a' || i>'h') && (i!='\33') && (i!=12))
X i=getcharacter();
X if (i==12) {
X sch_hed();
X continue;
X }
X else if (i=='\33') {
X nosignal = 0;
X drawscreen(); /* enable signals */
X
X return;
X }
X lprc(i);
X if (c[GOLD] < 250)
X nogold();
X else
X if (course[i-'a']) {
X lprcat("\nSorry, but that class is filled.");
X nap(1000);
X }
X else if (i <= 'h') {
X c[GOLD] -= 250;
X time_used=0;
X switch(i) {
X case 'a':
X c[STRENGTH] += 2;
X c[CONSTITUTION]++;
X lprcat("\nYou feel stronger!");
X cl_line(16,7);
X break;
X
X case 'b':
X if (course[0]==0) {
X lprcat("\nSorry, but this class has a prerequisite of Fighters Training I");
X c[GOLD]+=250;
X time_used= -10000;
X break;
X }
X lprcat("\nYou feel much stronger!");
X cl_line(16,8);
X c[STRENGTH] += 2;
X c[CONSTITUTION] += 2;
X break;
X
X case 'c':
X c[INTELLIGENCE] += 2;
X lprcat("\nThe task before you now seems more attainable!");
X cl_line(16,9);
X break;
X
X case 'd':
X if (course[2]==0) {
X lprcat("\nSorry, but this class has a prerequisite of Introduction to Wizardry");
X c[GOLD]+=250;
X time_used= -10000;
X break;
X }
X lprcat("\nThe task before you now seems very attainable!");
X cl_line(16,10);
X c[INTELLIGENCE] += 2;
X break;
X
X case 'e':
X c[CHARISMA] += 3;
X lprcat("\nYou now feel like a born leader!");
X cl_line(16,11);
X break;
X
X case 'f':
X c[WISDOM] += 2;
X lprcat("\nYou now feel more confident that you can find the potion in time!");
X cl_line(16,12);
X break;
X
X case 'g':
X c[DEXTERITY] += 3;
X lprcat("\nYou feel like dancing!");
X cl_line(16,13);
X break;
X
X case 'h':
X c[INTELLIGENCE]++;
X lprcat("\nWow!! E = MC^2!!!\n");
X cl_line(16,14);
X break;
X }
X time_used += coursetime[i-'a']*100;
X if (time_used > 0) {
X gtime += time_used;
X /*remember that he has taken that course*/
X course[i-'a']++;
X /* he regenerated */
X c[HP] = c[HPMAX];
X c[SPELLS] = c[SPELLMAX];
X
X /* cure blindness too! */
X if (c[BLINDCOUNT])
X c[BLINDCOUNT]=1;
X
X /* end confusion */
X if (c[CONFUSE])
X c[CONFUSE]=1;
X
X /* adjust parameters for time change */
X adjtime((long)time_used);
X }
X nap(1000);
X }
X }
X}
X
X/*
X * for the first national bank of Ularn
X */
Xint lasttime=0; /* last time he was in bank */
Xobank()
X{
X banktitle(" Welcome to the First National Bank of Ularn.");
X}
Xobank2()
X{
Xbanktitle("Welcome to the 8th level branch office of the First National Bank of Ularn.");
X}
X
Xbanktitle(str)
Xchar *str;
X{
X nosignal = 1; /* disable signals */
X clear();
X lprcat(str);
X if (outstanding_taxes>0) {
X register int i;
Xlprcat("\n\nThe Ularn Revenue Service has ordered that your account be frozen until all\n");
X beep();
Xlprintf("levied taxes have been paid. They have also told us that you owe %d gp in\n",(long)outstanding_taxes);
Xlprcat("taxes, and we must comply with them. We cannot serve you at this time. Sorry.\n");
Xlprcat("We suggest you go to the LRS office and pay your taxes.\n");
X cursors();
X lprcat("\nPress ");
X standout("escape");
X lprcat(" to leave: ");
X lflush();
X i=0;
X while (i!='\33')
X i=getcharacter();
X drawscreen();
X nosignal = 0; /* enable signals */
X
X return;
X }
X lprcat("\n\n\tGemstone\t Appraisal\t\tGemstone\t Appraisal");
X obanksub();
X 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
X if (c[BANKACCOUNT]<0)
X c[BANKACCOUNT] = 0;
X else if ((c[BANKACCOUNT]>0) && (c[BANKACCOUNT]<1000000)) {
X i = (gtime-lasttime)/100; /* # mobuls elapsed */
X while ((i-- > 0) && (c[BANKACCOUNT]<1000000))
X c[BANKACCOUNT] += c[BANKACCOUNT]/250;
X if (c[BANKACCOUNT]>1000000)
X c[BANKACCOUNT]=1000000; /* interest limit */
X }
X lasttime = (gtime/100)*100;
X}
X
Xstatic short gemorder[26]={0}; /* the reference to screen location for each */
Xstatic long gemvalue[26]={0}; /* the appraisal of the gems */
X
Xobanksub()
X{
X long amt;
X register int i,k;
X ointerest(); /* credit any needed interest */
X
X if (level==8) c[TELEFLAG] = 0;
X
X for (k=i=0; i<26; i++)
X switch(iven[i]) {
X case OLARNEYE:
X case ODIAMOND:
X case OEMERALD:
X case ORUBY:
X case OSAPPHIRE:
X if (iven[i]==OLARNEYE) {
X gemvalue[i]=250000-((gtime*7)/100)*100;
X if (gemvalue[i]<50000)
X 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]);
X k++;
X };
X cursor(31,17);
X lprintf("You have %8d gold pieces in the bank.",(long)c[BANKACCOUNT]);
X cursor(40,18);
X lprintf("You have %8d gold pieces",(long)c[GOLD]);
X if (c[BANKACCOUNT]+c[GOLD] >= 500000)
X lprcat("\nNote: Ularndom law states that only deposits under 1,000,000gp can earn interest.");
X while (1) {
X cl_dn(1,20);
X lprcat("\nYour wish? [(");
X standout("d");
X lprcat(") deposit, (");
X standout("w");
X lprcat(") withdraw, (");
X standout("s");
X lprcat(") sell a stone, or ");
X standout("escape");
X lprcat("] ");
X yrepcount=0;
X i=0;
X while (i!='d' && i!='w' && i!='s' && i!='\33')
X i=getcharacter();
X switch(i) {
X case 'd':
X lprcat("deposit\nHow much? ");
X amt = readnum((long)c[GOLD]);
X if (amt < 0) {
X lprcat("\nSorry, but we can't take negative gold!");
X nap(2000);
X amt=0;
X }
X else if (amt>c[GOLD]) {
X lprcat(" You don't have that much.");
X nap(2000);
X }
X else {
X c[GOLD] -= amt;
X c[BANKACCOUNT] += amt;
X }
X break;
X
X case 'w':
X lprcat("withdraw\nHow much? ");
X amt = readnum((long)c[BANKACCOUNT]);
X if (amt<0) {
X lprcat("\nSorry, but we don't have any negative gold!");
X nap(2000);
X amt=0;
X }
X else if (amt > c[BANKACCOUNT]) {
X lprcat("\nYou don't have that much in the bank!");
X nap(2000);
X }
X else {
X c[GOLD] += amt;
X c[BANKACCOUNT] -= amt;
X }
X break;
X
X case 's':
X lprcat("\nWhich stone would you like to sell? ");
X i=0;
X while ((i<'a' || i>'z') && i!='*')
X i=getcharacter();
X if (i=='*')
X for (i=0; i<26; i++) {
X if (gemvalue[i]) {
X if (iven[i]==OLARNEYE) {
X monstnamelist[DEMONLORD]=' ';
X monstnamelist[DEMONLORD+1]=' ';
X monstnamelist[DEMONLORD+2]= ' ';
X monstnamelist[DEMONLORD+3]= ' ';
X monstnamelist[DEMONLORD+4]= ' ';
X monstnamelist[DEMONLORD+5]= ' ';
X monstnamelist[DEMONLORD+6]= ' ';
X monstnamelist[DEMONPRINCE]= ' ';
X monstnamelist[LUCIFER] = ' ';
X }
X c[GOLD]+=gemvalue[i];
X iven[i]=0;
X gemvalue[i]=0;
X k = gemorder[i];
X cursor( (k%2)*40+1 , (k>>1)+4 );
X lprintf("%39s","");
X }
X }
X else {
X if (gemvalue[i=i-'a']==0) {
X lprintf("\nItem %c is not a gemstone!",i+'a');
X nap(2000);
X break;
X }
X if (iven[i]==OLARNEYE) {
X monstnamelist[DEMONLORD]=' ';
X monstnamelist[DEMONLORD+1]=' ';
X monstnamelist[DEMONLORD+2]= ' ';
X monstnamelist[DEMONLORD+3]= ' ';
X monstnamelist[DEMONLORD+4]= ' ';
X monstnamelist[DEMONLORD+5]= ' ';
X monstnamelist[DEMONLORD+6]= ' ';
X monstnamelist[DEMONPRINCE]= ' ';
X monstnamelist[LUCIFER] = ' ';
X }
X c[GOLD]+=gemvalue[i];
X iven[i]=0;
X gemvalue[i]=0;
X k = gemorder[i];
X cursor( (k%2)*40+1 , (k>>1)+4 );
X lprintf("%39s","");
X }
X break;
X case '\33':
X return;
X };
X cursor(40,17);
X lprintf("%8d",(long)c[BANKACCOUNT]);
X cursor(49,18);
X lprintf("%8d",(long)c[GOLD]);
X }
X}
X
X/*
X subroutine to appraise any stone for the bank
X */
Xappraise(gemstone)
Xint gemstone;
X{
X register int j,amt;
X
X for (j=0; j<26; j++)
X if (iven[j]==gemstone) {
X lprintf("\nI see you have %s",objectname[gemstone]);
X if (gemstone==OLARNEYE)
X lprcat(" I must commend you. I didn't think\nyou could get it.");
X lprcat(" Shall I appraise it for you? ");
X yrepcount=0;
X if (getyn()=='y') {
X lprcat("yes.\n Just one moment please \n");
X nap(1000);
X if (gemstone==OLARNEYE) {
X amt = 250000-((gtime*7)/100)*100;
X if (amt<50000) amt=50000;
X }
X else amt = (255 & ivenarg[j]) * 100;
X lprintf("\nI can see this is an excellent stone, It is worth %d",(long)amt);
X lprcat("\nWould you like to sell it to us? ");
X yrepcount=0;
X if (getyn()=='y') {
X lprcat("yes\n");
X c[GOLD]+=amt;
X iven[j]=0;
X }
X else lprcat("no thank you.\n");
X if (gemstone==OLARNEYE) lprcat("It is, of course, your privilege to keep the stone\n");
X }
X else lprcat("no\nO. K.\n");
X }
X}
X/*
X function for the trading post
X */
Xotradhead()
X{
X clear();
Xlprcat("Welcome to the Ularn Trading Post. We buy items that explorers no longer find\n");
Xlprcat("useful. Since the condition of the items you bring in is not certain,\n");
Xlprcat("and we incur great expense in reconditioning the items, we usually pay\n");
Xlprcat("only 20% of their value were they to be new. If the items are badly\n");
Xlprcat("damaged, we will pay only 10% of their new value.\n\n");
X}
X
Xotradepost()
X{
X int i,j,value,isub,izarg;
X
X dnditm = dndcount = 0;
X nosignal = 1; /* disable signals */
X resetscroll();
X otradhead();
X while (1) {
X lprcat("\nWhat item do you want to sell to us [");
X standout("*");
X lprcat(" for list, or ");
X standout("escape");
X lprcat("] ? ");
X i=0;
X while (i>'z' || (i<'a' && i!='*' && i!='\33' && i!='.'))
X i=getcharacter();
X if (i == '\33') {
X setscroll();
X recalc();
X drawscreen();
X nosignal=0; /* enable signals */
X
X return;
X }
X isub = i - 'a';
X j=0;
X if (iven[isub]==OSCROLL)
X if (scrollname[ivenarg[isub]][0]==0) {
X j=1;
X cnsitm();
X } /* can't sell unidentified item */
X if (iven[isub]==OPOTION)
X if (potionname[ivenarg[isub]][0]==0) {
X j=1;
X cnsitm();
X } /* can't sell unidentified item */
X if (!j)
X if (i=='*') {
X clear();
X qshowstr();
X otradhead();
X }
X else if (iven[isub]==0)
X lprintf("\nYou don't have item %c!",isub+'a');
X else {
X for (j=0; j<maxitm; j++)
X if ((itm[j].obj == iven[isub]) ||
X (iven[isub] == ODIAMOND) ||
X (iven[isub] == ORUBY) ||
X (iven[isub] == OEMERALD) ||
X (iven[isub] == OSAPPHIRE)) {
X srcount=0;
X show3(isub); /* show what the item was */
X if ((iven[isub] == ODIAMOND)
X || (iven[isub] == ORUBY)
X || (iven[isub] == OEMERALD)
X || (iven[isub] == OSAPPHIRE))
X value = 20*ivenarg[isub];
X else if ((itm[j].obj == OSCROLL)
X || (itm[j].obj == OPOTION))
X value = 2*itm[j+ivenarg[isub]].price;
X else {
X izarg=ivenarg[isub];
X /* appreciate if a +n object */
X value = itm[j].price;
X if (izarg >= 0) value *= 2;
X while ((izarg-- > 0) && ((value=14*(67+value)/10) < 500000))
X ;
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 lprcat("yes\n");
X 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 }
X else lprcat("no thanks.\n");
X j = maxitm+100; /* get out of the inner loop */
X }
X if (j <= maxitm+2) lprcat("\nSo sorry, but we are not authorized to accept that item.");
X }
X }
X}
X
Xcnsitm()
X{
X lprcat("\nSorry, we can't accept unidentified objects.");
X}
X
X/*
X * for the Ularn Revenue Service
X */
Xolrs()
X{
X register int i,first;
X long amt;
X
X first = nosignal = 1; /* disable signals */
X clear();
X resetscroll();
X cursor(1,4);
X if (outstanding_taxes)
X if (cheat) {
Xlprcat("Sorry, but it seems you are trying to pay off your taxes by cheating!");
X lprcat("\n\n\tpress [escape] to exit the office.");
X cursors();
X i=0;
X while (i!='\33')
X i=getcharacter();
X nosignal = 0; /* enable signals */
X setscroll();
X drawscreen();
X return;
X }
X lprcat("Welcome to the Ularn Revenue Service district office. How can we help you?");
X while (1) {
X if (first) {
X first=0;
X goto nxt;
X }
X cursor(1, 20);
X lprcat("\n\nYour wish? [(");
X standout("p");
X lprcat(") pay taxes, or ");
X standout("escape");
X lprcat("] ");
X yrepcount=0;
X i=0;
X while (i!='p' && i!='\33')
X i=getcharacter();
X switch(i) {
X case 'p':
X lprcat("pay taxes\nHow much? ");
X amt = readnum((long)c[GOLD]);
X if (amt<0) {
X lprcat("\nSorry, but we can't take negative gold\n");
X amt=0;
X }
X else
X if (amt>c[GOLD])
X lprcat(" You don't have that much.\n");
X else c[GOLD] -= paytaxes((long)amt);
X break;
X case '\33':
X nosignal = 0; /* enable signals */
X setscroll();
X drawscreen();
X return;
X };
X
Xnxt:
X 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}
X
X
Xnomore()
X{
X lprcat("\nSorry man, I ain't got no more of that shit.");
X lflush();
X nap(2200);
X}
Xnocash()
X{
X lprcat("\nWhattaya trying to pull on me? You aint got the cash!");
X lflush();
X nap(1200);
X}
X
X/*
X Dealer McDopes Pad
X */
X/*
X function to display the header info for the pad
X */
Xchar drug[5]={0};
Xpad_hd()
X{
X clear();
X lprcat("Hey man, welcome to Dealer McDope's Pad! I gots the some of the finest shit\n");
X lprcat("you'll find anywhere in Ularn - check it out...\n\n\n");
X lprcat("\t\t The Stash\t\t\tThe Cash\n\n");
X
X /*line 7 of crt*/
X if (drug[0]==0) lprcat("\t\ta) Killer Speed\t\t100 bucks");
X lprc('\n');
X if (drug[1]==0) lprcat("\t\tb) Groovy Acid\t\t\t250 bucks");
X lprc('\n');
X if (drug[2]==0) lprcat("\t\tc) Monster Hash\t\t500 bucks");
X lprc('\n');
X if (drug[3]==0) lprcat("\t\td) Trippy Shrooms\t\t1000 bucks");
X lprc('\n');
X if (drug[4]==0) lprcat("\t\te) Cool Coke\t\t\t5000 bucks");
X lprc('\n');
X
X cursor(30,18);
X lprcat("Looks like you got about ");
X}
X
Xopad()
X{
X register int i,flag;
X
X nosignal = 1; /* disable signals */
X
X pad_hd();
X
X while (1) {
X cursor(57,18);
X lprintf("%d bucks on you. ",(long)c[GOLD]);
X cursors();
X lprcat("\nSo, whatdya want [escape");
X lprcat(" to split] ? ");
X yrepcount=0;
X
X i=flag=0;
X
X while ((i<'a' || i>'e') && (i!='\33') && (i!=12))
X i=getcharacter();
X
X if (i==12) {
X pad_hd();
X continue;
X }
X else if (i=='\33') {
X nosignal = 0;
X drawscreen(); /* enable signals */
X return;
X }
X lprc(i);
X if (drug[i-'a']) {
X nomore();
X flag++;
X }
X else
X switch(i) {
X case 'a':
X if (c[GOLD] < 100) {
X nocash();
X flag++;
X }
X break;
X case 'b':
X if (c[GOLD] < 250) {
X nocash();
X flag++;
X }
X break;
X case 'c':
X if (c[GOLD] < 500) {
X nocash();
X flag++;
X }
X break;
X case 'd':
X if (c[GOLD] < 1000) {
X nocash();
X flag++;
X }
X break;
X case 'e':
X if (c[GOLD] < 5000) {
X nocash();
X flag++;
X }
X break;
X }
X if (flag>0) continue;
X switch(i) {
X case 'a': /* speed */
X if (snag(OSPEED)) {
X c[GOLD] -= 100;
X cl_line(16,7);
X flag++;
X }
X break;
X
X case 'b': /* acid */
X if (snag(OACID)) {
X c[GOLD] -= 250;
X cl_line(16,8);
X flag++;
X }
X break;
X
X case 'c': /* hash */
X if (snag(OHASH)) {
X c[GOLD] -= 500;
X cl_line(16,9);
X flag++;
X }
X break;
X
X case 'd': /* shrooms */
X if (snag(OSHROOMS)) {
X c[GOLD] -= 1000;
X cl_line(16,10);
X flag++;
X }
X break;
X
X case 'e': /* coke */
X if (snag(OCOKE)) {
X c[GOLD] -= 5000;
X cl_line(16,11);
X flag++;
X }
X break;
X } /* end switch */
X
X /*remember that he has snagged that drug*/
X if (flag)
X drug[i-'a']++;
X nap(1000);
X } /*end while(1) */
X} /* end pad() */
X
Xsnag(itm)
Xint itm;
X{
X int i,limit;
X
X if ( (limit = 15 + (c[LEVEL] >> 1)) > 26) limit=26;
X
X for(i=0;i<limit;i++)
X if (iven[i]==0) {
X iven[i]=itm;
X ivenarg[i]=0;
X limit=0;
X lprcat("\nOk, here ya go");
X show3(i);
X return(1);
X }
X lprcat("\nHey, you can't carry anymore");
X return(0);
X}
X
Xint char_picked = 0;
X
Xpick_char(foo)
Xint foo;
X{
X int i;
X
X nosignal = 1; /* disable signals */
X
X if (foo == 0) {
X clear();
X lprcat("\t\tThe Addiction of Ularn\n\n");
X lprcat("Pick a character class...\n\n\n");
X lprcat("\t\t Character\n\n");
X
X lprcat("\t\ta) Ogre");
X lprc('\n');
X lprcat("\t\tb) Wizard");
X lprc('\n');
X lprcat("\t\tc) Klingon");
X lprc('\n');
X lprcat("\t\td) Elf");
X lprc('\n');
X lprcat("\t\te) Rogue");
X lprc('\n');
X lprcat("\t\tf) Geek");
X lprc('\n');
X lprcat("\t\tg) Dwarf");
X lprc('\n');
X lprcat("\t\th) Rambo");
X lprc('\n');
X
X cursors();
X lprcat("\nSo, what are ya? ");
X lflush();
X
X while (i<'a' || i>'h')
X i=getcharacter();
X
X } else {
X i = foo;
X c[SHIELD] = c[WEAR] = c[WIELD] = -1;
X }
X switch(i) {
X case 'a': /* Ogre */
X strcpy(char_class, "Ogre");
X spelknow[1]=1; /* mle */
X c[SPELLMAX]=c[SPELLS]=1;
X c[HPMAX]=c[HP]=16;
X c[0] = 18; /* strength */
X c[1] = 4; /* intelligence */
X c[2] = 6; /* wisdom */
X c[3] = 16; /* constitution */
X c[4] = 6; /* dexterity */
X c[5] = 4; /* charisma */
X iven[0]=OPOTION;
X ivenarg[0]=rund(6);
X iven[1]=OPOTION;
X ivenarg[1]=rund(6);
X c[WIELD]=c[WEAR]= -1;
X break;
X case 'b': /* Wizard */
X strcpy(char_class, "Wizard");
X spelknow[1]=1; /* mle */
X spelknow[4]=1; /* chm */
X c[SPELLMAX]=c[SPELLS]=2;
X c[HPMAX]=c[HP]=8;
X c[0] = 8; /* strength */
X c[1] = 16; /* intelligence */
X c[2] = 16; /* wisdom */
X c[3] = 6; /* constitution */
X c[4] = 6; /* dexterity */
X c[5] = 8; /* charisma */
X iven[0]=OPOTION;
X ivenarg[0]=19; /* potion of treasure detection */
X iven[1]=OSCROLL;
X ivenarg[1]=rund(6);
X iven[2]=OSCROLL;
X ivenarg[2]=rund(6);
X c[WIELD]=c[WEAR]= -1;
X break;
X case 'c': /* Klingon */
X strcpy(char_class, "Klingon");
X spelknow[5]=1; /* ssp */
X c[SPELLMAX]=c[SPELLS]=1;
X c[HPMAX]=c[HP]=14;
X c[0] = 14; /* strength */
X c[1] = 12; /* intelligence */
X c[2] = 4; /* wisdom */
X c[3] = 12; /* constitution */
X c[4] = 8; /* dexterity */
X c[5] = 3; /* charisma */
X iven[0]=OSTUDLEATHER;
X ivenarg[0]=0;
X iven[1]=OPOTION;
X ivenarg[1]=rund(6);
X c[WIELD]= -1;
X c[WEAR] = 0;
X break;
X case 'd': /* Elf */
X strcpy(char_class, "Elf");
X spelknow[0]=1;
X c[SPELLS]=1;
X c[SPELLMAX]=2;
X c[HPMAX]=c[HP]=8;
X c[0] = 8; /* strength */
X c[1] = 14; /* intelligence */
X c[2] = 12; /* wisdom */
X c[3] = 8; /* constitution */
X c[4] = 8; /* dexterity */
X c[5] = 14; /* charisma */
X iven[0]=OLEATHER;
X ivenarg[0]=0;
X iven[1]=OSCROLL;
X ivenarg[1]=rund(6);
X c[WIELD]= -1;
X c[WEAR]=0;
X break;
X case 'e': /* Rogue */
X strcpy(char_class, "Rogue");
X spelknow[1]=1;
X c[SPELLMAX]=c[SPELLS]=1;
X c[HPMAX]=c[HP]=12;
X c[0] = 8; /* strength */
X c[1] = 12; /* intelligence */
X c[2] = 8; /* wisdom */
X c[3] = 10; /* constitution */
X c[4] = 14; /* dexterity */
X c[5] = 6; /* charisma */
X iven[0]=OLEATHER;
X iven[1]=ODAGGER;
X ivenarg[1]=ivenarg[0]=c[WEAR]=0;
X c[WIELD]=1;
X iven[2]=OSCROLL;
X ivenarg[2]=14; /* stealth */
X break;
X case 'f': /* Geek */
X strcpy(char_class, "Geek");
X spelknow[0]=1;
X spelknow[1]=1;
X c[SPELLMAX]=c[SPELLS]=1;
X c[HPMAX]=c[HP]=10;
X c[0] = 12; /* strength */
X c[1] = 12; /* intelligence */
X c[2] = 12; /* wisdom */
X c[3] = 12; /* constitution */
X c[4] = 12; /* dexterity */
X c[5] = 12; /* charisma */
X iven[0]=OLEATHER;
X iven[1]=ODAGGER;
X ivenarg[1]=ivenarg[0]=c[WEAR]=0;
X c[WIELD]=1;
X break;
X case 'g': /* Dwarf*/
X strcpy(char_class, "Dwarf");
X spelknow[0]=1;
X c[SPELLMAX]=c[SPELLS]=1;
X c[HPMAX]=c[HP]=12;
X c[0] = 16; /* strength */
X c[1] = 6; /* intelligence */
X c[2] = 8; /* wisdom */
X c[3] = 16; /* constitution */
X c[4] = 4; /* dexterity */
X c[5] = 4; /* charisma */
X iven[0]=OSPEAR;
X ivenarg[0]=c[WIELD]=0;
X break;
X case 'h': /* Rambo */
X strcpy(char_class, "Rambo");
X c[SPELLMAX]=c[SPELLS]=0;
X c[HPMAX]=c[HP]=1;
X c[0] = 3; /* strength */
X c[1] = 3; /* intelligence */
X c[2] = 3; /* wisdom */
X c[3] = 3; /* constitution */
X c[4] = 3; /* dexterity */
X c[5] = 3; /* charisma */
X iven[0]=OLANCE;
X ivenarg[0]=c[WIELD]=0;
X c[LANCEDEATH] = 1;
X break;
X } /* end switch */
X nosignal = 0;
X} /* end pick_char */
END_OF_FILE
if test 29301 -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 4 \(of 8\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 8 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0

0 new messages