v07i005: ularn - ultra-larn, an enhancement of the larn adventure game, Part05/08

5 views
Skip to first unread message

Bill Randle

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

#! /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 8)."
# Contents: Umaps help.c main.c
# Wrapped by billr@saab on Thu Jun 29 08:10:20 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Umaps' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Umaps'\"
else
echo shar: Extracting \"'Umaps'\" \(23140 characters\)
sed "s/^X//" >'Umaps' <<'END_OF_FILE'
X###################################################################
X# # . # # # # # . #
X# D D . . D . #
X###D########################################## # # ###D###
X# -# #. # # ################ . .#
X# ####### ######## ############ D #### # # #
X# ... #.# # # # . # # # #### # ############ # ###D###
X# #.# # # ## # # # ############ #### # #- # # # #. #
X# . # # # # ## #- # # # - D #### # # . D # #.# # ... #
X# # #.# # # # # # . . # # # # # # #-# # ~.! #
X###D### ### #######D## # ############ ###### ########## ### #######
X# # .# # ..... ...#
X###D###########################################################D###
X# . #.....# # # # -# # # # # #
X# ..... . D D D D. #
X# #.....# # # # # # .# # # #
X###################################################################
X
X###################################################################
X# # . - . . . #
X# #D############################################################ .#
X# # # . - . # ##
X#.#.#D####################################################### #. #
X# # # # . . . # ##-#
X# #-# #D################################################### # # .#
X# # # # # . # - # # . -# . #.......#!# # # ##
X# # # # # ### ### ### ###.### ### ### ### ### ###.###.###~# # #. #
X#.# # # . # . . # . # - # . . # ....#.....# # ## #
X# #.# ##################################################### # # .#
X# # # .. . #. #-##
X# # ######################################################### #. #
X# # .. - . . . . ## #
X#-############################################################## #
X#. . #
X###################################################################
X
X###################################################################
X### # ## #...# . . . . # # # ## .###
X# ## # ## # ####################### # #. ## #####D#D #
X# D######## ## ##### # D D # # # # ## ## -..## #
X# # ##..- # ## # # ## ## . # # # # # ### ### ### #
X# # ##-..# ## . ## # ##-. ## . # # # # ## # #-.-## # #
X# # ## -##### ## # . ## . - ## # # # # ## # #..## # #
X#.#### ##D##-.# ## # . ## .....-## # # # #..## -#### ## # #
X# # # DD ##-.D ## # ..######D###### # # # #.DD ### D## ### #
X# #.## ## ##### ## ### # #D# # # #..## # ##...# #
X# #.# ##..## ## # # ##.## ######## ## ## ####..# #
X#-#. ##...## ##. ###### ### .-## # - # ## ## ## # #
X# # ##..#.## ##. ### # # ##.-. .## # ###### ## #### ##D. #
X# ### ##### ## .###!. . .~##. ## # ## ## -## #
X# ## ## ############ ##################### ### ## #### ## #
X### # D . . . - .. ##..... ####
X###################################################################
X
X###################################################################
X#. # # # . # # # ## #### .. #
X# # # # ###### # # . . . # . # .# . ##. .. #
X# #. # . . # # . # #D######################## #D## - #
X# ################# # ##.## . . #..## #
X# # .# . # ### ##. .## ##################### ## #
X# # - .D . - # # - # ## # ## #. # # # # ## ## #
X# ######## .. # ## ### ## # # # # # # # # # ## ###
X# D. # ## ##!## ## # # # # # # # # .. ##
X# ################# . ## ##.~.## ##### # # # # # # ##### ... #
X# D. # . # ##. ## .#. ## ## ..# # #.# # #.# . -. #
X# # .- . #. - # ## ## ..#.. ## ## # # #-# # # # ######
X# # D. # ## ## #####- ## ## # # # # # # #.# #
X# ##############D## ## ## .. ... .. ## ##### #.# # # ## # - ##
X# #. . # ## ########D######## ## . # # # # # # # . #
X# # - . ### - . . ##. # # #### # #
X###################################################################
X
X###################################################################
X# # .- . #. - # ## ## ..#. ## ## # # #-# # # # ######
X# # D. # ## ## #####- ## ## . # # # # # #.# #
X# ##############D## ## ## . .. ## ##### #.# # # ## # - ##
X#. # # # . ##### # # # #### .. #
X# #D# # ###### # # . . . # . # .# . ##. .. #
X# #. # . . # # . # #D######################## D## - #
X# ################# . ## ##. .## ##### # # # # # # ##### ... #
X# D. # . # ##. ## .#. ## ## ..# # #.# # #.# . -. #
X# #. . # ## ########D######## ## . # # # # # # # . #
X# ################# # ##.## . . #..## #
X# # .# . # #### ##. .##DD##################### ## #
X# # - .D . - # # -## ## # ## #. # # #. # ## ## #
X# ######## .. # # # ## .### .## # # # # # # # # # ## ###
X# D. # # ## ##!## ## # # # # # # # .. ##
X# # - . ### -## . .~. . ## ###. # # #### # #
X###################################################################
X
X###################################################################
X#.. . D # . # #- #
X############# ######### # ## ### ##### ## #### ###### ####### ### #
X#.#!#~# # # .-# # #- # # # # -# # # #
X# # #.# . # ####### # # # # # # # # # #####
X# # ..# ##### # # # #### # ## ## ## # ###### ####### # #
X# - ..D # D # . D # # # #.##### ## ## # #. #.# #..# # ### #
X####### ####### ### # # # # # # D # D D #..D # #
X#- # # # #### # ###### # ## # #. # #..# #####
X### #######################- # # # ###################### # #
X# ... # . # #..# ### # - .. . #. ### #
X# ######## # # # # ### #################### # # #
X# # ### #
X################################################################# #
X#- # # D ### # # # #
X# . # # # # D #
X###################################################################
X
X###################################################################
X# .. #
X# ############## ############################################## # #
X# # # # # .. # # #
X# #D## # # ############D################# ########### # # #
X######### #- # # # #- D # # ~ # # # # # # #
X# # # # # # # ### # # # D - # # ####### # # # #
X# .... # #### # # # #!# # # ###### .. #.# # # # # # #
X# .... # # # # ### # # # # #########D#### # ### # # # # #
X# .... ######## # # D # #- # #.. # ...#.# # #.# # # # # #
X# # # ### # #### #.- D - #.# #.#.# # # # # #
X#####DD## ######## # # D D. # # # #...# # # # # #
X# # ..# # # # ############################## # ##### # # # # #
X# ......# # # # # # # # # #
X# ####### ###### ################################ ######### # ### #
X# .D. # #
X###################################################################
X
X###################################################################
X# ## ## ### ## #
X# ##### ## ..- ## ##.## ## #
X# # ! ## ## . ## ## .## .. ## #
X# #....###### ## ## ## . ## ## #
X# # - # ## ##D# ## . ## ## #
X# #####D ~ ####### ###........ ## ... ## ## #
X# # # ## ## .... ## . ## ## #
X# #. ######## ## ## . - ####D#### - #
X# #.- #...## ## ... ## ### ...... ## ## #
X# #. #..## ## ######### ## ... ## ### ## .. #
X# #.. #.## ## ## - ## . #### ## ## ##### ## #
X# #####D## ## ## ###### ## ## ####### ## #
X# D -.## #### ######## ##DD## ######## #D #
X# ###### ... ## ########## ## #
X#### . . ###
X###################################################################
X
X###################################################################
X# #
X# ####.########################################## ## ##########
X# # #.#.#.# #.. #. # # #
X####### # # # # # ##### #! # ########### # ### #
X# # # # # # # ##...## # # # # # #-# #
X# ..- D # # # # # ## . ## ####D##### .. ### # # # #
X# # # # ##. ~ .## # # ### # # ##### # #
X############ # # # # ## . . .## #...# .. #.# # # # #
X# .. .# # # # # ## - ## # # D.D # ######### #
X# . D # # # # ##.......## ####D#####.# # #
X# - . # # # # # ## ## # . # ### ########### #
X############ #.#.# # ###D### # . #....# # #
X# # #-# D .. # .# ###....## ##-### #
X#### ########################################## ###### ### #
X# . #
X###################################################################
X
X###################################################################
X# #
X# ###########################D####### ## #
X# ####################### # ##...... ## ## #
X# ########D###### # # !##.... ## ## #
X# ############ ## ## ... # # #...## ~ ## ###### #
X# # # # # ...... # # # .. ##### ## #
X# # - .. # # # ########### # # . ######### ## #
X# ##### ##### # # # # #... ## ## #
X# # # ########## ######## ########DD#### ####### #
X# # # .... # # # # # ## ## #
X# ##### # # ....# # ######### # # ##### ## #
X# #- ######D##########..# # ######### # - #.. ## ## #
X# ##### # # # #... #.....## #
X# # ################### ###############... #### # ######
X# # #
X###################################################################
X
X###################################################################
X# #
X########### ##### ##### #####D#### ##### ###### #
X#.. # #-..D ###### ## # ## # ## ..## ### #### #
X# #### ### ##### # ## # ##### # ## ### ## # # #
X# # # # # # ##### # ## # # #### # #..##### - ### #
X# # # ####### ### #...# # ######## # # #~. .... # #
X# # # # #...# # # ######### ############## #
X# # ###### ####### # ### ### # .. # #
X# # # - # #-#####!# # # #### ## #### # #
X# ###### # ########## #.. ....# # ######## # # # ## ## #
X# -.# ##### ####...## # . .# #..# # ## # #
X# #### ###### #.### #####.#### #### ### ## # #
X# #- #######....#### ...... #.# . # ## # #
X# ####### ##### ###########.############### ### #
X# . #
X###################################################################
X
X###################################################################
X# # #- . # # # # # # # # #
X# # # #####.##### # # # # # # # # # # ###########D########### #
X# # ##### # # ### # # # # # # # # # ### #.... # # # #
X# # # # # # # # # # # # # # #.!. -.. #.##.# # #
X# # . - # # ####### # # # # # # # # # ########## ## # #
X#.####### # # D # . # # #
X#. -# ################################################### #
X# ##### D. . #
X# # ### ###D### ### ### ###D### ### ### ###D### ###.### #
X# # ###### ### .# .# #. # # # # # # # # . # #
X# ### # -# ### .#. - .# # # #...- # # .. # # -..# # . # #
X# # # ### #. ~ .# # # # # # # # .. .# # # #
X#.###### # ### # # #.....# # # # # # # # # #
X# # ####### ####### ####### ####### ####### ####### ####### #
X# # ... .. #
X###################################################################
X
X###################################################################
X# # . # ### # # # # . #
X# D D . # . D . #
X############################################### # # ###D###
X# -# #. # # ################ . .#
X# #######D######## ############ # #### # # #
X# ... #. # #!~ . # # # #--# # ############ #####D###
X# #.# # # ## # # # ############ #--# # #- # # # #. #
X# . # #-# # ## #- # # # - D ## # # # . D #### #.# # ... #
X# # #-# # # # # # . . # # # # # # #-# # -.- #
X###D### ### ####### ## # ############ ###### ########## ### ###D###
X# # . ..... ...#
X##################################### # ###############D###
X# . #.....# # # # -########### # # # #
X# ..... . D D # D D. #
X# #.....# # # # # .# # # #
X###################################################################
X
X###################################################################
X#.. . # D . #- #
X### ######### ######### # ## ### ##### ## ########### ####### ### #
X#.# # # # .-# # #- # # # # -# # # #
X# # #.# . # ####### # # # # # # # # # #####
X# # ..####### # # # #### # ## ## ##!# ###### ####### # #
X# - ..D # D # . D # # # #.##### ## ## # #. #.# #..# # ### #
X####### ####### ### # # # # # # D # D D #..D # #
X#- # # # #### # ###### # ## # #. # #..# #####
X### #######################- # # # ###################### # #
X# ... # . #..# ### # - .. . #. ### #
X# # # # #-# #################### # # #
X# # # #
X################################-################################ #
X#-..... # ####D ### # # # #
X#~..... # # # # D #
X###################################################################
X
X###################################################################
X# .. #
X# ############## ############################################## # #
X# # # # # .. # # #
X# #D## # # ############D################# ########### # # #
X######### #- # # # #- D # #.!..# # # # # # #
X# # # # # # # # ### ## # #....D - # # ####### # # # #
X# .... # #### # # # #~# # # ###### .. #.# # # # # # #
X###....## # # # ###.# # # #########D## # # ### # # # # #
X# .... ######## # # D .# #- # .. # ...#.# # #.# # # # # #
X# # ## # ### .# #### .- D - #.# #.#.# # # # # #
X#####DD## ######## #... .# . # # # #.#. # # # # #
X# # ..# # # ############################## # # ##### # # # #
X# ......# # # # # # # # # # #
X# ####### ###### ################################D# ######### ### #
X# .D. #-.-#
X###################################################################
X
X###################################################################
X# ## ## ## ## ## #
X# ############## ## ..- ## ## . ## ## #
X# # # ## ## . ## ## . ##.. ## #
X# #....###### ## ## ######## ####### . ## ## #
X# # - # ## ## ##D# ## . ## ## #
X# # D###### ###........ ## ... ## ###### #
X# # # ## ## .... ## . ## ## - # #
X# #. ######## ## ## . - ####D####.. D #
X# #.- #...## ## ... ## ### ...... ## ##### #
X# #. #..## ## ######### ## ... ## ### ## .. #
X# #.. #.## ## ## - ## . #### ## ## ##### ## #
X# #####D####### # ## ## ##..## ## ## ## ## ## #
X# D -.## # # #### ##.-.-## ##DD## ### #### ## #
X# ######. ...# #### ## #### ##### ## ##D#
X####~!.... D . . #
X###################################################################
X
X###################################################################
X# #
X# ####.########################################## ## ##########
X# # #.#.#.# #.. . # # #
X####### # # # # # ############# # ########### # ### #
X# # # # # # # --##...##-- # # # # #-# #
X# ..- D # # # # # #-## . ##-# ####D##### .. ### # # # #
X# # # # ###. .### # ~ # ### ### ##### # #
X############ # # # # ## . . .## #...# .. #.# # #
X# .. .# # # # # ## - ## # # D. # ######### #
X# . D # # # # ###.......### ####D#####.# # #
X# - . # # # # # -## ##- # . ### ########### #
X############ #.#.# # ######D###### # . ....# # #
X# #!#-# # .. # . ###....## ##-### #
X#### ############################## ########## ###### ### #
X# D . #
X###################################################################
X
X###################################################################
X# #
X# ###############D####################D# #
X# ####################### # ##...... # #
X# ########D###### # # ##.... # #
X# ############### ## ## ... # # #...## ##### #
X# # ~ # # #!...... # # # .. ##### # #
X# # - .. # # # ########### # # . ######### # #
X# ##### ######## # # # # # #... ## # #
X# . # # # ########## ######## ########D #### ###### #
X# . # # ....# # # # # # ## # #
X# ##### # ###### # ....# # ######### # # #####D# #
X# #- ## # #######..# # ######### # - #.. #
X# ##### # # # #... #..... #
X# # ################### ###############... #### ######
X# # #
X###################################################################
X
X###################################################################
X# # #
X########### ##### # #####D#### ##### ###### #
X#.. # #~..D ###### ## # ## # ## ..## ### #### #
X# #### ### ##### # ## # ##### # ## ### ## # # #
X# # # # # # ##### # ## # # #### # #..##### - ### #
X# # # ####### ### #...# # ######## # # #!. .... # #
X# # # # #...# # # ######### ############## #
X# # ###### ####### # ### ### # .. # #
X# # # - # #- # # # ######## #### # #
X# # # ########## #.. ....# # ######## # ## ## #
X# # -. ##### ####...## # . .# .. # # #
X# # ###### ##### #####.#### ####### # #
X# # - #######....#### ...... #.# . # ## # #
X# ######### ##### ###########.############### ### #
X# . #
X###################################################################
X
X###################################################################
X# D D #-..........# # # # # #
X# # # #####.#####.# # # # # # #############D########### #
X# # ##### #.-#.#~###.# # # # # # ### .... # # # #
X# # . # #D###.......# # # # # # # . . -.. #. #.# # #
X# # . - # ##. #.####### # # # # # ################## # #
X#D####### # ##. # D # . # # #
X#. D D -# # ################################################### #
X# ###### ## . . #
X# # D ### ###D###D####### ###D###D####### ###D###D####### #
X# # ###### # # .# .# #. # # # # # # # # . # #
X# ### -# # # .#. - .# # # #...- # # .. # # -..# # . # #
X#DD# # # # #. .# # # # # # # # .. .# # # #
X#.###### # # # # #.....# # # # # # ! # # # #
X# # ####### ####### ### ###D####### ### ###D####### ### ###D#
X# # ... .. #
X###################################################################
X
END_OF_FILE
if test 23140 -ne `wc -c <'Umaps'`; then
echo shar: \"'Umaps'\" unpacked with wrong size!
fi
# end of 'Umaps'
fi
if test -f 'help.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'help.c'\"
else
echo shar: Extracting \"'help.c'\" \(2009 characters\)
sed "s/^X//" >'help.c' <<'END_OF_FILE'
X/* help.c */
X#include "header.h"
X
X/*
X * help function to display the help info
X *
X * format of the .larn.help file
X *
X * 1st character of file: # of pages of help available (ascii digit)
X * page (23 lines) for the introductory message (not counted in above)
X * pages of help text (23 lines per page)
X */
Xextern char helpfile[];
Xhelp()
X{
X register int i,j;
X char tmbuf[128];
X /* intermediate translation buffer when not a VT100 */
X if ((j=openhelp()) < 0)
X return; /* open the help file and get # pages */
X
X for (i=0; i<23; i++) lgetl(); /* skip over intro message */
X for (; j>0; j--) {
X clear();
X for (i=0; i<23; i++) {
X tmcapcnv(tmbuf,lgetl());
X lprcat(tmbuf);
X } /* intercept \33's */
X if (j>1) {
X lprcat(" ---- Press ");
X standout("return");
X lprcat(" to exit, ");
X standout("space");
X lprcat(" for more help ---- ");
X i=0;
X while ((i!=' ') && (i!='\n') && (i!='\33'))
X i=getcharacter();
X if ((i=='\n') || (i=='\33')) {
X lrclose();
X setscroll();
X drawscreen();
X return;
X }
X }
X }
X lrclose();
X retcont();
X drawscreen();
X}
X
X/*
X * function to display the welcome message and background
X */
Xwelcome()
X{
X register int i;
X char tmbuf[128];/* intermediate translation buffer when not a VT100 */
X
X if (openhelp() < 0)
X return; /* open the help file */
X clear();
X for(i=0; i<23; i++) {
X tmcapcnv(tmbuf,lgetl());
X lprcat(tmbuf);
X } /* intercept \33's */
X lrclose();
X retcont(); /* press return to continue */
X}
X
X/*
X * function to say press return to continue and reset scroll when done
X */
Xretcont()
X{
X cursor(1,24);
X lprcat("Press ");
X standout("return");
X lprcat(" to continue: ");
X while (getcharacter() != '\n')
X ;
X setscroll();
X}
X
X/*
X * routine to open the help file and return the first character - '0'
X */
Xopenhelp()
X{
X if (lopen(helpfile)<0) {
X lprintf("Can't open help file \"%s\" ",helpfile);
X lflush();
X sleep(4);
X drawscreen();
X setscroll();
X return(-1);
X }
X resetscroll();
X return(lgetc() - '0');
X}
END_OF_FILE
if test 2009 -ne `wc -c <'help.c'`; then
echo shar: \"'help.c'\" unpacked with wrong size!
fi
# end of 'help.c'
fi
if test -f 'main.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'main.c'\"
else
echo shar: Extracting \"'main.c'\" \(26141 characters\)
sed "s/^X//" >'main.c' <<'END_OF_FILE'
X/* main.c */
X/* This game is bad for you. It is evil. It will rot your brain. */
X#include "header.h"
X
Xstatic char copyright[]=
X"\nUlarn was created by Phil Cordier and is based on Larn by Noah Morgan\n";
X
Xint srcount=0; /* line counter for showstr() */
Xint dropflag=0; /* if 1 then don't lookforobject() next round */
Xint rmst=80; /* random monster creation counter */
Xint userid; /* the players login user id number */
Xint stayflag=0;
X
Xchar nowelcome=0,
Xnomove=0; /* if (nomove) then don't count next iteration as a move */
X
Xstatic char viewflag=0;
X/* if viewflag then we have done a 99 stay here and
X don't showcell in the main loop */
X
Xchar restorflag=0; /* 1 means restore has been done */
Xstatic char cmdhelp[] = "\
XCmd line format: Ularn [-slicnh] [-o<optsfile>] [-##] [++]\n\
X -s show the scoreboard\n\
X -i show scoreboard with inventories\n\
X -c create new scoreboard (wizard only)\n\
X -n suppress welcome message on starting game\n\
X -h print this help text\n\
X -o<optsfile> specify .Ularnopts file to be used instead of \"~/.Ularnopts\"\n\
X -## specify level of difficulty (example: Ularn -5)\n\
X -++ restore game checkpoint file\n";
X
X/*
X ************
X MAIN PROGRAM
X ************
X */
X
Xmain(argc,argv)
Xint argc;
Xchar **argv;
X{
X register int i;
X int hard;
X char *ptr=0;
X struct passwd *pwe,*getpwuid();
X
X init_term(); /*setup the terminal (find out what type) for termcap */
X
X/*
X * first task is to identify the player
X */
X if ((ptr = getlogin()) == NULL)
X if (pwe=getpwuid(geteuid()))
X ptr = pwe->pw_name;
X else if ((ptr = getenv("USER")) == NULL) {
Xnoone: fprintf(stderr, "Can't find your logname. Who Are You?\n");
X fflush(stderr);
X exit(1);
X }
X if (ptr==NULL) goto noone;
X if (strlen(ptr)==0) goto noone;
X/*
X * second task is to prepare the pathnames the player will need
X */
X strcpy(loginname,ptr);
X
X /* save loginname of the user for logging purposes */
X strcpy(logname,ptr);
X
X /* this will be overwritten with the players name */
X if ((ptr = getenv("HOME")) == NULL)
X if ((ptr = pwe->pw_dir) == NULL)
X ptr = ".";
X
X /* save file name in home directory */
X strcpy(savefilename, ptr);
X strcat(savefilename, "/Ularn.sav");
X
X sprintf(optsfile, "%s/.Ularnopts",ptr); /* the .Ularnopts filename */
X strcat(scorefile, SCORENAME); /* the Ularn scoreboard filename */
X strcat(logfile, LOGFNAME);
X
X /* Ularn activity logging filename */
X strcat(helpfile, HELPNAME); /* the Ularn on-line help file */
X strcat(larnlevels, LEVELSNAME); /* the pre-made cave level data file */
X strcat(fortfile, FORTSNAME); /* the fortune data file name */
X/*
X * now malloc the memory for the dungeon
X */
Xcell = (struct cel *)malloc(sizeof(struct cel)*(MAXLEVEL+MAXVLEVEL)*MAXX*MAXY);
X
X if (cell == (struct cel *)NULL)
X died(-285); /* malloc failure */
X
X if ( ( lpbuf = malloc ((5* BUFBIG)>>2) ) == (char *)NULL)
X died(-285);
X
X if ( ( inbuffer = malloc( (5*MAXIBUF) >>2) ) == (char *)NULL)
X died(-285);
X
X lcreat((char*)0);
X newgame(); /* set the initial clock */
X hard= -1;
X
X/*
X * now make scoreboard if it is not there (don't clear)
X */
X if (access(scorefile,0) == -1) /* not there */
X makeboard();
X
X/*
X * now process the command line arguments
X */
X for (i=1; i<argc; i++) {
X if (argv[i][0] == '-')
X switch(argv[i][1]) {
X case 's': showscores();
X exit(0); /* show scoreboard */
X
X case 'i': showallscores();
X exit(0); /* show all scoreboard */
X
X case 'c': /*anyone with password can create scoreboard*/
X setupvt100();
X lprcat("Preparing to initialize the scoreboard.\n");
X if (getpassword() != 0) {
X makeboard();
X showscores();
X }
X exit(0);
X
X case 'n': nowelcome=1;
X argv[i][0]=0;
X break;
X
X case '0': case '1': case '2': case '3':
X case '4': case '5': case '6': case '7':
X case '8': case '9': /* for hardness */
X sscanf(&argv[i][1],"%d",&hard);
X if (hard > 100) hard = 100;
X break;
X
X case 'h': /* print out command line arguments */
X fprintf(stderr, "%s", cmdhelp);
X fflush(stderr);
X exit(0);
X case 'o': /* specify a .Ularnopts filename */
X strncpy(optsfile,argv[i]+2,127); break;
X default:
X fprintf(stderr,"Unknown option <%s>\n",argv[i]);
X fprintf(stderr,"%s", cmdhelp);
X fflush(stderr);
X exit(1);
X };
X if (argv[i][0] == '+') {
X clear(); restorflag = 1;
X if (argv[i][1] == '+') {
X hitflag=1;
X restoregame(ckpfile);
X /* restore checkpointed game */
X }
X i = argc;
X }
X }
X
X
X userid = geteuid(); /* obtain the user's effective id number */
X
X sigsetup(); /* trap all needed signals */
X sethard(hard); /* set up the desired difficulty */
X setupvt100(); /* setup the terminal special mode */
X readopts(); /* read the options file if there is one */
X
X /* restore game if need to */
X if (access(savefilename,0)==0) {
X clear();
X restorflag = 1;
X hitflag=1;
X restoregame(savefilename);
X }
X
X /* create new game */
X if (c[HP]==0) {
X makeplayer(); /* make the character that will play*/
X newcavelevel(0);/* make the dungeon */
X predostuff = 1;
X
X /* tell signals that we are in the welcome screen */
X if (nowelcome==0)
X welcome(); /* welcome the player to the game */
X }
X
X drawscreen(); /* show the initial dungeon */
X
X /* tell the trap functions that they must do a showplayer()
X from here on */
X predostuff = 2;
X
X yrepcount = hit2flag = 0;
X /*
X * M A I N L O O P
X */
X while (1) {
X if (dropflag==0)
X lookforobject(); /* see if there is an object here*/
X else
X dropflag=0; /* don't show it just dropped an item */
X
X if (hitflag==0) {
X if (c[HASTEMONST])
X movemonst();
X movemonst();
X } /* move the monsters */
X
X if (viewflag==0)
X showcell(playerx,playery);
X else viewflag=0; /* show stuff around player */
X
X if (hit3flag)
X flushall();
X hitflag = hit3flag = 0;
X nomove=1;
X bot_linex(); /* update bottom line */
X
X while (nomove)/* get commands and make moves */
X {
X if (hit3flag)
X flushall();
X nomove=0;
X parse();
X }
X
X regen(); /* regenerate hp and spells*/
X
X if (c[TIMESTOP]==0)
X if (--rmst <= 0) {
X rmst = 120-(level<<2);
X fillmonst(makemonst(level));
X }
X } /* end main loop */
X} /* end main */
X
X/*
X showstr()
X
X show character's inventory
X */
Xshowstr()
X{
X register int i,number;
X
X for (number=3, i=0; i<26; i++)
X if (iven[i]) number++; /* count items in inventory */
X t_setup(number);
X qshowstr();
X t_endup(number);
X}
X
Xqshowstr()
X{
X register int k,sigsav;
X
X srcount=0;
X sigsav=nosignal;
X nosignal=1; /* don't allow ^c etc */
X if (c[GOLD]) {
X lprintf(".) %d gold pieces",(long)c[GOLD]);
X srcount++;
X }
X
X for (k=0; k<=26; k++)
X if (iven[k]) show3(k);
X
X lprintf("\nElapsed time is %d. You have %d mobuls left",
X (long)((gtime+99)/100+1),(long)((TIMELIMIT-gtime)/100));
X more();
X nosignal=sigsav;
X}
X
X/*
X * subroutine to clear screen depending on # lines to display
X */
Xt_setup(count)
Xregister int count;
X{
X if (count<20) {
X cl_up(79,count);
X cursor(1,1);
X }
X else {
X resetscroll();
X clear();
X }
X}
X
X/*
X * subroutine to restore normal display screen depending on t_setup()
X */
Xt_endup(count)
Xregister int count;
X{
X if (count<18) /* how did we clear the screen? */
X draws(0,MAXX,0,(count>MAXY) ? MAXY : count);
X else {
X drawscreen();
X setscroll();
X }
X}
X
X/*
X function to show the things player is wearing only
X */
Xshowwear()
X{
X register int i,j,sigsav,count;
X
X sigsav=nosignal;
X nosignal=1; /* don't allow ^c etc */
X srcount=0;
X
X /* count number of items we will display */
X for (count=2,j=0; j<=26; j++)
X if (i=iven[j])
X switch(i) {
X case OLEATHER:
X case OPLATE:
X case OCHAIN:
X case ORING:
X case OSTUDLEATHER:
X case OSPLINT:
X case OPLATEARMOR:
X case OSSPLATE:
X case OSHIELD:
X case OELVENCHAIN:
X count++;
X };
X
X t_setup(count);
X
X for (i=22; i<93; i++)
X for (j=0; j<=26; j++)
X if (i==iven[j])
X switch(i) {
X case OLEATHER:
X case OPLATE:
X case OCHAIN:
X case ORING:
X case OSTUDLEATHER:
X case OSPLINT:
X case OPLATEARMOR:
X case OSSPLATE:
X case OSHIELD:
X case OELVENCHAIN:
X show3(j);
X };
X more();
X nosignal=sigsav;
X t_endup(count);
X}
X
X/*
X function to show the things player can wield only
X */
Xshowwield()
X{
X register int i,j,sigsav,count;
X sigsav=nosignal; nosignal=1; /* don't allow ^c etc */
X srcount=0;
X
X for (count=2,j=0; j<=26; j++) /* count how many items */
X if (i=iven[j])
X switch(i) {
X case ODIAMOND: case ORUBY: case OEMERALD:
X case OSAPPHIRE:
X case OBOOK: case OCHEST: case OLARNEYE:
X case ONOTHEFT:
X case OSPIRITSCARAB: case OCUBEofUNDEAD:
X case OPOTION:
X case OORB:
X case OHANDofFEAR:
X case OBRASSLAMP:
X case OURN:
X case OWWAND:
X case OSPHTALISMAN:
X case OSCROLL: break;
X default: count++;
X };
X
X t_setup(count);
X
X for (i=22; i<93; i++)
X for (j=0; j<=26; j++)
X if (i==iven[j])
X switch(i) {
X case ODIAMOND: case ORUBY:
X case OEMERALD: case OSAPPHIRE:
X case OBOOK: case OCHEST:
X case OLARNEYE: case ONOTHEFT:
X case OSPIRITSCARAB: case OCUBEofUNDEAD:
X case OPOTION: case OHANDofFEAR:
X case OBRASSLAMP: case OURN:
X case OSPHTALISMAN:
X case OWWAND:
X case OORB: case OSCROLL: break;
X default: show3(j);
X };
X more();
X nosignal=sigsav;
X t_endup(count);
X }
X
X/*
X * function to show the things player can read only
X */
Xshowread()
X {
X register int i,j,sigsav,count;
X sigsav=nosignal; nosignal=1; /* don't allow ^c etc */
X srcount=0;
X
X for (count=2,j=0; j<=26; j++)
X switch(iven[j]) {
X case OBOOK:
X case OSCROLL:
X count++;
X };
X t_setup(count);
X
X for (i=22; i<84; i++)
X for (j=0; j<=26; j++)
X if (i==iven[j])
X switch(i) {
X case OBOOK:
X case OSCROLL:
X show3(j);
X };
X more();
X nosignal=sigsav;
X t_endup(count);
X }
X
X/*
X * function to show the things player can eat only
X */
Xshoweat()
X{
X register int i,j,sigsav,count;
X
X sigsav=nosignal;
X nosignal=1; /* don't allow ^c etc */
X srcount=0;
X
X for (count=2,j=0; j<=26; j++)
X switch(iven[j]) {
X case OCOOKIE:
X count++;
X };
X t_setup(count);
X
X for (i=22; i<84; i++)
X for (j=0; j<=26; j++)
X if (i==iven[j])
X switch(i) {
X case OCOOKIE:
X show3(j);
X };
X more();
X nosignal=sigsav;
X t_endup(count);
X }
X
X/*
X function to show the things player can quaff only
X */
Xshowquaff()
X{
X register int i,j,sigsav,count;
X
X sigsav=nosignal;
X nosignal=1; /* don't allow ^c etc */
X srcount=0;
X
X for (count=2,j=0; j<=26; j++)
X switch(iven[j]) {
X case OPOTION:
X count++;
X };
X t_setup(count);
X
X for (i=22; i<84; i++)
X for (j=0; j<=26; j++)
X if (i==iven[j])
X switch(i) {
X case OPOTION:
X show3(j);
X };
X more();
X nosignal=sigsav;
X t_endup(count);
X}
X
Xshow1(idx,str2)
Xregister int idx;
Xregister char *str2[];
X{
X if (str2==0)
X lprintf("\n%c) %s",idx+'a',objectname[iven[idx]]);
X else if (*str2[ivenarg[idx]]==0)
X lprintf("\n%c) %s",idx+'a',objectname[iven[idx]]);
X else
X lprintf("\n%c) %s of%s",
X idx+'a',objectname[iven[idx]],str2[ivenarg[idx]]);
X}
X
Xshow3(index)
Xregister int index;
X{
X switch(iven[index]) {
X case OPOTION: show1(index,potionname); break;
X case OSCROLL: show1(index,scrollname); 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: show1(index,(char **)0); break;
X
X default:
X lprintf("\n%c) %s",index+'a',objectname[iven[index]]);
X if (ivenarg[index]>0)
X lprintf(" + %d",(long)ivenarg[index]);
X else if (ivenarg[index]<0)
X lprintf(" %d",(long)ivenarg[index]);
X break;
X }
X if (c[WIELD]==index)
X lprcat(" (weapon in hand)");
X if ((c[WEAR]==index) || (c[SHIELD]==index))
X lprcat(" (being worn)");
X if (++srcount>=22) {
X srcount=0;
X more();
X clear();
X }
X}
X
X/*
X subroutine to randomly create monsters if needed
X */
Xrandmonst()
X{ /* don't make monsters if time is stopped */
X if (c[TIMESTOP]) return;
X if (--rmst <= 0) {
X rmst = 120 - (level<<2);
X fillmonst(makemonst(level));
X }
X}
X
X
X/*
X parse()
X
X get and execute a command
X */
Xparse()
X{
X register int i,j,k,flag;
X while (1) {
X k = yylex();
X /* get the token from the input and switch on it */
X switch(k) {
X case 'A': if (wizard)
X diag();
X yrepcount=0;
X return;
X case 'h': moveplayer(4);
X return; /* west */
X case 'H': run(4);
X return; /* west */
X case 'l': moveplayer(2);
X return; /* east */
X case 'L': run(2);
X return; /* east */
X case 'j': moveplayer(1);
X return; /* south */
X case 'J': run(1);
X return; /* south */
X case 'k': moveplayer(3);
X return; /* north */
X case 'K': run(3);
X return; /* north */
X case 'u': moveplayer(5);
X return; /* northeast */
X case 'U': run(5);
X return; /* northeast */
X case 'y': moveplayer(6);
X return; /* northwest */
X case 'Y': run(6);
X return; /* northwest */
X case 'n': moveplayer(7);
X return; /* southeast */
X case 'N': run(7);
X return; /* southeast */
X case 'b': moveplayer(8);
X return; /* southwest */
X case 'B': run(8);
X return; /* southwest */
X
X case '.': if (yrepcount)
X viewflag=1;
X return; /* stay here */
X
X case 'w': yrepcount=0;
X wield();
X return; /* wield a weapon */
X
X case 'W': yrepcount=0;
X wear();
X return; /* wear armor */
X
X case 'r': yrepcount=0;
X if (c[BLINDCOUNT]) {
X cursors();
X lprcat("\nYou can't read anything when you're blind!");
X } else if (c[TIMESTOP]==0)
X readscr();
X return; /* to read a scroll */
X
X case 'q': yrepcount=0;
X if (c[TIMESTOP]==0)
X quaff();
X return; /* quaff a potion */
X
X case 'd': yrepcount=0;
X if (c[TIMESTOP]==0)
X dropobj();
X return; /* to drop an object */
X
X case 'c': yrepcount=0;
X cast();
X return; /* cast a spell */
X
X case 'i': yrepcount=0;
X nomove=1;
X showstr();
X return; /* status */
X
X case 'e': yrepcount=0;
X if (c[TIMESTOP]==0)
X eatcookie();
X return; /* to eat a fortune cookie */
X
X case 'D': yrepcount=0;
X seemagic(0);
X nomove=1;
X return; /*list spells and scrolls */
X
X case '?': yrepcount=0;
X help();
X nomove=1;
X return; /*give the help screen*/
X
X case 'S': clear();
X lprcat("Saving . . .");
X lflush();
X savegame(savefilename);
X wizard=1;
X died(-257);
X /* save the game -
X doesn't return */
X
X case 'Z': yrepcount=0;
X if (wizard) {
X int t;
X cursors();
X lprcat("\nWhich level do you wish to teleport to? ");
X t = readnum(20);
X if (t > 20 || t < 0) {
X lprcat(" sorry!");
X return;
X }
X playerx = rnd(MAXX-2);
X playery = rnd(MAXY-2);
X newcavelevel(t);
X positionplayer();
X draws(0,MAXX,0,MAXY);
X bot_linex();
X return;
X }
X if (c[LEVEL]>9) {
X oteleport(1);
X return;
X }
X cursors();
X lprcat("\nYou don't know how to teleport yet");
X return; /* teleport yourself */
X
X case '^': /* identify traps */
X flag=yrepcount=0;
X cursors();
X lprc('\n');
X for (j=playery-1; j<playery+2; j++) {
X if (j < 0) j=0;
X if (j >= MAXY) break;
X for (i=playerx-1; i<playerx+2; i++) {
X if (i < 0) i=0;
X if (i >= MAXX) break;
X switch(item[i][j]) {
X case OTRAPDOOR:
X case ODARTRAP:
X case OTRAPARROW:
X case OTELEPORTER:
X case OELEVATORUP:
X case OELEVATORDOWN:
X lprcat("\nIt's ");
X lprcat(objectname[item[i][j]]);
X flag++;
X };
X }
X }
X if (flag==0)
X lprcat("\nNo traps are visible");
X return;
X
X case '#':
X yrepcount=0;
X cursors();
X nomove=1;
X if (getpassword()==0) {
X scbr();
X return;
X }
X scbr();
X raiseexperience(370 * 1000000);
X bottomline();
X drawscreen();
X return;
X
X#if WIZID
X case '_': /*this is the fudge player password
X for wizard mode*/
X yrepcount=0;
X cursors();
X nomove=1;
X if (getpassword()==0) {
X scbr();
X return;
X }
X wizard=1;
X scbr();
X for (i=0; i<6; i++)
X c[i]=70;
X iven[0]=iven[1]=0;
X take(OPROTRING,50);
X take(OLANCE,25);
X for (i=0; i<26; i++)
X if (iven[i]==OLANCE && ivenarg[i]==25) {
X c[WIELD]=i;
X break;
X }
X c[LANCEDEATH]=1;
X c[WEAR] = c[SHIELD] = -1;
X raiseexperience(370*1000000);
X c[AWARENESS] += 25000;
X {
X register int i,j;
X for (i=0; i<MAXY; i++)
X for (j=0; j<MAXX; j++)
X know[j][i]=1;
X for (i=0; i<SPNUM; i++)
X spelknow[i]=1;
X for (i=0; i<MAXSCROLL; i++)
X scrollname[i][0]=' ';
X for (i=0; i<MAXPOTION; i++)
X potionname[i][0]=' ';
X }
X for (i=0; i<MAXSCROLL; i++)
X if (strlen(scrollname[i])>2)
X { item[i][0]=OSCROLL;
X iarg[i][0]=i;
X }
X for (i=MAXX-1; i>MAXX-1-MAXPOTION; i--)
X if (strlen(potionname[i-MAXX+MAXPOTION])>2)
X /* no null items */
X { item[i][0]=OPOTION;
X iarg[i][0]=i-MAXX+MAXPOTION;
X }
X for (i=1; i<MAXY; i++)
X { item[0][i]=i;
X iarg[0][i]=0;
X }
X for (i=MAXY; i<MAXY+MAXX; i++)
X { item[i-MAXY][MAXY-1]=i;
X iarg[i-MAXY][MAXY-1]=0;
X }
X for (i=MAXX+MAXY; i<MAXX+MAXY+MAXY; i++)
X { item[MAXX-1][i-MAXX-MAXY]=i;
X iarg[MAXX-1][i-MAXX-MAXY]=0;
X }
X c[GOLD]+=250000;
X bottomline();
X drawscreen();
X return;
X#endif /* WIZID */
X
X case 'T': yrepcount=0;
X cursors();
X if (c[SHIELD] != -1) {
X c[SHIELD] = -1;
X lprcat("\nYour shield is off");
X bottomline();
X } else
X if (c[WEAR] != -1) {
X c[WEAR] = -1;
X lprcat("\nYour armor is off");
X bottomline();
X }
X else lprcat("\nYou aren't wearing anything");
X return;
X
X case 'g': cursors();
X lprintf("\nThe stuff you are carrying presently weighs %d pounds",
X (long)packweight());
X
X case ' ': yrepcount=0;
X nomove=1;
X return;
X
X case 'v': yrepcount=0;
X cursors();
Xlprintf( "\nThe Addiction of Ularn, by Satyr. Difficulty : %d",
X (long)c[HARDGAME]);
X if (wizard) lprcat(" (WIZARD)");
X nomove=1;
X if (cheat) lprcat(" (Cheater)");
X lprcat(copyright);
X return;
X
X case 'Q': yrepcount=0;
X quit();
X nomove=1;
X return; /* quit */
X
X case 'L'-64: yrepcount=0;
X drawscreen();
X nomove=1;
X return; /* look */
X
X case 'P': cursors();
X if (outstanding_taxes>0)
X lprintf("\nYou presently owe %d gp in taxes.",(long)outstanding_taxes);
X else
X lprcat("\nYou do not owe any taxes.");
X return;
X };
X }
X}
X
Xparse2()
X{
X if (c[HASTEMONST])
X movemonst();
X movemonst(); /* move the monsters */
X randmonst();
X regen();
X}
X
Xrun(dir)
Xint dir;
X{
X register int i;
X i=1;
X while (i) {
X i=moveplayer(dir);
X if (i>0) {
X if (c[HASTEMONST])
X movemonst();
X movemonst();
X randmonst();
X regen();
X }
X if (hitflag) i=0;
X if (i!=0)
X showcell(playerx,playery);
X }
X}
X
X/*
X function to wield a weapon
X */
Xwield()
X{
X register int i;
X
X while (1) {
X if ((i = whatitem("wield"))=='\33') return;
X if (i != '.') {
X if (i=='*') showwield();
X else if (iven[i-'a']==0) { ydhi(i); return; }
X else if (iven[i-'a']==OPOTION) { ycwi(i); return; }
X else if (iven[i-'a']==OSCROLL) { ycwi(i); return; }
X else if ((c[SHIELD]!= -1) && (iven[i-'a']==O2SWORD)) {
X lprcat("\nBut one arm is busy with your shield!");
X return;
X }
X else {
X c[WIELD]=i-'a';
X if (iven[i-'a'] == OLANCE) c[LANCEDEATH]=1;
X else c[LANCEDEATH]=0;
X bottomline();
X return;
X }
X }
X }
X}
X
X/*
X common routine to say you don't have an item
X */
Xydhi(x)
Xint x;
X{ cursors(); lprintf("\nYou don't have item %c!",x); }
X
Xycwi(x)
Xint x;
X{ cursors(); lprintf("\nYou can't wield item %c!",x); }
X
X/*
X function to wear armor
X */
Xwear()
X{
X register int i;
X while (1) {
X if ((i = whatitem("wear"))=='\33') return;
X if (i != '.') {
X if (i=='*') showwear(); else
X switch(iven[i-'a']) {
X case 0: ydhi(i); return;
X case OLEATHER:
X case OCHAIN:
X case OPLATE:
X case OSTUDLEATHER:
X case ORING:
X case OSPLINT:
X case OPLATEARMOR:
X case OELVENCHAIN:
X case OSSPLATE:
X if (c[WEAR] != -1) {
X lprcat("\nYou're already wearing some armor");
X return; }
X c[WEAR]=i-'a';
X bottomline();
X return;
X
X case OSHIELD:
X if (c[SHIELD] != -1) {
X lprcat("\nYou are already wearing a shield");
X return;
X }
X if (iven[c[WIELD]]==O2SWORD) {
X lprcat("\nYour hands are busy with the two handed sword!");
X return;
X }
X c[SHIELD] = i-'a'; bottomline(); return;
X
X default: lprcat("\nYou can't wear that!");
X };
X }
X }
X}
X
X/*
X function to drop an object
X */
Xdropobj()
X{
X register int i;
X register char *p;
X long amt;
X
X p = &item[playerx][playery];
X while (1) {
X if ((i = whatitem("drop"))=='\33') return;
X if (i=='*')
X showstr();
X else {
X /* drop some gold */
X if (i=='.') {
X if (*p) {
X lprcat("\nThere's something here already!");
X return;
X }
X lprcat("\n\n");
X cl_dn(1,23);
X lprcat("How much gold do you drop? ");
X if ((amt=readnum((long)c[GOLD])) == 0) return;
X if (amt>c[GOLD]) {
X lprcat("\nYou don't have that much!");
X return;
X }
X if (amt<=32767) {
X *p=OGOLDPILE;
X i=amt;
X }
X else if (amt<=327670L) {
X *p=ODGOLD;
X i=amt/10;
X amt = 10*i;
X }
X else if (amt<=3276700L) {
X *p=OMAXGOLD;
X i=amt/100;
X amt = 100*i;
X }
X else if (amt<=32767000L) {
X *p=OKGOLD;
X i=amt/1000;
X amt = 1000*i;
X }
X else {
X *p=OKGOLD;
X i=32767;
X amt = 32767000L;
X }
X c[GOLD] -= amt;
X lprintf("You drop %d gold pieces",(long)amt);
X iarg[playerx][playery]=i;
X bottomgold();
X know[playerx][playery]=0;
X dropflag=1;
X return;
X }
X drop_object(i-'a');
X return;
X }
X }
X}
X
X/*
X * readscr() Subroutine to read a scroll one is carrying
X */
Xreadscr()
X {
X register int i;
X while (1) {
X if ((i = whatitem("read"))=='\33') return;
X if (i != '.') {
X if (i=='*') showread(); else {
X if (iven[i-'a']==OSCROLL) { read_scroll(ivenarg[i-'a']); iven[i-'a']=0; return; }
X if (iven[i-'a']==OBOOK) { readbook(ivenarg[i-'a']); iven[i-'a']=0; return; }
X if (iven[i-'a']==0) { ydhi(i); return; }
X lprcat("\nThere's nothing on it to read"); return;
X }
X }
X }
X }
X
X/*
X * subroutine to eat a cookie one is carrying
X */
Xeatcookie()
X{
X register int i;
X char *p;
X
X while (1) {
X if ((i = whatitem("eat"))=='\33')
X return;
X if (i != '.')
X if (i=='*') showeat(); else {
X if (iven[i-'a']==OCOOKIE) {
X lprcat("\nThe cookie was delicious.");
X iven[i-'a']=0;
X if (!c[BLINDCOUNT]) {
X if (p=fortune(fortfile)) {
X lprcat(" Inside you find a scrap of paper that says:\n");
X lprcat(p);
X }
X }
X return;
X }
X if (iven[i-'a']==0) { ydhi(i); return; }
X lprcat("\nYou can't eat that!"); return;
X }
X }
X}
X
X/*
X * subroutine to quaff a potion one is carrying
X */
Xquaff()
X{
X register int i;
X
X while (1) {
X if ((i = qwhatitem())=='\33') return;
X if (i != '.') {
X if (i=='*') showquaff();
X else {
X if (iven[i-'a']==OPOTION) {
X quaffpotion(ivenarg[i-'a']);
X iven[i-'a']=0;
X return;
X }
X if (iven[i-'a']==0) { ydhi(i); return; }
X lprcat("\nYou wouldn't want to quaff that, would you? ");
X return;
X }
X }
X }
X}
X
Xqwhatitem()
X{
X int j, i=0;
X char gack[26];
X
X cursors();
X for (j=0; j<=26; j++)
X switch(iven[j]) {
X case OPOTION: gack[i++] = j;
X };
X lprintf("\nWhat do you want to quaff [");
X if (i)
X for (j=0;j<i;j++)
X lprintf("%c",gack[j] + 'a');
X lprintf(" * for all] ?");
X i=0;
X while (i>'z' || (i<'a' && i!='*' && i!='\33' && i!='.'))
X i=getcharacter();
X if (i=='\33')
X lprcat(" aborted");
X return(i);
X}
X
X/*
X function to ask what player wants to do
X */
Xwhatitem(str)
Xchar *str;
X{
X register int j=0, flag=0, i=0;
X int wld=0, q=0, r=0, w=0, e=0, d=0;
X char gack[26];
X
X cursors();
X if (!strcmp(str, "wield")) wld = 1;
X else if (!strcmp(str, "quaff")) q = 1;
X else if (!strcmp(str, "read")) r = 1;
X else if (!strcmp(str, "wear")) w = 1;
X else if (!strcmp(str, "eat")) e = 1;
X else if (!strcmp(str, "drop")) d = 1;
X
X for (j=0; j<=26; j++) {
X switch(iven[j]) {
X case OSWORDofSLASHING :
X case OHAMMER:
X case OSWORD:
X case O2SWORD:
X case OSPEAR :
X case ODAGGER:
X case OBATTLEAXE:
X case OLONGSWORD:
X case OFLAIL:
X case OSLAYER :
X case OLANCE :
X flag = 1; break; /* wield */
X case OPOTION:
X flag = 2; break; /* quaff */
X case OSCROLL:
X flag = 3; break; /* read */
X case OPLATE :
X case OCHAIN:
X case OLEATHER :
X case ORING :
X case OSTUDLEATHER :
X case OSPLINT :
X case OPLATEARMOR :
X case OSSPLATE :
X case OSHIELD :
X case OELVENCHAIN :
X flag = 4; break; /* wear */
X case OCOOKIE:
X flag = 5; break; /* eat */
X default : flag = 0; break;
X }
X if (!d) switch (flag) {
X case 0 : break;
X case 1 : if (wld) gack[i++] = j;
X break;
X case 2 : if (q) gack[i++] = j;
X break;
X case 3 : if (r) gack[i++] = j;
X break;
X case 4 : if (w) gack[i++] = j;
X break;
X case 5 : if (e) gack[i++] = j;
X default : break;
X }
X else if (iven[j]) gack[i++] = j;
X }
X lprintf("\nWhat do you want to %s [", str);
X if (i) {
X for (j=0;j<i;j++)
X lprintf("%c",gack[j] + 'a');
X lprintf(" ");
X }
X lprintf("* for all] ?");
X i=0;
X while (i>'z' || (i<'a' && i!='*' && i!='\33' && i!='.'))
X i=getcharacter();
X if (i=='\33')
X lprcat(" aborted");
X return(i);
X}
X
X
X
X/*
X subroutine to get a number from the player
X and allow * to mean return amt, else return the number entered
X */
Xlong readnum(mx)
Xlong mx;
X{
X register int i;
X long amt=0;
X
X sncbr();
X if ((i=getcharacter()) == '*')
X amt = mx; /* allow him to say * for all gold */
X else while (i != '\n') {
X if (i=='\033') { scbr(); lprcat(" aborted"); return(0); }
X if ((i <= '9') && (i >= '0') && (amt<999999999))
X amt = amt*10+i-'0';
X i = getcharacter();
X }
X scbr();
X return(amt);
X}
END_OF_FILE
if test 26141 -ne `wc -c <'main.c'`; then
echo shar: \"'main.c'\" unpacked with wrong size!
fi
# end of 'main.c'
fi
echo shar: End of archive 5 \(of 8\).
cp /dev/null ark5isdone
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

Reply all
Reply to author
Forward
0 new messages