billr@saab.CNA.TEK.COM (Bill Randle) (07/06/89)
Submitted-by: "Philip A. Cordier" <philc@sco.COM> Posting-number: Volume 7, Issue 6 Archive-name: ularn/Part06 #! /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 6 (of 8)." # Contents: create.c global.c header.h regen.c # Wrapped by billr@saab on Thu Jun 29 08:10:21 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'create.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'create.c'\" else echo shar: Extracting \"'create.c'\" \(14814 characters\) sed "s/^X//" >'create.c' <<'END_OF_FILE' X/* create.c */ X#include "header.h" X Xextern char spelknow[],larnlevels[]; Xextern char beenhere[],wizard,level; Xextern short oldx,oldy; X X/* X makeplayer() X X subroutine to create the player and the players attributes X this is called at the beginning of a game and at no other time X */ Xmakeplayer() X{ X register int i; X extern int char_picked; X X scbr(); X clear(); X c[LEVEL]=1; /* player starts at level one */ X c[REGENCOUNTER]=16; X c[ECOUNTER]=96; /*start regeneration correctly*/ X X c[SHIELD] = c[WEAR] = c[WIELD] = -1; X X if (char_picked >= 'a' && char_picked <= 'h') X pick_char(char_picked); X else { X for (i=0; i<26; i++) X iven[i]=0; X pick_char(0); X } X playerx=rnd(MAXX-2); X playery=rnd(MAXY-2); X oldx=0; X oldy=25; X gtime=0; /* time clock starts at zero */ X cbak[SPELLS] = -50; X recalc(); X} X X/* X newcavelevel(level) X int level; X X function to enter a new level. This routine must be called anytime the X player changes levels. If that level is unknown it will be created. X A new set of monsters will be created for a new level, and existing X levels will get a few more monsters. X Note that it is here we remove genocided monsters from the present level X */ Xnewcavelevel(x) Xregister int x; X{ X register int i,j; X X if (beenhere[level]) X savelevel(); /* put the level back into storage */ X level = x; /* get the new level and put in working storage*/ X if (beenhere[x]==0) X for (i=0; i<MAXY; i++) X for (j=0; j<MAXX; j++) X know[j][i]=mitem[j][i]=0; X else { X getlevel(); X sethp(0); X goto chgn; /* yuck! */ X } X makemaze(x); X makeobject(x); X beenhere[x]=1; X sethp(1); X X#if WIZID X if (wizard || x==0) X#else X if (x==0) X#endif X for (j=0; j<MAXY; j++) X for (i=0; i<MAXX; i++) X know[i][j]=1; Xchgn: X checkgen(); /* wipe out any genocided monsters */ X} X X/* X makemaze(level) X int level; X X subroutine to make the caverns for a given level. only walls are made. X */ Xstatic int mx,mxl,mxh,my,myl,myh,tmp2; Xmakemaze(k) Xint k; X{ X register int i,j; X int tmp, z; X X if (k > 1 && (rnd(17)<=4 || k==MAXLEVEL-1 || k==MAXLEVEL+MAXVLEVEL-1)) { X if (cannedlevel(k)); X return; /* read maze from data file */ X } X if (k==0) X tmp=0; X else X tmp=OWALL; X for (i=0; i<MAXY; i++) X for (j=0; j<MAXX; j++) X item[j][i]=tmp; X if (k==0) X return; X eat(1,1); X if (k==1) X item[33][MAXY-1]=0; /* exit from dungeon */ X X /* now for open spaces -- not on level 10 */ X if (k != MAXLEVEL-1) { X tmp2 = rnd(3)+3; X for (tmp=0; tmp<tmp2; tmp++) { X my = rnd(11)+2; X myl = my - rnd(2); X myh = my + rnd(2); X if (k < MAXLEVEL) { X mx = rnd(44)+5; X mxl = mx - rnd(4); X mxh = mx + rnd(12)+3; X z=0; X } X else { X mx = rnd(60)+3; X mxl = mx - rnd(2); X mxh = mx + rnd(2); X z = makemonst(k); X } X for (i=mxl; i<mxh; i++) X for (j=myl; j<myh; j++) { X item[i][j]=0; X if ((mitem[i][j]=z)) X hitp[i][j]=monster[z].hitpoints; X } X } X } X if (k!=MAXLEVEL-1) { X my=rnd(MAXY-2); X for (i=1; i<MAXX-1; i++) X item[i][my] = 0; X } X if (k>1) treasureroom(k); X} X X/* X function to eat away a filled in maze X */ Xeat(xx,yy) Xregister int xx,yy; X{ X register int dir,try; X X dir = rnd(4); X try=2; X while (try) { X switch(dir) { X case 1: X if (xx <= 2) break; /* west */ X if ((item[xx-1][yy]!=OWALL) || (item[xx-2][yy]!=OWALL)) X break; X item[xx-1][yy] = item[xx-2][yy] = 0; X eat(xx-2,yy); X break; X case 2: X if (xx >= MAXX-3) break; /* east */ X if ((item[xx+1][yy]!=OWALL) || (item[xx+2][yy]!=OWALL)) X break; X item[xx+1][yy] = item[xx+2][yy] = 0; X eat(xx+2,yy); X break; X case 3: X if (yy <= 2) break; /* south */ X if ((item[xx][yy-1]!=OWALL) || (item[xx][yy-2]!=OWALL)) X break; X item[xx][yy-1] = item[xx][yy-2] = 0; X eat(xx,yy-2); X break; X case 4: X if (yy >= MAXY-3 ) break; /*north */ X if ((item[xx][yy+1]!=OWALL) || (item[xx][yy+2]!=OWALL)) X break; X item[xx][yy+1] = item[xx][yy+2] = 0; X eat(xx,yy+2); X break; X }; X if (++dir > 4) { X dir=1; X --try; X } X } X} X X/* X * function to read in a maze from a data file X * X * Format of maze data file: X * 1st character = # of mazes in file (ascii digit) X * For each maze: X * 18 lines (1st 17 used) X * 67 characters per line X * X * Special characters in maze data file: X * X * # wall D door X * . random monster ~ eye of larn X * ! cure dianthroritis - random object X */ Xcannedlevel(k) Xint k; X{ X char *row,*lgetl(); X register int i,j; X int it,arg,mit,marg; X X if (lopen(larnlevels)<0) { X write(1,"Can't open the maze data file\n",30); X died(-282); X return(0); X } X for (i=18*rund(20); i>0; i--) X lgetl(); /* advance to desired maze */ X X for (i=0; i<MAXY; i++) { X row = lgetl(); X for (j=0; j<MAXX; j++) { X it = mit = arg = marg = 0; X switch(*row++) { X case '#': X it = OWALL; X break; X case 'D': X it = OCLOSEDDOOR; X arg = rnd(30); X break; X case '~': X if (k!=MAXLEVEL-1) break; X it = OLARNEYE; X mit = DEMONPRINCE; X marg = monster[mit].hitpoints; X break; X case '!': X if (k!=MAXLEVEL+MAXVLEVEL-1) X break; X it = OPOTION; X arg = 21; X mit = LUCIFER; X marg = monster[mit].hitpoints; X break; X case '.': X if (k<MAXLEVEL) break; X mit = makemonst(k+1); X marg = monster[mit].hitpoints; X break; X case '-': X it = newobject(k+1,&arg); X break; X }; X item[j][i] = it; X iarg[j][i] = arg; X mitem[j][i] = mit; X hitp[j][i] = marg; X#if WIZID X know[j][i] = (wizard) ? 1 : 0; X#else X know[j][i] = 0; X#endif X } X } X lrclose(); X return(1); X} X X/* X function to make a treasure room on a level X level 10's treasure room has the eye in it and demon lords X level V3 has potion of cure dianthroritis and demon prince X */ Xtreasureroom(lv) Xregister int lv; X{ X register int tx,ty,xsize,ysize; X X for (tx=1+rnd(10); tx<MAXX-10; tx+=10) X if ( (lv==MAXLEVEL-1) || (lv==MAXLEVEL+MAXVLEVEL-1) || rnd(13)==2) { X xsize = rnd(6)+3; X ysize = rnd(3)+3; X ty = rnd(MAXY-9)+1; /* upper left corner of room */ X if (lv==MAXLEVEL-1 || lv==MAXLEVEL+MAXVLEVEL-1) X troom(lv,xsize,ysize,tx=tx+rnd(MAXX-24),ty,rnd(3)+6); X else X troom(lv,xsize,ysize,tx,ty,rnd(9)); X } X} X X/* X * subroutine to create a treasure room of any size at a given location X * room is filled with objects and monsters X * the coordinate given is that of the upper left corner of the room X */ Xtroom(lv,xsize,ysize,tx,ty,glyph) Xint lv,xsize,ysize,tx,ty,glyph; X{ X register int i,j; X int tp1,tp2; X X for (j=ty-1; j<=ty+ysize; j++) X for (i=tx-1; i<=tx+xsize; i++) /* clear out space for room */ X item[i][j]=0; X for (j=ty; j<ty+ysize; j++) X for (i=tx; i<tx+xsize; i++) /* now put in the walls */ X { X item[i][j]=OWALL; X mitem[i][j]=0; X } X for (j=ty+1; j<ty+ysize-1; j++) X for (i=tx+1; i<tx+xsize-1; i++) /* now clear out interior */ X item[i][j]=0; X switch(rnd(2)) /* locate the door on the treasure room */ X { X case 1: X item[i=tx+rund(xsize)][j=ty+(ysize-1)*rund(2)]=OCLOSEDDOOR; X iarg[i][j] = glyph; /* on horizontal walls */ X break; X case 2: X item[i=tx+(xsize-1)*rund(2)][j=ty+rund(ysize)]=OCLOSEDDOOR; X iarg[i][j] = glyph; /* on vertical walls */ X break; X }; X X tp1=playerx; X tp2=playery; X playery=ty+(ysize>>1); X if (c[HARDGAME]<2) X for (playerx=tx+1; playerx<=tx+xsize-2; playerx+=2) X for (i=0, j=rnd(6); i<=j; i++) { X something(lv+2); X createmonster(makemonst(lv+2)); X } X else X for (playerx=tx+1; playerx<=tx+xsize-2; playerx+=2) X for (i=0, j=rnd(4); i<=j; i++) { X something(lv+2); X createmonster(makemonst(lv+4)); X } X playerx=tp1; X playery=tp2; X} X X/* X *********** X MAKE_OBJECT X *********** X subroutine to create the objects in the maze for the given level X */ Xmakeobject(j) Xregister int j; X{ X register int i; X X if (j==0) { X fillroom(OENTRANCE,0); /* entrance to dungeon*/ X fillroom(ODNDSTORE,0); /* the DND STORE */ X fillroom(OSCHOOL,0); /* college of Larn */ X fillroom(OBANK,0); /* 1st national bank of larn*/ X fillroom(OVOLDOWN,0); /* volcano shaft to temple*/ X fillroom(OHOME,0); /* the players home & family*/ X fillroom(OTRADEPOST,0); /* the trading post */ X fillroom(OLRS,0); /* the larn revenue service */ X return; X } X if (j==MAXLEVEL) X fillroom(OVOLUP,0); /* volcano shaft up from the temple */ X X /* make the fixed object in the maze STAIRS and X random object ELEVATORS */ X X if ((j>0) && (j != MAXLEVEL-1) && (j < MAXLEVEL+MAXVLEVEL-3)) X fillroom(OSTAIRSDOWN,0); X X if ((j > 1) && (j != MAXLEVEL)) X fillroom(OSTAIRSUP,0); X X if ((j>3) && (j != MAXLEVEL)) X if (c[ELVUP]==0) X if (rnd(100) > 85) { X fillroom(OELEVATORUP,0); X c[ELVUP]++; X } X X if ((j>0) && (j<=MAXLEVEL-2)) X if (c[ELVDOWN]==0) X if (rnd(100) > 85) { X fillroom(OELEVATORDOWN,0); X c[ELVDOWN]++; X } X X /* make the random objects in the maze */ X fillmroom(rund(3),OBOOK,j); X fillmroom(rund(3),OCOOKIE,0); X fillmroom(rund(3),OALTAR,0); X fillmroom(rund(3),OSTATUE,0); X fillmroom(rund(3),OFOUNTAIN,0); X fillmroom(rund(2),OTHRONE,0); X fillmroom(rund(2),OMIRROR,0); X X if (j >= MAXLEVEL+MAXVLEVEL-3) X fillroom(OPIT,0); X fillmroom(rund(3),OPIT,0); X X if (j >= MAXLEVEL+MAXVLEVEL-3) X fillroom(OIVTRAPDOOR,0); X fillmroom(rund(2),OIVTRAPDOOR,0); X fillmroom(rund(2),OTRAPARROWIV,0); X fillmroom(rnd(3)-2,OIVTELETRAP,0); X fillmroom(rnd(3)-2,OIVDARTRAP,0); X X if (j==1) fillmroom(1,OCHEST,j); X else fillmroom(rund(2),OCHEST,j); X X if (j<MAXLEVEL-1) { X fillmroom(rund(2),ODIAMOND,rnd(10*j+1)+10); X fillmroom(rund(2),ORUBY,rnd(6*j+1)+6); X fillmroom(rund(2),OEMERALD,rnd(4*j+1)+4); X fillmroom(rund(2),OSAPPHIRE,rnd(3*j+1)+2); X } X X for (i=0; i<rnd(4)+3; i++) X fillroom(OPOTION,newpotion()); /* make a POTION */ X X for (i=0; i<rnd(5)+3; i++) X fillroom(OSCROLL,newscroll()); /* make a SCROLL */ X X for (i=0; i<rnd(12)+11; i++) X fillroom(OGOLDPILE,12*rnd(j+1)+(j<<3)+10); /* make GOLD */ X X if (j==8) X fillroom(OBANK2,0); /* branch office of the bank */ X X if ( (c[PAD]==0) && (j>=4) ) X if (rnd(100) > 75) { X fillroom(OPAD,0); /* Dealer McDope's Pad */ X c[PAD]++; X } X X froom(2,ORING,0); /* a ring mail */ X froom(1,OSTUDLEATHER,0); /* a studded leather */ X froom(3,OSPLINT,0); /* a splint mail*/ X froom(5,OSHIELD,rund(3)); /* a shield */ X froom(2,OBATTLEAXE,rund(3)); /* a battle axe */ X froom(5,OLONGSWORD,rund(3)); /* a long sword */ X froom(5,OFLAIL,rund(3)); /* a flail */ X froom(7,OSPEAR,rnd(5)); /* a spear */ X froom(4,OREGENRING,rund(3)); /* ring of regeneration */ X froom(1,OPROTRING,rund(3)); /* ring of protection */ X froom(2,OSTRRING,rund(5)); /* ring of strength */ X froom(2,ORINGOFEXTRA,0); /* ring of extra regen */ X X if (c[LAMP]==0) { X if (rnd(120) < 8) { X fillroom (OBRASSLAMP,0); X c[LAMP]++; X goto zug; X } X } X X if (c[WAND]==0) { /* wand of wonder */ X if (rnd(120) < 8) { X fillroom(OWWAND,0); X c[WAND]++; X goto zug; X } X } X X if (c[DRAGSLAY]==0) /* orb of dragon slaying */ X if(rnd(120) < 8) { X fillroom(OORBOFDRAGON,0); X c[DRAGSLAY]++; X goto zug; X } X X if (c[NEGATE]==0) /* scarab of negate spirit */ X if(rnd(120) < 8) { X fillroom(OSPIRITSCARAB,0); X c[NEGATE]++; X goto zug; X } X X if (c[CUBEUNDEAD]==0) /* cube of undead control */ X if (rnd(120) < 8) { X fillroom(OCUBEofUNDEAD,0); X c[CUBEUNDEAD]++; X goto zug; X } X X if (c[DEVICE]==0) /* device of antitheft */ X if (rnd(120) < 8) { X fillroom(ONOTHEFT,0); X c[DEVICE]++; X goto zug; X } X X if(c[TALISMAN]==0) /* talisman of the sphere */ X if(rnd(120) < 8) { X fillroom(OSPHTALISMAN,0); X c[TALISMAN]++; X goto zug; X } X X if (c[HAND]==0) /* hand of fear */ X if (rnd(120) < 8) { X fillroom(OHANDofFEAR,0); X c[HAND]++; X goto zug; X } X X if (c[ORB] == 0) /* orb of enlightenment */ X if (rnd(120) < 8) { X fillroom(OORB,0); X c[ORB]++; X goto zug; X } X X if (c[ELVEN]==0) /* elven chain */ X if (rnd(120) < 8) { X fillroom(OELVENCHAIN,0); X c[ELVEN]++; X } Xzug: X if (c[SLASH]==0) /* sword of slashing */ X if (rnd(120) < 8) { X fillroom(OSWORDofSLASHING,0); X c[SLASH]++; X } X X if (c[BESSMANN]==0) /* Bessman's flailing hammer */ X if(rnd(120) < 8) { X fillroom(OHAMMER,0); X c[BESSMANN]++; X } X X if ((j>=10)&&(j<=20)&&(c[SLAY]==0)) /* Slayer */ X if (rnd(100) > 85-(j-10)) { X fillroom (OSLAYER,0); X c[SLAY]++; X } X X if ((c[STAFF]==0) && (j>=8) && (j<=20)) /* staff of power */ X if (rnd(100) > 85-(j-10)) { X fillroom(OPSTAFF,0); X c[STAFF]++; X } X X if (c[HARDGAME]<3 || (rnd(4)==3)) { X if (j>3) { X froom(3,OSWORD,rund(6)); /* sunsword */ X froom(5,O2SWORD,rnd(6)); /* a two handed sword */ X froom(3,OBELT,rund(7)); /* belt of striking */ X froom(3,OENERGYRING,rund(6)); /* energy ring */ X froom(4,OPLATE,rund(8)); /* platemail */ X } X } X} X X/* X subroutine to fill in a number of objects of the same kind X */ Xfillmroom(n,what,arg) Xint n,arg; Xchar what; X{ X register int i; X X for (i=0; i<n; i++) X fillroom(what,arg); X} X Xfroom(n,itm,arg) Xint n; Xchar itm; Xint arg; X{ X if (rnd(151) < n) X fillroom(itm,arg); X} X X/* X * subroutine to put an object into an empty room X * uses a random walk X */ Xfillroom(what,arg) Xchar what; Xint arg; X{ X register int x,y; X X x=rnd(MAXX-2); X y=rnd(MAXY-2); X while (item[x][y]) { X x += rnd(3)-2; X y += rnd(3)-2; X if (x > MAXX-2) x=1; X if (x < 1) x=MAXX-2; X if (y > MAXY-2) y=1; X if (y < 1) y=MAXY-2; X } X item[x][y]=what; X iarg[x][y]=arg; X} X X/* X subroutine to put monsters into an empty room without walls or other X monsters X */ Xfillmonst(what) Xchar what; X{ X register int x,y,trys; X X for (trys=10; trys>0; --trys) /* max # of creation attempts */ X { X x=rnd(MAXX-2); X y=rnd(MAXY-2); X if ((item[x][y]==0) && (mitem[x][y]==0) && X ((playerx!=x) || (playery!=y))) { X mitem[x][y] = what; X know[x][y]=0; X hitp[x][y] = monster[what].hitpoints; X return(0); X } X } X return(-1); /* creation failure */ X} X X/* X creates an entire set of monsters for a level X must be done when entering a new level X if sethp(1) then wipe out old monsters else leave them there X */ Xsethp(flg) Xint flg; X{ X register int i,j; X X if (flg) X for (i=0; i<MAXY; i++) X for (j=0; j<MAXX; j++) X stealth[j][i]=0; X if (level==0) { X c[TELEFLAG]=0; X return; X } /* if teleported and found level 1 then know level we are on */ X X if (flg) X j = rnd(12) + 2 + (level>>1); X else X j = (level>>1) + 1; X X for (i=0; i<j; i++) X fillmonst(makemonst(level)); X X if ((level >= 11) && (level<=15)) { X i=level-10; X for (j=1;j<=i;j++) X if (fillmonst(DEMONLORD+rund(7))==-1) X j--; X } X if (level > 15 ) { X i=level-15; X for (j=1;j<=i;j++) X if (fillmonst(DEMONPRINCE)==-1) X j--; X } X positionplayer(); X} X X/* X * Function to destroy all genocided monsters on the present level X */ Xcheckgen() X{ X register int x,y; X X for (y=0; y<MAXY; y++) X for (x=0; x<MAXX; x++) X if (monster[mitem[x][y]].genocided) X mitem[x][y]=0; /* no more monster */ X} END_OF_FILE if test 14814 -ne `wc -c <'create.c'`; then echo shar: \"'create.c'\" unpacked with wrong size! fi # end of 'create.c' 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'\" \(18790 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 X * the player X * raisehp(x) subroutine to gain hit points X * raisemhp(x) subroutine to gain maximum hit points X * losespells(x) subroutine to lose spells X * losemspells(x) subroutine to lose maximum spells X * raisespells(x) subroutine to gain spells X * raisemspells(x) subroutine to gain maximum spells X * recalc() function to recalculate the armor class of X * the player X * makemonst(lev) function to return monster number for a randomly X * selected monster X * positionplayer() function to be sure player is not in a wall X * quit() subroutine to ask if the player really wants X * to quit X */ X X#include "header.h" Xextern int score[],srcount,dropflag; Xextern int random;/* the random number seed */ 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 *********** X RAISE LEVEL 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) X raiseexperience((long)(skill[c[LEVEL]]-c[EXPERIENCE])); X} X X/* X *********** X LOOSE LEVEL 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 **************** X RAISE EXPERIENCE X **************** X raiseexperience(x) X X subroutine to increase experience points X */ Xraiseexperience(x) Xregister long x; X{ X register int i,tmp; X X i=c[LEVEL]; X c[EXPERIENCE]+=x; X while (c[EXPERIENCE] >= skill[c[LEVEL]] && (c[LEVEL] < MAXPLEVEL)) { X tmp = (c[CONSTITUTION]-c[HARDGAME])>>1; X c[LEVEL]++; X raisemhp((int)(rnd(3)+rnd((tmp>0)?tmp:1))); X raisemspells((int)rund(3)); X if (c[LEVEL] < 7-c[HARDGAME]) X raisemhp((int)(c[CONSTITUTION]>>2)); X } X if (c[LEVEL] != i) { X cursors(); X beep(); X lprintf("\nWelcome to level %d",(long)c[LEVEL]); X /* if we changed levels */ X switch (c[LEVEL]) { X case 94: /* earth guardian */ X c[WTW] = 99999L; X break; X case 95: /* air guardian */ X c[INVISIBILITY] = 99999L; X break; X case 96: /* fire guardian */ X c[FIRERESISTANCE] = 99999L; X break; X case 97: /* water guardian */ X c[CANCELLATION] = 99999L; X break; X case 98: /* time guardian */ X c[HASTESELF] = 99999L; X break; X case 99: /* ethereal guardian */ X c[STEALTH] = 99999L; X c[SPIRITPRO] = 99999L; X break; X case 100: X lprcat("\nYou are now The Creator "); X { X register int i,j; X 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/* c[STEALTH] = 99999L; X c[UNDEADPRO] = 99999L; X c[SPIRITPRO] = 99999L; X c[CHARMCOUNT] = 99999L; X c[GIANTSTR] = 99999L; X c[FIRERESISTANCE] = 99999L; X c[DEXCOUNT] = 99999L; X c[STRCOUNT] = 99999L; X c[SCAREMONST] = 99999L; X c[HASTESELF] = 99999L; X c[CANCELLATION] = 99999L; X c[INVISIBILITY] = 99999L; X c[ALTPRO] = 99999L; X c[WTW] = 99999L; X c[AWARENESS] = 99999L; X*/ X break; X } X } X} X X/* X **************** X LOOSE EXPERIENCE X **************** X loseexperience(x) X X subroutine to lose experience points X */ Xloseexperience(x) Xregister long x; X{ X register int i,tmp; X X i=c[LEVEL]; X 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) X 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]) X losemhp((int)(c[CONSTITUTION]>>2)); X losemspells((int)rund(3)); /* lose spells */ X } X if (i!=c[LEVEL]) X { X cursors(); X beep(); X lprintf("\nYou went down to level %d!",(long)c[LEVEL]); X } X bottomline(); X} X X/* X ******** X LOOSE HP 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) Xregister int x; X{ X if ((c[HP] -= x) <= 0) X { X beep(); X lprcat("\n"); X nap(3000); X died(lastnum); X } X} X Xlosemhp(x) Xregister int x; X{ X c[HP] -= x; X if (c[HP] < 1) X c[HP]=1; X c[HPMAX] -= x; X if (c[HPMAX] < 1) X c[HPMAX]=1; X} X X/* X ******** X RAISE HP X ******** X raisehp(x) X raisemhp(x) X X subroutine to gain maximum hit points X */ Xraisehp(x) Xregister int x; X{ X if ((c[HP] += x) > c[HPMAX]) c[HP] = c[HPMAX]; X} X Xraisemhp(x) Xregister int x; X{ X c[HPMAX] += x; X c[HP] += x; X} X X/* X ************ X RAISE SPELLS X ************ X raisespells(x) X raisemspells(x) X X subroutine to gain maximum spells X */ Xraisespells(x) Xregister int x; X{ X if ((c[SPELLS] += x) > c[SPELLMAX]) c[SPELLS] = c[SPELLMAX]; X} X Xraisemspells(x) Xregister int x; X{ X c[SPELLMAX]+=x; X c[SPELLS]+=x; X} X X/* X ************ X LOSE SPELLS X ************ X losespells(x) X losemspells(x) X X subroutine to lose maximum spells X */ Xlosespells(x) Xregister int x; X{ X if ((c[SPELLS] -= x) < 0) c[SPELLS]=0; X} X Xlosemspells(x) Xregister 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) Xregister int lev; X{ X register int tmp,x; X X X if (lev < 1) X lev = 1; X if (lev > 12) X lev = 12; X X tmp=WATERLORD; X X if (lev < 5) X while (tmp==WATERLORD) X tmp=rnd((x=monstlevel[lev-1])?x:1); X X else while (tmp==WATERLORD) X tmp=rnd((x=monstlevel[lev-1]-monstlevel[lev-4])?x:1)+monstlevel[lev-4]; X X while (monster[tmp].genocided && tmp<MAXMONST) tmp++; /* genocided? */ X X if (level < 16) X if (rnd(100)<10) tmp=LEMMING; X X return(tmp); X} X X/* X positionplayer() X X function to be sure player is not in a wall X */ Xpositionplayer() X{ X int try; X try = 2; X X while ((item[playerx][playery] || mitem[playerx][playery]) && (try)) X if (++playerx >= MAXX-1) X { X playerx = 1; X if (++playery >= MAXY-1) X { X playery = 1; X --try; X } X } X if (try==0) 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 X c[AC] = c[MOREDEFENSES]; X if (c[WEAR] >= 0) X switch(iven[c[WEAR]]) { X case OSHIELD: X c[AC] += 2 + ivenarg[c[WEAR]]; X break; X case OLEATHER: X c[AC] += 2 + ivenarg[c[WEAR]]; X break; X case OSTUDLEATHER: X c[AC] += 3 + ivenarg[c[WEAR]]; X break; X case ORING: X c[AC] += 5 + ivenarg[c[WEAR]]; X break; X case OCHAIN: X c[AC] += 6 + ivenarg[c[WEAR]]; X break; X case OSPLINT: X c[AC] += 7 + ivenarg[c[WEAR]]; X break; X case OPLATE: X c[AC] += 9 + ivenarg[c[WEAR]]; X break; X case OPLATEARMOR: X c[AC] += 10 + ivenarg[c[WEAR]]; X break; X case OSSPLATE: X c[AC] += 12 + ivenarg[c[WEAR]]; X break; X case OELVENCHAIN: X c[AC] += 15 + ivenarg[c[WEAR]]; X 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; X else { X i = ivenarg[c[WIELD]]; X switch(iven[c[WIELD]]) { X case ODAGGER: X c[WCLASS] = 3 + i; X break; X case OBELT: X c[WCLASS] = 7 + i; X break; X case OSHIELD: X c[WCLASS] = 8 + i; X break; X case OPSTAFF: X case OSPEAR: X c[WCLASS] = 10 + i; X break; X case OFLAIL: X c[WCLASS] = 14 + i; X break; X case OBATTLEAXE: X c[WCLASS] = 17 + i; X break; X case OLANCE: X c[WCLASS] = 20 + i; X break; X case OLONGSWORD: X c[WCLASS] = 22 + i; X break; X case O2SWORD: X c[WCLASS] = 26 + i; X break; X case OSWORDofSLASHING: X c[WCLASS] = 30 + i; X break; X case OSLAYER: X c[WCLASS] = 30 + i; X break; X case OSWORD: X c[WCLASS] = 32 + i; X break; X case OHAMMER: X c[WCLASS] = 35 + i; X break; X default: X c[WCLASS] = 0; X } X } X c[WCLASS] += c[MOREDAM]; X X /* now for regeneration abilities based on rings */ X c[REGEN]=1; X c[ENERGY]=0; X j=0; X for (k=25; k>0; k--) if (iven[k]) { X j=k; X k=0; X } X for (i=0; i<=j; i++) { X switch(iven[i]) { X case OPROTRING: X c[AC] += ivenarg[i] + 1; X break; X case ODAMRING: X c[WCLASS] += ivenarg[i] + 1; X break; X case OBELT: X c[WCLASS] += ((ivenarg[i]<<1)) + 2; X break; X X case OREGENRING: X c[REGEN] += ivenarg[i] + 1; X break; X case ORINGOFEXTRA: X c[REGEN] += 5 * (ivenarg[i]+1); X break; X case OENERGYRING: X c[ENERGY] += ivenarg[i] + 1; X 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 X cursors(); X strcpy(lastmonst,""); X lprcat("\n\nDo you really want to quit? (y)es, (n)o, (s)ave"); X while (1) { X i=getcharacter(); X if (i == 'y') { X died(300); X return; X } X if ((i == 'n') || (i == '\33')) { X lprcat(" no"); X lflush(); X return; X } X if (i == 's') { X lprcat(" save"); X lflush(); X clear(); X lprcat("Saving . . ."); X lflush(); X savegame(savefilename); X wizard=1; X died(-257); X } X lprcat("\n"); X if (boldon) setbold(); X lprcat("Yes"); X if (boldon) resetbold(); X lprcat(" "); X if (boldon) setbold(); X lprcat("Save"); X if (boldon) resetbold(); X lprcat(" or "); X if (boldon) setbold(); X lprcat("No"); X if (boldon) resetbold(); X lprcat(" please? Do you want to quit? "); X } X} X X/* X function to ask --more-- then the user must enter a space X */ Xmore() X{ X lprcat("\n --- press "); X standout("space"); X lprcat(" to continue --- "); X while (getcharacter() != ' '); X} X X/* X function to put something in the players inventory X returns 0 if success, 1 if a failure X */ Xtake(itm,arg) Xint itm,arg; X{ X register int i,limit; X X /* cursors(); */ X if ((limit = 15+(c[LEVEL]>>1)) > 26) limit=26; X for (i=0; i<limit; i++) X if (iven[i]==0) { X iven[i] = itm; X ivenarg[i] = arg; X limit=0; X switch(itm) { X case OPROTRING: X case ODAMRING: X case OBELT: X limit=1; X break; X case ODEXRING: X c[DEXTERITY] += ivenarg[i]+1; X limit=1; X break; X case OSTRRING: X c[STREXTRA] += ivenarg[i]+1; X limit=1; X break; X case OCLEVERRING: X c[INTELLIGENCE] += ivenarg[i]+1; X limit=1; X break; X case OHAMMER: X c[DEXTERITY] += 10; X c[STREXTRA]+=10; X c[INTELLIGENCE]-=10; X limit=1; X break; X case OORB: X c[ORB]++; X c[AWARENESS]++; X break; X case OORBOFDRAGON: X c[SLAYING]++; X break; X case OSPIRITSCARAB: X c[NEGATESPIRIT]++; X break; X case OCUBEofUNDEAD: X c[CUBEofUNDEAD]++; X break; X case ONOTHEFT: X c[NOTHEFT]++; X break; X case OSWORDofSLASHING: X c[DEXTERITY] +=5; X limit=1; X break; X case OSLAYER: X c[INTELLIGENCE]+=10; X break; X case OPSTAFF: X c[WISDOM]+=10; X break; X case OLARNEYE: X monstnamelist[DEMONLORD] = '1'; X monstnamelist[DEMONLORD+1] = '2'; X monstnamelist[DEMONLORD+2] = '3'; X monstnamelist[DEMONLORD+3] = '4'; X monstnamelist[DEMONLORD+4] = '5'; X monstnamelist[DEMONLORD+5] = '6'; X monstnamelist[DEMONLORD+6] = '7'; X monstnamelist[DEMONPRINCE] = '9'; X monstnamelist[LUCIFER] = '0'; X break; X }; X X lprcat("\nYou pick up:"); X srcount=0; X show3(i); X if (limit) bottomline(); X return(0); X } X lprcat("\nYou can't carry anything else"); X return(1); X} X X/* X subroutine to drop an object returns 1 if something there already else X X k is index into iven list of object to drop X */ X Xdrop_object(k) Xint k; X{ X int itm; X X if ((k<0) || (k>25)) return(0); X itm = iven[k]; X cursors(); X if (itm==0) { X lprintf("\nYou don't have item %c! ",k+'a'); X return(1); X } X if (item[playerx][playery]) { X beep(); X lprcat("\nThere's something here already"); X return(1); X } X if (playery==MAXY-1 && playerx==33) X return(1); /* not in entrance */ X X item[playerx][playery] = itm; X iarg[playerx][playery] = ivenarg[k]; X X srcount=0; X lprcat("\n You drop:"); X show3(k); /* show what item you dropped*/ X know[playerx][playery] = 0; X iven[k]=0; X if (c[WIELD]==k) X c[WIELD]= -1; X if (c[WEAR]==k) X c[WEAR] = -1; X if (c[SHIELD]==k) X c[SHIELD]= -1; X adjustcvalues(itm,ivenarg[k]); X if (itm==OLANCE) recalc(); X/* say dropped an item so wont ask to pick it up right away */ X dropflag=1; X return(0); X} X X/* X function to enchant armor player is currently wearing X */ Xenchantarmor() X{ X register int tmp; X if (c[WEAR]<0) { X if (c[SHIELD] < 0) X { X cursors(); X beep(); X lprcat("\nYou feel a sense of loss"); X return; X } X else { X tmp=iven[c[SHIELD]]; X if (tmp != OSCROLL) if (tmp != OPOTION) { X ivenarg[c[SHIELD]]++; X bottomline(); X } X } X } X tmp = iven[c[WEAR]]; X if (tmp!=OSCROLL) if (tmp!=OPOTION) { X ivenarg[c[WEAR]]++; X bottomline(); X } X} X X/* X function to enchant a weapon presently being wielded X */ Xenchweapon() X{ X register int tmp; X X if (c[WIELD]<0) { X cursors(); X beep(); X lprcat("\nYou feel depressed"); X return; X } X tmp = iven[c[WIELD]]; X if (tmp!=OSCROLL) if (tmp!=OPOTION) { X ivenarg[c[WIELD]]++; X if (tmp==OCLEVERRING) c[INTELLIGENCE]++; X else X if (tmp==OSTRRING) c[STREXTRA]++; X else X if (tmp==ODEXRING) c[DEXTERITY]++; X bottomline(); X } X} X X/* X routine to tell if player can carry one more thing X returns 1 if pockets are full, else 0 X */ Xpocketfull() X{ X register int i,limit; X if ((limit = 15+(c[LEVEL]>>1)) > 26) limit=26; X for (i=0; i<limit; i++) if (iven[i]==0) return(0); X return(1); 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 X j=100; X while (1) { X i=rund(26); X if (iven[i]) if (c[WEAR]!=i) if (c[WIELD]!=i) if (c[SHIELD]!=i) { X srcount=0; X show3(i); X adjustcvalues(iven[i],ivenarg[i]); X iven[i]=0; X 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 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: X i=ODIAMOND; X j=50; X break; X case 2: X i=ORUBY; X j=40; X break; X case 3: X i=OEMERALD; X j=30; X break; X default: X i=OSAPPHIRE; X j=20; X 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) Xint itm,arg; X{ X register int flag,i; X X flag=0; X switch(itm) { X case ODEXRING: X c[DEXTERITY] -= arg+1; X flag=1; X break; X case OSTRRING: X c[STREXTRA] -= arg+1; X flag=1; X break; X case OCLEVERRING: X c[INTELLIGENCE] -= arg+1; X flag=1; X break; X case OHAMMER: X c[DEXTERITY] -= 10; X c[STREXTRA] -= 10; X c[INTELLIGENCE] += 10; X flag=1; X break; X case OORB: X c[ORB]--; X c[AWARENESS]--; X case OSWORDofSLASHING: X c[DEXTERITY] -= 5; X flag=1; X break; X case OSLAYER: X c[INTELLIGENCE]-=10; X flag=1; X break; X case OPSTAFF: X c[WISDOM]-=10; X flag=1; X break; X case OORBOFDRAGON: X --c[SLAYING]; X return; X case OSPIRITSCARAB: X --c[NEGATESPIRIT]; X return; X case OCUBEofUNDEAD: X --c[CUBEofUNDEAD]; X return; X case ONOTHEFT: X --c[NOTHEFT]; X return; X case OLANCE: X c[LANCEDEATH]=0; X return; X case OLARNEYE: X monstnamelist[DEMONLORD] = ' '; X monstnamelist[DEMONLORD+1] = ' '; X monstnamelist[DEMONLORD+2] = ' '; X monstnamelist[DEMONLORD+3] = ' '; X monstnamelist[DEMONLORD+4] = ' '; X monstnamelist[DEMONLORD+5] = ' '; X monstnamelist[DEMONLORD+6] = ' '; X monstnamelist[DEMONPRINCE] = ' '; X monstnamelist[LUCIFER] = ' '; X cursors(); X return; X case OPOTION: X case OSCROLL: X return; X X default: X flag=1; X }; X if (flag) bottomline(); X X for (i=0;i<6;i++) X if (c[i] < 3) X c[i] = 3; X} X X/* X function to read a string from token input "string" X returns a pointer to the string X */ Xgettokstr(str) Xregister char *str; X{ X register int i,j; X X i=50; X while ((getcharacter() != '"') && (--i > 0)); X i=36; X while (--i > 0) { X if ((j=getcharacter()) != '"') *str++ = j; X else i=0; X } X *str = 0; X i=50; X if (j != '"') while ((getcharacter() != '"') && (--i > 0)); /* if end due to too long, then find closing quote */ 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]; X Xgetpassword() X{ X register int i,j; X register char *gpwp; X extern char *password; X X scbr(); /* system("stty -echo cbreak"); */ X gpwp = gpwbuf; X lprcat("\nEnter Password: "); X lflush(); X i = strlen(password); X for (j=0; j<i; j++) read(0,gpwp++,1); X gpwbuf[i]=0; X sncbr(); /* system("stty echo -cbreak"); */ X if (strcmp(gpwbuf,password) != 0) { X lprcat("\nSorry\n"); X lflush(); X return(0); X } 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; X X i=0; X while (i!='y' && i!='n' && i!='\33') i=getcharacter(); 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,k; X X k=c[GOLD]/1000; X j=25; X while ((iven[j]==0) && (j>0)) --j; X for (i=0; i<=j; i++) X switch(iven[i]) { 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 X case OCHAIN: X case OBATTLEAXE: X case O2SWORD: X k += 23; X break; X X case OLONGSWORD: X case OPSTAFF: X case OSWORD: X case ORING: X case OFLAIL: X k += 20; X break; X X case OELVENCHAIN: X case OSWORDofSLASHING: X case OLANCE: X case OSLAYER: X case OSTUDLEATHER: X k += 15; X break; X X X case OLEATHER: X case OSPEAR: X k += 8; X break; X X case OORBOFDRAGON: X case OORB: X case OBELT: X k += 4; X break; X X case OSHIELD: X k += 7; X break; X case OCHEST: X k += 30 + ivenarg[i]; X break; X default: X k++; X }; X return(k); X} END_OF_FILE if test 18790 -ne `wc -c <'global.c'`; then echo shar: \"'global.c'\" unpacked with wrong size! fi # end of 'global.c' fi if test -f 'header.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'header.h'\" else echo shar: Extracting \"'header.h'\" \(13542 characters\) sed "s/^X//" >'header.h' <<'END_OF_FILE' X/* header.h */ X#include <sys/types.h> X#include <sys/stat.h> X#include <sys/timeb.h> X X#ifdef BSD X# include <sys/time.h> X# include <sgtty.h> X#else X# include <sys/times.h> X# include <termio.h> X#endif X X#include <fcntl.h> X#include <ctype.h> X#include <varargs.h> X#include <pwd.h> X#include <signal.h> X#include <stdio.h> X X#define SCORENAME "Uscore" X#define LOGFNAME "Ulog" X#define HELPNAME "Uhelp" X#define LEVELSNAME "Umaps" X#define FORTSNAME "Ufortune" X X#define MAXLEVEL 16 /* max # levels + 1 in the dungeon */ X#define MAXVLEVEL 5 /* max # of levels in the temple of the luran (volcano) */ X X#define MAXX 67 X#define MAXY 17 X X#define SCORESIZE 25 /* this is the number of people on a scoreboard max */ X#define MAXPLEVEL 100 /* maximum player level allowed */ X X/* 56 monsters, 7 demon lords, 1 demon prince, 1 God of Hellfire*/ X#define MAXMONST 57 /* maximum # monsters in the dungeon */ X X#define SPNUM 39 /* maximum number of spells in existance */ X#define MAXSCROLL 28 /* maximum number of scrolls that are possible */ X#define MAXPOTION 35 /* maximum number of potions that are possible */ X#define TIMELIMIT 40000 /* the maximum number moves before the game is called*/ X#define TAXRATE 1/20 /* the tax rate for the LRS */ X#define MAXOBJ 93 /* the maximum number of objects n < MAXOBJ */ X X/* this is the structure definition of the monster data */ Xstruct monst X{ X char *name; X char level; X short armorclass; X char damage; X char attack; X char defense; X char genocided; X char intelligence; /* used to choose movement */ X short gold; X short hitpoints; X unsigned long experience; X}; X X/* this is the structure definition for the items in the dnd store */ Xstruct _itm X{ X short price; X char **mem; X char obj; X char arg; X char qty; X}; X X/* this is the structure that holds the entire dungeon specifications */ Xstruct cel X{ X short hitp; /* monster's hit points */ X char mitem; /* the monster ID */ X char item; /* the object's ID */ X short iarg; /* the object's argument */ X char know; /* have we been here before*/ X}; X X/* this is the structure for maintaining & moving the spheres of annihilation */ Xstruct sphere X{ X struct sphere *p; /* pointer to next structure */ X char x,y,lev; /* location of the sphere */ X char dir; /* direction sphere is going in */ X char lifetime; /* duration of the sphere */ X}; X X/* defines for the character attribute array c[] */ X#define STRENGTH 0 /* characters physical strength not due to objects */ X#define INTELLIGENCE 1 X#define WISDOM 2 X#define CONSTITUTION 3 X#define DEXTERITY 4 X#define CHARISMA 5 X#define HPMAX 6 X#define HP 7 X#define GOLD 8 X#define EXPERIENCE 9 X#define LEVEL 10 X#define REGEN 11 X#define WCLASS 12 X#define AC 13 X#define BANKACCOUNT 14 X#define SPELLMAX 15 X#define SPELLS 16 X#define ENERGY 17 X#define ECOUNTER 18 X#define MOREDEFENSES 19 X#define WEAR 20 X#define PROTECTIONTIME 21 X#define WIELD 22 X#define AMULET 23 /* if have amulet of invisibility */ X#define REGENCOUNTER 24 X#define MOREDAM 25 X#define DEXCOUNT 26 X#define STRCOUNT 27 X#define BLINDCOUNT 28 /* if blind */ X#define CAVELEVEL 29 X#define CONFUSE 30 /* if confused */ X#define ALTPRO 31 X#define HERO 32 /* if hero */ X#define CHARMCOUNT 33 X#define INVISIBILITY 34 /* if invisible */ X#define CANCELLATION 35 /* if cancel cast */ X#define HASTESELF 36 /* if hasted */ X#define EYEOFLARN 37 /* if have eye */ X#define AGGRAVATE 38 X#define GLOBE 39 X#define TELEFLAG 40 /* if been teleported */ X#define SLAYING 41 /* if have orb of dragon slaying */ X#define NEGATESPIRIT 42 /* if negate spirit */ X#define SCAREMONST 43 /* if scare cast */ X#define AWARENESS 44 /* if awareness cast */ X#define HOLDMONST 45 X#define TIMESTOP 46 X#define HASTEMONST 47 X#define CUBEofUNDEAD 48 /* if have cube */ X#define GIANTSTR 49 /* if giant strength */ X#define FIRERESISTANCE 50 X#define BESSMANN 51 /* flag for hammer */ X#define NOTHEFT 52 X#define HARDGAME 53 X#define BYTESIN 54 /* used for checkpointing in tok.c */ X X /* 55 to 59 are open */ X X X X#define LANCEDEATH 60 /* if have LoD */ X#define SPIRITPRO 61 X#define UNDEADPRO 62 X#define SHIELD 63 X#define STEALTH 64 X#define ITCHING 65 X#define LAUGHING 66 /* not implemented */ X#define DRAINSTRENGTH 67 X#define CLUMSINESS 68 X#define INFEEBLEMENT 69 X#define HALFDAM 70 X#define SEEINVISIBLE 71 X#define FILLROOM 72 X /* 73 is open */ X#define SPHCAST 74 /* nz if an active sphere of annihilation */ X#define WTW 75 /* walk through walls */ X#define STREXTRA 76 /* character strength due to objects or enchantments */ X#define TMP 77 /* misc scratch space */ X#define LIFEPROT 78 /* life protection counter */ X X /* FLAGS : non-zero if object has been made */ X#define ORB 79 /* orb - 1 if created, 2 if held */ X#define ELVUP 80 /* elevator up */ X#define ELVDOWN 81 /* elevator down */ X#define HAND 82 /* Hand of Fear */ X#define CUBEUNDEAD 83 /* cube of undead control */ X#define DRAGSLAY 84 /* orb of dragon slaying */ X#define NEGATE 85 /* scarab of negate spirit */ X#define URN 86 /* golden urn */ X#define LAMP 87 /* brass lamp */ X#define TALISMAN 88 /* Talisman of the Sphere */ X#define WAND 89 /* wand of wonder */ X#define STAFF 90 /* staff of power */ X#define DEVICE 91 /* anti-theft */ X#define SLASH 92 /* sword of slashing */ X#define ELVEN 93 /* elven chain */ X#define VORP 94 /* Vorpal */ X#define SLAY 95 /* Slayer */ X#define PAD 96 /* Dealer McDopes */ X X#define COKED 97 /* timer for being coked out */ X/* used up to 97 of 100 */ X X/* defines for the objects in the game */ X#define OALTAR 1 X#define OTHRONE 2 X#define OORB 3 /* orb of enlightement - gives expanded awareness X as long as held */ X#define OPIT 4 X#define OSTAIRSUP 5 X#define OELEVATORUP 6 X#define OFOUNTAIN 7 X#define OSTATUE 8 X#define OTELEPORTER 9 X#define OSCHOOL 10 X#define OMIRROR 11 X#define ODNDSTORE 12 X#define OSTAIRSDOWN 13 X#define OELEVATORDOWN 14 X#define OBANK2 15 X#define OBANK 16 X#define ODEADFOUNTAIN 17 X#define OMAXGOLD 70 X#define OGOLDPILE 18 X#define OOPENDOOR 19 X#define OCLOSEDDOOR 20 X#define OWALL 21 X#define OTRAPARROW 66 X#define OTRAPARROWIV 67 X X#define OLARNEYE 22 X X#define OPLATE 23 X#define OCHAIN 24 X#define OLEATHER 25 X#define ORING 60 X#define OSTUDLEATHER 61 X#define OSPLINT 62 X#define OPLATEARMOR 63 X#define OSSPLATE 64 X#define OSHIELD 68 X X#define OSWORDofSLASHING 26 /* impervious to rust, light, strong */ X#define OHAMMER 27 /* Bessman's Flailing Hammer */ X#define OSWORD 28 X#define O2SWORD 29 /* 2 handed sword */ X#define OSPEAR 30 X#define ODAGGER 31 X#define OBATTLEAXE 57 X#define OLONGSWORD 58 X#define OFLAIL 59 X#define OLANCE 65 X X#define ORINGOFEXTRA 32 X#define OREGENRING 33 X#define OPROTRING 34 X#define OENERGYRING 35 X#define ODEXRING 36 X#define OSTRRING 37 X#define OCLEVERRING 38 X#define ODAMRING 39 X X#define OBELT 40 X X#define OSCROLL 41 X#define OPOTION 42 X#define OBOOK 43 X#define OCHEST 44 X X#define OAMULET 45 X#define OORBOFDRAGON 46 X#define OSPIRITSCARAB 47 X#define OCUBEofUNDEAD 48 X#define ONOTHEFT 49 X X#define ODIAMOND 50 X#define ORUBY 51 X#define OEMERALD 52 X#define OSAPPHIRE 53 X X#define OENTRANCE 54 X#define OVOLDOWN 55 X#define OVOLUP 56 X#define OHOME 69 X X#define OKGOLD 71 X#define ODGOLD 72 X#define OIVDARTRAP 73 X#define ODARTRAP 74 X#define OTRAPDOOR 75 X#define OIVTRAPDOOR 76 X#define OTRADEPOST 77 X#define OIVTELETRAP 78 X#define ODEADTHRONE 79 X#define OANNIHILATION 80 /* sphere of annihilation */ X#define OTHRONE2 81 X#define OLRS 82 /* Larn Revenue Service */ X#define OCOOKIE 83 X#define OURN 84 /* golden urn - not implemented */ X#define OBRASSLAMP 85 /* brass lamp - genie pops up and offers spell */ X#define OHANDofFEAR 86 /* hand of fear - scare monster spell lasts X twice as long if have this */ X#define OSPHTALISMAN 87 /* talisman of the sphere */ X#define OWWAND 88 /* wand of wonder - cant fall in trap doors/pits */ X#define OPSTAFF 89 /* staff of power - cancels drain life attack*/ X X#define OVORPAL 90 /* ? - not implemented */ X#define OSLAYER 91 /* magical sword - increases intelligence by 10, X halves damage caused by demons, demon prince X and lucifer - strong as lance of death against them*/ X X#define OELVENCHAIN 92 /* elven chain - strong and light, X impervious to rust */ X#define OSPEED 93 X#define OACID 94 X#define OHASH 95 X#define OSHROOMS 96 X#define OCOKE 97 X#define OPAD 98 /* Dealer McDope's Pad */ X/* used up to 98 */ X X/* defines for the monsters as objects */ X X#define LEMMING 1 X#define GNOME 2 X#define HOBGOBLIN 3 X#define JACKAL 4 X#define KOBOLD 5 X#define ORC 6 X#define SNAKE 7 X#define CENTIPEDE 8 X#define JACULI 9 X#define TROGLODYTE 10 X#define ANT 11 X#define EYE 12 X#define LEPRECHAUN 13 X#define NYMPH 14 X#define QUASIT 15 X#define RUSTMONSTER 16 X#define ZOMBIE 17 X#define ASSASSINBUG 18 X#define BUGBEAR 19 X#define HELLHOUND 20 X#define ICELIZARD 21 X#define CENTAUR 22 X#define TROLL 23 X#define YETI 24 X#define WHITEDRAGON 25 X#define ELF 26 X#define CUBE 27 X#define METAMORPH 28 X#define VORTEX 29 X#define ZILLER 30 X#define VIOLETFUNGI 31 X#define WRAITH 32 X#define FORVALAKA 33 X#define LAMANOBE 34 X#define OSEQUIP 35 X#define ROTHE 36 X#define XORN 37 X#define VAMPIRE 38 X#define INVISIBLESTALKER 39 X#define POLTERGEIST 40 X#define DISENCHANTRESS 41 X#define SHAMBLINGMOUND 42 X#define YELLOWMOLD 43 X#define UMBERHULK 44 X#define GNOMEKING 45 X#define MIMIC 46 X#define WATERLORD 47 X#define BRONZEDRAGON 48 X#define GREENDRAGON 49 X#define PURPLEWORM 50 X#define XVART 51 X#define SPIRITNAGA 52 X#define SILVERDRAGON 53 X#define PLATINUMDRAGON 54 X#define GREENURCHIN 55 X#define REDDRAGON 56 X#define DEMONLORD 57 X#define DEMONPRINCE 64 X#define LUCIFER 65 X X#define BUFBIG 4096 /* size of the output buffer */ X#define MAXIBUF 4096 /* size of the input buffer */ X#define LOGNAMESIZE 40 /* max size of the players name */ X#define PSNAMESIZE 40 /* max size of the process name */ X#define SAVEFILENAMESIZE 128 /* max size of the savefile path */ X Xextern char aborted[],beenhere[],boldon,cheat,ckpfile[],ckpflag; Xextern char *class[],course[],diagfile[],fortfile[],helpfile[]; Xextern char *inbuffer,drug[]; Xextern char item[MAXX][MAXY],iven[],know[MAXX][MAXY],larnlevels[],lastmonst[]; Xextern char level,*levelname[],logfile[],loginname[],logname[],*lpbuf,*lpend; Xextern char *lpnt,moved[MAXX][MAXY],mitem[MAXX][MAXY],monstlevel[]; Xextern char monstnamelist[],nch[],ndgg[],nlpts[],nomove,nosignal,nowelcome; Xextern char nplt[],nsw[],*objectname[], char_class[]; Xextern char objnamelist[],optsfile[],*potionname[],potprob[]; Xextern char predostuff,restorflag,savefilename[],scorefile[],scprob[]; Xextern char screen[MAXX][MAXY],*scrollname[],sex,*spelcode[],*speldescript[]; Xextern char spelknow[],*spelname[],*spelmes[],spelweird[MAXMONST+8][SPNUM]; Xextern char splev[],stealth[MAXX][MAXY],wizard; Xextern short diroffx[],diroffy[],hitflag,hit2flag,hit3flag,hitp[MAXX][MAXY]; Xextern short iarg[MAXX][MAXY],ivenarg[],lasthx,lasthy,lastnum,lastpx,lastpy; Xextern short nobeep,oldx,oldy,playerx,playery; Xextern int dayplay,enable_scroll,srcount,stayflag,yrepcount,userid,lfd,fd; Xextern long initialtime,outstanding_taxes,skill[],gtime,c[],cbak[]; Xextern unsigned long randx; Xextern struct cel *cell; Xextern struct monst monster[]; Xextern struct sphere *spheres; Xextern struct _itm itm[]; X Xchar *fortune(),*malloc(),*getenv(),*getlogin(),*lgetw(),*lgetl(),*ctime(); Xchar *tmcapcnv(),*tgetstr(),*tgoto(); Xlong paytaxes(),lgetc(),lrint(),time(); Xlong readnum(); X X /* macro to create scroll #'s with probability of occurrence */ X#define newscroll() (scprob[rund(81)]) X /* macro to return a potion # created with probability of occurrence */ X#define newpotion() (potprob[rund(41)]) X /* macro to return the + points on created leather armor */ X#define newleather() (nlpts[rund(c[HARDGAME]?10:13)]) X /* macro to return the + points on chain armor */ X#define newchain() (nch[rund(10)]) X /* macro to return + points on plate armor */ X#define newplate() (nplt[rund(c[HARDGAME]?3:10)]) X /* macro to return + points on new daggers */ X#define newdagger() (ndgg[rund(13)]) X /* macro to return + points on new swords */ X#define newsword() (nsw[rund(c[HARDGAME]?6:13)]) X /* macro to destroy object at present location */ X#define forget() (item[playerx][playery]=know[playerx][playery]=0) X /* macro to wipe out a monster at a location */ X#define disappear(x,y) (mitem[x][y]=know[x][y]=0) X X /* defines below are for use in the termcap mode only */ X#define ST_START 1 X#define ST_END 2 X#define BOLD 3 X#define END_BOLD 4 X#define CLEAR 5 X#define CL_LINE 6 X#define CL_DOWN 14 X#define CURSOR 15 X /* macro to turn on bold display for the terminal */ X#define setbold() (*lpnt++ = ST_START) X /* macro to turn off bold display for the terminal */ X#define resetbold() (*lpnt++ = ST_END) X /* macro to setup the scrolling region for the terminal */ X#define setscroll() enable_scroll=1 X /* macro to clear the scrolling region for the terminal */ X#define resetscroll() enable_scroll=0 X /* macro to clear the screen and home the cursor */ X#define clear() (*lpnt++ =CLEAR, cbak[SPELLS]= -50) X /* macro to clear to end of line */ X#define cltoeoln() (*lpnt++ = CL_LINE) X X /* macro to output one byte to the output buffer */ X#define lprc(ch) ((lpnt>=lpend)?(*lpnt++ =(ch), lflush()):(*lpnt++ =(ch))) X X /* macro to seed the random number generator */ X#define srand(x) (randx=x) X /* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */ X#define rnd(x) ((((randx=randx*1103515245+12345)>>7)%(x))+1) X#define rund(x) ((((randx=randx*1103515245+12345)>>7)%(x))) X /* macros for miscellaneous data conversion */ X#define min(x,y) (((x)>(y))?(y):(x)) X#define max(x,y) (((x)>(y))?(x):(y)) END_OF_FILE if test 13542 -ne `wc -c <'header.h'`; then echo shar: \"'header.h'\" unpacked with wrong size! fi # end of 'header.h' fi if test -f 'regen.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'regen.c'\" else echo shar: Extracting \"'regen.c'\" \(3702 characters\) sed "s/^X//" >'regen.c' <<'END_OF_FILE' X/* regen.c */ X#include "header.h" X/* X ******* X REGEN() X ******* X regen() X X subroutine to regenerate player hp and spells X */ Xregen() X{ X register int i,flag; X register long *d; X X d = c; X if (d[TIMESTOP]) { X if(--d[TIMESTOP]<=0) X bottomline(); X return; X } /* for stop time spell */ X flag=0; X X if (d[STRENGTH]<3) { X d[STRENGTH]=3; X flag=1; X } X if ((d[HASTESELF]==0) || ((d[HASTESELF] & 1) == 0)) X gtime++; X X if (d[HP] != d[HPMAX]) X if (d[REGENCOUNTER]-- <= 0) /*regenerate hit points */ X { X d[REGENCOUNTER] = 22 + (d[HARDGAME]<<1) - d[LEVEL]; X if ((d[HP] += d[REGEN]) > d[HPMAX]) X d[HP] = d[HPMAX]; X bottomhp(); X } X X if (d[SPELLS] < d[SPELLMAX]) /*regenerate spells */ X if (d[ECOUNTER]-- <= 0) { X d[ECOUNTER] = 100+4*(d[HARDGAME]-d[LEVEL]-d[ENERGY]); X d[SPELLS]++; X bottomspell(); X } X X if (d[HERO]) X if (--d[HERO]<=0) { X for (i=0; i<6; i++) X d[i] -= 10; X flag=1; X } X if (d[COKED]) X if (--d[COKED]<=0) { X for (i=0; i<6; i++) X d[i] -= 34; X flag=1; X } X if (d[ALTPRO]) X if (--d[ALTPRO]<=0) { X d[MOREDEFENSES]-=3; X flag=1; X } X if (d[PROTECTIONTIME]) X if (--d[PROTECTIONTIME]<=0) { X d[MOREDEFENSES]-=2; X flag=1; X } X if (d[DEXCOUNT]) X if (--d[DEXCOUNT]<=0) { X if ( (d[DEXTERITY]-=3) < 3 ) X d[DEXTERITY] = 3; X flag=1; X } X if (d[STRCOUNT]) X if (--d[STRCOUNT]<=0) { X d[STREXTRA]-=3; X flag=1; X } X if (d[BLINDCOUNT]) X if (--d[BLINDCOUNT]<=0) { X cursors(); X lprcat("\nThe blindness lifts "); X beep(); X } X if (d[CONFUSE]) X if (--d[CONFUSE]<=0) { X cursors(); X lprcat("\nYou regain your senses"); X beep(); X } X if (d[GIANTSTR]) X if (--d[GIANTSTR]<=0) { X d[STREXTRA] -= 20; X flag=1; X } X if (d[CHARMCOUNT]) X if ((--d[CHARMCOUNT]) <= 0) flag=1; X if (d[INVISIBILITY]) X if ((--d[INVISIBILITY]) <= 0) flag=1; X if (d[CANCELLATION]) X if ((--d[CANCELLATION]) <= 0) flag=1; X if (d[WTW]) X if ((--d[WTW]) <= 0) flag=1; X if (d[HASTESELF]) X if ((--d[HASTESELF]) <= 0) flag=1; X if (d[AGGRAVATE]) X --d[AGGRAVATE]; X if (d[SCAREMONST]) X if ((--d[SCAREMONST]) <= 0) flag=1; X if (d[STEALTH]) X if ((--d[STEALTH]) <= 0) flag=1; X if (d[AWARENESS]) X if(c[ORB] != 2) X --d[AWARENESS]; X if (d[HOLDMONST]) X if ((--d[HOLDMONST]) <= 0) flag=1; X if (d[HASTEMONST]) X --d[HASTEMONST]; X if (d[FIRERESISTANCE]) X if ((--d[FIRERESISTANCE]) <= 0) flag=1; X if (d[GLOBE]) X if (--d[GLOBE]<=0) { X d[MOREDEFENSES]-=10; X flag=1; X } X if (d[SPIRITPRO]) X if (--d[SPIRITPRO] <= 0) flag=1; X if (d[UNDEADPRO]) X if (--d[UNDEADPRO] <= 0) flag=1; X if (d[HALFDAM]) X if (--d[HALFDAM]<=0) { X cursors(); X lprcat("\nYou now feel better "); X beep(); X } X if (d[SEEINVISIBLE]) { X int i; X for (i=0;i<26;i++) X if (iven[i]==OAMULET) { X i=999; X break; X } X if (i!=999) X if (--d[SEEINVISIBLE]<=0) { X monstnamelist[INVISIBLESTALKER] = ' '; X cursors(); X lprcat("\nYou feel your vision return to normal"); X beep(); X } X } X X if (d[ITCHING]) { X if (d[ITCHING]>1) X if ((d[WEAR]!= -1) || (d[SHIELD]!= -1)) X if (rnd(100)<50) { X d[WEAR]=d[SHIELD]= -1; X cursors(); X lprcat("\nThe hysteria of itching forces you to remove your armor!"); X beep(); X recalc(); X bottomline(); X } X if (--d[ITCHING]<=0) { X cursors(); X lprcat("\nYou now feel the irritation subside!"); X beep(); X } X } X if (d[CLUMSINESS]) { X if (d[WIELD] != -1) X if (d[CLUMSINESS]>1) X if (item[playerx][playery]==0)/* if nothing there */ X if (rnd(100)<33) /* drop your weapon */ X drop_object((int)d[WIELD]); X if (--d[CLUMSINESS]<=0) { X cursors(); X lprcat("\nYou now feel less awkward!"); X beep(); X } X } X if (flag) X bottomline(); X} END_OF_FILE if test 3702 -ne `wc -c <'regen.c'`; then echo shar: \"'regen.c'\" unpacked with wrong size! fi # end of 'regen.c' fi echo shar: End of archive 6 \(of 8\). cp /dev/null ark6isdone 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