-+-+-+-+-+-+-+-+ START OF PART 3 -+-+-+-+-+-+-+-+ X# ifndef MSDOS X /* the game save filename */ Xchar savefilename`5BSAVEFILENAMESIZE`5D = LARNHOME; X X /* the score file */ Xchar scorefile`5Bsizeof(LARNHOME)+sizeof(SCORENAME)`5D = LARNHOME; X X /* the logging file */ Xchar logfile`5Bsizeof(LARNHOME)+sizeof(LOGFNAME)`5D = LARNHOME; X X /* the help text file */ Xchar helpfile`5Bsizeof(LARNHOME)+sizeof(HELPNAME)`5D = LARNHOME; X X /* the maze data file */ Xchar larnlevels`5Bsizeof(LARNHOME)+sizeof(LEVELSNAME)`5D = LARNHOME; X X /* the fortune data file */ Xchar fortfile`5Bsizeof(LARNHOME)+sizeof(FORTSNAME)`5D = LARNHOME; X X /* the .larnopts filename */ Xchar optsfile`5B128`5D; /* the option file */ X X /* the player id datafile name */ Xchar playerids`5Bsizeof(LARNHOME)+sizeof(PLAYERIDS)`5D = LARNHOME; X X# ifdef TIMECHECK X /* the holiday datafile */ Xchar holifile`5Bsizeof(LARNHOME)+sizeof(HOLIFILE)`5D = LARNHOME; X# endif X Xchar ckpfile`5Bsizeof(LARNHOME)+sizeof(CKPFILE)`5D = LARNHOME; X X# ifdef EXTRA Xchar diagfile`5B`5D ="Diagfile"; /* the diagnostic filename */ X# endif X X# else /* ndef MSDOS */ X X/* For MSDOS, use fixed length files because of a bug in sizeof. X */ X# ifdef MSDOS X/* Make LARNHOME readable from the larnopt file into a lardir variable. X */ Xchar savefilename`5BPATHLEN`5D; Xchar scorefile`5BPATHLEN`5D; Xchar logfile`5BPATHLEN`5D; Xchar helpfile`5BPATHLEN`5D; Xchar larnlevels`5BPATHLEN`5D; Xchar fortfile`5BPATHLEN`5D; Xchar optsfile`5BPATHLEN`5D; Xchar playerids`5BPATHLEN`5D; Xchar ckpfile`5BPATHLEN`5D; Xchar swapfile`5BPATHLEN`5D; Xchar larndir`5BDIRLEN`5D = LARNHOME; X# ifdef EXTRA Xchar diagfile`5BPATHLEN`5D; /* the diagnostic filename */ X# endif X# else Xchar savefilename`5BPATHLEN`5D = LARNHOME; Xchar scorefile`5BPATHLEN`5D = LARNHOME; Xchar logfile`5BPATHLEN`5D = LARNHOME; Xchar helpfile`5BPATHLEN`5D = LARNHOME; Xchar larnlevels`5BPATHLEN`5D = LARNHOME; Xchar fortfile`5BPATHLEN`5D = LARNHOME; Xchar optsfile`5BPATHLEN`5D = LARNHOME; Xchar playerids`5BPATHLEN`5D = LARNHOME; Xchar swapfile`5BPATHLEN`5D = LARNHOME; Xchar ckpfile`5BPATHLEN`5D = LARNHOME; X# endif X# endif /* ndef MSDOS */ X Xchar *password ="pvnert(x)"; /* the wizards password <=32*/ X#ifndef MSDOS X#if WIZID == -1 Xint wisid=0; /* the user id of the only person who can be wizard V */ X#else Xint wisid=WIZID; /* the user id of the only person who can be wizard V */ X#endif Xchar psname`5BPSNAMESIZE`5D="larn"; /* the process name */ X#endif MSDOS $ CALL UNPACK CONFIG.C;1 34897552 $ create 'f' X/* create.c */ X#include "header.h" X#include "larndefs.h" X#include "monsters.h" X#include "objects.h" X#include "player.h" 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 `7B X register int i; X scbr(); clear(); X c`5BHPMAX`5D=c`5BHP`5D=10; /* start player off with 15 hit points V */ X c`5BLEVEL`5D=1; /* player starts at level one */ X c`5BSPELLMAX`5D=c`5BSPELLS`5D=1; /* total # spells starts off as 3 V */ X c`5BREGENCOUNTER`5D=16; c`5BECOUNTER`5D=96; /*start regeneration cor Vrectly*/ X c`5BSHIELD`5D = c`5BWEAR`5D = c`5BWIELD`5D = -1; X for (i=0; i<26; i++) iven`5Bi`5D=0; X spelknow`5B0`5D=spelknow`5B1`5D=1; /*he knows protection, magic missile* V/ X if (c`5BHARDGAME`5D<=0) X `7B X iven`5B0`5D=OLEATHER; iven`5B1`5D=ODAGGER; iven`5B2`5D = 0; X ivenarg`5B1`5D=ivenarg`5B0`5D=c`5BWEAR`5D=0; c`5BWIELD`5D=1; X `7D X playerx=rnd(MAXX-2); playery=rnd(MAXY-2); X regen_bottom = TRUE ; X for (i=0; i<6; i++) c`5Bi`5D=12; /* make the attributes, ie str, int, e Vtc. */ X recalc(); X `7D 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 V. X */ Xnewcavelevel(x) X register int x; X `7B X register int i,j; X if (beenhere`5Blevel`5D) savelevel(); /* put the level back into stora Vge */ X level = x; /* get the new level and put in working storage V */ X if (beenhere`5Bx`5D) X `7B X getlevel(); X sethp(0); X positionplayer(); X checkgen(); X return; X `7D X X /* fill in new level X */ X for (i=0; i 1 && (rnd(17)<=4 `7C`7C k==MAXLEVEL-1 `7C`7C k==MAXLEVEL+MAXVLEV VEL-1)) X `7B X if (cannedlevel(k)); return; /* read maze from data file */ X `7D X if (k==0) tmp=0; else tmp=OWALL; X for (i=0; i1) treasureroom(k); X `7D X X/* X function to eat away a filled in maze X */ Xeat(xx,yy) X register int xx,yy; X `7B X register int dir,try; X dir = rnd(4); try=2; X while (try) X `7B X switch(dir) X `7B X case 1: if (xx <= 2) break; /* west */ X if ((item`5Bxx-1`5D`5Byy`5D!=OWALL) `7C`7C (item`5Bxx-2` V5D`5Byy`5D!=OWALL)) break; X item`5Bxx-1`5D`5Byy`5D = item`5Bxx-2`5D`5Byy`5D = 0; X eat(xx-2,yy); break; X X case 2: if (xx >= MAXX-3) break; /* east */ X if ((item`5Bxx+1`5D`5Byy`5D!=OWALL) `7C`7C (item`5Bxx+2` V5D`5Byy`5D!=OWALL)) break; X item`5Bxx+1`5D`5Byy`5D = item`5Bxx+2`5D`5Byy`5D = 0; X eat(xx+2,yy); break; X X case 3: if (yy <= 2) break; /* south */ X if ((item`5Bxx`5D`5Byy-1`5D!=OWALL) `7C`7C (item`5Bxx`5D V`5Byy-2`5D!=OWALL)) break; X item`5Bxx`5D`5Byy-1`5D = item`5Bxx`5D`5Byy-2`5D = 0; X eat(xx,yy-2); break; X X case 4: if (yy >= MAXY-3 ) break; /* north */ X if ((item`5Bxx`5D`5Byy+1`5D!=OWALL) `7C`7C (item`5Bxx`5D V`5Byy+2`5D!=OWALL)) break; X item`5Bxx`5D`5Byy+1`5D = item`5Bxx`5D`5Byy+2`5D = 0; X eat(xx,yy+2); break; X `7D; X if (++dir > 4) `7B dir=1; --try; `7D X `7D X `7D X X/* X * function to read in a maze from a data file X * X * Format of maze data file: 1st character = # of mazes in file (ascii dig Vit) X * For each maze: 18 lines (1st 17 used) 67 characters per line X * X * Special characters in maze data file: X * X * # wall D door . random monster X * `7E eye of larn ! cure dianthroritis X * - random object X */ Xstatic cannedlevel(k) X int k; X `7B X char *row,*lgetl(); X register int i,j; X int it,arg,mit,marg; X if (lopen(larnlevels)<0) X `7B X write(1,"Can't open the maze data file\n",30); died(-282); return( V0); X `7D X i=lgetc(); if (i<='0') `7B died(-282); return(0); `7D X for (i=18*rund(i-'0'); i>0; i--) lgetl(); /* advance to desired maz Ve */ X for (i=0; i>1); X if (c`5BHARDGAME`5D<2) X for (playerx=tx+1; playerx<=tx+xsize-2; playerx+=2) X for (i=0, j=rnd(6); i<=j; i++) X `7B something(lv+2); createmonster(makemonst(lv+1)); `7D X else X for (playerx=tx+1; playerx<=tx+xsize-2; playerx+=2) X for (i=0, j=rnd(4); i<=j; i++) X `7B something(lv+2); createmonster(makemonst(lv+3)); `7D X X playerx=tp1; playery=tp2; X `7D X X/* X *********** X MAKE_OBJECT X *********** X subroutine to create the objects in the maze for the given level X */ Xstatic makeobject(j) X register int j; X `7B X register int i; X if (j==0) X `7B 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 `7D X X if (j==MAXLEVEL) fillroom(OVOLUP,0); /* volcano shaft up from the temple V */ X X/* make the fixed objects in the maze STAIRS */ X if ((j>0) && (j != MAXLEVEL-1) && (j != MAXLEVEL+MAXVLEVEL-1)) X fillroom(OSTAIRSDOWN,0); X if ((j > 1) && (j != MAXLEVEL)) +-+-+-+-+-+-+-+- END OF PART 3 +-+-+-+-+-+-+-+-