/* * readscr() Subroutine to read a scroll one is carrying */ void readscr (void) { int i; while (1) { if ((i = whatitem("read"))==ESC) return; if (i != '.') { if (i=='*') showread(); else { if (iven[i-'a']==OSCROLL) { read_scroll(ivenarg[i-'a']); iven[i-'a']=0; return; } if (iven[i-'a']==OBOOK) { readbook(ivenarg[i-'a']); iven[i-'a']=0; return; } if (iven[i-'a']==0) { ydhi(i); return; } lprcat("\nThere's nothing on it to read."); return; } /* end else */ } } }
/* ============================================================================= * FUNCTION: oscroll * * DESCRIPTION: * Function to process finding a mogic scroll. * * PARAMETERS: * * typ : The type of scroll found. * * RETURN VALUE: * * None. */ void oscroll(int typ, int ans) { switch(ans) { case ESC: case 'i': break; case 'r': if (c[BLINDCOUNT]) break; /* remove the scroll */ forget(); /* read the scroll */ read_scroll(typ); break; case 't': if (take(OSCROLL,typ)==0) forget(); /* destroy it */ break; default: break; } }
/* ******* 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; }; }
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 ); }
bool use_object(object_type *o_ptr, bool *ident) { bool used; /* Analyze the object */ switch (o_ptr->tval) { case TV_FOOD: { used = eat_food(o_ptr, ident); break; } case TV_POTION: { used = quaff_potion(o_ptr, ident); break; } case TV_SCROLL: { used = read_scroll(o_ptr, ident); break; } case TV_STAFF: { used = use_staff(o_ptr, ident); break; } case TV_WAND: { used = aim_wand(o_ptr, ident); break; } case TV_ROD: { used = zap_rod(o_ptr, ident); break; } default: { used = activate_object(o_ptr, ident); break; } } return (used); }
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; } } } }