void obook() { lprcat("\nDo you "); if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); lprcat("(t) take it"); iopts(); while (1) switch(getcharacter()) { case ESC: case 'i': ignore(); return; case 'r': if (c[BLINDCOUNT]) break; lprcat("read."); readbook(iarg[playerx][playery]); /* no more book */ forget(); return; case 't': lprcat("take."); if (take(OBOOK,iarg[playerx][playery])==0) forget(); /* no more book */ return; }; }
void ocookie() { char *fortune(), *p; lprcat("\nDo you (e) eat it, (t) take it"); iopts(); while (1) switch(getcharacter()) { case ESC: case 'i': ignore(); return; case 'e': lprcat("eat.\nThe cookie tasted good."); forget(); /* no more cookie */ if (c[BLINDCOUNT]) return; if ((p=fortune(fortfile))==(char *)NULL) return; lprcat(" A message inside the cookie reads:\n"); lprcat(p); return; case 't': lprcat("take."); if (take(OCOOKIE,0)==0) forget(); return; }; }
void oelevator(int dir) { if (dir==1) { if (level == 0) { lprcat(",\nunfortunately, it is out of order."); return; } playerx = rnd(MAXX-2); playery = rnd(MAXY-2); nap(2000); newcavelevel(rund(level)); } else { if (level==DBOTTOM || level==VBOTTOM) { nap(2000); lprcat("\nand it leads straight to HELL!"); beep(); lflush(); nap(3000); died(287); } playerx = rnd(MAXX-2); playery = rnd(MAXY-2); nap(2000); newcavelevel(level + rnd(DBOTTOM - level)); } positionplayer(); draws(0,MAXX,0,MAXY); bot_linex(); }
void opit() { int i; if (rnd(101)>81) return; if (rnd(70) > 9*c[DEXTERITY]-packweight() || rnd(101)<5) { for (i=0;i<IVENSIZE;i++) if (iven[i]==OWWAND) { lprcat("\nYou float right over the pit."); return; } if (level==DBOTTOM || level == VBOTTOM) obottomless(); else { if (rnd(101)<20) { i=0; lprcat("\nYou fell ino a pit! " "A poor monster cushions your fall!\n"); } else { i = rnd(level*3+3); if (i > c[HP]) i = c[HP]; lprintf("\nYou fell into a pit! " "You suffer %d hit point%s damage.",(long)i, (i==1)?"":"s"); lastnum=261; /* if he dies scoreboard will say so */ } losehp(i); lflush(); nap(2000); newcavelevel(level+1); draws(0,MAXX,0,MAXY); } } }
/* ******* OSCROLL ******* function to process a magic scroll */ void oscroll(int typ) { lprcat("\nDo you "); if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); lprcat("(t) take it"); iopts(); while (1) switch(getcharacter()) { case ESC: case 'i': ignore(); return; case 'r': if (c[BLINDCOUNT]) break; lprcat("read."); forget(); if (typ==2 || typ==15) { show1cell(playerx,playery); cursors(); } /* destroy it */ read_scroll(typ); return; case 't': lprcat("take."); if (take(OSCROLL,typ)==0) forget(); /* destroy it */ return; }; }
void closedoor() { int i; /* can't find objects is time is stopped*/ if (c[TIMESTOP]) return; showcell(playerx,playery); cursors(); yrepcount=0; i=item[playerx][playery]; if (i != OOPENDOOR) { lprcat("\nThere is no open door here."); return; } lprcat("\nThe door closes."); forget(); item[playerx][playery]=OCLOSEDDOOR; iarg[playerx][playery]=0; dropflag=1; /* So we won't be asked to open it */ /* playerx = lastpx; playery = lastpy;*/ /* if there is now a monster on the space we ** need to move back on to, get rid of it */ /* if (mitem[lastpx][lastpy].mon) { lprintf("\nThe %s disappears mysteriously.", monster[mitem[lastpx][lastpy].mon].name); disappear(lastpx, lastpy); hitp[lastpx][lastpy]=0; }*/ }
/* subroutine to process a throne object */ void othrone(int arg) { lprcat("\nDo you (p) pry off jewels, (s) sit down"); iopts(); while (1) { while (1) switch (ttgetch()) { case 'p': lprcat(" pry off"); act_remove_gems(arg); return; case 's': lprcat(" sit down"); act_sit_throne(arg); return; case 'i': case '\33': ignore(); return; }; } }
/* * writeboard() * Function to write the scoreboard from readboard()'s buffer * * returns -1 if unable to write the scoreboard, returns 0 if all is OK */ writeboard() { FILE *fp; if ((fp = fopen(scorefile, "w")) == (FILE *)NULL) { lprcat("Can't open scorefile for writing\n"); lflush(); return(-1); } if (fwrite((char * )sco, sizeof(sco), 1, fp) != 1) { lprcat("Can't write scorefile\n"); lflush(); fclose(fp); return(-1); } if (fwrite((char * )winr, sizeof(winr), 1, fp) != 1) { lprcat("Can't write scorefile\n"); lflush(); fclose(fp); return(-1); } fflush(fp); fclose(fp); return(0); }
/* Performs the act of opening a chest. Parameters: x,y location of the chest to open. Assumptions: cursors() has been called previously */ void act_open_chest(int x, int y) { int i,k; k=rnd(101); if (k<40) { lprcat("\nThe chest explodes as you open it"); i = rnd(10); lastnum=281; /* in case he dies */ lprintf("\nYou suffer %d hit points damage!",(long)i); checkloss(i); switch(rnd(10)) /* see if he gets a curse */ { case 1: c[ITCHING]+= rnd(1000)+100; lprcat("\nYou feel an irritation spread over your skin!"); break; case 2: c[CLUMSINESS]+= rnd(1600)+200; lprcat("\nYou begin to lose hand to eye coordination!"); break; case 3: c[HALFDAM]+= rnd(1600)+200; lprcat("\nA sickness engulfs you!"); break; }; item[x][y]=know[x][y]=0; /* destroy the chest */ if (rnd(100)<69) creategem(); /* gems from the chest */ dropgold(rnd(110*iarg[playerx][playery]+200)); for (i=0; i<rnd(4); i++) something(iarg[playerx][playery]+2); } else lprcat("\nNothing happens"); return; }
/* function to drop an object */ static void dropobj(void) { int i; unsigned char *p; long amt; p = &item[playerx][playery]; while (1) { if ((i = whatitem("drop")) == '\33') return; if (i == '*') showstr(); else { if (i == '.') { /* drop some gold */ if (*p) { lprcat("\nThere's something here already!"); return; } lprcat("\n\n"); cl_dn(1, 23); lprcat("How much gold do you drop? "); if ((amt = readnum((long) c[GOLD])) == 0) return; if (amt > c[GOLD]) { lprcat("\nYou don't have that much!"); return; } if (amt <= 32767) { *p = OGOLDPILE; i = amt; } else if (amt <= 327670L) { *p = ODGOLD; i = amt / 10; amt = 10 * i; } else if (amt <= 3276700L) { *p = OMAXGOLD; i = amt / 100; amt = 100 * i; } else if (amt <= 32767000L) { *p = OKGOLD; i = amt / 1000; amt = 1000 * i; } else { *p = OKGOLD; i = 32767; amt = 32767000L; } c[GOLD] -= amt; lprintf("You drop %ld gold pieces", (long)amt); iarg[playerx][playery] = i; bottomgold(); know[playerx][playery] = 0; dropflag = 1; return; } drop_object(i - 'a'); return; } } }
void odeadthrone() { int k; lprcat("\nDo you (s) sit down"); iopts(); while (1) { while (1) switch(getcharacter()) { case 's': lprcat(" sit down"); k=rnd(101); if (k<5) raiselevel(); else if (k<25) { lprcat("\nZaaaappp! You've been teleported!\n"); beep(); oteleport(0); } else lprcat("\nNothing happens."); return; case 'i': case ESC: ignore(); return; }; } /* NOTREACHED */ }
/* Perform the actions common to command and prompt mode when opening a door. Assumes cursors(). Parameters: the X,Y location of the door to open. Return value: TRUE if successful in opening the door, false if not. */ int act_open_door(int x, int y) { if (rnd(11)<7) { switch(iarg[x][y]) { case 6: c[AGGRAVATE] += rnd(400); break; case 7: lprcat("\nYou are jolted by an electric shock "); lastnum=274; losehp(rnd(20)); bottomline(); break; case 8: loselevel(); break; case 9: lprcat("\nYou suddenly feel weaker "); if (c[STRENGTH]>3) c[STRENGTH]--; bottomline(); break; default: break; } return( 0 ); } else { know[x][y]=0; item[x][y]=OOPENDOOR; return( 1 ); } }
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; }
void odeadthrone(void) { int k; lprcat("\nDo you (s) sit down"); iopts(); while (1) { while (1) switch (ttgetch()) { case 's': lprcat(" sit down"); k = rnd(101); if (k < 35) { lprcat("\nZaaaappp! You've been teleported!\n"); beep(); oteleport(0); } else lprcat("\nnothing happens"); return; case 'i': case '\33': ignore(); return; }; } }
/* process a fountain object */ void ofountain(void) { cursors(); lprcat("\nDo you (d) drink, (w) wash yourself"); iopts(); while (1) switch (ttgetch()) { case 'd': lprcat("drink"); act_drink_fountain(); return; case '\33': case 'i': ignore(); return; case 'w': lprcat("wash yourself"); act_wash_fountain(); return; } }
/* subroutine to process a throne object */ void ochest(void) { lprcat("\nDo you (t) take it, (o) try to open it"); iopts(); while (1) { while (1) switch (ttgetch()) { case 'o': lprcat(" open it"); act_open_chest(playerx, playery); return; case 't': lprcat(" take"); if (take(OCHEST, iarg[playerx][playery]) == 0) item[playerx][playery] = know[playerx][playery] = 0; return; case 'i': case '\33': ignore(); return; }; } }
/* function to wear armor */ static void wear(void) { int i; while (1) { if ((i = whatitem("wear"))=='\33') return; if (i != '.' && i != '-') { if (i=='*') { i = showwear(); cursors(); } if (i && i != '.') switch(iven[i-'a']) { case 0: ydhi(i); return; case OLEATHER: case OCHAIN: case OPLATE: case ORING: case OSPLINT: case OPLATEARMOR: case OSTUDLEATHER: case OSSPLATE: if (c[WEAR] != -1) { lprcat("\nYou're already wearing some armor"); return; } c[WEAR]=i-'a'; bottomline(); return; case OSHIELD: if (c[SHIELD] != -1) { lprcat("\nYou are already wearing a shield"); return; } if (iven[c[WIELD]]==O2SWORD) { lprcat("\nYour hands are busy with the two handed sword!"); return; } c[SHIELD] = i-'a'; bottomline(); return; default: lprcat("\nYou can't wear that!"); }; } } }
letter1() { int write_len; sprintf(mail600, "/tmp/#%dmail600",pid); /* prepare path */ if (lcreat(mail600) < 0) { write_len = write(1,"can't write 600 letter\n",23); return(0); } lprcat("From: [email protected] (Ularn Revenue Service)\n"); lprcat("Subject: undeclared income\n"); lprcat("\n We heard you survived the caverns of Ularn. Let me be the"); lprcat("\nfirst to congratulate you on your success. It is quite a feat."); lprcat("\nIt must also have been very profitable for you."); lprcat("\n\n The Dungeon Master has informed us that you brought"); lprintf("\n%d gold piece%s back with you from your journey. As the", (long)c[GOLD], (c[GOLD]==1)?"":"s"); lprcat("\ncounty of Ularn is in dire need of funds, we have spared no time"); lprintf("\nin preparing your tax bill. You owe %d gold piece%s as", Taxes, (Taxes==1)?"":"s"); lprcat("\nof this notice, and is due within 5 days. Failure to pay will"); lprcat("\nmean penalties. Once again, congratulations. We look forward"); lprcat("\nto your future successful expeditions.\n"); lwclose(); return(1); }
/* Code to perform the action of washing at a fountain. Assumes that cursors() has already been called and that a check has been made that the player is actually standing at a live fountain. */ void act_wash_fountain(void) { int x ; if (rnd(100) < 11) { x=rnd((level<<2)+2); lprintf("\nOh no! The water was foul! You suffer %d hit points!",(long)x); lastnum=273; losehp(x); bottomline(); cursors(); } else if (rnd(100) < 29) lprcat("\nYou got the dirt off!"); else if (rnd(100) < 31) lprcat("\nThis water seems to be hard water! The dirt didn't come off!"); else if (rnd(100) < 34) createmonster(WATERLORD); /* make water lord */ else lprcat("\nnothing seems to have happened"); return; }
/* * subroutine to eat a cookie one is carrying */ void eatcookie (void) { int i; char *p; while (1) { if ((i = whatitem("eat"))==ESC) return; if (i != '.') { if (i=='*') { showeat(); } else { if (iven[i-'a']==OCOOKIE) { lprcat("\nThe cookie was delicious."); iven[i-'a']=0; if (!c[BLINDCOUNT]) { if ((p=fortune(fortfile))!=0) { lprcat(" Inside you find a scrap of paper that says:\n"); lprcat(p); } } return; } if (iven[i-'a']==0) { ydhi(i); return; } lprcat("\nYou can't eat that!"); return; } } } }
/* Text to be displayed if ^C during intro screen */ static void s2choose() { cursor(1, 24); lprcat("Prees "); setbold(); lprcat("return"); resetbold(); lprcat(" to continue: "); lflush(); }
/* * Subroutine to print out the non-winners scoreboard * * Enter with 0 to list the scores, enter with 1 to list inventories too * Returns the number of players on scoreboard that were shown */ static int shou (int x) { int i, j, n, k; int count; for (count = j = i = 0; i < SCORESIZE; i++) /* is the scoreboard empty? */ if (sco[i].score != 0) { j++; break; } if (j) { lprcat ("\n Score Difficulty Larn Visitor Log\n"); for (i = 0; i < SCORESIZE; i++) /* be sure to print them out in order */ for (j = 0; j < SCORESIZE; j++) if (sco[j].order == i) { if (sco[j].score) { count++; lprintf ("%10ld %2d %s ", sco[j].score, sco[j].hardlev, sco[j].who); if (sco[j].what < 256) lprintf ("killed by a %s", monster[sco[j].what].name); else lprintf ("%s", whydead[sco[j].what - 256]); if (x != 263) lprintf (" on %s", levelname[sco[j].level]); if (x) { for (n = 0; n < 26; n++) { iven[n] = sco[j].sciv[n][0]; ivenarg[n] = sco[j].sciv[n][1]; } for (k = 1; k < 99; k++) { for (n = 0; n < 26; n++) { if (k == iven[n]) show3 (n); } } lprcat ("\n\n"); } else lprc ('\n'); } j = SCORESIZE; } } return (count); /* return the number of players just shown */ }
static int letter3() { /* Prepare path */ sprintf(mail600, "/tmp#%dmail600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 602 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" Count Endelford\n"); standout(); lprcat("\nSubject:"); standend(); lprcat(" You Bastard!\n"); lprcat("\n I heard (from sources) of your journey. Congratulations!"); lprcat("\nYou bastard! With several attempts I have yet to endure the"); lprcat(" caves,\nand you, a nobody, makes the journey! From this time"); lprcat(" onward, be warned\nupon our meeting you shall pay the price!\n"); lwclose(); return 1; }
/* * function to say press return to continue and reset scroll when done */ static void retcont(void) { cursor(1, 24); lprcat("Press "); standout("return"); lprcat(" to continue: "); while (getchr() != '\n') ; /* nothing */ setscroll(); }
static void s2choose(void) /* text to be displayed if ^C during intro screen */ { cursor(1, 24); lprcat("Press "); setbold(); lprcat("return"); resetbold(); lprcat(" to continue: "); lflush(); }
/* *** FCH *** subroutine to process an up/down of a character attribute for ofountain */ static void fch(int how, long *x) { if (how < 0) { lprcat(" went down by one!"); --(*x); } else { lprcat(" went up by one!"); (*x)++; } bottomline(); }
/* * *** * FCH * *** * * process an up/down of a character attribute for ofountain */ void fch(int how,long *x) { if (how < 0 ) { if (*x > 3) { lprcat(" went down by one!"); --(*x); } else lprcat(" remained unchanged!"); } else { lprcat(" went up by one!"); (*x)++; } bottomline(); }
/* * winshou() Subroutine to print out the winning scoreboard * * Returns the number of players on scoreboard that were shown */ static int winshou(void) { struct wscofmt *p; int i, j, count; for (count = j = i = 0; i < SCORESIZE; i++) /* is there anyone on * the scoreboard? */ if (winr[i].score != 0) { j++; break; } if (j) { lprcat("\n Score Difficulty Time Needed Larn Winners List\n"); for (i = 0; i < SCORESIZE; i++) /* this loop is needed to * print out the */ for (j = 0; j < SCORESIZE; j++) { /* winners in order */ p = &winr[j]; /* pointer to the scoreboard * entry */ if (p->order == i) { if (p->score) { count++; lprintf("%10ld %2ld %5ld Mobuls %s \n", (long) p->score, (long) p->hardlev, (long) p->timeused, p->who); } break; } } } return (count); /* return number of people on scoreboard */ }
/* * readboard() Function to read in the scoreboard into a static buffer * * returns -1 if unable to read in the scoreboard, returns 0 if all is OK */ readboard() { if (lopen(scorefile)<0) { lprcat("Can't read scoreboard\n"); lflush(); return(-1); } lrfill((char*)sco,sizeof(sco)); lrfill((char*)winr,sizeof(winr)); lrclose(); lcreat((char*)0); return(0); }
/* act_remove_gems Remove gems from a throne. arg is zero if there is a gnome king associated with the throne Assumes that cursors() has been called previously, and that a check has been made that the throne actually has gems. */ void act_remove_gems(int arg) { int i, k ; k = rnd(101); if (k < 25) { for (i = 0; i < rnd(4); i++) { /* gems pop ohf the throne */ creategem(); } item[playerx][playery]=ODEADTHRONE; know[playerx][playery]=0; } else if (k < 40 && arg == 0) { createmonster(GNOMEKING); item[playerx][playery] = OTHRONE2; know[playerx][playery] = 0; } else { lprcat("\nNothing happens"); } }