/* * 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; } } } }
/* * 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; } } } }
/* * 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 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!"); }; } } }
/* function to wield a weapon */ static void wield(void) { int i; while (1) { if ((i = whatitem("wield")) == '\33') return; if (i != '.') { if (i == '*') showwield(); else if (iven[i - 'a'] == 0) { ydhi(i); return; } else if (iven[i - 'a'] == OPOTION) { ycwi(i); return; } else if (iven[i - 'a'] == OSCROLL) { ycwi(i); return; } else if ((c[SHIELD] != -1) && (iven[i - 'a'] == O2SWORD)) { lprcat("\nBut one arm is busy with your shield!"); return; } else { c[WIELD] = i - 'a'; if (iven[i - 'a'] == OLANCE) c[LANCEDEATH] = 1; else c[LANCEDEATH] = 0; bottomline(); return; } } } }
/* function to wield a weapon */ void wield (void) { int i; while (1) { if ((i = whatitem("wield"))==ESC) return; if (i != '.') { if (i=='*') showwield(); else if (i=='-') { c[WIELD]=-1; lprcat("\nYou unwield your weapon."); bottomline(); return; } else if (iven[i-'a']==0) { ydhi(i); return; } else if (iven[i-'a']==OPOTION) { ycwi(i); return; } else if (iven[i-'a']==OSCROLL) { ycwi(i); return; } else if ((c[SHIELD]!= -1) && (iven[i-'a']==O2SWORD)) { lprcat("\nBut one arm is busy with your shield!"); return; } else if (i-'a'==c[WEAR] || i-'a'==c[SHIELD]) { lprintf("\nYou can't wield your %s while you're wearing it!", (i-'a'==c[WEAR]) ? "armor" : "shield"); return; } else { c[WIELD]=i-'a'; lprintf("\nYou wield %s", objectname[iven[i-'a']]); if (ivenarg[i-'a']>0) lprintf (" +%d", (long)ivenarg[i-'a']); if (ivenarg[i-'a']<0) lprintf (" %d", (long)ivenarg[i-'a']); lprc('.'); if (iven[i-'a'] == OLANCE) c[LANCEDEATH]=1; else c[LANCEDEATH]=0; bottomline(); return; } } } }
/* function to wear armor */ void wear (void) { int i; while (1) { if ((i = whatitem("wear"))==ESC) return; if (i != '.') { if (i=='*') showwear(); else switch(iven[i-'a']) { case 0: ydhi(i); return; case OLEATHER: case OCHAIN: case OPLATE: case OSTUDLEATHER: case ORING: case OSPLINT: case OPLATEARMOR: case OELVENCHAIN: case OSSPLATE: if (c[WEAR] != -1) { lprcat("\nYou are already wearing some armor."); return; } c[WEAR]=i-'a'; if (c[WIELD] == i-'a') c[WIELD] = -1; lprintf("\nYou put on your %s", objectname[iven[i-'a']]); if (ivenarg[i-'a']>0) lprintf (" +%d", (long)ivenarg[i-'a']); if (ivenarg[i-'a']<0) lprintf (" %d", (long)ivenarg[i-'a']); lprc('.'); 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'; if (c[WIELD] == i-'a') c[WIELD] = -1; lprcat("\nYou put on your shield"); if (ivenarg[i-'a']>0) lprintf (" +%d", (long)ivenarg[i-'a']); if (ivenarg[i-'a']<0) lprintf (" %d", (long)ivenarg[i-'a']); lprc('.'); bottomline(); return; default: lprcat("\nYou can't wear that!"); }; } } }
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; } } } }
/* * function to wield a weapon */ static void wield(void) { int i; while (TRUE) { i = whatitem("wield (- for nothing)"); if (i == '\33') return; if (i != '.') { if (i == '*') { i = showwield(); cursors(); } if ( i == '-' ) { c[WIELD] = -1 ; bottomline(); return; } if (!i || i == '.') { continue; } if (iven[i-'a']==0) { ydhi(i); return; } else if (iven[i - 'a'] == OPOTION) { ycwi(i); return; } else if (iven[i-'a'] == OSCROLL) { ycwi(i); return; } else if (c[SHIELD] != -1 && iven[i-'a'] == O2SWORD) { lprcat("\nBut one arm is busy with your shield!"); return; } else { c[WIELD]= i - 'a'; if (iven[i - 'a'] == OLANCE) { c[LANCEDEATH]=1; } else { c[LANCEDEATH]=0; } bottomline(); return; } } } }