-+-+-+-+-+-+-+-+ START OF PART 11 -+-+-+-+-+-+-+-+ X if (mitem`5Btmp`5D`5Btmp2`5D) return(1); /* if monster nearby */ X return(0); X `7D X X/* X function to steal an item from the players pockets X returns 1 if steals something else returns 0 X */ Xstealsomething() X `7B X register int i,j; X j=100; X while (1) X `7B X i=rund(26); X if (iven`5Bi`5D) if (c`5BWEAR`5D!=i) if (c`5BWIELD`5D!=i) if (c`5BSH VIELD`5D!=i) X `7B X show3(i); X adjustcvalues(iven`5Bi`5D,ivenarg`5Bi`5D); iven`5Bi`5D=0; retur Vn(1); X `7D X if (--j <= 0) return(0); X `7D X `7D X X/* X function to return 1 is player carrys nothing else return 0 X */ Xemptyhanded() X `7B X register int i; X for (i=0; i<26; i++) X if (iven`5Bi`5D) if (i!=c`5BWIELD`5D) if (i!=c`5BWEAR`5D) if (i!=c`5 VBSHIELD`5D) return(0); X return(1); X `7D X X/* X function to create a gem on a square near the player X */ Xcreategem() X `7B X register int i,j; X switch(rnd(4)) X `7B 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 `7D; X createitem(i,rnd(j)+j/10); X `7D 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 `7B X register int flag; X flag=0; X switch(itm) X `7B X case ODEXRING: c`5BDEXTERITY`5D -= arg+1; flag=1; break; X case OSTRRING: c`5BSTREXTRA`5D -= arg+1; flag=1; break; X case OCLEVERRING: c`5BINTELLIGENCE`5D -= arg+1; flag=1; break; X case OHAMMER: c`5BDEXTERITY`5D -= 10; c`5BSTREXTRA`5D -= 10; X c`5BINTELLIGENCE`5D += 10; flag=1; break; X case OSWORDofSLASHING: c`5BDEXTERITY`5D -= 5; flag=1; break; X case OORBOFDRAGON: --c`5BSLAYING`5D; return; X case OSPIRITSCARAB: --c`5BNEGATESPIRIT`5D; return; X case OCUBEofUNDEAD: --c`5BCUBEofUNDEAD`5D; return; X case ONOTHEFT: --c`5BNOTHEFT`5D; return; X case OLANCE: c`5BLANCEDEATH`5D=0; return; X case OPOTION: case OSCROLL: return; X X default: flag=1; X `7D; X if (flag) bottomline(); X `7D 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`5B33`5D; Xgetpassword() X `7B 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; j0)) X --j; X for (i=0; i<=j; i++) X switch(iven`5Bi`5D) X `7B 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`5Bi`5D; X break; X default: X k++; X break; X `7D; X return(k); X `7D 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 `7B X return((((lrandx=lrandx*1103515245+12345)>>7)%(x))+1); X `7D X Xrund(x) X int x; X `7B X return((((lrandx=lrandx*1103515245+12345)>>7)%(x)) ); X `7D 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 `7B X register int i,j; X i=50; X while ((ttgetch() != '"') && (--i > 0)); X i=36; X while (--i > 0) X `7B X if ((j=ttgetch()) != '"') *str++ = j; else i=0; X `7D X *str = 0; X i=50; X if (j != '"') while ((ttgetch() != '"') && (--i > 0)); /* if end due to V too long, then find closing quote */ X `7D X#endif $ CALL UNPACK GLOBAL.C;1 124189379 $ create 'f' X/* header.h Larn is copyrighted 1986 by Noah Morgan. */ X X#ifdef MSDOS X# define LARNHOME "" X#endif X X#ifndef WIZID X# define WIZID 1000 X#endif X X#define TRUE 1 X#define FALSE 0 X X#ifdef VMS X#define unlink(x) delete(x) /* remove a file */ X#endif X X#define SCORENAME "larn.scr" X#define LOGFNAME "larn.log" X#define HELPNAME "larn.hlp" X#define LEVELSNAME "larn.maz" X#define FORTSNAME "larn.ftn" X#define PLAYERIDS "larn.pid" X#define HOLIFILE "holidays" X#define DIAGFILE "Diagfile" X#ifdef MSDOS X# define LARNOPTS "larn.opt" X# define SAVEFILE "larn.sav" X# define SWAPFILE "larn.swp" X# define CKPFILE "larn.ckp" X#else X# ifdef VMS X# define LARNOPTS "larn.opt" X# define SAVEFILE "larn.sav" X# define CKPFILE "larn.ckp" X# else X# define LARNOPTS ".larnopts" X# define SAVEFILE "Larn.sav" X# define CKPFILE "Larn.ckp" X# define MAIL /* disable the mail routines for MSDOS */ X# endif VMS X#endif MSDOS X X#define MAXLEVEL 11 /* max # levels in the dungeon */ X#define MAXVLEVEL 3 /* max # of levels in the temple of the luran */ X#define MAXX 67 X#define MAXY 17 X X#define SCORESIZE 10 /* this is the number of people on a scoreboard max V */ X#define MAXPLEVEL 100 /* maximum player level allowed */ X#define SPNUM 38 /* maximum number of spells in existance */ X#define TIMELIMIT 30000 /* maximum number of moves before the game is called V */ X#define TAXRATE 1/20 /* tax rate for the LRS */ X X X/* this is the structure that holds the entire dungeon specifications */ Xstruct cel X `7B 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 `7D; X X/* this is the structure for maintaining & moving the spheres of annihilatio Vn */ Xstruct sphere X `7B 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 `7D; X X# ifdef MSDOS X/* Since only 1 level is needed at one time, each level can be swapped X * to disk if there is not enough memory to allocate it. Thus, there X * need only be room for 1 level. When a level is needed, if it is X * already in memory, there is nothing to do. If it isn't, get it from X * disk after swapping out the oldest level - dgk. X */ X# define FREEBLOCK -99 Xtypedef struct _ramblock RAMBLOCK; Xtypedef struct _diskblock DISKBLOCK; Xstruct _ramblock `7B X RAMBLOCK *next; /* For a linked list */ X int level; /* Level stored or FREEBLOCK */ X long gtime; /* The time stored */ X struct cel cell`5BMAXX * MAXY`5D; /* The storage */ X`7D; Xstruct _diskblock `7B X DISKBLOCK *next; /* For linked list */ X int level; /* Level stored or FREEBLOCK */ X long gtime; /* The time stored */ X long fpos; /* The disk position */ X`7D; Xextern RAMBLOCK *ramblks; Xextern DISKBLOCK *diskblks; X X# endif MSDOS X X# ifdef MSDOS X# define NULL 0L /* For large model only */ X# else X# define NULL 0 X# endif MSDOS 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 */ $ CALL UNPACK HEADER.H;1 525688092 $ create 'f' X/* help.c */ X#include "header.h" X#include "larndefs.h" X X/* X * help function to display the help info X * X * format of the .larn.help file X * X * 1st character of file: # of pages of help available (ascii digit) X * page (23 lines) for the introductory message (not counted in above) X * pages of help text (23 lines per page) X */ Xextern char helpfile`5B`5D; Xhelp() X `7B X register int i,j,maxj; X#ifndef VT100 X#ifndef MSDOS X char tmbuf`5B128`5D; /* intermediate translation buffer when not a VT V100 */ X#endif X#endif X X /* open the help file and get # pages`20 X */ X if ((j=openhelp()) < 0) `20 X return; X X /* skip over intro message`20 X */ X for (i=0; i<23; i++)`20 X lgetl(); X X /* if command mode, skip over the second page (prompt mode help) X */ X if (!prompt_mode) X `7B X for (i=0; i<23; i++) X lgetl(); X j--; X `7D X X for (maxj = j; j>0; j--) X `7B X clear(); X for (i=0; i<23; i++) X#if (defined(VT100) `7C`7C defined(MSDOS)) X lprcat(lgetl()); /* print out each line that we read in */ X#else X `7B`20 X tmcapcnv(tmbuf,lgetl()); `20 X lprcat(tmbuf);`20 X `7D /* intercept \33's */ X#endif X if (j>1) X `7B X lprcat(" ---- Press "); standout("return"); X lprcat(" to exit, "); standout("space"); X lprcat(" for more help ---- "); X i=0; while ((i!=' ') && (i!='\n') && (i!='\33')) i=ttgetch(); X if ((i=='\n') `7C`7C (i=='\33')) X `7B X lrclose(); `20 X setscroll(); `20 X drawscreen(); `20 X return; X `7D X `7D X X /* For prompt mode, skip over the third page (command mode help) X This could be done more efficiently, but its not worth the trouble. X */ X if ((prompt_mode) && (j==maxj)) X `7B X for (i=0; i<23; i++) X lgetl(); X j--; X `7D X X `7D X lrclose(); `20 X retcont(); `20 X drawscreen(); X `7D X X/* X * function to display the welcome message and background X */ Xwelcome() X `7B X register int i; X#ifndef VT100 X char tmbuf`5B128`5D; /* intermediate translation buffer when not a VT V100 */ X#endif X if (openhelp() < 0) return; /* open the help file */ X clear(); X for(i=0; i<23; i++) X#ifdef VT100 X lprcat(lgetl()); /* print out each line that we read in */ X#else X `7B tmcapcnv(tmbuf,lgetl()); lprcat(tmbuf); `7D /* intercept \3 V3's */ X#endif X lrclose(); retcont(); /* press return to continue */ X `7D X X/* X * function to say press return to continue and reset scroll when done X */ Xretcont() X `7B X cursor(1,24); lprcat("Press "); standout("return"); X lprcat(" to continue: "); while (ttgetch() != '\n'); X setscroll(); X `7D X X/* X * routine to open the help file and return the first character - '0' X */ Xstatic openhelp() X `7B X if (lopen(helpfile)<0) X `7B X lprintf("Can't open help file \"%s\" ",helpfile); X lflush(); sleep(4); drawscreen(); setscroll(); return(-1); X `7D X resetscroll(); return(lgetc() - '0'); X `7D $ CALL UNPACK HELP.C;1 1561405898 $ create 'f' X#include "header.h" X#include "larndefs.h" X#include "objects.h" X#include "player.h" X X#ifdef __STDC__ X`09 show1( int, char*`5B`5D ); X show3( int ); Xstatic show2( int ); Xstatic void t_setup( int ); Xstatic void t_endup( int ); X X#define SIGNED signed X#else X`09 show1( ); X show3( ); Xstatic show2( ); Xstatic void t_setup( ); Xstatic void t_endup( ); X X#define SIGNED X#endif X Xstatic int qshowstr(); Xshowwear(); Xshowwield(); Xshowread(); Xshowquaff(); Xshoweat(); Xextern int dropflag; X X/* Allow only 26 items (a to z) in the player's inventory */ X#define MAXINVEN 26 X X/* The starting limit to the number of items the player can carry. `20 X The limit should probably be based on player strength and the X weight of the items. X*/ X#define MIN_LIMIT 15 X X/* define a sentinel to place at the end of the sorted inventory. X (speeds up display reads ) X*/ X#define END_SENTINEL 255 X X/* declare the player's inventory. These should only be referenced X in this module. X iven - objects in the player's inventory X ivenarg - attribute of each item ( + values, etc ) X ivensort - sorted inventory (so we don't sort each time) X*/ Xchar iven`5BMAXINVEN`5D; XSIGNED short ivenarg`5BMAXINVEN`5D; Xunsigned char ivensort`5BMAXINVEN+1`5D; /* extra is for sentinel */ X Xstatic char srcount = 0 ; /* line counter for showstr() */ X X/* X Initialize the player's inventory X*/ Xvoid init_inventory( ) X `7B X int i; X X for ( i = 0; i < MAXINVEN ; i++ ) X `7B X iven`5Bi`5D = ivenarg`5Bi`5D = 0; +-+-+-+-+-+-+-+- END OF PART 11 +-+-+-+-+-+-+-+-