billr@saab.CNA.TEK.COM (Bill Randle) (04/24/91)
Submitted-by: routley@tle.ENET.DEC.COM (Kevin Routley) Posting-number: Volume 12, Issue 55 Archive-name: larn2/Part02 Supersedes: larn: Volume 11, Issue 84-94 Environment: Unix, VMS, MS-DOS, OS/2, termcap #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 2 (of 12)." # Contents: Makefile.unix global.c object.c # Wrapped by billr@saab on Tue Apr 23 13:50:28 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile.unix' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile.unix'\" else echo shar: Extracting \"'Makefile.unix'\" \(589 characters\) sed "s/^X//" >'Makefile.unix' <<'END_OF_FILE' X# XOBJ= action.o bill.o config.o create.o data.o diag.o display.o \ X fortune.o global.o help.o io.o iventory.o main.o monster.o \ X moreobj.o movem.o msdos.o nap.o object.o regen.o savelev.o \ X scores.o signal.o spells.o spheres.o store.o \ X tok.o vms.o X# X# X X# Add -DSIG_RTNS_INT to the CFLAGS line for older Unixes that return X# int ptr rather than void ptr from the call to signal(). X# XCFLAGS= -DBSD -D'LARNHOME="/usr/users/routley/larncc/"' X Xlarn123: $(OBJ) X cc -o larn123 $(OBJ) -ltermcap X X.c.o: X cc $(CFLAGS) -c $*.c X X.c: header.h larndefs.h player.h monsters.h objects.h patchlev.h X END_OF_FILE if test 589 -ne `wc -c <'Makefile.unix'`; then echo shar: \"'Makefile.unix'\" unpacked with wrong size! fi # end of 'Makefile.unix' fi if test -f 'global.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'global.c'\" else echo shar: Extracting \"'global.c'\" \(16992 characters\) sed "s/^X//" >'global.c' <<'END_OF_FILE' X/* global.c X * X * raiselevel() subroutine to raise the player one level X * loselevel() subroutine to lower the player by one level X * raiseexperience(x) subroutine to increase experience points X * loseexperience(x) subroutine to lose experience points X * losehp(x) subroutine to remove hit points from the player X * losemhp(x) subroutine to remove max # hit points from the player X * raisehp(x) subroutine to gain hit points X * raisemhp(x) subroutine to gain maximum hit points X * losemspells(x) subroutine to lose maximum spells X * raisemspells(x) subroutine to gain maximum spells X * makemonst(lev) function to return monster number for a randomly selected monster X * positionplayer() function to be sure player is not in a wall X * recalc() function to recalculate the armor class of the player X * quit() subroutine to ask if the player really wants to quit X * more() X * take() X * drop_object() X * enchantarmor() X * enchweapon() X * pocketfull() X * nearbymonst() X * stealsomething() X * emptyhanded() X * creategem() X * adjustcvalues() X * gettokstr() X * getpassword() X * getyn() X * packweight() X */ X X#include <ctype.h> X#include "header.h" X#include "larndefs.h" X#include "monsters.h" X#include "objects.h" X#include "player.h" X Xextern int score[],dropflag; Xextern short playerx,playery,lastnum; Xextern char cheat,level,monstnamelist[]; Xextern char lastmonst[],*what[],*who[]; Xextern char winner[]; Xextern char logname[],monstlevel[]; Xextern char sciv[SCORESIZE+1][26][2],*potionname[],*scrollname[]; X X#ifdef __STDC__ Xextern void show3( int ); X#else Xextern void show3(); X#endif X X/* X raiselevel() X X subroutine to raise the player one level X uses the skill[] array to find level boundarys X uses c[EXPERIENCE] c[LEVEL] X */ Xraiselevel() X { X if (c[LEVEL] < MAXPLEVEL) raiseexperience((long)(skill[c[LEVEL]]-c[EXPERIENCE])); X } X X/* X loselevel() X X subroutine to lower the players character level by one X */ Xloselevel() X { X if (c[LEVEL] > 1) loseexperience((long)(c[EXPERIENCE] - skill[c[LEVEL]-1] + 1)); X } X X/* X raiseexperience(x) X X subroutine to increase experience points X */ Xraiseexperience(x) X register long x; X { X register int i,tmp; X i=c[LEVEL]; c[EXPERIENCE]+=x; X while (c[EXPERIENCE] >= skill[c[LEVEL]] && (c[LEVEL] < MAXPLEVEL)) X { X tmp = (c[CONSTITUTION]-c[HARDGAME])>>1; X c[LEVEL]++; raisemhp((int)(rnd(3)+rnd((tmp>0)?tmp:1))); X raisemspells((int)rund(3)); X if (c[LEVEL] < 7-c[HARDGAME]) raisemhp((int)(c[CONSTITUTION]>>2)); X } X if (c[LEVEL] != i) X { X cursors(); X beep(); lprintf("\nWelcome to level %d",(long)c[LEVEL]); /* if we changed levels */ X } X bottomline(); X } X X/* X loseexperience(x) X X subroutine to lose experience points X */ Xloseexperience(x) X register long x; X { X register int i,tmp; X i=c[LEVEL]; c[EXPERIENCE]-=x; X if (c[EXPERIENCE] < 0) c[EXPERIENCE]=0; X while (c[EXPERIENCE] < skill[c[LEVEL]-1]) X { X if (--c[LEVEL] <= 1) c[LEVEL]=1; /* down one level */ X tmp = (c[CONSTITUTION]-c[HARDGAME])>>1; /* lose hpoints */ X losemhp((int)rnd((tmp>0)?tmp:1)); /* lose hpoints */ X if (c[LEVEL] < 7-c[HARDGAME]) losemhp((int)(c[CONSTITUTION]>>2)); X losemspells((int)rund(3)); /* lose spells */ X } X if (i!=c[LEVEL]) X { X cursors(); X beep(); lprintf("\nYou went down to level %d!",(long)c[LEVEL]); X } X bottomline(); X } X X/* X losehp(x) X losemhp(x) X X subroutine to remove hit points from the player X warning -- will kill player if hp goes to zero X */ Xlosehp(x) X register int x; X { X if ((c[HP] -= x) <= 0) X { X beep(); lprcat("\n"); nap(3000); died(lastnum); X } X } X Xlosemhp(x) X register int x; X { X c[HP] -= x; if (c[HP] < 1) c[HP]=1; X c[HPMAX] -= x; if (c[HPMAX] < 1) c[HPMAX]=1; X } X X/* X raisehp(x) X raisemhp(x) X X subroutine to gain maximum hit points X */ Xraisehp(x) X register int x; X { X if ((c[HP] += x) > c[HPMAX]) c[HP] = c[HPMAX]; X } X Xraisemhp(x) X register int x; X { X c[HPMAX] += x; c[HP] += x; X } X X/* X raisemspells(x) X X subroutine to gain maximum spells X*/ Xraisemspells(x) X register int x; X { X c[SPELLMAX]+=x; c[SPELLS]+=x; X } X X/* X losemspells(x) X X subroutine to lose maximum spells X*/ Xlosemspells(x) X register int x; X { X if ((c[SPELLMAX] -= x) < 0) c[SPELLMAX]=0; X if ((c[SPELLS] -= x) < 0) c[SPELLS]=0; X } X X/* X makemonst(lev) X int lev; X X function to return monster number for a randomly selected monster X for the given cave level X */ Xmakemonst(lev) X register int lev; X { X register int tmp,x; X if (lev < 1) X lev = 1; X if (lev > 12) X lev = 12; X if (lev < 5) X tmp=rnd((x=monstlevel[lev-1])?x:1); X else X tmp=rnd((x=monstlevel[lev-1]-monstlevel[lev-4])?x:1)+monstlevel[lev-4]; X X while (monster[tmp].genocided && tmp<MAXMONST) X tmp++; /* genocided? */ X return(tmp); X } X X/* X positionplayer() X X Insure player is not in a wall or on top of a monster. Could be more X intelligent about what kinds of objects the player can land on. X */ Xpositionplayer() X { X int z, try = 2; X X /* set the previous player x,y position to the new one, so that X clearing the player indicator from the previous location will X not do the wrong thing. X */ X oldx = playerx ; X oldy = playery ; X X /* short-circuit the testing if current position empty X */ X if (!item[playerx][playery] && X !mitem[playerx][playery]) X return; X X /* make at most two complete passes across the dungeon, looking X for a clear space. In most situations, should find a clear X spot right around the current player position. X */ X do X { X X /* check all around the player position for a clear space. X */ X for (z=1; z<9 ; z++) X { X int tmpx = playerx + diroffx[z]; X int tmpy = playery + diroffy[z]; X if (!item[tmpx][tmpy] && X !mitem[tmpx][tmpy]) X { X playerx = tmpx ; X playery = tmpy ; X return; X } X } X X /* no clear spots around the player. try another position, X wrapping around the dungeon. X */ X if (++playerx >= MAXX-1) X { X playerx = 1; X if (++playery >= MAXY-1) X { X playery = 1; X try--; X } X } X } X while (try); X X /* no spot found. X */ X lprcat("Failure in positionplayer\n"); X } X X/* X recalc() function to recalculate the armor class of the player X */ Xrecalc() X { X register int i,j,k; X c[AC] = c[MOREDEFENSES]; X if (c[WEAR] >= 0) X switch(iven[c[WEAR]]) X { X case OSHIELD: c[AC] += 2 + ivenarg[c[WEAR]]; break; X case OLEATHER: c[AC] += 2 + ivenarg[c[WEAR]]; break; X case OSTUDLEATHER: c[AC] += 3 + ivenarg[c[WEAR]]; break; X case ORING: c[AC] += 5 + ivenarg[c[WEAR]]; break; X case OCHAIN: c[AC] += 6 + ivenarg[c[WEAR]]; break; X case OSPLINT: c[AC] += 7 + ivenarg[c[WEAR]]; break; X case OPLATE: c[AC] += 9 + ivenarg[c[WEAR]]; break; X case OPLATEARMOR: c[AC] += 10 + ivenarg[c[WEAR]]; break; X case OSSPLATE: c[AC] += 12 + ivenarg[c[WEAR]]; break; X } X X if (c[SHIELD] >= 0) if (iven[c[SHIELD]] == OSHIELD) c[AC] += 2 + ivenarg[c[SHIELD]]; X if (c[WIELD] < 0) c[WCLASS] = 0; else X { X i = ivenarg[c[WIELD]]; X switch(iven[c[WIELD]]) X { X case ODAGGER: c[WCLASS] = 3 + i; break; X case OBELT: c[WCLASS] = 7 + i; break; X case OSHIELD: c[WCLASS] = 8 + i; break; X case OSPEAR: c[WCLASS] = 10 + i; break; X case OFLAIL: c[WCLASS] = 14 + i; break; X case OBATTLEAXE: c[WCLASS] = 17 + i; break; X case OLANCE: c[WCLASS] = 19 + i; break; X case OLONGSWORD: c[WCLASS] = 22 + i; break; X case O2SWORD: c[WCLASS] = 26 + i; break; X case OSWORD: c[WCLASS] = 32 + i; break; X case OSWORDofSLASHING: c[WCLASS] = 30 + i; break; X case OHAMMER: c[WCLASS] = 35 + i; break; X default: c[WCLASS] = 0; X } X } X c[WCLASS] += c[MOREDAM]; X X/* now for regeneration abilities based on rings */ X c[REGEN]=1; c[ENERGY]=0; X j=0; for (k=25; k>0; k--) if (iven[k]) {j=k; k=0; } X for (i=0; i<=j; i++) X { X switch(iven[i]) X { X case OPROTRING: c[AC] += ivenarg[i] + 1; break; X case ODAMRING: c[WCLASS] += ivenarg[i] + 1; break; X case OBELT: c[WCLASS] += ((ivenarg[i]<<1)) + 2; break; X X case OREGENRING: c[REGEN] += ivenarg[i] + 1; break; X case ORINGOFEXTRA: c[REGEN] += 5 * (ivenarg[i]+1); break; X case OENERGYRING: c[ENERGY] += ivenarg[i] + 1; break; X } X } X } X X X/* X quit() X X subroutine to ask if the player really wants to quit X */ Xquit() X { X register int i; X cursors(); strcpy(lastmonst,""); X lprcat("\n\nDo you really want to quit?"); X while (1) X { X i=ttgetch(); X if ((i == 'y') || (i == 'Y')) X { X died(300); X return; X } X if ((i == 'n') || (i == 'N') || (i == '\33')) X { X lprcat(" no"); X lflush(); X return; X } X lprcat("\n"); X setbold(); lprcat("Yes"); resetbold(); X lprcat(" or "); X setbold(); lprcat("No"); resetbold(); X lprcat(" please? Do you want to quit? "); X } X } X X/* X function to ask --more--. If the user enters a space, returns 0. If user X enters Escape, returns 1. If user enters alphabetic, then returns that X value. X */ Xmore(select_allowed) Xchar select_allowed; X { X register int i; X X lprcat("\n --- press "); standout("space"); lprcat(" to continue --- "); X if (select_allowed) X lprcat("letter to select --- "); X X while (TRUE) X { X if ((i=ttgetch()) == ' ' || i == '\n') X return 0 ; X if (i== '\x1B') X return 1 ; X if (select_allowed) X { X if (isupper(i)) X i = tolower(i); X if ( i >= 'a' && i <= 'z' || i == '.' ) X return i; X } X } X } X X/* X function to enchant armor player is currently wearing X */ Xenchantarmor() X { X register int tmp; X if (c[WEAR]<0) { if (c[SHIELD] < 0) X { cursors(); beep(); lprcat("\nYou feel a sense of loss"); return; } X else { tmp=iven[c[SHIELD]]; if (tmp != OSCROLL) if (tmp != OPOTION) { ivenarg[c[SHIELD]]++; bottomline(); } } } X tmp = iven[c[WEAR]]; X if (tmp!=OSCROLL) if (tmp!=OPOTION) { ivenarg[c[WEAR]]++; bottomline(); } X } X X/* X function to enchant a weapon presently being wielded X */ Xenchweapon() X { X register int tmp; X if (c[WIELD]<0) X { cursors(); beep(); lprcat("\nYou feel a sense of loss"); return; } X tmp = iven[c[WIELD]]; X if (tmp!=OSCROLL) if (tmp!=OPOTION) X { ivenarg[c[WIELD]]++; X if (tmp==OCLEVERRING) c[INTELLIGENCE]++; else X if (tmp==OSTRRING) c[STREXTRA]++; else X if (tmp==ODEXRING) c[DEXTERITY]++; bottomline(); } X } X X/* X function to return 1 if a monster is next to the player else returns 0 X */ Xnearbymonst() X { X register int tmp,tmp2; X for (tmp=playerx-1; tmp<playerx+2; tmp++) X for (tmp2=playery-1; tmp2<playery+2; tmp2++) X if (mitem[tmp][tmp2]) return(1); /* if monster nearby */ X return(0); X } X X/* X function to steal an item from the players pockets X returns 1 if steals something else returns 0 X */ Xstealsomething() X { X register int i,j; X j=100; X while (1) X { X i=rund(26); X if (iven[i]) if (c[WEAR]!=i) if (c[WIELD]!=i) if (c[SHIELD]!=i) X { X show3(i); X adjustcvalues(iven[i],ivenarg[i]); iven[i]=0; return(1); X } X if (--j <= 0) return(0); X } X } X X/* X function to return 1 is player carrys nothing else return 0 X */ Xemptyhanded() X { X register int i; X for (i=0; i<26; i++) X if (iven[i]) if (i!=c[WIELD]) if (i!=c[WEAR]) if (i!=c[SHIELD]) return(0); X return(1); X } X X/* X function to create a gem on a square near the player X */ Xcreategem() X { X register int i,j; X switch(rnd(4)) X { X case 1: i=ODIAMOND; j=50; break; X case 2: i=ORUBY; j=40; break; X case 3: i=OEMERALD; j=30; break; X default: i=OSAPPHIRE; j=20; break; X }; X createitem(i,rnd(j)+j/10); X } X X/* X function to change character levels as needed when dropping an object X that affects these characteristics X */ Xadjustcvalues(itm,arg) X int itm,arg; X { X register int flag; X flag=0; X switch(itm) X { X case ODEXRING: c[DEXTERITY] -= arg+1; flag=1; break; X case OSTRRING: c[STREXTRA] -= arg+1; flag=1; break; X case OCLEVERRING: c[INTELLIGENCE] -= arg+1; flag=1; break; X case OHAMMER: c[DEXTERITY] -= 10; c[STREXTRA] -= 10; X c[INTELLIGENCE] += 10; flag=1; break; X case OSWORDofSLASHING: c[DEXTERITY] -= 5; flag=1; break; X case OORBOFDRAGON: --c[SLAYING]; return; X case OSPIRITSCARAB: --c[NEGATESPIRIT]; return; X case OCUBEofUNDEAD: --c[CUBEofUNDEAD]; return; X case ONOTHEFT: --c[NOTHEFT]; return; X case OLANCE: c[LANCEDEATH]=0; return; X case OPOTION: case OSCROLL: return; X X default: flag=1; X }; X if (flag) bottomline(); X } X X/* X function to ask user for a password (no echo) X returns 1 if entered correctly, 0 if not X */ Xstatic char gpwbuf[33]; Xgetpassword() X { X register int i,j; X register char *gpwp; X extern char *password; X scbr(); /* system("stty -echo cbreak"); */ X gpwp = gpwbuf; lprcat("\nEnter Password: "); lflush(); X i = strlen(password); X for (j=0; j<i; j++) X *gpwp++ = ttgetch(); X gpwbuf[i]=0; X sncbr(); /* system("stty echo -cbreak"); */ X if (strcmp(gpwbuf,password) != 0) X { lprcat("\nSorry\n"); lflush(); return(0); } X else return(1); X } X X/* X subroutine to get a yes or no response from the user X returns y or n X */ Xgetyn() X { X register int i=0; X while (i!='y' && i!='n' && i!='\33') X i=ttgetch(); X return(i); X } X X/* X function to calculate the pack weight of the player X returns the number of pounds the player is carrying X */ Xpackweight() X { X register int i, j=25, k; X X k=c[GOLD]/1000; X while ((iven[j]==0) && (j>0)) X --j; X for (i=0; i<=j; i++) X switch(iven[i]) X { X case 0: X break; X case OSSPLATE: X case OPLATEARMOR: X k += 40; X break; X case OPLATE: X k += 35; X break; X case OHAMMER: X k += 30; X break; X case OSPLINT: X k += 26; X break; X case OSWORDofSLASHING: X case OCHAIN: X case OBATTLEAXE: X case O2SWORD: X k += 23; X break; X case OLONGSWORD: X case OSWORD: X case ORING: X case OFLAIL: X k += 20; X break; X case OLANCE: X case OSTUDLEATHER: X k += 15; X break; X case OLEATHER: X case OSPEAR: X k += 8; X break; X case OORBOFDRAGON: X case OBELT: X k += 4; X break; X case OSHIELD: X k += 7; X break; X case OCHEST: X k += 30 + ivenarg[i]; X break; X default: X k++; X break; X }; X return(k); X } X X#ifndef MACRORND X /* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */ Xrnd(x) X int x; X { X return((((lrandx=lrandx*1103515245+12345)>>7)%(x))+1); X } X Xrund(x) X int x; X { X return((((lrandx=lrandx*1103515245+12345)>>7)%(x)) ); X } X#endif MACRORND X X#if 0 X/* X function to read a string from token input "string" X returns a pointer to the string X */ Xgettokstr(str) X register char *str; X { X register int i,j; X i=50; X while ((ttgetch() != '"') && (--i > 0)); X i=36; X while (--i > 0) X { X if ((j=ttgetch()) != '"') *str++ = j; else i=0; X } X *str = 0; X i=50; X if (j != '"') while ((ttgetch() != '"') && (--i > 0)); /* if end due to too long, then find closing quote */ X } X#endif END_OF_FILE if test 16992 -ne `wc -c <'global.c'`; then echo shar: \"'global.c'\" unpacked with wrong size! fi # end of 'global.c' fi if test -f 'object.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'object.c'\" else echo shar: Extracting \"'object.c'\" \(33382 characters\) sed "s/^X//" >'object.c' <<'END_OF_FILE' X/* object.c */ X#include "header.h" X#include "larndefs.h" X#include "monsters.h" X#include "objects.h" X#include "player.h" X X#define min(x,y) (((x)>(y))?(y):(x)) X#define max(x,y) (((x)>(y))?(x):(y)) X X/* LOOK_FOR_OBJECT X subroutine to look for an object and give the player his options if an object X was found. X*/ Xlookforobject(do_ident, do_pickup, do_action) X char do_ident; /* identify item: T/F */ X char do_pickup; /* pickup item: T/F */ X char do_action; /* prompt for actions on object: T/F */ X{ X register int i, j; X X /* can't find objects if time is stopped */ X if (c[TIMESTOP]) X return; X i = item[playerx][playery]; X if (i == 0) X return; X j = iarg[playerx][playery]; X showcell(playerx, playery); X cursors(); X yrepcount = 0; X switch (i) X { X case OGOLDPILE: X case OMAXGOLD: X case OKGOLD: X case ODGOLD: X lprcat("\n\nYou have found some gold!"); X ogold(i); X break; X X case OPOTION: X if (do_ident) X { X lprcat("\n\nYou have found a magic potion"); X if (potionname[j][0]) X lprintf(" of %s", &potionname[j][1]); X } X if (do_pickup) X if (take(OPOTION, j) == 0) X forget(); X if (do_action) X opotion(j); X break; X X case OSCROLL: X if (do_ident) X { X lprcat("\n\nYou have found a magic scroll"); X if (scrollname[j][0]) X lprintf(" of %s", &scrollname[j][1]); X } X if (do_pickup) X if (take(OSCROLL, j) == 0) X forget(); X if (do_action) X oscroll(j); X break; X X case OALTAR: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\n\nThere is a Holy Altar here!"); X if (do_action) X oaltar(); X break; X X case OBOOK: X if (do_ident) X lprcat("\n\nYou have found a book."); X if (do_pickup) X if (take(OBOOK, j) == 0) X forget(); X if (do_action) X obook(); X break; X X case OCOOKIE: X if (do_ident) X lprcat("\n\nYou have found a fortune cookie."); X if (do_pickup) X if (take(OCOOKIE, 0) == 0) X forget(); X if (do_action) X ocookie(); X break; X X case OTHRONE: X if (nearbymonst()) X return; X if (do_ident) X lprintf("\n\nThere is %s here!", objectname[i]); X if (do_action) X othrone(0); X break; X X case OTHRONE2: X if (nearbymonst()) X return; X if (do_ident) X lprintf("\n\nThere is %s here!", objectname[i]); X if (do_action) X othrone(1); X break; X X case ODEADTHRONE: X if (do_ident) X lprintf("\n\nThere is %s here!", objectname[i]); X if (do_action) X odeadthrone(); X break; X X case OPIT: X /* always perform these actions. */ X lprcat("\n\nYou're standing at the top of a pit."); X opit(); X break; X X case OSTAIRSUP: /* up */ X if (do_ident) X lprcat("\n\nThere is a circular staircase here"); X if (do_action) X ostairs(1); X break; X X case OFOUNTAIN: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\n\nThere is a fountain here"); X if (do_action) X ofountain(); X break; X X case OSTATUE: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\n\nYou are standing in front of a statue"); X if (do_action) X ostatue(); X break; X X case OCHEST: X if (do_ident) X lprcat("\n\nThere is a chest here"); X if (do_pickup) X if (take(OCHEST, j) == 0) X forget(); X if (do_action) X ochest(); X break; X X case OSCHOOL: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\n\nYou have found the College of Larn."); X if (do_action) X prompt_enter(); X break; X X case OMIRROR: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\n\nThere is a mirror here"); X if (do_action) X omirror(); X break; X X case OBANK2: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\n\nYou have found a branch office of the bank of Larn."); X if (do_action) X prompt_enter(); X break; X X case OBANK: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\n\nYou have found the bank of Larn."); X if (do_action) X prompt_enter(); X break; X X case ODEADFOUNTAIN: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\n\nThere is a dead fountain here"); X break; X X case ODNDSTORE: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\n\nThere is a DND store here."); X if (do_action) X prompt_enter(); X break; X X case OSTAIRSDOWN: /* down */ X if (do_ident) X lprcat("\n\nThere is a circular staircase here"); X if (do_action) X ostairs(-1); X break; X X case OOPENDOOR: X if (do_ident) X lprintf("\n\nYou have found %s", objectname[i]); X if (do_action) X o_open_door(); X break; X X case OCLOSEDDOOR: X if (do_ident) X lprintf("\n\nYou have found %s", objectname[i]); X if (do_action) X o_closed_door(); X break; X X case OENTRANCE: X if (do_ident) X lprcat("\nYou have found "); X lprcat(objectname[i]); X if (do_action) X prompt_enter(); X break; X X case OVOLDOWN: X if (do_ident) X lprcat("\nYou have found "); X lprcat(objectname[i]); X if (do_action) X prompt_volshaft(-1); X break; X X case OVOLUP: X if (do_ident) X lprcat("\nYou have found "); X lprcat(objectname[i]); X if (do_action) X prompt_volshaft(1); X break; X X case OIVTELETRAP: X if (rnd(11) < 6) X return; X item[playerx][playery] = OTELEPORTER; X know[playerx][playery] = KNOWALL; X /* fall through to OTELEPORTER case below!!! */ X X case OTELEPORTER: X lprcat("\nZaaaappp! You've been teleported!\n"); X beep(); X nap(3000); X oteleport(0); X break; X X case OTRAPARROWIV: /* for an arrow trap */ X if (rnd(17) < 13) X return; X item[playerx][playery] = OTRAPARROW; X know[playerx][playery] = 0; X /* fall through to OTRAPARROW case below!!! */ X X case OTRAPARROW: X lprcat("\nYou are hit by an arrow"); X beep(); X lastnum = 259; X losehp(rnd(10) + level); X bottomhp(); X return; X X case OIVDARTRAP: /* for a dart trap */ X if (rnd(17) < 13) X return; X item[playerx][playery] = ODARTRAP; X know[playerx][playery] = 0; X /* fall through to ODARTTRAP case below!!! */ X X case ODARTRAP: X lprcat("\nYou are hit by a dart"); X beep(); /* for a dart trap */ X lastnum = 260; X losehp(rnd(5)); X if ((--c[STRENGTH]) < 3) X c[STRENGTH] = 3; X bottomline(); X return; X X case OIVTRAPDOOR: /* for a trap door */ X if (rnd(17) < 13) X return; X item[playerx][playery] = OTRAPDOOR; X know[playerx][playery] = KNOWALL; X /* fall through to OTRAPDOOR case below!!! */ X X case OTRAPDOOR: X lastnum = 272; /* a trap door */ X if ((level == MAXLEVEL - 1) || (level == MAXLEVEL + MAXVLEVEL - 1)) X { X lprcat("\nYou fell through a bottomless trap door!"); X beep(); X nap(3000); X died(271); X } X i = rnd(5 + level); X lprintf("\nYou fall through a trap door! You lose %d hit points.", (long) i); X beep(); X losehp(i); X nap(2000); X newcavelevel(level + 1); X draws(0, MAXX, 0, MAXY); X bot_linex(); X return; X X case OTRADEPOST: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\nYou have found the Larn trading Post."); X if (do_action) X prompt_enter(); X return; X X case OHOME: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\nYou have found your way home."); X if (do_action) X prompt_enter(); X return; X X case OWALL: X break; X X case OANNIHILATION: X died(283); /* annihilated by sphere of annihilation */ X return; X X case OLRS: X if (nearbymonst()) X return; X if (do_ident) X lprcat("\n\nThere is an LRS office here."); X if (do_action) X prompt_enter(); X break; X X default: X if (do_ident) X { X lprintf("\n\nYou have found %s ", objectname[i]); X switch (i) X { X case ODIAMOND: X case ORUBY: X case OEMERALD: X case OSAPPHIRE: X case OSPIRITSCARAB: X case OORBOFDRAGON: X case OCUBEofUNDEAD: X case ONOTHEFT: X break; X X default: X if (j > 0) X lprintf("+ %d", (long) j); X else X if (j < 0) X lprintf(" %d", (long) j); X break; X } X } X if (do_pickup) X if (take(i, j) == 0) X forget(); X if (do_action) X { X char tempc = 0; X X lprcat("\nDo you want to (t) take it"); X iopts(); X while (tempc != 't' && tempc != 'i' && tempc != '\33') X tempc = ttgetch(); X if (tempc == 't') X { X lprcat("take"); X if (take(i, j) == 0) X forget(); X return; X } X ignore(); X } X break; X }; X} X X X/* X * subroutine to process the stair cases if dir > 0 the up else down X */ Xstatic ostairs(dir) X int dir; X{ X register int k; X lprcat("\nDo you (s) stay here "); X if (dir > 0) X lprcat("or (u) go up? "); X else X lprcat("or (d) go down? "); X X while (1) X switch (ttgetch()) X { X case '\33': X case 's': X case 'i': X lprcat("stay here"); X return; X X case 'u': X lprcat("go up"); X act_up_stairs(); X return; X X case 'd': X lprcat("go down"); X act_down_stairs(); X return; X }; X} X X X X/* X * subroutine to handle a teleport trap +/- 1 level maximum X */ Xoteleport(err) X int err; X{ X register int tmp; X if (err) X if (rnd(151) < 3) X died(264); /* stuck in a rock */ X c[TELEFLAG] = 1; /* show ?? on bottomline if been teleported */ X if (level == 0) X tmp = 0; X else X if (level < MAXLEVEL) X { X tmp = rnd(5) + level - 3; X if (tmp >= MAXLEVEL) X tmp = MAXLEVEL - 1; X if (tmp < 1) X tmp = 1; X } else X { X tmp = rnd(3) + level - 2; X if (tmp >= MAXLEVEL + MAXVLEVEL) X tmp = MAXLEVEL + MAXVLEVEL - 1; X if (tmp < MAXLEVEL) X tmp = MAXLEVEL; X } X playerx = rnd(MAXX - 2); X playery = rnd(MAXY - 2); X if (level != tmp) X newcavelevel(tmp); X positionplayer(); X draws(0, MAXX, 0, MAXY); X bot_linex(); X} X X X/* X * function to process a potion X */ Xstatic opotion(pot) X int pot; X{ X lprcat("\nDo you (d) drink it, (t) take it"); X iopts(); X while (1) X switch (ttgetch()) X { X case '\33': X case 'i': X ignore(); X return; X X case 'd': X lprcat("drink\n"); X forget(); /* destroy potion */ X quaffpotion(pot, TRUE); X return; X X case 't': X lprcat("take\n"); X if (take(OPOTION, pot) == 0) X forget(); X return; X }; X} X X/* X * function to drink a potion X * X * Also used to perform the action of a potion without quaffing a potion (see X * invisible capability when drinking from a fountain). X */ Xquaffpotion(pot, set_known) X int pot; X int set_known; X{ X register int i, j, k; X X /* check for within bounds */ X if (pot < 0 || pot >= MAXPOTION) X return; X X /* X * if player is to know this potion (really quaffing one), make it X * known X */ X if (set_known) X potionname[pot][0] = ' '; X X switch (pot) X { X case 0: X lprcat("\nYou fall asleep. . ."); X i = rnd(11) - (c[CONSTITUTION] >> 2) + 2; X while (--i > 0) X { X parse2(); X nap(1000); X } X cursors(); X lprcat("\nYou woke up!"); X return; X X case 1: X lprcat("\nYou feel better"); X if (c[HP] == c[HPMAX]) X raisemhp(1); X else X if ((c[HP] += rnd(20) + 20 + c[LEVEL]) > c[HPMAX]) X c[HP] = c[HPMAX]; X break; X X case 2: X lprcat("\nSuddenly, you feel much more skillful!"); X raiselevel(); X raisemhp(1); X return; X X case 3: X lprcat("\nYou feel strange for a moment"); X c[rund(6)]++; X break; X X case 4: X lprcat("\nYou feel more self confident!"); X c[WISDOM] += rnd(2); X break; X X case 5: X lprcat("\nWow! You feel great!"); X if (c[STRENGTH] < 12) X c[STRENGTH] = 12; X else X c[STRENGTH]++; X break; X X case 6: X lprcat("\nYour charm went up by one!"); X c[CHARISMA]++; X break; X X case 7: X lprcat("\nYou become dizzy!"); X if (--c[STRENGTH] < 3) X c[STRENGTH] = 3; X break; X X case 8: X lprcat("\nYour intelligence went up by one!"); X c[INTELLIGENCE]++; X break; X X case 9: X lprcat("\nYou sense the presence of objects!"); X nap(1000); X if (c[BLINDCOUNT]) X return; X for (i = 0; i < MAXY; i++) X for (j = 0; j < MAXX; j++) X switch (item[j][i]) X { 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 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 OLANCE: X case ORINGOFEXTRA: X case OREGENRING: X case OPROTRING: X case OENERGYRING: X case ODEXRING: X case OSTRRING: X case OCLEVERRING: X case ODAMRING: X case OBELT: X case OSCROLL: X case OPOTION: X case OBOOK: X case OCHEST: X case OAMULET: X case OORBOFDRAGON: X case OSPIRITSCARAB: X case OCUBEofUNDEAD: X case ONOTHEFT: X case OCOOKIE: X know[j][i] = HAVESEEN; X show1cell(j, i); X break; X } X showplayer(); X return; X X case 10: /* monster detection */ X lprcat("\nYou detect the presence of monsters!"); X nap(1000); X if (c[BLINDCOUNT]) X return; X for (i = 0; i < MAXY; i++) X for (j = 0; j < MAXX; j++) X if (mitem[j][i] && (monstnamelist[mitem[j][i]] != floorc)) X { X know[j][i] = HAVESEEN; X show1cell(j, i); X } X return; X X case 11: X lprcat("\nYou stagger for a moment . ."); X for (i = 0; i < MAXY; i++) X for (j = 0; j < MAXX; j++) X know[j][i] = 0; X nap(1000); X draws(0, MAXX, 0, MAXY); /* potion of forgetfulness */ X return; X X case 12: X lprcat("\nThis potion has no taste to it"); X return; X X case 13: X lprcat("\nYou can't see anything!"); /* blindness */ X c[BLINDCOUNT] += 500; X return; X X case 14: X lprcat("\nYou feel confused"); X c[CONFUSE] += 20 + rnd(9); X return; X X case 15: X lprcat("\nWOW!!! You feel Super-fantastic!!!"); X if (c[HERO] == 0) X for (i = 0; i < 6; i++) X c[i] += 11; X c[HERO] += 250; X break; X X case 16: X lprcat("\nYou have a greater intestinal constitude!"); X c[CONSTITUTION]++; X break; X X case 17: X lprcat("\nYou now have incredibly bulging muscles!!!"); X if (c[GIANTSTR] == 0) X c[STREXTRA] += 21; X c[GIANTSTR] += 700; X break; X X case 18: X lprcat("\nYou feel a chill run up your spine!"); X c[FIRERESISTANCE] += 1000; X break; X X case 19: X lprcat("\nYou feel greedy . . ."); X nap(1000); X if (c[BLINDCOUNT]) X return; X for (i = 0; i < MAXY; i++) X for (j = 0; j < MAXX; j++) X { X k = item[j][i]; X if ((k == ODIAMOND) || X (k == ORUBY) || X (k == OEMERALD) || X (k == OMAXGOLD) || X (k == OSAPPHIRE) || X (k == OLARNEYE) || X (k == OGOLDPILE)) X { X know[j][i] = HAVESEEN; X show1cell(j, i); X } X } X showplayer(); X return; X X case 20: X c[HP] = c[HPMAX]; X break; /* instant healing */ X X case 21: X lprcat("\nYou don't seem to be affected"); X return; /* cure dianthroritis */ X X case 22: X lprcat("\nYou feel a sickness engulf you"); /* poison */ X c[HALFDAM] += 200 + rnd(200); X return; X X case 23: X lprcat("\nYou feel your vision sharpen"); /* see invisible */ X c[SEEINVISIBLE] += rnd(1000) + 400; X monstnamelist[INVISIBLESTALKER] = 'I'; X return; X }; X bottomline(); /* show new stats */ X return; X} X X X/* X * function to process a magic scroll X */ Xstatic oscroll(typ) X int typ; X{ X lprcat("\nDo you "); X if (c[BLINDCOUNT] == 0) X lprcat("(r) read it, "); X lprcat("(t) take it"); X iopts(); X while (1) X switch (ttgetch()) X { X case '\33': X case 'i': X ignore(); X return; X X case 'r': X if (c[BLINDCOUNT]) X break; X lprcat("read"); X forget(); X if (typ == 2 || typ == 15) X { X show1cell(playerx, playery); X cursors(); X } X /* destroy it */ read_scroll(typ); X return; X X case 't': X lprcat("take"); X if (take(OSCROLL, typ) == 0) X forget(); /* destroy it */ X return; X }; X} X X/* X * data for the function to read a scroll X */ Xstatic int xh, yh, yl, xl; Xstatic char curse[] = {BLINDCOUNT, CONFUSE, AGGRAVATE, HASTEMONST, ITCHING, X LAUGHING, DRAINSTRENGTH, CLUMSINESS, INFEEBLEMENT, X HALFDAM}; Xstatic char exten[] = {PROTECTIONTIME, DEXCOUNT, STRCOUNT, CHARMCOUNT, X INVISIBILITY, CANCELLATION, HASTESELF, GLOBE, X SCAREMONST, HOLDMONST, TIMESTOP}; Xstatic char time_change[] = {HASTESELF, HERO, ALTPRO, PROTECTIONTIME, DEXCOUNT, X STRCOUNT, GIANTSTR, CHARMCOUNT, INVISIBILITY, X CANCELLATION,HASTESELF, AGGRAVATE, SCAREMONST, X STEALTH, AWARENESS, HOLDMONST, HASTEMONST, X FIRERESISTANCE, GLOBE, SPIRITPRO, UNDEADPRO, X HALFDAM, SEEINVISIBLE, ITCHING, CLUMSINESS, WTW}; X/* X * function to adjust time when time warping and taking courses in school X */ Xadjtime(tim) X register long tim; X{ X register int j; X for (j = 0; j < 26; j++)/* adjust time related parameters */ X if (c[time_change[j]]) X if ((c[time_change[j]] -= tim) < 1) X c[time_change[j]] = 1; X regen(); X} X X/* X * function to read a scroll X */ Xread_scroll(typ) X int typ; X{ X register int i, j; X if (typ < 0 || typ >= MAXSCROLL) X return; /* be sure we are within bounds */ X scrollname[typ][0] = ' '; X switch (typ) X { X case 0: X lprcat("\nYour armor glows for a moment"); X enchantarmor(); X return; X X case 1: X lprcat("\nYour weapon glows for a moment"); X enchweapon(); X return; /* enchant weapon */ X X case 2: X lprcat("\nYou have been granted enlightenment!"); X yh = min(playery + 7, MAXY); X xh = min(playerx + 25, MAXX); X yl = max(playery - 7, 0); X xl = max(playerx - 25, 0); X for (i = yl; i < yh; i++) X for (j = xl; j < xh; j++) X know[j][i] = KNOWALL; X draws(xl, xh, yl, yh); X return; X X case 3: X lprcat("\nThis scroll seems to be blank"); X return; X X case 4: X createmonster(makemonst(level + 1)); X return; /* this one creates a monster */ X X case 5: X something(level); /* create artifact */ X return; X X case 6: X c[AGGRAVATE] += 800; X return; /* aggravate monsters */ X X case 7: X gtime += (i = rnd(1000) - 850); /* time warp */ X if (i >= 0) X lprintf("\nYou went forward in time by %d mobuls", (long) ((i + 99) / 100)); X else X lprintf("\nYou went backward in time by %d mobuls", (long) (-(i + 99) / 100)); X adjtime((long) i); /* adjust time for time warping */ X return; X X case 8: X oteleport(0); X return; /* teleportation */ X X case 9: X c[AWARENESS] += 1800; X return; /* expanded awareness */ X X case 10: X c[HASTEMONST] += rnd(55) + 12; X return; /* haste monster */ X X case 11: X for (i = 0; i < MAXY; i++) X for (j = 0; j < MAXX; j++) X if (mitem[j][i]) X hitp[j][i] = monster[mitem[j][i]].hitpoints; X return; /* monster healing */ X case 12: X c[SPIRITPRO] += 300 + rnd(200); X bottomline(); X return; /* spirit protection */ X X case 13: X c[UNDEADPRO] += 300 + rnd(200); X bottomline(); X return; /* undead protection */ X X case 14: X c[STEALTH] += 250 + rnd(250); X bottomline(); X return; /* stealth */ X X case 15: X lprcat("\nYou have been granted enlightenment!"); /* magic mapping */ X for (i = 0; i < MAXY; i++) X for (j = 0; j < MAXX; j++) X know[j][i] = KNOWALL; X draws(0, MAXX, 0, MAXY); X return; X X case 16: X c[HOLDMONST] += 30; X bottomline(); X return; /* hold monster */ X X case 17: X for (i = 0; i < 26; i++) /* gem perfection */ X switch (iven[i]) X { X case ODIAMOND: X case ORUBY: X case OEMERALD: X case OSAPPHIRE: X j = ivenarg[i]; X j &= 255; X j <<= 1; X if (j > 255) X j = 255; /* double value */ X ivenarg[i] = j; X break; X } X break; X X case 18: X for (i = 0; i < 11; i++) X c[exten[i]] <<= 1; /* spell extension */ X break; X X case 19: X for (i = 0; i < 26; i++) /* identify */ X { X if (iven[i] == OPOTION) X potionname[ivenarg[i]][0] = ' '; X if (iven[i] == OSCROLL) X scrollname[ivenarg[i]][0] = ' '; X } X break; X X case 20: X for (i = 0; i < 10; i++) /* remove curse */ X if (c[curse[i]]) X c[curse[i]] = 1; X break; X X case 21: X annihilate(); X break; /* scroll of annihilation */ X X case 22: X godirect(22, 150, "The ray hits the %s", 0, ' '); /* pulverization */ X break; X case 23: X c[LIFEPROT]++; X break; /* life protection */ X }; X} X Xstatic opit() X{ X register int i; X if (rnd(101) < 81) X if (rnd(70) > 9 * c[DEXTERITY] - packweight() || rnd(101) < 5) X if (level == MAXLEVEL - 1) X obottomless(); X else X if (level == MAXLEVEL + MAXVLEVEL - 1) X obottomless(); X else X { X if (rnd(101) < 20) X { X i = 0; X lprcat("\nYou fell into a pit! Your fall is cushioned by an unknown force\n"); X } else X { X i = rnd(level * 3 + 3); X lprintf("\nYou fell into a pit! You suffer %d hit points damage", (long) i); X lastnum = 261; /* if he dies scoreboard X * will say so */ X } X losehp(i); X nap(2000); X newcavelevel(level + 1); X draws(0, MAXX, 0, MAXY); X } X} X Xstatic obottomless() X{ X lprcat("\nYou fell into a bottomless pit!"); X beep(); X nap(3000); X died(262); X} X Xstatic ostatue() X{ X} X Xstatic omirror() X{ X} X Xstatic obook() X{ X lprcat("\nDo you "); X if (c[BLINDCOUNT] == 0) X lprcat("(r) read it, "); X lprcat("(t) take it"); X iopts(); X while (1) X switch (ttgetch()) X { X case '\33': X case 'i': X ignore(); X return; X X case 'r': X if (c[BLINDCOUNT]) X break; X lprcat("read"); X /* no more book */ readbook(iarg[playerx][playery]); X forget(); X return; X X case 't': X lprcat("take"); X if (take(OBOOK, iarg[playerx][playery]) == 0) X forget(); /* no more book */ X return; X }; X} X X/* X * function to read a book X */ Xreadbook(lev) X register int lev; X{ X register int i, tmp; X if (lev <= 3) X i = rund((tmp = splev[lev]) ? tmp : 1); X else X i = rnd((tmp = splev[lev] - 9) ? tmp : 1) + 9; X spelknow[i] = 1; X lprintf("\nSpell \"%s\": %s\n%s", spelcode[i], spelname[i], speldescript[i]); X if (rnd(10) == 4) X { X lprcat("\nYour int went up by one!"); X c[INTELLIGENCE]++; X bottomline(); X } X} X Xstatic ocookie() X{ X char *p; X lprcat("\nDo you (e) eat it, (t) take it"); X iopts(); X while (1) X switch (ttgetch()) X { X case '\33': X case 'i': X ignore(); X return; X X case 'e': X lprcat("eat"); X forget(); /* no more cookie */ X outfortune(); X return; X X case 't': X lprcat("take"); X if (take(OCOOKIE, 0) == 0) X forget(); /* no more book */ X return; X }; X} X X/* X * routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth X * 100* the argument X */ Xstatic ogold(arg) X int arg; X{ X register long i; X i = iarg[playerx][playery]; X if (arg == OMAXGOLD) X i *= 100; X else X if (arg == OKGOLD) X i *= 1000; X else X if (arg == ODGOLD) X i *= 10; X lprintf("\nIt is worth %d!", (long) i); X c[GOLD] += i; X bottomgold(); X item[playerx][playery] = know[playerx][playery] = 0; /* destroy gold */ X} X Xohome() X{ X register int i; X nosignal = 1; /* disable signals */ X for (i = 0; i < 26; i++) X if (iven[i] == OPOTION) X if (ivenarg[i] == 21) X { X iven[i] = 0; /* remove the potion of cure X * dianthroritis from X * inventory */ X clear(); X lprcat("Congratulations. You found a potion of cure dianthroritis.\n"); X lprcat("\nFrankly, No one thought you could do it. Boy! Did you surprise them!\n"); X if (gtime > TIMELIMIT) X { X lprcat("\nThe doctor has the sad duty to inform you that your daughter died"); X lprcat("\nbefore your return. There was nothing he could do without the potion.\n"); X nap(5000); X died(269); X } else X { X lprcat("\nThe doctor is now administering the potion, and in a few moments\n"); X lprcat("your daughter should be well on her way to recovery.\n"); X nap(6000); X lprcat("\nThe potion is"); X nap(3000); X lprcat(" working! The doctor thinks that\n"); X lprcat("your daughter will recover in a few days. Congratulations!\n"); X beep(); X nap(5000); X died(263); X } X } X while (1) X { X clear(); X lprintf("Welcome home %s. Latest word from the doctor is not good.\n", logname); X X if (gtime > TIMELIMIT) X { X lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n"); X lprcat("You didn't make it in time. There was nothing he could do without the potion.\n"); X nap(5000); X died(269); X } X lprcat("\nThe diagnosis is confirmed as dianthroritis. He guesses that\n"); X lprintf("your daughter has only %d mobuls left in this world. It's up to you,\n", (long) ((TIMELIMIT - gtime + 99) / 100)); X lprintf("%s, to find the only hope for your daughter, the very rare\n", logname); X lprcat("potion of cure dianthroritis. It is rumored that only deep in the\n"); X lprcat("depths of the caves can this potion be found.\n\n\n"); X lprcat("\n ----- press "); X standout("return"); X lprcat(" to continue, "); X standout("escape"); X lprcat(" to leave ----- "); X i = ttgetch(); X while (i != '\33' && i != '\n') X i = ttgetch(); X if (i == '\33') X { X drawscreen(); X nosignal = 0; /* enable signals */ X return; X } X } X} X X/* routine to save program space */ Xiopts() X{ X lprcat(", or (i) ignore it? "); X} Xignore() X{ X lprcat("ignore\n"); X} X X/* X * For prompt mode, prompt for entering a building. X */ Xstatic prompt_enter() X{ X char i; X X lprcat("\nDo you (g) go inside, or (i) stay here? "); X i = 0; X while ((i != 'g') && (i != 'i') && (i != '\33')) X i = ttgetch(); X if (i == 'g') X enter(); X else X lprcat(" stay here"); X} X X/* X * For prompt mode, prompt for climbing up/down the volcanic shaft. X * X * Takes one parameter: if it is negative, going down the shaft, otherwise, X * going up the shaft. X */ Xstatic prompt_volshaft(dir) X int dir; X{ X char i; X X lprcat("\nDo you (c) climb "); X if (dir > 0) X lprcat("up"); X else X lprcat("down"); X iopts(); X X i = 0; X while ((i != 'c') && (i != 'i') && (i != '\33')) X i = ttgetch(); X X if ((i == '\33') || (i == 'i')) X { X ignore(); X return; X } X if (dir > 0) X act_up_shaft(); X else X act_down_shaft(); X} X Xstatic o_open_door() X{ X char i; X lprcat("\nDo you (c) close it"); X iopts(); X i = 0; X while ((i != 'c') && (i != 'i') && (i != '\33')) X i = ttgetch(); X if ((i == '\33') || (i == 'i')) X { X ignore(); X return; X } X lprcat("close"); X forget(); X item[playerx][playery] = OCLOSEDDOOR; X iarg[playerx][playery] = 0; X playerx = lastpx; X playery = lastpy; X} X Xstatic o_closed_door() X{ X char i; X lprcat("\nDo you (o) try to open it"); X iopts(); X i = 0; X while ((i != 'o') && (i != 'i') && (i != '\33')) X i = ttgetch(); X if ((i == '\33') || (i == 'i')) X { X ignore(); X playerx = lastpx; X playery = lastpy; X return; X } else X { X lprcat("open"); X /* X * if he failed to open the door ... X */ X if (!act_open_door(playerx, playery)) X { X playerx = lastpx; X playery = lastpy; X } X } X} END_OF_FILE if test 33382 -ne `wc -c <'object.c'`; then echo shar: \"'object.c'\" unpacked with wrong size! fi # end of 'object.c' fi echo shar: End of archive 2 \(of 12\). cp /dev/null ark2isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 12 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0