void do_create(void) { int t, a; gett: cursors(); lprintf("\nType of item (Scroll/Potion/Monster/Other) : "); do { t=getcharacter(); } while (isspace(t)); switch(t) { case ESC: return; case 's': case 'S': cursors(); cl_dn(1, 23); lprcat("Scroll Arg: "); a=readnum((long)MAXSCROLL); lprintf("createitem(OSCROLL, %d)", a); createitem(playerx,playery,OSCROLL, a); dropflag=1; return; case 'p': case 'P': cursors(); cl_dn(1, 23); lprcat("Potion Arg: "); a=readnum((long)MAXPOTION); lprintf("createitem(OPOTION, %d)", a); createitem(playerx,playery,OPOTION, a); dropflag=1; return; case 'o': case 'O': cursors(); lprcat("\n\n"); cl_dn(1, 23); lprcat("Item : "); t=readnum(0); lprcat("Arg : "); a=readnum(0); lprintf("\ncreateitem(%d, %d)", t, a); createitem(playerx,playery,t, a); dropflag=1; return; case 'm': case 'M': cursors(); lprcat("\n\n"); cl_dn(1, 23); lprcat("Monst : "); t=readnum(0); lprintf("\ncreatemonster(%d)", t); createmonster(t); dropflag=1; return; default: goto gett; } }
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); } } } }
/* 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; } } }
/* function to drop an object */ void dropobj (void) { int i, pitflag=0; char *p; long amt; p = &item[playerx][playery]; while (1) { if ((i = whatitem("drop"))==ESC) return; if (i=='*') showstr(); else { /* drop some gold */ if (i=='.') { if (*p == OPIT) pitflag=1; if (*p && !pitflag) { 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=(int)amt; } else if (amt<=327670L) { *p=ODGOLD; i=(int)amt/10; amt = 10L*i; } else if (amt<=3276700L) { *p=OMAXGOLD; i=(int)amt/100; amt = 100L*i; } else if (amt<=32767000L) { *p=OKGOLD; i=(int)amt/1000; amt = 1000L*i; } else { *p=OKGOLD; i=(int)32767; amt = 32767000L; } c[GOLD] -= amt; lprintf("You drop %d gold piece%s.",(long)amt,(amt==1)?"":"s"); if (pitflag) { *p = OPIT; lprcat("\nThe gold disappears down the pit."); } else iarg[playerx][playery]=i; bottomgold(); know[playerx][playery]=0; dropflag=1; return; } drop_object(i-'a'); return; } } }