1 /*- 2 * Copyright (c) 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)store.c 5.4 (Berkeley) 05/13/91"; 10 #endif /* not lint */ 11 12 /* store.c Larn is copyrighted 1986 by Noah Morgan. */ 13 #include "header.h" 14 static int dndcount=0,dnditm=0; 15 16 /* this is the data for the stuff in the dnd store */ 17 int maxitm=83; /* number of items in the dnd inventory table */ 18 struct _itm itm[90] = { 19 /*cost memory iven name iven arg how 20 gp pointer iven[] ivenarg[] many */ 21 22 { 2, 0, OLEATHER, 0, 3 }, 23 { 10, 0, OSTUDLEATHER, 0, 2 }, 24 { 40, 0, ORING, 0, 2 }, 25 { 85, 0, OCHAIN, 0, 2 }, 26 { 220, 0, OSPLINT, 0, 1 }, 27 { 400, 0, OPLATE, 0, 1 }, 28 { 900, 0, OPLATEARMOR, 0, 1 }, 29 { 2600, 0, OSSPLATE, 0, 1 }, 30 { 150, 0, OSHIELD, 0, 1 }, 31 32 /*cost memory iven name iven arg how 33 gp pointer iven[] ivenarg[] many */ 34 35 { 2, 0, ODAGGER, 0, 3 }, 36 { 20, 0, OSPEAR, 0, 3 }, 37 { 80, 0, OFLAIL, 0, 2 }, 38 { 150, 0, OBATTLEAXE, 0, 2 }, 39 { 450, 0, OLONGSWORD, 0, 2 }, 40 { 1000, 0, O2SWORD, 0, 2 }, 41 { 5000, 0, OSWORD, 0, 1 }, 42 { 16500, 0, OLANCE, 0, 1 }, 43 { 6000, 0, OSWORDofSLASHING, 0, 0 }, 44 { 10000, 0, OHAMMER, 0, 0 }, 45 46 /*cost memory iven name iven arg how 47 gp pointer iven[] ivenarg[] many */ 48 49 { 150, 0, OPROTRING, 1, 1 }, 50 { 85, 0, OSTRRING, 1, 1 }, 51 { 120, 0, ODEXRING, 1, 1 }, 52 { 120, 0, OCLEVERRING, 1, 1 }, 53 { 180, 0, OENERGYRING, 0, 1 }, 54 { 125, 0, ODAMRING, 0, 1 }, 55 { 220, 0, OREGENRING, 0, 1 }, 56 { 1000, 0, ORINGOFEXTRA, 0, 1 }, 57 58 { 280, 0, OBELT, 0, 1 }, 59 60 { 400, 0, OAMULET, 0, 1 }, 61 62 { 6500, 0, OORBOFDRAGON, 0, 0 }, 63 { 5500, 0, OSPIRITSCARAB, 0, 0 }, 64 { 5000, 0, OCUBEofUNDEAD, 0, 0 }, 65 { 6000, 0, ONOTHEFT, 0, 0 }, 66 67 { 590, 0, OCHEST, 6, 1 }, 68 { 200, 0, OBOOK, 8, 1 }, 69 { 10, 0, OCOOKIE, 0, 3 }, 70 71 /*cost memory iven name iven arg how 72 gp pointer iven[] ivenarg[] many */ 73 74 { 20, potionname, OPOTION, 0, 6 }, 75 { 90, potionname, OPOTION, 1, 5 }, 76 { 520, potionname, OPOTION, 2, 1 }, 77 { 100, potionname, OPOTION, 3, 2 }, 78 { 50, potionname, OPOTION, 4, 2 }, 79 { 150, potionname, OPOTION, 5, 2 }, 80 { 70, potionname, OPOTION, 6, 1 }, 81 { 30, potionname, OPOTION, 7, 7 }, 82 { 200, potionname, OPOTION, 8, 1 }, 83 { 50, potionname, OPOTION, 9, 1 }, 84 { 80, potionname, OPOTION, 10, 1 }, 85 86 /*cost memory iven name iven arg how 87 gp pointer iven[] ivenarg[] many */ 88 89 { 30, potionname, OPOTION, 11, 3 }, 90 { 20, potionname, OPOTION, 12, 5 }, 91 { 40, potionname, OPOTION, 13, 3 }, 92 { 35, potionname, OPOTION, 14, 2 }, 93 { 520, potionname, OPOTION, 15, 1 }, 94 { 90, potionname, OPOTION, 16, 2 }, 95 { 200, potionname, OPOTION, 17, 2 }, 96 { 220, potionname, OPOTION, 18, 4 }, 97 { 80, potionname, OPOTION, 19, 6 }, 98 { 370, potionname, OPOTION, 20, 3 }, 99 { 50, potionname, OPOTION, 22, 1 }, 100 { 150, potionname, OPOTION, 23, 3 }, 101 102 /*cost memory iven name iven arg how 103 gp pointer iven[] ivenarg[] many */ 104 105 { 100, scrollname, OSCROLL, 0, 2 }, 106 { 125, scrollname, OSCROLL, 1, 2 }, 107 { 60, scrollname, OSCROLL, 2, 4 }, 108 { 10, scrollname, OSCROLL, 3, 4 }, 109 { 100, scrollname, OSCROLL, 4, 3 }, 110 { 200, scrollname, OSCROLL, 5, 2 }, 111 { 110, scrollname, OSCROLL, 6, 1 }, 112 { 500, scrollname, OSCROLL, 7, 2 }, 113 { 200, scrollname, OSCROLL, 8, 2 }, 114 { 250, scrollname, OSCROLL, 9, 4 }, 115 { 20, scrollname, OSCROLL, 10, 5 }, 116 { 30, scrollname, OSCROLL, 11, 3 }, 117 118 /*cost memory iven name iven arg how 119 gp pointer iven[] ivenarg[] many */ 120 121 { 340, scrollname, OSCROLL, 12, 1 }, 122 { 340, scrollname, OSCROLL, 13, 1 }, 123 { 300, scrollname, OSCROLL, 14, 2 }, 124 { 400, scrollname, OSCROLL, 15, 2 }, 125 { 500, scrollname, OSCROLL, 16, 2 }, 126 { 1000, scrollname, OSCROLL, 17, 1 }, 127 { 500, scrollname, OSCROLL, 18, 1 }, 128 { 340, scrollname, OSCROLL, 19, 2 }, 129 { 220, scrollname, OSCROLL, 20, 3 }, 130 { 3900, scrollname, OSCROLL, 21, 0 }, 131 { 610, scrollname, OSCROLL, 22, 1 }, 132 { 3000, scrollname, OSCROLL, 23, 0 } 133 }; 134 135 /* 136 function for the dnd store 137 */ 138 dnd_2hed() 139 { 140 lprcat("Welcome to the Larn Thrift Shoppe. We stock many items explorers find useful\n"); 141 lprcat(" in their adventures. Feel free to browse to your hearts content.\n"); 142 lprcat("Also be advised, if you break 'em, you pay for 'em."); 143 } 144 145 static void dnditem(); 146 147 dnd_hed() 148 { 149 register int i; 150 for (i=dnditm; i<26+dnditm; i++) dnditem(i); 151 cursor(50,18); lprcat("You have "); 152 } 153 154 static void 155 handsfull() 156 { 157 lprcat("\nYou can't carry anything more!"); 158 lflush(); 159 nap(2200); 160 } 161 162 static void 163 outofstock() 164 { 165 lprcat("\nSorry, but we are out of that item."); 166 lflush(); 167 nap(2200); 168 } 169 170 static void nogold() 171 { 172 lprcat("\nYou don't have enough gold to pay for that!"); 173 lflush(); 174 nap(2200); 175 } 176 177 dndstore() 178 { 179 register int i; 180 dnditm = 0; 181 nosignal = 1; /* disable signals */ 182 clear(); dnd_2hed(); 183 if (outstanding_taxes>0) 184 { 185 lprcat("\n\nThe Larn Revenue Service has ordered us to not do business with tax evaders.\n"); beep(); 186 lprintf("They have also told us that you owe %d gp in back taxes, and as we must\n",(long)outstanding_taxes); 187 lprcat("comply with the law, we cannot serve you at this time. Soo Sorry.\n"); 188 cursors(); 189 lprcat("\nPress "); standout("escape"); lprcat(" to leave: "); lflush(); 190 i=0; 191 while (i!='\33') i=getchar(); 192 drawscreen(); nosignal = 0; /* enable signals */ return; 193 } 194 195 dnd_hed(); 196 while (1) 197 { 198 cursor(59,18); lprintf("%d gold pieces",(long)c[GOLD]); 199 cltoeoln(); cl_dn(1,20); /* erase to eod */ 200 lprcat("\nEnter your transaction ["); standout("space"); 201 lprcat(" for more, "); standout("escape"); 202 lprcat(" to leave]? "); 203 i=0; 204 while ((i<'a' || i>'z') && (i!=' ') && (i!='\33') && (i!=12)) i=getchar(); 205 if (i==12) { clear(); dnd_2hed(); dnd_hed(); } 206 else if (i=='\33') 207 { drawscreen(); nosignal = 0; /* enable signals */ return; } 208 else if (i==' ') 209 { 210 cl_dn(1,4); 211 if ((dnditm += 26) >= maxitm) dnditm=0; dnd_hed(); 212 } 213 else 214 { /* buy something */ 215 lprc(i); /* echo the byte */ 216 i += dnditm - 'a'; 217 if (i>=maxitm) outofstock(); else 218 if (itm[i].qty <= 0) outofstock(); else 219 if (pocketfull()) handsfull(); else 220 if (c[GOLD] < itm[i].price*10) nogold(); else 221 { 222 if (itm[i].mem != 0) *itm[i].mem[itm[i].arg] = ' '; 223 c[GOLD] -= itm[i].price*10; 224 itm[i].qty--; take(itm[i].obj,itm[i].arg); 225 if (itm[i].qty==0) dnditem(i); nap(1001); 226 } 227 } 228 229 } 230 } 231 232 /* 233 dnditem(index) 234 235 to print the item list; used in dndstore() enter with the index into itm 236 */ 237 static void 238 dnditem(i) 239 register int i; 240 { 241 register int j,k; 242 if (i >= maxitm) return; 243 cursor( (j=(i&1)*40+1) , (k=((i%26)>>1)+5) ); 244 if (itm[i].qty == 0) { lprintf("%39s",""); return; } 245 lprintf("%c) ",(i%26)+'a'); 246 if (itm[i].obj == OPOTION) 247 { lprcat("potion of "); lprintf("%s",&potionname[itm[i].arg][1]); } 248 else if (itm[i].obj == OSCROLL) 249 { lprcat("scroll of "); lprintf("%s",&scrollname[itm[i].arg][1]); } 250 else lprintf("%s",objectname[itm[i].obj]); 251 cursor( j+31,k ); lprintf("%6d",(long)(itm[i].price*10)); 252 } 253 254 255 /* 256 for the college of larn 257 */ 258 char course[26]={0}; /* the list of courses taken */ 259 char coursetime[] = { 10, 15, 10, 20, 10, 10, 10, 5 }; 260 /* 261 function to display the header info for the school 262 */ 263 sch_hed() 264 { 265 clear(); 266 lprcat("The College of Larn offers the exciting opportunity of higher education to\n"); 267 lprcat("all inhabitants of the caves. Here is a list of the class schedule:\n\n\n"); 268 lprcat("\t\t Course Name \t Time Needed\n\n"); 269 270 if (course[0]==0) lprcat("\t\ta) Fighters Training I 10 mobuls"); /*line 7 of crt*/ 271 lprc('\n'); 272 if (course[1]==0) lprcat("\t\tb) Fighters Training II 15 mobuls"); 273 lprc('\n'); 274 if (course[2]==0) lprcat("\t\tc) Introduction to Wizardry 10 mobuls"); 275 lprc('\n'); 276 if (course[3]==0) lprcat("\t\td) Applied Wizardry 20 mobuls"); 277 lprc('\n'); 278 if (course[4]==0) lprcat("\t\te) Behavioral Psychology 10 mobuls"); 279 lprc('\n'); 280 if (course[5]==0) lprcat("\t\tf) Faith for Today 10 mobuls"); 281 lprc('\n'); 282 if (course[6]==0) lprcat("\t\tg) Contemporary Dance 10 mobuls"); 283 lprc('\n'); 284 if (course[7]==0) lprcat("\t\th) History of Larn 5 mobuls"); 285 286 lprcat("\n\n\t\tAll courses cost 250 gold pieces."); 287 cursor(30,18); 288 lprcat("You are presently carrying "); 289 } 290 291 oschool() 292 { 293 register int i; 294 long time_used; 295 nosignal = 1; /* disable signals */ 296 sch_hed(); 297 while (1) 298 { 299 cursor(57,18); lprintf("%d gold pieces. ",(long)c[GOLD]); cursors(); 300 lprcat("\nWhat is your choice ["); standout("escape"); 301 lprcat(" to leave] ? "); yrepcount=0; 302 i=0; while ((i<'a' || i>'h') && (i!='\33') && (i!=12)) i=getchar(); 303 if (i==12) { sch_hed(); continue; } 304 else if (i=='\33') 305 { nosignal = 0; drawscreen(); /* enable signals */ return; } 306 lprc(i); 307 if (c[GOLD] < 250) nogold(); else 308 if (course[i-'a']) 309 { lprcat("\nSorry, but that class is filled."); nap(1000); } 310 else 311 if (i <= 'h') 312 { 313 c[GOLD] -= 250; time_used=0; 314 switch(i) 315 { 316 case 'a': c[STRENGTH] += 2; c[CONSTITUTION]++; 317 lprcat("\nYou feel stronger!"); 318 cl_line(16,7); 319 break; 320 321 case 'b': if (course[0]==0) 322 { 323 lprcat("\nSorry, but this class has a prerequisite of Fighters Training I"); 324 c[GOLD]+=250; time_used= -10000; break; 325 } 326 lprcat("\nYou feel much stronger!"); 327 cl_line(16,8); 328 c[STRENGTH] += 2; c[CONSTITUTION] += 2; break; 329 330 case 'c': c[INTELLIGENCE] += 2; 331 lprcat("\nThe task before you now seems more attainable!"); 332 cl_line(16,9); break; 333 334 case 'd': if (course[2]==0) 335 { 336 lprcat("\nSorry, but this class has a prerequisite of Introduction to Wizardry"); 337 c[GOLD]+=250; time_used= -10000; break; 338 } 339 lprcat("\nThe task before you now seems very attainable!"); 340 cl_line(16,10); 341 c[INTELLIGENCE] += 2; break; 342 343 case 'e': c[CHARISMA] += 3; 344 lprcat("\nYou now feel like a born leader!"); 345 cl_line(16,11); break; 346 347 case 'f': c[WISDOM] += 2; 348 lprcat("\nYou now feel more confident that you can find the potion in time!"); 349 cl_line(16,12); break; 350 351 case 'g': c[DEXTERITY] += 3; 352 lprcat("\nYou feel like dancing!"); 353 cl_line(16,13); break; 354 355 case 'h': c[INTELLIGENCE]++; 356 lprcat("\nYour instructor told you that the Eye of Larn is rumored to be guarded\n"); 357 lprcat("by a platinum dragon who possesses psionic abilities. "); 358 cl_line(16,14); break; 359 } 360 time_used += coursetime[i-'a']*100; 361 if (time_used > 0) 362 { 363 gtime += time_used; 364 course[i-'a']++; /* remember that he has taken that course */ 365 c[HP] = c[HPMAX]; c[SPELLS] = c[SPELLMAX]; /* he regenerated */ 366 367 if (c[BLINDCOUNT]) c[BLINDCOUNT]=1; /* cure blindness too! */ 368 if (c[CONFUSE]) c[CONFUSE]=1; /* end confusion */ 369 adjtime((long)time_used); /* adjust parameters for time change */ 370 } 371 nap(1000); 372 } 373 } 374 } 375 376 /* 377 * for the first national bank of Larn 378 */ 379 int lasttime=0; /* last time he was in bank */ 380 static void banktitle(); 381 382 obank() 383 { 384 banktitle(" Welcome to the First National Bank of Larn."); 385 } 386 obank2() 387 { 388 banktitle("Welcome to the 5th level branch office of the First National Bank of Larn."); 389 } 390 static void 391 banktitle(str) 392 char *str; 393 { 394 nosignal = 1; /* disable signals */ 395 clear(); lprcat(str); 396 if (outstanding_taxes>0) 397 { 398 register int i; 399 lprcat("\n\nThe Larn Revenue Service has ordered that your account be frozen until all\n"); beep(); 400 lprintf("levied taxes have been paid. They have also told us that you owe %d gp in\n",(long)outstanding_taxes); 401 lprcat("taxes, and we must comply with them. We cannot serve you at this time. Sorry.\n"); 402 lprcat("We suggest you go to the LRS office and pay your taxes.\n"); 403 cursors(); 404 lprcat("\nPress "); standout("escape"); lprcat(" to leave: "); lflush(); 405 i=0; 406 while (i!='\33') i=getchar(); 407 drawscreen(); nosignal = 0; /* enable signals */ return; 408 } 409 lprcat("\n\n\tGemstone\t Appraisal\t\tGemstone\t Appraisal"); 410 obanksub(); nosignal = 0; /* enable signals */ 411 drawscreen(); 412 } 413 414 /* 415 * function to put interest on your bank account 416 */ 417 ointerest() 418 { 419 register int i; 420 if (c[BANKACCOUNT]<0) c[BANKACCOUNT] = 0; 421 else if ((c[BANKACCOUNT]>0) && (c[BANKACCOUNT]<500000)) 422 { 423 i = (gtime-lasttime)/100; /* # mobuls elapsed */ 424 while ((i-- > 0) && (c[BANKACCOUNT]<500000)) 425 c[BANKACCOUNT] += c[BANKACCOUNT]/250; 426 if (c[BANKACCOUNT]>500000) c[BANKACCOUNT]=500000; /* interest limit */ 427 } 428 lasttime = (gtime/100)*100; 429 } 430 431 static short gemorder[26]={0}; /* the reference to screen location for each */ 432 static long gemvalue[26]={0}; /* the appraisal of the gems */ 433 obanksub() 434 { 435 unsigned long amt; 436 register int i,k; 437 ointerest(); /* credit any needed interest */ 438 439 for (k=i=0; i<26; i++) 440 switch(iven[i]) 441 { 442 case OLARNEYE: case ODIAMOND: case OEMERALD: 443 case ORUBY: case OSAPPHIRE: 444 445 if (iven[i]==OLARNEYE) 446 { 447 gemvalue[i]=250000-((gtime*7)/100)*100; 448 if (gemvalue[i]<50000) gemvalue[i]=50000; 449 } 450 else gemvalue[i] = (255&ivenarg[i])*100; 451 gemorder[i]=k; 452 cursor( (k%2)*40+1 , (k>>1)+4 ); 453 lprintf("%c) %s",i+'a',objectname[iven[i]]); 454 cursor( (k%2)*40+33 , (k>>1)+4 ); 455 lprintf("%5d",(long)gemvalue[i]); k++; 456 }; 457 cursor(31,17); lprintf("You have %8d gold pieces in the bank.",(long)c[BANKACCOUNT]); 458 cursor(40,18); lprintf("You have %8d gold pieces",(long)c[GOLD]); 459 if (c[BANKACCOUNT]+c[GOLD] >= 500000) 460 lprcat("\nNote: Larndom law states that only deposits under 500,000gp can earn interest."); 461 while (1) 462 { 463 cl_dn(1,20); 464 lprcat("\nYour wish? [("); standout("d"); lprcat(") deposit, ("); 465 standout("w"); lprcat(") withdraw, ("); standout("s"); 466 lprcat(") sell a stone, or "); standout("escape"); lprcat("] "); 467 yrepcount=0; 468 i=0; while (i!='d' && i!='w' && i!='s' && i!='\33') i=getchar(); 469 switch(i) 470 { 471 case 'd': lprcat("deposit\nHow much? "); amt = readnum((long)c[GOLD]); 472 if (amt<0) { lprcat("\nSorry, but we can't take negative gold!"); nap(2000); amt=0; } else 473 if (amt>c[GOLD]) 474 { lprcat(" You don't have that much."); nap(2000); } 475 else { c[GOLD] -= amt; c[BANKACCOUNT] += amt; } 476 break; 477 478 case 'w': lprcat("withdraw\nHow much? "); amt = readnum((long)c[BANKACCOUNT]); 479 if (amt<0) { lprcat("\nSorry, but we don't have any negative gold!"); nap(2000); amt=0; } 480 else if (amt > c[BANKACCOUNT]) 481 { lprcat("\nYou don't have that much in the bank!"); nap(2000); } 482 else { c[GOLD] += amt; c[BANKACCOUNT] -= amt; } 483 break; 484 485 case 's': lprcat("\nWhich stone would you like to sell? "); 486 i=0; while ((i<'a' || i>'z') && i!='*') i=getchar(); 487 if (i=='*') 488 for (i=0; i<26; i++) 489 { 490 if (gemvalue[i]) 491 { 492 c[GOLD]+=gemvalue[i]; iven[i]=0; 493 gemvalue[i]=0; k = gemorder[i]; 494 cursor( (k%2)*40+1 , (k>>1)+4 ); 495 lprintf("%39s",""); 496 } 497 } 498 else 499 { 500 if (gemvalue[i=i-'a']==0) 501 { 502 lprintf("\nItem %c is not a gemstone!",i+'a'); 503 nap(2000); break; 504 } 505 c[GOLD]+=gemvalue[i]; iven[i]=0; 506 gemvalue[i]=0; k = gemorder[i]; 507 cursor( (k%2)*40+1 , (k>>1)+4 ); lprintf("%39s",""); 508 } 509 break; 510 511 case '\33': return; 512 }; 513 cursor(40,17); lprintf("%8d",(long)c[BANKACCOUNT]); 514 cursor(49,18); lprintf("%8d",(long)c[GOLD]); 515 } 516 } 517 518 /* 519 subroutine to appraise any stone for the bank 520 */ 521 appraise(gemstone) 522 register int gemstone; 523 { 524 register int j,amt; 525 for (j=0; j<26; j++) 526 if (iven[j]==gemstone) 527 { 528 lprintf("\nI see you have %s",objectname[gemstone]); 529 if (gemstone==OLARNEYE) lprcat(" I must commend you. I didn't think\nyou could get it."); 530 lprcat(" Shall I appraise it for you? "); yrepcount=0; 531 if (getyn()=='y') 532 { 533 lprcat("yes.\n Just one moment please \n"); nap(1000); 534 if (gemstone==OLARNEYE) 535 { 536 amt = 250000-((gtime*7)/100)*100; 537 if (amt<50000) amt=50000; 538 } 539 else amt = (255 & ivenarg[j]) * 100; 540 lprintf("\nI can see this is an excellent stone, It is worth %d",(long)amt); 541 lprcat("\nWould you like to sell it to us? "); yrepcount=0; 542 if (getyn()=='y') { lprcat("yes\n"); c[GOLD]+=amt; iven[j]=0; } 543 else lprcat("no thank you.\n"); 544 if (gemstone==OLARNEYE) lprcat("It is, of course, your privilege to keep the stone\n"); 545 } 546 else lprcat("no\nO. K.\n"); 547 } 548 } 549 /* 550 function for the trading post 551 */ 552 static otradhead() 553 { 554 clear(); 555 lprcat("Welcome to the Larn Trading Post. We buy items that explorers no longer find\n"); 556 lprcat("useful. Since the condition of the items you bring in is not certain,\n"); 557 lprcat("and we incur great expense in reconditioning the items, we usually pay\n"); 558 lprcat("only 20% of their value were they to be new. If the items are badly\n"); 559 lprcat("damaged, we will pay only 10% of their new value.\n\n"); 560 } 561 562 otradepost() 563 { 564 register int i,j,value,isub,izarg; 565 dnditm = dndcount = 0; 566 nosignal = 1; /* disable signals */ 567 resetscroll(); otradhead(); 568 while (1) 569 { 570 lprcat("\nWhat item do you want to sell to us ["); standout("*"); 571 lprcat(" for list, or "); standout("escape"); lprcat("] ? "); 572 i=0; while (i>'z' || (i<'a' && i!='*' && i!='\33' && i!='.')) i=getchar(); 573 if (i == '\33') 574 { setscroll(); recalc(); drawscreen(); nosignal=0; /* enable signals */ return; } 575 isub = i - 'a'; j=0; 576 if (iven[isub]==OSCROLL) if (scrollname[ivenarg[isub]][0]==0) 577 { j=1; cnsitm(); } /* can't sell unidentified item */ 578 if (iven[isub]==OPOTION) if (potionname[ivenarg[isub]][0]==0) 579 { j=1; cnsitm(); } /* can't sell unidentified item */ 580 if (!j) 581 if (i=='*') { clear(); qshowstr(); otradhead(); } 582 else if (iven[isub]==0) lprintf("\nYou don't have item %c!",isub+'a'); 583 else 584 { 585 for (j=0; j<maxitm; j++) 586 if ((itm[j].obj == iven[isub]) || (iven[isub] == ODIAMOND) || (iven[isub] == ORUBY) || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE)) 587 { 588 srcount=0; show3(isub); /* show what the item was */ 589 if ((iven[isub] == ODIAMOND) || (iven[isub] == ORUBY) 590 || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE)) 591 value = 20*ivenarg[isub]; 592 else 593 if ((itm[j].obj == OSCROLL) || (itm[j].obj == OPOTION)) value = 2*itm[j+ivenarg[isub]].price; 594 else 595 { 596 izarg=ivenarg[isub]; value = itm[j].price; /* appreciate if a +n object */ 597 if (izarg >= 0) value *= 2; 598 while ((izarg-- > 0) && ((value=14*(67+value)/10) < 500000)); 599 } 600 lprintf("\nItem (%c) is worth %d gold pieces to us. Do you want to sell it? ",i,(long)value); 601 yrepcount=0; 602 if (getyn()=='y') 603 { 604 lprcat("yes\n"); c[GOLD]+=value; 605 if (c[WEAR] == isub) c[WEAR] = -1; 606 if (c[WIELD] == isub) c[WIELD] = -1; 607 if (c[SHIELD] == isub) c[SHIELD] = -1; 608 adjustcvalues(iven[isub],ivenarg[isub]); 609 iven[isub]=0; 610 } 611 else lprcat("no thanks.\n"); 612 j = maxitm+100; /* get out of the inner loop */ 613 } 614 if (j <= maxitm+2) lprcat("\nSo sorry, but we are not authorized to accept that item."); 615 } 616 } 617 } 618 619 cnsitm() 620 { lprcat("\nSorry, we can't accept unidentified objects."); } 621 622 /* 623 * for the Larn Revenue Service 624 */ 625 olrs() 626 { 627 register int i,first; 628 unsigned long amt; 629 first = nosignal = 1; /* disable signals */ 630 clear(); resetscroll(); cursor(1,4); 631 lprcat("Welcome to the Larn Revenue Service district office. How can we help you?"); 632 while (1) 633 { 634 if (first) { first=0; goto nxt; } 635 cursors(); 636 lprcat("\n\nYour wish? [("); 637 standout("p"); 638 lprcat(") pay taxes, or "); 639 standout("escape"); 640 lprcat("] "); yrepcount=0; 641 i=0; while (i!='p' && i!='\33') i=getchar(); 642 switch(i) 643 { 644 case 'p': lprcat("pay taxes\nHow much? "); amt = readnum((long)c[GOLD]); 645 if (amt<0) { lprcat("\nSorry, but we can't take negative gold\n"); amt=0; } else 646 if (amt>c[GOLD]) lprcat(" You don't have that much.\n"); 647 else c[GOLD] -= paytaxes((long)amt); 648 break; 649 650 case '\33': nosignal = 0; /* enable signals */ 651 setscroll(); drawscreen(); return; 652 }; 653 654 nxt: cursor(1,6); 655 if (outstanding_taxes>0) 656 lprintf("You presently owe %d gp in taxes. ",(long)outstanding_taxes); 657 else 658 lprcat("You do not owe us any taxes. "); 659 cursor(1,8); 660 if (c[GOLD]>0) 661 lprintf("You have %6d gp. ",(long)c[GOLD]); 662 else 663 lprcat("You have no gold pieces. "); 664 } 665 } 666