Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!princeton!allegra!mit-eddie!genrad!panda!condor!noah From: noah@condor.UUCP (Noah Morgan) Newsgroups: net.sources.games Subject: larn 12.0 part 2/6 Message-ID: <1294@condor.UUCP> Date: Fri, 8-Aug-86 13:08:10 EDT Article-I.D.: condor.1294 Posted: Fri Aug 8 13:08:10 1986 Date-Received: Mon, 11-Aug-86 01:52:05 EDT Distribution: net Organization: GenRad, Inc., Bolton, Mass. Lines: 1842 *** REPLACE THIS LINE WITH YOUR MESSAGE *** #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # data.c # display.c # global.c # nap.c # This archive created: Wed Aug 6 14:58:57 1986 export PATH; PATH=/bin:$PATH echo shar: extracting "'data.c'" '(31123 characters)' if test -f 'data.c' then echo shar: will not over-write existing file "'data.c'" else cat << \SHAR_EOF > 'data.c' /* data.c Larn is copyrighted 1986 by Noah Morgan. */ #define NODEFS #include "header.h" /* class[c[LEVEL]-1] gives the correct name of the players experience level */ static char aa1[] = " mighty evil master"; static char aa2[] = "apprentice demi-god"; static char aa3[] = " minor demi-god "; static char aa4[] = " major demi-god "; static char aa5[] = " minor deity "; static char aa6[] = " major deity "; static char aa7[] = " novice guardian "; static char aa8[] = "apprentice guardian"; static char aa9[] = " The Creator "; char *class[]= { " novice explorer ", "apprentice explorer", " practiced explorer",/* -3*/ " expert explorer ", " novice adventurer", " adventurer ",/* -6*/ "apprentice conjurer", " conjurer ", " master conjurer ",/* -9*/ " apprentice mage ", " mage ", " experienced mage ",/* -12*/ " master mage ", " apprentice warlord", " novice warlord ",/* -15*/ " expert warlord ", " master warlord ", " apprentice gorgon ",/* -18*/ " gorgon ", " practiced gorgon ", " master gorgon ",/* -21*/ " demi-gorgon ", " evil master ", " great evil master ",/* -24*/ aa1 , aa1 , aa1 ,/* -27*/ aa1 , aa1 , aa1 ,/* -30*/ aa1 , aa1 , aa1 ,/* -33*/ aa1 , aa1 , aa1 ,/* -36*/ aa1 , aa1 , aa1 ,/* -39*/ aa2 , aa2 , aa2 ,/* -42*/ aa2 , aa2 , aa2 ,/* -45*/ aa2 , aa2 , aa2 ,/* -48*/ aa3 , aa3 , aa3 ,/* -51*/ aa3 , aa3 , aa3 ,/* -54*/ aa3 , aa3 , aa3 ,/* -57*/ aa4 , aa4 , aa4 ,/* -60*/ aa4 , aa4 , aa4 ,/* -63*/ aa4 , aa4 , aa4 ,/* -66*/ aa5 , aa5 , aa5 ,/* -69*/ aa5 , aa5 , aa5 ,/* -72*/ aa5 , aa5 , aa5 ,/* -75*/ aa6 , aa6 , aa6 ,/* -78*/ aa6 , aa6 , aa6 ,/* -81*/ aa6 , aa6 , aa6 ,/* -84*/ aa7 , aa7 , aa7 ,/* -87*/ aa8 , aa8 , aa8 ,/* -90*/ aa8 , aa8 , aa8 ,/* -93*/ " earth guardian ", " air guardian ", " fire guardian ",/* -96*/ " water guardian ", " time guardian ", " ethereal guardian ",/* -99*/ aa9 , aa9 , aa9 ,/* -102*/ }; /* table of experience needed to be a certain level of player skill[c[LEVEL]] is the experience required to attain the next level */ #define MEG 1000000 long skill[] = { 0, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, /* 1-11 */ 10240, 20480, 40960, 100000, 200000, 400000, 700000, 1*MEG, /* 12-19 */ 2*MEG,3*MEG,4*MEG,5*MEG,6*MEG,8*MEG,10*MEG, /* 20-26 */ 12*MEG,14*MEG,16*MEG,18*MEG,20*MEG,22*MEG,24*MEG,26*MEG,28*MEG, /* 27-35 */ 30*MEG,32*MEG,34*MEG,36*MEG,38*MEG,40*MEG,42*MEG,44*MEG,46*MEG, /* 36-44 */ 48*MEG,50*MEG,52*MEG,54*MEG,56*MEG,58*MEG,60*MEG,62*MEG,64*MEG, /* 45-53 */ 66*MEG,68*MEG,70*MEG,72*MEG,74*MEG,76*MEG,78*MEG,80*MEG,82*MEG, /* 54-62 */ 84*MEG,86*MEG,88*MEG,90*MEG,92*MEG,94*MEG,96*MEG,98*MEG,100*MEG, /* 63-71 */ 105*MEG,110*MEG,115*MEG,120*MEG, 125*MEG, 130*MEG, 135*MEG, 140*MEG, /* 72-79 */ 145*MEG,150*MEG,155*MEG,160*MEG, 165*MEG, 170*MEG, 175*MEG, 180*MEG, /* 80-87 */ 185*MEG,190*MEG,195*MEG,200*MEG, 210*MEG, 220*MEG, 230*MEG, 240*MEG, /* 88-95 */ 250*MEG,260*MEG,270*MEG,280*MEG, 290*MEG, 300*MEG /* 96-101*/ }; #undef MEG char *lpbuf,*lpnt,*inbuffer,*lpend; /* input/output pointers to the buffers */ struct cel *cell; /* pointer to the dungeon storage */ short hitp[MAXX][MAXY]; /* monster hp on level */ short iarg[MAXX][MAXY]; /* arg for the item array */ char item[MAXX][MAXY]; /* objects in maze if any */ char know[MAXX][MAXY]; /* 1 or 0 if here before */ char mitem[MAXX][MAXY]; /* monster item array */ char moved[MAXX][MAXY]; /* monster movement flags */ char stealth[MAXX][MAXY]; /* 0=sleeping 1=awake monst*/ char iven[26]; /* inventory for player */ short ivenarg[26]; /* inventory for player */ char lastmonst[40]; /* this has the name of the current monster */ char beenhere[MAXLEVEL+MAXVLEVEL]=0; /* 1 if have been on this level */ char VERSION=VER; /* this is the present version # of the program */ char SUBVERSION=SUBVER; char nosignal=0; /* set to 1 to disable the signals from doing anything */ char predostuff=0; /* 2 means that the trap handling routines must do a showplayer() after a trap. 0 means don't showplayer() 0 - we are in create player screen 1 - we are in welcome screen 2 - we are in the normal game */ char loginname[20]; /* players login name */ char logname[LOGNAMESIZE]; /* players name storage for scoring */ char sex=1; /* default is a man 0=woman */ char boldon=1; /* 1=bold objects 0=inverse objects */ char ckpflag=0; /* 1 if want checkpointing of game, 0 otherwise */ char cheat=0; /* 1 if the player has fudged save file */ char level=0; /* cavelevel player is on = c[CAVELEVEL] */ char wizard=0; /* the wizard mode flag */ short lastnum=0; /* the number of the monster last hitting player */ short hitflag=0; /* flag for if player has been hit when running */ short hit2flag=0; /* flag for if player has been hit when running */ short hit3flag=0; /* flag for if player has been hit flush input */ short playerx,playery; /* the room on the present level of the player */ short lastpx,lastpy; /* 0 --- MAXX-1 or 0 --- MAXY-1 */ short oldx,oldy; short lasthx=0,lasthy=0; /* location of monster last hit by player */ short nobeep=0; /* true if program is not to beep */ unsigned long randx=33601; /* the random number seed */ long initialtime=0; /* time playing began */ long gtime=0; /* the clock for the game */ long outstanding_taxes=0; /* present tax bill from score file */ long c[100],cbak[100]; /* the character description arrays */ int enable_scroll=0; /* constant for enabled/disabled scrolling regn */ char aborted[] = " aborted"; struct sphere *spheres=0; /*pointer to linked list for spheres of annihilation*/ char *levelname[]= { " H"," 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9","10","V1","V2","V3" }; char objnamelist[]=" ATOP%^F&^+M=%^$$f*OD#~][[)))(((||||||||{?!BC}o:@.<<< 'display.c' /* display.c Larn is copyrighted 1986 by Noah Morgan. */ #include "header.h" #define makecode(_a,_b,_c) (((_a)<<16) + ((_b)<<8) + (_c)) static int minx,maxx,miny,maxy,k,m; static char bot1f=0,bot2f=0,bot3f=0; char always=0; /* bottomline() now for the bottom line of the display */ bottomline() { recalc(); bot1f=1; } bottomhp() { bot2f=1; } bottomspell() { bot3f=1; } bottomdo() { if (bot1f) { bot3f=bot1f=bot2f=0; bot_linex(); return; } if (bot2f) { bot2f=0; bot_hpx(); } if (bot3f) { bot3f=0; bot_spellx(); } } bot_linex() { register int i; if (cbak[SPELLS] <= -50 || (always)) { cursor( 1,18); if (c[SPELLMAX]>99) lprintf("Spells:%3d(%3d)",(long)c[SPELLS],(long)c[SPELLMAX]); else lprintf("Spells:%3d(%2d) ",(long)c[SPELLS],(long)c[SPELLMAX]); lprintf(" AC: %-3d WC: %-3d Level",(long)c[AC],(long)c[WCLASS]); if (c[LEVEL]>99) lprintf("%3d",(long)c[LEVEL]); else lprintf(" %-2d",(long)c[LEVEL]); lprintf(" Exp: %-9d %s\n",(long)c[EXPERIENCE],class[c[LEVEL]-1]); lprintf("HP: %3d(%3d) STR=%-2d INT=%-2d ", (long)c[HP],(long)c[HPMAX],(long)(c[STRENGTH]+c[STREXTRA]),(long)c[INTELLIGENCE]); lprintf("WIS=%-2d CON=%-2d DEX=%-2d CHA=%-2d LV:", (long)c[WISDOM],(long)c[CONSTITUTION],(long)c[DEXTERITY],(long)c[CHARISMA]); if ((level==0) || (wizard)) c[TELEFLAG]=0; if (c[TELEFLAG]) lprcat(" ?"); else lprcat(levelname[level]); lprintf(" Gold: %-6d",(long)c[GOLD]); always=1; botside(); c[TMP] = c[STRENGTH]+c[STREXTRA]; for (i=0; i<100; i++) cbak[i]=c[i]; return; } botsub(makecode(SPELLS,8,18),"%3d"); if (c[SPELLMAX]>99) botsub(makecode(SPELLMAX,12,18),"%3d)"); else botsub(makecode(SPELLMAX,12,18),"%2d) "); botsub(makecode(HP,5,19),"%3d"); botsub(makecode(HPMAX,9,19),"%3d"); botsub(makecode(AC,21,18),"%-3d"); botsub(makecode(WCLASS,30,18),"%-3d"); botsub(makecode(EXPERIENCE,49,18),"%-9d"); if (c[LEVEL] != cbak[LEVEL]) { cursor(59,18); lprcat(class[c[LEVEL]-1]); } if (c[LEVEL]>99) botsub(makecode(LEVEL,40,18),"%3d"); else botsub(makecode(LEVEL,40,18)," %-2d"); c[TMP] = c[STRENGTH]+c[STREXTRA]; botsub(makecode(TMP,18,19),"%-2d"); botsub(makecode(INTELLIGENCE,25,19),"%-2d"); botsub(makecode(WISDOM,32,19),"%-2d"); botsub(makecode(CONSTITUTION,39,19),"%-2d"); botsub(makecode(DEXTERITY,46,19),"%-2d"); botsub(makecode(CHARISMA,53,19),"%-2d"); if ((level != cbak[CAVELEVEL]) || (c[TELEFLAG] != cbak[TELEFLAG])) { if ((level==0) || (wizard)) c[TELEFLAG]=0; cbak[TELEFLAG] = c[TELEFLAG]; cbak[CAVELEVEL] = level; cursor(59,19); if (c[TELEFLAG]) lprcat(" ?"); else lprcat(levelname[level]); } botsub(makecode(GOLD,69,19),"%-6d"); botside(); } /* special subroutine to update only the gold number on the bottomlines called from ogold() */ bottomgold() { botsub(makecode(GOLD,69,19),"%-6d"); /* botsub(GOLD,"%-6d",69,19); */ } /* special routine to update hp and level fields on bottom lines called in monster.c hitplayer() and spattack() */ bot_hpx() { if (c[EXPERIENCE] != cbak[EXPERIENCE]) { recalc(); bot_linex(); } else botsub(makecode(HP,5,19),"%3d"); } /* special routine to update number of spells called from regen() */ bot_spellx() { botsub(makecode(SPELLS,9,18),"%2d"); } /* common subroutine for a more economical bottomline() */ static struct bot_side_def { int typ; char *string; } bot_data[] = { STEALTH,"stealth", UNDEADPRO,"undead pro", SPIRITPRO,"spirit pro", CHARMCOUNT,"Charm", TIMESTOP,"Time Stop", HOLDMONST,"Hold Monst", GIANTSTR,"Giant Str", FIRERESISTANCE,"Fire Resit", DEXCOUNT,"Dexterity", STRCOUNT,"Strength", SCAREMONST,"Scare", HASTESELF,"Haste Self", CANCELLATION,"Cancel", INVISIBILITY,"Invisible", ALTPRO,"Protect 3", PROTECTIONTIME,"Protect 2", WTW,"Wall-Walk" }; botside() { register int i,idx; for (i=0; i<17; i++) { idx = bot_data[i].typ; if ((always) || (c[idx] != cbak[idx])) { if ((always) || (cbak[idx] == 0)) { if (c[idx]) { cursor(70,i+1); lprcat(bot_data[i].string); } } else if (c[idx]==0) { cursor(70,i+1); lprcat(" "); } cbak[idx]=c[idx]; } } always=0; } static botsub(idx,str) register int idx; char *str; { register int x,y; y = idx & 0xff; x = (idx>>8) & 0xff; idx >>= 16; if (c[idx] != cbak[idx]) { cbak[idx]=c[idx]; cursor(x,y); lprintf(str,(long)c[idx]); } } /* * subroutine to draw only a section of the screen * only the top section of the screen is updated. If entire lines are being * drawn, then they will be cleared first. */ int d_xmin=0,d_xmax=MAXX,d_ymin=0,d_ymax=MAXY; /* for limited screen drawing */ draws(xmin,xmax,ymin,ymax) int xmin,xmax,ymin,ymax; { register int i,idx; if (xmin==0 && xmax==MAXX) /* clear section of screen as needed */ { if (ymin==0) cl_up(79,ymax); else for (i=ymin; i= d_xmax) m=d_xmin; /* don't search backwards if blank line */ else { /* search backwards for end of line */ m=d_xmax-1; while ((screen[m][i]==' ') && (m>d_xmin)) --m; if (j<=m) cursor(j+1,i+1); else continue; } while (j <= m) { if (j <= m-3) { for (k=j; k<=j+3; k++) if (screen[k][i] != ' ') k=1000; if (k < 1000) { while(screen[j][i]==' ' && j<=m) j++; cursor(j+1,i+1); } } lprc(screen[j++][i]); } } setbold(); /* print out only bold objects now */ for (lastx=lasty=127, i=d_ymin; i MAXX-1) maxx = MAXX-1; if (miny < 0) miny=0; if (maxy > MAXY-1) maxy = MAXY-1; for (j=miny; j<=maxy; j++) for (m=minx; m<=maxx; m++) if (know[m][j]==0) { cursor(m+1,j+1); x=maxx; while (know[x][j]) --x; for (i=m; i<=x; i++) { if ((k=mitem[i][j]) != 0) lprc(monstnamelist[k]); else switch(k=item[i][j]) { case OWALL: case 0: case OIVTELETRAP: case OTRAPARROWIV: case OIVDARTRAP: case OIVTRAPDOOR: lprc(objnamelist[k]); break; default: setbold(); lprc(objnamelist[k]); resetbold(); }; know[i][j]=1; } m = maxx; } } /* this routine shows only the spot that is given it. the spaces around these coordinated are not shown used in godirect() in monster.c for missile weapons display */ show1cell(x,y) int x,y; { if (c[BLINDCOUNT]) return; /* see nothing if blind */ cursor(x+1,y+1); if ((k=mitem[x][y]) != 0) lprc(monstnamelist[k]); else switch(k=item[x][y]) { case OWALL: case 0: case OIVTELETRAP: case OTRAPARROWIV: case OIVDARTRAP: case OIVTRAPDOOR: lprc(objnamelist[k]); break; default: setbold(); lprc(objnamelist[k]); resetbold(); }; know[x][y]|=1; /* we end up knowing about it */ } /* showplayer() subroutine to show where the player is on the screen cursor values start from 1 up */ showplayer() { cursor(playerx+1,playery+1); oldx=playerx; oldy=playery; } /* moveplayer(dir) subroutine to move the player from one room to another returns 0 if can't move in that direction or hit a monster or on an object else returns 1 nomove is set to 1 to stop the next move (inadvertent monsters hitting players when walking into walls) if player walks off screen or into wall */ short diroffx[] = { 0, 0, 1, 0, -1, 1, -1, 1, -1 }; short diroffy[] = { 0, 1, 0, -1, 0, -1, -1, 1, 1 }; moveplayer(dir) int dir; /* from = present room # direction = [1-north] [2-east] [3-south] [4-west] [5-northeast] [6-northwest] [7-southeast] [8-southwest] if direction=0, don't move--just show where he is */ { register int k,m,i,j; if (c[CONFUSE]) if (c[LEVEL]=MAXX || m<0 || m>=MAXY) { nomove=1; return(yrepcount = 0); } i = item[k][m]; j = mitem[k][m]; if (i==OWALL && c[WTW]==0) { nomove=1; return(yrepcount = 0); } /* hit a wall */ if (k==33 && m==MAXY-1 && level==1) { newcavelevel(0); for (k=0; k0) { hitmonster(k,m); return(yrepcount = 0); } /* hit a monster*/ lastpx = playerx; lastpy = playery; playerx = k; playery = m; if (i && i!=OTRAPARROWIV && i!=OIVTELETRAP && i!=OIVDARTRAP && i!=OIVTRAPDOOR) return(yrepcount = 0); else return(1); } /* * function to show what magic items have been discovered thus far * enter with -1 for just spells, anything else will give scrolls & potions */ static int lincount,count; seemagic(arg) int arg; { register int i,number; count = lincount = 0; nosignal=1; if (arg== -1) /* if display spells while casting one */ { for (number=i=0; i17) { lincount=0; more(); clear(); } } } SHAR_EOF if test 11954 -ne "`wc -c < 'display.c'`" then echo shar: error transmitting "'display.c'" '(should have been 11954 characters)' fi fi echo shar: extracting "'global.c'" '(15478 characters)' if test -f 'global.c' then echo shar: will not over-write existing file "'global.c'" else cat << \SHAR_EOF > 'global.c' /* global.c Larn is copyrighted 1986 by Noah Morgan. * * raiselevel() subroutine to raise the player one level * loselevel() subroutine to lower the player by one level * raiseexperience(x) subroutine to increase experience points * loseexperience(x) subroutine to lose experience points * losehp(x) subroutine to remove hit points from the player * losemhp(x) subroutine to remove max # hit points from the player * raisehp(x) subroutine to gain hit points * raisemhp(x) subroutine to gain maximum hit points * losespells(x) subroutine to lose spells * losemspells(x) subroutine to lose maximum spells * raisespells(x) subroutine to gain spells * raisemspells(x) subroutine to gain maximum spells * recalc() function to recalculate the armor class of the player * makemonst(lev) function to return monster number for a randomly selected monster * positionplayer() function to be sure player is not in a wall * quit() subroutine to ask if the player really wants to quit */ #include "header.h" extern int score[],srcount,dropflag; extern int random;/* the random number seed */ extern short playerx,playery,lastnum; extern char cheat,level,monstnamelist[]; extern char lastmonst[],*what[],*who[]; extern char winner[]; extern char logname[],monstlevel[]; extern char sciv[SCORESIZE+1][26][2],*potionname[],*scrollname[]; /* *********** RAISE LEVEL *********** raiselevel() subroutine to raise the player one level uses the skill[] array to find level boundarys uses c[EXPERIENCE] c[LEVEL] */ raiselevel() { if (c[LEVEL] < MAXPLEVEL) raiseexperience((long)(skill[c[LEVEL]]-c[EXPERIENCE])); } /* *********** LOOSE LEVEL *********** loselevel() subroutine to lower the players character level by one */ loselevel() { if (c[LEVEL] > 1) loseexperience((long)(c[EXPERIENCE] - skill[c[LEVEL]-1] + 1)); } /* **************** RAISE EXPERIENCE **************** raiseexperience(x) subroutine to increase experience points */ raiseexperience(x) register long x; { register int i,tmp; i=c[LEVEL]; c[EXPERIENCE]+=x; while (c[EXPERIENCE] >= skill[c[LEVEL]] && (c[LEVEL] < MAXPLEVEL)) { tmp = (c[CONSTITUTION]-c[HARDGAME])>>1; c[LEVEL]++; raisemhp((int)(rnd(3)+rnd((tmp>0)?tmp:1))); raisemspells((int)rund(3)); if (c[LEVEL] < 7-c[HARDGAME]) raisemhp((int)(c[CONSTITUTION]>>2)); } if (c[LEVEL] != i) { cursors(); beep(); lprintf("\nWelcome to level %d",(long)c[LEVEL]); /* if we changed levels */ } bottomline(); } /* **************** LOOSE EXPERIENCE **************** loseexperience(x) subroutine to lose experience points */ loseexperience(x) register long x; { register int i,tmp; i=c[LEVEL]; c[EXPERIENCE]-=x; if (c[EXPERIENCE] < 0) c[EXPERIENCE]=0; while (c[EXPERIENCE] < skill[c[LEVEL]-1]) { if (--c[LEVEL] <= 1) c[LEVEL]=1; /* down one level */ tmp = (c[CONSTITUTION]-c[HARDGAME])>>1; /* lose hpoints */ losemhp((int)rnd((tmp>0)?tmp:1)); /* lose hpoints */ if (c[LEVEL] < 7-c[HARDGAME]) losemhp((int)(c[CONSTITUTION]>>2)); losemspells((int)rund(3)); /* lose spells */ } if (i!=c[LEVEL]) { cursors(); beep(); lprintf("\nYou went down to level %d!",(long)c[LEVEL]); } bottomline(); } /* ******** LOOSE HP ******** losehp(x) losemhp(x) subroutine to remove hit points from the player warning -- will kill player if hp goes to zero */ losehp(x) register int x; { if ((c[HP] -= x) <= 0) { beep(); lprcat("\n"); nap(3000); died(lastnum); } } losemhp(x) register int x; { c[HP] -= x; if (c[HP] < 1) c[HP]=1; c[HPMAX] -= x; if (c[HPMAX] < 1) c[HPMAX]=1; } /* ******** RAISE HP ******** raisehp(x) raisemhp(x) subroutine to gain maximum hit points */ raisehp(x) register int x; { if ((c[HP] += x) > c[HPMAX]) c[HP] = c[HPMAX]; } raisemhp(x) register int x; { c[HPMAX] += x; c[HP] += x; } /* ************ RAISE SPELLS ************ raisespells(x) raisemspells(x) subroutine to gain maximum spells */ raisespells(x) register int x; { if ((c[SPELLS] += x) > c[SPELLMAX]) c[SPELLS] = c[SPELLMAX]; } raisemspells(x) register int x; { c[SPELLMAX]+=x; c[SPELLS]+=x; } /* ************ LOOSE SPELLS ************ losespells(x) losemspells(x) subroutine to lose maximum spells */ losespells(x) register int x; { if ((c[SPELLS] -= x) < 0) c[SPELLS]=0; } losemspells(x) register int x; { if ((c[SPELLMAX] -= x) < 0) c[SPELLMAX]=0; if ((c[SPELLS] -= x) < 0) c[SPELLS]=0; } /* makemonst(lev) int lev; function to return monster number for a randomly selected monster for the given cave level */ makemonst(lev) register int lev; { register int tmp,x; if (lev < 1) lev = 1; if (lev > 12) lev = 12; tmp=WATERLORD; if (lev < 5) while (tmp==WATERLORD) tmp=rnd((x=monstlevel[lev-1])?x:1); else while (tmp==WATERLORD) tmp=rnd((x=monstlevel[lev-1]-monstlevel[lev-4])?x:1)+monstlevel[lev-4]; while (monster[tmp].genocided && tmp= MAXX-1) { playerx = 1; if (++playery >= MAXY-1) { playery = 1; --try; } } if (try==0) lprcat("Failure in positionplayer\n"); } /* recalc() function to recalculate the armor class of the player */ recalc() { register int i,j,k; c[AC] = c[MOREDEFENSES]; if (c[WEAR] >= 0) switch(iven[c[WEAR]]) { case OSHIELD: c[AC] += 2 + ivenarg[c[WEAR]]; break; case OLEATHER: c[AC] += 2 + ivenarg[c[WEAR]]; break; case OSTUDLEATHER: c[AC] += 3 + ivenarg[c[WEAR]]; break; case ORING: c[AC] += 5 + ivenarg[c[WEAR]]; break; case OCHAIN: c[AC] += 6 + ivenarg[c[WEAR]]; break; case OSPLINT: c[AC] += 7 + ivenarg[c[WEAR]]; break; case OPLATE: c[AC] += 9 + ivenarg[c[WEAR]]; break; case OPLATEARMOR: c[AC] += 10 + ivenarg[c[WEAR]]; break; case OSSPLATE: c[AC] += 12 + ivenarg[c[WEAR]]; break; } if (c[SHIELD] >= 0) if (iven[c[SHIELD]] == OSHIELD) c[AC] += 2 + ivenarg[c[SHIELD]]; if (c[WIELD] < 0) c[WCLASS] = 0; else { i = ivenarg[c[WIELD]]; switch(iven[c[WIELD]]) { case ODAGGER: c[WCLASS] = 3 + i; break; case OBELT: c[WCLASS] = 7 + i; break; case OSHIELD: c[WCLASS] = 8 + i; break; case OSPEAR: c[WCLASS] = 10 + i; break; case OFLAIL: c[WCLASS] = 14 + i; break; case OBATTLEAXE: c[WCLASS] = 17 + i; break; case OLANCE: c[WCLASS] = 19 + i; break; case OLONGSWORD: c[WCLASS] = 22 + i; break; case O2SWORD: c[WCLASS] = 26 + i; break; case OSWORD: c[WCLASS] = 32 + i; break; case OSWORDofSLASHING: c[WCLASS] = 30 + i; break; case OHAMMER: c[WCLASS] = 35 + i; break; default: c[WCLASS] = 0; } } c[WCLASS] += c[MOREDAM]; /* now for regeneration abilities based on rings */ c[REGEN]=1; c[ENERGY]=0; j=0; for (k=25; k>0; k--) if (iven[k]) {j=k; k=0; } for (i=0; i<=j; i++) { switch(iven[i]) { case OPROTRING: c[AC] += ivenarg[i] + 1; break; case ODAMRING: c[WCLASS] += ivenarg[i] + 1; break; case OBELT: c[WCLASS] += ((ivenarg[i]<<1)) + 2; break; case OREGENRING: c[REGEN] += ivenarg[i] + 1; break; case ORINGOFEXTRA: c[REGEN] += 5 * (ivenarg[i]+1); break; case OENERGYRING: c[ENERGY] += ivenarg[i] + 1; break; } } } /* quit() subroutine to ask if the player really wants to quit */ quit() { register int i; cursors(); strcpy(lastmonst,""); lprcat("\n\nDo you really want to quit?"); while (1) { i=getchar(); if (i == 'y') { died(300); return; } if ((i == 'n') || (i == '\33')) { lprcat(" no"); lflush(); return; } lprcat("\n"); setbold(); lprcat("Yes"); resetbold(); lprcat(" or "); setbold(); lprcat("No"); resetbold(); lprcat(" please? Do you want to quit? "); } } /* function to ask --more-- then the user must enter a space */ more() { lprcat("\n --- press "); standout("space"); lprcat(" to continue --- "); while (getchar() != ' '); } /* function to put something in the players inventory returns 0 if success, 1 if a failure */ take(itm,arg) int itm,arg; { register int i,limit; /* cursors(); */ if ((limit = 15+(c[LEVEL]>>1)) > 26) limit=26; for (i=0; i25)) return(0); itm = iven[k]; cursors(); if (itm==0) { lprintf("\nYou don't have item %c! ",k+'a'); return(1); } if (item[playerx][playery]) { beep(); lprcat("\nThere's something here already"); return(1); } if (playery==MAXY-1 && playerx==33) return(1); /* not in entrance */ item[playerx][playery] = itm; iarg[playerx][playery] = ivenarg[k]; srcount=0; lprcat("\n You drop:"); show3(k); /* show what item you dropped*/ know[playerx][playery] = 0; iven[k]=0; if (c[WIELD]==k) c[WIELD]= -1; if (c[WEAR]==k) c[WEAR] = -1; if (c[SHIELD]==k) c[SHIELD]= -1; adjustcvalues(itm,ivenarg[k]); dropflag=1; /* say dropped an item so wont ask to pick it up right away */ return(0); } /* function to enchant armor player is currently wearing */ enchantarmor() { register int tmp; if (c[WEAR]<0) { if (c[SHIELD] < 0) { cursors(); beep(); lprcat("\nYou feel a sense of loss"); return; } else { tmp=iven[c[SHIELD]]; if (tmp != OSCROLL) if (tmp != OPOTION) { ivenarg[c[SHIELD]]++; bottomline(); } } } tmp = iven[c[WEAR]]; if (tmp!=OSCROLL) if (tmp!=OPOTION) { ivenarg[c[WEAR]]++; bottomline(); } } /* function to enchant a weapon presently being wielded */ enchweapon() { register int tmp; if (c[WIELD]<0) { cursors(); beep(); lprcat("\nYou feel a sense of loss"); return; } tmp = iven[c[WIELD]]; if (tmp!=OSCROLL) if (tmp!=OPOTION) { ivenarg[c[WIELD]]++; if (tmp==OCLEVERRING) c[INTELLIGENCE]++; else if (tmp==OSTRRING) c[STREXTRA]++; else if (tmp==ODEXRING) c[DEXTERITY]++; bottomline(); } } /* routine to tell if player can carry one more thing returns 1 if pockets are full, else 0 */ pocketfull() { register int i,limit; if ((limit = 15+(c[LEVEL]>>1)) > 26) limit=26; for (i=0; i 0)); i=36; while (--i > 0) { if ((j=getchar()) != '"') *str++ = j; else i=0; } *str = 0; i=50; if (j != '"') while ((getchar() != '"') && (--i > 0)); /* if end due to too long, then find closing quote */ } /* function to ask user for a password (no echo) returns 1 if entered correctly, 0 if not */ static char gpwbuf[33]; getpassword() { register int i,j; register char *gpwp; extern char *password; scbr(); /* system("stty -echo cbreak"); */ gpwp = gpwbuf; lprcat("\nEnter Password: "); lflush(); i = strlen(password); for (j=0; j0)) --j; for (i=0; i<=j; i++) switch(iven[i]) { case 0: break; case OSSPLATE: case OPLATEARMOR: k += 40; break; case OPLATE: k += 35; break; case OHAMMER: k += 30; break; case OSPLINT: k += 26; break; case OSWORDofSLASHING: case OCHAIN: case OBATTLEAXE: case O2SWORD: k += 23; break; case OLONGSWORD: case OSWORD: case ORING: case OFLAIL: k += 20; break; case OLANCE: case OSTUDLEATHER: k += 15; break; case OLEATHER: case OSPEAR: k += 8; break; case OORBOFDRAGON: case OBELT: k += 4; break; case OSHIELD: k += 7; break; case OCHEST: k += 30 + ivenarg[i]; break; default: k++; }; return(k); } #ifndef MACRORND /* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */ rnd(x) int x; { return((((randx=randx*1103515245+12345)>>7)%(x))+1); } rund(x) int x; { return((((randx=randx*1103515245+12345)>>7)%(x)) ); } #endif MACRORND SHAR_EOF if test 15478 -ne "`wc -c < 'global.c'`" then echo shar: error transmitting "'global.c'" '(should have been 15478 characters)' fi fi echo shar: extracting "'nap.c'" '(2399 characters)' if test -f 'nap.c' then echo shar: will not over-write existing file "'nap.c'" else cat << \SHAR_EOF > 'nap.c' /* nap.c Larn is copyrighted 1986 by Noah Morgan. */ #include #include #ifdef SYSV #include #else #ifdef BSD #include #endif BSD #endif SYSV /* * routine to take a nap for n milliseconds */ nap(x) register int x; { if (x<=0) return; /* eliminate chance for infinite loop */ lflush(); if (x > 999) sleep(x/1000); else napms(x); } #ifdef NONAP napms(x) /* do nothing */ int x; { } #else NONAP #ifdef SYSV /* napms - sleep for time milliseconds - uses times() */ /* this assumes that times returns a relative time in 60ths of a second */ /* this will do horrible things if your times() returns seconds! */ napms(time) int time; { long matchclock, times(); struct tms stats; if (time<=0) time=1; /* eliminate chance for infinite loop */ if ((matchclock = times(&stats)) == -1 || matchclock == 0) return; /* error, or BSD style times() */ matchclock += (time / 17); /*17 ms/tic is 1000 ms/sec / 60 tics/sec */ while(matchclock < times(&stats)) ; } #else not SYSV #ifdef BSD #ifdef SIGVTALRM /* This must be BSD 4.2! */ #include #define bit(_a) (1<<((_a)-1)) static nullf() { } /* napms - sleep for time milliseconds - uses setitimer() */ napms(time) int time; { struct itimerval timeout; int (*oldhandler) (); int oldsig; if (time <= 0) return; timerclear(&timeout.it_interval); timeout.it_value.tv_sec = time / 1000; timeout.it_value.tv_usec = (time % 1000) * 1000; oldsig = sigblock(bit(SIGALRM)); setitimer(ITIMER_REAL, &timeout, (struct itimerval *)0); oldhandler = signal(SIGALRM, nullf); sigpause(oldsig); signal(SIGALRM, oldhandler); sigsetmask(oldsig); } #else /* napms - sleep for time milliseconds - uses ftime() */ static napms(time) int time; { /* assumed to be BSD UNIX */ struct timeb _gtime; time_t matchtime; unsigned short matchmilli; register struct timeb *tp = & _gtime; if (time <= 0) return; ftime(tp); matchmilli = tp->millitm + time; matchtime = tp->time; while (matchmilli >= 1000) { ++matchtime; matchmilli -= 1000; } while(1) { ftime(tp); if ((tp->time > matchtime) || ((tp->time == matchtime) && (tp->millitm >= matchmilli))) break; } } #endif #else not BSD static napms(time) int time; {} /* do nothing, forget it */ #endif BSD #endif SYSV #endif NONAP SHAR_EOF if test 2399 -ne "`wc -c < 'nap.c'`" then echo shar: error transmitting "'nap.c'" '(should have been 2399 characters)' fi fi exit 0 # End of shell archive