/* * subroutine to quaff a potion one is carrying */ void quaff (void) { int i; while (1) { if ((i = qwhatitem()) == ESC) return; if (i != '.') { if (i=='*') showquaff(); else { if (iven[i-'a']==OPOTION) { quaffpotion(ivenarg[i-'a']); iven[i-'a']=0; return; } if (iven[i-'a']==0) { ydhi(i); return; } lprcat("\nYou wouldn't want to quaff that, would you? "); return; } } } }
static int floor_consume(int search_item, char *cons_verb) { int i; char tempc; cursors(); i = item[playerx][playery]; /* item not there, quit */ if (i != search_item) return( 0 ); /* item there. does the player want to consume it? */ lprintf("\nThere is %s", objectname[i] ); if (i==OSCROLL) if (scrollname[iarg[playerx][playery]][0]) lprintf(" of%s", scrollname[iarg[playerx][playery]]); if (i==OPOTION) if (potionname[iarg[playerx][playery]][0]) lprintf(" of%s", potionname[iarg[playerx][playery]]); lprintf(" here. Do you want to %s it?", cons_verb ); if ((tempc = getyn()) == 'n' ) return( 0 ); /* item there, not consumed */ else if (tempc != 'y') { lprcat(" aborted"); return( -1 ); /* abort */ } /* consume the item. */ switch( i ) { case OCOOKIE: outfortune(); forget(); break; case OBOOK: readbook( iarg[playerx][playery] ); forget(); break; case OPOTION: quaffpotion(iarg[playerx][playery], 1); forget(); break; case OSCROLL: /* scrolls are tricky because of teleport. */ i = iarg[playerx][playery]; know[playerx][playery] = 0; item[playerx][playery] = iarg[playerx][playery] = 0 ; read_scroll( i ); break; } return( 1 ); }
/* ============================================================================= * FUNCTION: opotion * * DESCRIPTION: * Function to handle finding a potion. * * PARAMETERS: * * pot : The potion type found. * * RETURN VALUE: * * None. */ static void opotion(int pot, int ans) { switch(ans) { case ESC: case 'i': break; case 'd': forget(); /* destroy potion */ quaffpotion(pot); break; case 't': if (take(OPOTION,pot)==0) forget(); break; default: break; } }
/* Code to perform the action of drinking at a fountian. 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_drink_fountain(void) { int x ; if (rnd(1501)<2) { lprcat("\nOops! You seem to have caught the dreadful sleep!"); lflush(); nap(3000); died(280); return; } x = rnd(100); if (x<7) { c[HALFDAM] += 200 + rnd(200); lprcat("\nYou feel a sickness coming on"); } else if (x < 13) quaffpotion(23, FALSE ); /* see invisible,but don't know the potion */ else if (x < 45) lprcat("\nnothing seems to have happened"); else if (rnd(3) != 2) fntchange(1); /* change char levels upward */ else fntchange(-1); /* change char levels downward */ if (rnd(12)<3) { lprcat("\nThe fountains bubbling slowly quiets"); item[playerx][playery]=ODEADFOUNTAIN; /* dead fountain */ know[playerx][playery]=0; } return; }
/* ******* OPOTION ******* function to process a potion */ void opotion(int pot) { lprcat("\nDo you (d) drink it, (t) take it"); iopts(); while (1) switch(getcharacter()) { case ESC: case 'i': ignore(); return; case 'd': lprcat("drink.\n"); forget(); /* destroy potion */ quaffpotion(pot); return; case 't': lprcat("take.\n"); if (take(OPOTION,pot)==0) forget(); return; }; }
/* * ********* * OFOUNTAIN * ********* */ void ofountain() { int x; cursors(); lprcat("\nDo you (d) drink, (w) wash yourself"); iopts(); while (1) switch(getcharacter()) { case 'd': lprcat("drink"); if (rnd(1501)<4) { lprcat("\nOH MY GOD!! You have caught the *dreadful sleep*!"); beep(); lflush(); sleep(3); died(280); return; } x = rnd(100); if (x==1) raiselevel(); else if (x < 11) { x=rnd((level<<2)+2); lprintf("\nBleah! The water tasted like stale gatorade! " "You lose %d hit point%s!", (long)x, x==1?"":"s"); lastnum=273; losehp(x); bottomline(); cursors(); } else if (x<14) { c[HALFDAM] += 200+rnd(200); lprcat("\nThe water makes you vomit."); } else if (x<17) quaffpotion(17); /* giant strength */ else if (x < 45) lprcat("\nNothing seems to have happened."); else if (rnd(3) != 2) fntchange(1); /*change char levels upward*/ else fntchange(-1); /*change char levels downward*/ if (rnd(12)<3) { lprcat("\nThe fountains bubbling slowly quietens."); /* dead fountain */ item[playerx][playery]=ODEADFOUNTAIN; know[playerx][playery]=0; } return; case 'i': case ESC: ignore(); return; case 'w': lprcat("wash yourself."); if (rnd(100) < 11) { x=rnd((level<<2)+2); lprintf("\nThe water burns like acid! You lose %d hit point%s!", (long)x, x==1?"":"s"); lastnum=273; losehp(x); bottomline(); cursors(); } else if (rnd(100) < 29) lprcat("\nYou are now clean."); else if (rnd(100) < 31) lprcat("\nThis water needs soap -- the dirt didn't come off."); else if (rnd(100) < 34) createmonster(WATERLORD); else lprcat("\nNothing seems to have happened."); return; } }
int strategize () { dwait (D_CONTROL, "Strategizing..."); /* If replaying, instead of making an action, return the old one */ if (replaying) return (replaycommand ()); /* Clear any messages we printed last turn */ if (msgonscreen) { at (0,0); clrtoeol (); msgonscreen = 0; at (row,col); } /* ----------------------- Production Rules --------------------------- */ if (fightmonster ()) /* We are under attack! */ return (1); if (fightinvisible ()) /* Claude Raines! */ return (1); if (tomonster ()) /* Go play with the pretty monster */ return (1); if (shootindark ()) /* Shoot arrows in dark rooms */ return (1); if (handleweapon ()) /* Play with the nice sword */ { dwait (D_BATTLE, "Switching to sword [1]"); return (1); } if (light ()) /* Fiat lux! Especially if we lost */ return (1); /* a monster from view. */ if (dinnertime ()) /* Soups on! */ return (1); /* * These variables are short term memory. Slowed and * cancelled are fuses which are disabled after a small * number of turns. */ lyinginwait = 0; /* No more monsters to wait for */ if (foughtmonster) foughtmonster--; /* Turns since fought monster */ if (slowed) slowed--; /* Turns since we slowed a monster */ if (cancelled) cancelled--; /* Turns since we zapped 'cancel' */ if (beingheld) beingheld--; /* Turns since held by a fungus */ /* ---- End of short term memory modification ---- */ if (dropjunk ()) /* Send it back */ return (1); if (readscroll ()) /* Get out the reading glasses */ return (1); /* Must come before handlearmor() */ if (handlearmor ()) /* Play dressup */ return (1); if (quaffpotion ()) /* Glug glug glug ... */ return (1); /* Must come before handlering() */ if (handlering ()) /* We are engaged! */ return (1); if (blinded && grope (50)) /* Who turned out the lights */ { display ("Blinded, groping..."); return (1); } if (aftermelee ()) /* Wait for lingering monsters */ return (1); if (tostuff ()) /* Pick up the play pretty */ return (1); if (restup ()) /* Yawn! */ return (1); if (goupstairs (NOTRUNNING)) /* Up we go! Make sure that we get */ return (1); /* a better rank on the board. */ if (trywand ()) /* Try to use a wand */ return (1); if (gotowardsgoal ()) /* Keep on trucking */ return (1); if (exploreroom ()) /* Search the room */ return (1); if (archery ()) /* Try to position for fight */ return (1); if (pickupafter ()) /* Look for stuff dropped by arched mon */ return (1); if (plunge ()) /* Plunge mode */ return (1); if (findarrow ()) /* Do we have an unitialized arrow? */ return (1); if (findroom ()) /* Look for another room */ return (1); /* * 'attempt' records the number of times we have completely searched * this level for secret doors. If attempt is greater than 0, then we * have failed once to find the stairs and go down. If this happens * three times, there could be amonster sleeping on the stairs. We set * the SLEEPER bit for each square with a sleeping monster. Go find * such a monster and kill it to see whether (s)he was on the stairs). */ if (attempt > 4 && makemove (ATTACKSLEEP, genericinit, sleepvalue, REUSE)) { display ("No stairs, attacking sleeping monster..."); return (1); } if (Level>1 && larder>0 && doorexplore ()) /* Grub around */ return (1); if (godownstairs (NOTRUNNING)) /* Down we go! */ return (1); if ((Level<2 || larder<1) && doorexplore()) /* Grub around anyway */ return (1); /* * If we think we are on the stairs, but arent, maybe they were moved * (ie we were hallucinating when we saw them last time). */ if (on (STAIRS) && (atrow != stairrow || atcol != staircol)) { dwait (D_ERROR, "Stairs moved!"); findstairs (NONE, NONE); return (1); } /* * If we failed to find the stairs, explore each possible secret door * another ten times. */ while (attempt++ < MAXATTEMPTS) { timestosearch += max (3, k_door / 5); foundnew (); if (doorexplore ()) return (1); } /* * Don't give up, start all over! */ newlevel (); display ("I would give up, but I am too stubborn, starting over..."); return (grope (10)); }
static void consume(int search_item, char *prompt, int (*showfunc)()) { int i; while (1) { if ((i = whatitem( prompt )) == '\33') return; if (i != '.' && i != '-') { if (i == '*') { i = showfunc(); cursors(); } if (i && i != '.') { switch (iven[i-'a']) { case OSCROLL: if ( search_item != OSCROLL ) { lprintf("\nYou can't %s that.", prompt ); return; } read_scroll( ivenarg[i-'a'] ); break; case OBOOK: if ( search_item != OSCROLL ) { lprintf("\nYou can't %s that.", prompt ); return; } readbook( ivenarg[i-'a'] ); break; case OCOOKIE: if ( search_item != OCOOKIE ) { lprintf("\nYou can't %s that.", prompt ); return; } outfortune(); break; case OPOTION: if ( search_item != OPOTION ) { lprintf("\nYou can't %s that.", prompt ); return; } quaffpotion( ivenarg[i-'a'], TRUE ); break; case 0: ydhi(i); return; default: lprintf("\nYou can't %s that.", prompt ); return; } iven[i-'a'] = 0; return; } } } }