dndstore() { register int i; dnditm = 0; nosignal = 1; /* disable signals */ clear(); dnd_2hed(); if (outstanding_taxes>0) { lprcat("\n\nThe Larn Revenue Service has ordered us to not do business with tax evaders.\n"); beep(); lprintf("They have also told us that you owe %d gp in back taxes, and as we must\n",(long)outstanding_taxes); lprcat("comply with the law, we cannot serve you at this time. Soo Sorry.\n"); cursors(); lprcat("\nPress "); standout("escape"); lprcat(" to leave: "); lflush(); i=0; while (i!='\33') i=getchar(); drawscreen(); nosignal = 0; /* enable signals */ return; } dnd_hed(); while (1) { cursor(59,18); lprintf("%d gold pieces",(long)c[GOLD]); cltoeoln(); cl_dn(1,20); /* erase to eod */ lprcat("\nEnter your transaction ["); standout("space"); lprcat(" for more, "); standout("escape"); lprcat(" to leave]? "); i=0; while ((i<'a' || i>'z') && (i!=' ') && (i!='\33') && (i!=12)) i=getchar(); if (i==12) { clear(); dnd_2hed(); dnd_hed(); } else if (i=='\33') { drawscreen(); nosignal = 0; /* enable signals */ return; } else if (i==' ') { cl_dn(1,4); if ((dnditm += 26) >= maxitm) dnditm=0; dnd_hed(); } else { /* buy something */ lprc(i); /* echo the byte */ i += dnditm - 'a'; if (i>=maxitm) outofstock(); else if (itm[i].qty <= 0) outofstock(); else if (pocketfull()) handsfull(); else if (c[GOLD] < itm[i].price*10) nogold(); else { if (itm[i].mem != 0) *itm[i].mem[itm[i].arg] = ' '; c[GOLD] -= itm[i].price*10; itm[i].qty--; take(itm[i].obj,itm[i].arg); if (itm[i].qty==0) dnditem(i); nap(1001); } } } }
/* Perform the actions associated with praying at an altar and giving a donation. */ void act_donation_pray(void) { unsigned long k,temp ; while (1) { lprcat("\n\n"); cursor(1,24); cltoeoln(); cursor(1,23); cltoeoln(); lprcat("how much do you donate? "); k = readnum((long)c[GOLD]); lprcat("\n"); /* make giving zero gold equivalent to 'just pray'ing. Allows player to 'just pray' in command mode, without having to add yet another command. */ if (k == 0) { act_just_pray(); return; } if (c[GOLD] >= k) { temp = c[GOLD] / 10 ; c[GOLD] -= k; bottomline(); /* if player gave less than 10% of _original_ gold, make a monster */ if (k < temp || k < rnd(50)) { createmonster(makemonst(level+1)); c[AGGRAVATE] += 200; return; } if (rnd(101) > 50) { act_prayer_heard(); return; } if (rnd(43) == 5) { if (c[WEAR]) lprcat("You feel your armor vibrate for a moment"); enchantarmor(); return; } if (rnd(43) == 8) { if (c[WIELD]) lprcat("You feel your weapon vibrate for a moment"); enchweapon(); return; } lprcat("Thank You."); return ; } /* Player donates more gold than they have. Loop back around so player can't escape the altar for free. */ lprcat("You don't have that much!"); } }
/* * ****** * OALTAR * ****** * */ void oaltar() { long k; int p; start: lprcat("\nDo you (p) pray (d) desecrate"); iopts(); while (1) { while (1) switch(getcharacter()) { case 'p': lprcat(" pray.\nDo you (m) give money or (j) just pray? "); while (1) switch(getcharacter()) { case 'j': p = rund(100); if (p < 12) createmonster(makemonst(level+2)); else if (p < 17) enchweapon(ENCH_ALTAR); else if (p < 22) enchantarmor(ENCH_ALTAR); else if (p < 27) ohear(); else lprcat("\nNothing happens."); return; case 'm': cursor(1,24); cltoeoln(); cursor(1,23); cltoeoln(); lprcat("how much do you donate? "); if ((k = readnum(c[GOLD])) < 0) goto start; if (c[GOLD] < k) { lprcat("You don't have that much!"); nap(1001); goto start; } if (k < (c[GOLD]/10) && rnd(60)<30 && !wizard) { lprcat("Cheapskate! The Gods are insulted by such a " "tiny offering!"); forget(); createmonster(DEMONPRINCE); c[AGGRAVATE] += 1500; return; } c[GOLD] -= k; if (k < (c[GOLD]+k)/10 || k < rnd(50) && !wizard) { createmonster(makemonst(level+2)); c[AGGRAVATE] += 500; bottomline(); return; } p = rund(16); if (p < 4) lprcat("Thank you."); else if (p < 6) { enchantarmor(ENCH_ALTAR); enchantarmor(ENCH_ALTAR); } else if (p < 8) { enchweapon(ENCH_ALTAR); enchweapon(ENCH_ALTAR); } else ohear(); bottomline(); return; } /* end while switch : case j or m */ case 'd': lprcat(" desecrate"); if (rnd(100)<60) { createmonster(makemonst(level+3)+8); c[AGGRAVATE] += 2500; } else if(rnd(100)<5) raiselevel(); else if (rnd(101)<30) { lprcat("\nThe altar crumbles into a pile of dust before your eyes."); forget(); /*remember to destroy the altar*/ } else lprcat("\nNothing happens."); return; case 'i': case ESC: ignore(); if (rnd(100)<30) { createmonster(makemonst(level+2)); c[AGGRAVATE] += rnd(450); } else lprcat("\nNothing happens."); return; } /* end while switch: pray, des, ignore */ } /* NOTREACHED */ } /* end oaltar */