1 /* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
2 /* site1.c */
3 /* 1st half of site functions and aux functions to them */
4 
5 #ifndef MSDOS_SUPPORTED_ANTIQUE
6 #include <unistd.h>
7 #endif
8 
9 #include "glob.h"
10 
11 /* the bank; can be broken into (!) */
l_bank()12 void l_bank()
13 {
14   int done=FALSE,valid=FALSE;
15   long amount;
16   char response;
17   char passwd[64];
18   print1("First Bank of Omega: Autoteller Carrel.");
19 
20   if (gamestatusp(BANK_BROKEN))
21     print2("You see a damaged autoteller.");
22   else {
23     print2("The proximity sensor activates the autoteller as you approach.");
24     morewait();
25     clearmsg();
26     while (! done) {
27       print1("Current Balance: ");
28       mlongprint(Balance);
29       nprint1("Au. ");
30       nprint1(" Enter command (? for help) > ");
31       response = mgetc();
32       if (response == '?') {
33 	menuclear();
34 	menuprint("?: This List.\n");
35 	if (strcmp(Password,"")==0)
36 	  menuprint("O: Open an account.\n");
37 	else {
38 	  menuprint("P: Enter password.\n");
39 	  menuprint("D: Deposit.\n");
40 	  menuprint("W: Withdraw\n");
41 	}
42 	menuprint("X: eXit\n");
43 	showmenu();
44 	morewait();
45 	xredraw();
46 	continue;
47       }
48       else if ((response == 'P') && (strcmp(Password,"") != 0)) {
49 	clearmsg();
50 	print1("Password: ");
51 	strcpy(passwd,msgscanstring());
52 	valid = (strcmp(passwd,Password)==0);
53 	if (! valid) {
54 	  done = TRUE;
55 	  menuclear();
56 	  menuprint("Alert! Alert! Invalid Password!\n");
57 	  menuprint("The police are being summoned!\n");
58 	  menuprint("Please wait for the police to arrive....\n\n");
59 	  menuprint("----Hit space bar to continue----\n");
60 	  showmenu();
61 	  response = menugetc();
62 	  if (response == ' ') {
63 	    Player.alignment += 5;
64 	    xredraw();
65 	    print1("Ah ha! Trying to rob the bank, eh?");
66 	    print2("Take him away, boys!");
67 	    morewait();
68 	    send_to_jail();
69 	  }
70 	  else {
71 	    Player.alignment -= 5;
72 	    menuclear();
73 	    sleep(4);
74 	    menuprint("^@^@^@^@^@00AD1203BC0F0000FFFFFFFFFFFF\n");
75 	    menuprint("Interrupt in _get_space. Illegal Character.\n");
76 	    showmenu();
77 	    sleep(4);
78 	    menuprint("Aborting _police_alert.....\n");
79 	    menuprint("Attempting reboot.....\n");
80 	    showmenu();
81 	    sleep(4);
82 	    menuprint("Warning: Illegal shmop at _count_cash.\n");
83 	    menuprint("Warning: Command Buffer NOT CLEARED\n");
84 	    showmenu();
85 	    sleep(4);
86 	    menuprint("Reboot Complete. Execution Continuing.\n");
87 	    menuprint("Withdrawing: 4294967297 Au.\n");
88 	    menuprint("Warning: Arithmetic Overflow in _withdraw\n");
89 	    showmenu();
90 	    sleep(4);
91 	    menuprint("Yo mama. Core dumped.\n");
92 	    showmenu();
93 	    sleep(4);
94 	    xredraw();
95 	    clearmsg();
96 	    print1("The cash machine begins to spew gold pieces!");
97 	    print2("You pick up your entire balance and then some!");
98 	    Player.cash += Balance + 1000 + random_range(3000);
99 	    Balance = 0;
100 	    setgamestatus(BANK_BROKEN);
101 	  }
102 	}
103 	else print2("Password accepted. Working.");
104       }
105       else if ((response == 'D') && valid) {
106 	clearmsg();
107 	print1("Amount: ");
108 	amount = get_money(Player.cash);
109 	if (amount < 1)
110 	  print3("Transaction aborted.");
111 	else if (amount > Player.cash)
112 	  print3("Deposit too large -- transaction aborted.");
113 	else {
114 	  print2("Transaction accomplished.");
115 	  Balance += amount;
116 	  Player.cash -= amount;
117 	}
118       }
119       else if ((response == 'W') && valid) {
120 	clearmsg();
121 	print1("Amount: ");
122 	amount = get_money(Balance);
123 	if (amount < 1)
124 	  print3("Transaction aborted.");
125 	else if (amount > Balance)
126 	  print3("Withdrawal too large -- transaction aborted.");
127 	else {
128 	  print2("Transaction accomplished.");
129 	  Balance -= amount;
130 	  Player.cash += amount;
131 	}
132       }
133       else if (response == 'X') {
134 	clearmsg();
135 	print1("Bye!");
136 	done = TRUE;
137       }
138       else if ((response == 'O') && (strcmp(Password,"")==0)) {
139 	clearmsg();
140 	print1("Opening new account.");
141 	nprint1(" Please enter new password: ");
142 	strcpy(Password,msgscanstring());
143 	if (strcmp(Password,"")==0) {
144 	  print3("Illegal to use null password -- aborted.");
145 	  done = TRUE;
146 	}
147 	else {
148 	  print2("Password validated; account saved.");
149 	  valid = TRUE;
150 	}
151       }
152       else print3(" Illegal command.");
153       dataprint();
154     }
155   }
156   xredraw();
157 }
158 
159 
160 
161 
l_armorer()162 void l_armorer()
163 {
164   int done = FALSE;
165   char action;
166   if (hour() == 12)
167     print3("Unfortunately, this is Julie's lunch hour -- try again later.");
168   else if (nighttime())
169     print3("It seems that Julie keeps regular business hours.");
170   else {
171     while (! done) {
172       clearmsg();
173       print1("Julie's: Buy Armor, Weapons, or Leave [a,w,ESCAPE] ");
174       action = mgetc();
175       if (action == ESCAPE)
176 	done = TRUE;
177       else if (action == 'a')
178 	buyfromstock(ARMORID,10);
179       else if (action == 'w')
180 	buyfromstock(WEAPONID,23);
181     }
182   }
183   xredraw();
184 }
185 
186 
buyfromstock(base,numitems)187 void buyfromstock(base,numitems)
188 int base,numitems;
189 {
190   int i;
191   char item;
192   pob newitem;
193 
194   print2("Purchase which item? [ESCAPE to quit] ");
195   menuclear();
196   for(i=0;i<numitems;i++) {
197     strcpy(Str4," :");
198     Str4[0] = i + 'a';
199     strcat(Str4,Objects[base+i].objstr);
200     menuprint(Str4);
201     menuprint("\n");
202   }
203   showmenu();
204   item = ' ';
205   while ((item != ESCAPE) &&
206 	 ((item < 'a') || (item >= 'a'+numitems)))
207     item = mgetc();
208   if (item != ESCAPE) {
209     i = item - 'a';
210     newitem = ((pob) checkmalloc(sizeof(objtype)));
211     *newitem = Objects[base+i];
212     newitem->known = 2;
213     clearmsg();
214     print1("I can let you have it for ");
215     mlongprint(2*true_item_value(newitem));
216     nprint1("Au. Buy it? [yn] ");
217     if (ynq1() == 'y') {
218       if (Player.cash < 2*true_item_value(newitem)) {
219 	print2("Why not try again some time you have the cash?");
220 	free((char *) newitem);
221       }
222       else {
223 	Player.cash -= 2*true_item_value(newitem);
224 	dataprint();
225 	gain_item(newitem);
226       }
227     }
228     else free((char *)newitem);
229   }
230 }
231 
232 
l_club()233 void l_club()
234 {
235 #define hinthour club_hinthour
236   char response;
237 
238   print1("Rampart Explorers' Club.");
239   if (! gamestatusp(CLUB_MEMBER)) {
240     if (Player.level < 2) print3("Only reknowned adventurers need apply.");
241     else {
242       print2("Dues are 100Au. Pay it? [yn] ");
243       if (ynq2()=='y') {
244 	if (Player.cash < 100)
245 	  print3("Beat it, or we'll blackball you!");
246 	else {
247 	  print1("Welcome to the club! You are taught the spell of Return.");
248           print2("When cast on the first level of a dungeon it");
249 	  morewait();
250 	  clearmsg();
251 	  print1("will transport you down to the lowest level");
252 	  print2("you have explored, and vice versa.");
253 	  Spells[S_RETURN].known = TRUE;
254 	  Player.cash -= 100;
255 	  setgamestatus(CLUB_MEMBER);
256 	}
257       }
258       else print2("OK, but you're missing out on our benefits....");
259     }
260   }
261   else {
262     print2("Shop at the club store or listen for rumors [sl] ");
263     do response = (char) mcigetc();
264     while ((response != 's') && (response != 'l') && (response != ESCAPE));
265     if (response == 'l') {
266       if (hinthour == hour()) print2("You don't hear anything useful.");
267       else {
268 	print1("You overhear a conversation....");
269 	hint();
270 	hinthour = hour();
271       }
272     }
273     else if (response == 's') {
274       buyfromstock(THINGID+7,2);
275       xredraw();
276     }
277     else if (response == ESCAPE)
278       print2("Be seeing you, old chap!");
279   }
280 }
281 #undef hinthour
282 
l_gym()283 void l_gym()
284 {
285   int done=TRUE;
286   int trained=0;
287   clearmsg();
288   do {
289     print1("The Rampart Gymnasium");
290     if ((Gymcredit > 0) || (Player.rank[ARENA])) {
291       nprint1("-- Credit: ");
292       mlongprint(Gymcredit);
293       nprint1("Au.");
294     }
295     done = FALSE;
296     menuclear();
297     menuprint("Train for 2000 Au. Choose:\n");
298     menuprint("\na: work out in the weight room");
299     menuprint("\nb: use our gymnastics equipment");
300     menuprint("\nc: take our new anaerobics course");
301     menuprint("\nd: enroll in dance lessons.");
302     menuprint("\nESCAPE: Leave this place.");
303     showmenu();
304     switch(mgetc()) {
305     case 'a':
306       gymtrain(&(Player.maxstr),&(Player.str));
307       break;
308     case 'b':
309       gymtrain(&(Player.maxdex),&(Player.dex));
310       break;
311     case 'c':
312       gymtrain(&(Player.maxcon),&(Player.con));
313       break;
314     case 'd':
315       gymtrain(&(Player.maxagi),&(Player.agi));
316       break;
317     case ESCAPE:
318       clearmsg();
319       if (trained == 0)
320 	  print1("Well, it's your body you're depriving!");
321       else if (trained < 3)
322 	  print1("You towel yourself off, and find the exit.");
323       else
324 	  print1("A refreshing bath, and you're on your way.");
325       done = TRUE;
326       break;
327     default:
328       trained--;
329       break;
330     }
331     trained++;
332   } while (! done);
333   xredraw();
334   calc_melee();
335 }
336 
337 
338 
l_healer()339 void l_healer()
340 {
341   print1("Rampart Healers. Member RMA.");
342   morewait();
343   clearmsg();
344   print1("a: Heal injuries (50 crowns)");
345   print2("b: Cure disease (250 crowns)");
346   print3("ESCAPE: Leave these antiseptic alcoves.");
347   switch((char) mcigetc()) {
348     case 'a': healforpay(); break;
349     case 'b': cureforpay(); break;
350     default: print3("OK, but suppose you have Acute Satyriasis?"); break;
351   }
352 }
353 
354 
statue_random(x,y)355 void statue_random(x,y)
356 int x,y;
357 {
358   pob item;
359   int i,j;
360   switch(random_range(difficulty()+3)-1) {
361   default: l_statue_wake(); break;
362   case 0:
363     print1("The statue crumbles with a clatter of gravel.");
364     Level->site[x][y].locchar = RUBBLE;
365     Level->site[x][y].p_locf = L_RUBBLE;
366     plotspot(x, y, TRUE);
367     lset(x, y, CHANGED);
368     break;
369   case 1:
370     print1("The statue stoutly resists your attack.");
371     break;
372   case 2:
373     print1("The statue crumbles with a clatter of gravel.");
374     Level->site[x][y].locchar = RUBBLE;
375     Level->site[x][y].p_locf = L_RUBBLE;
376     plotspot(x, y, TRUE);
377     lset(x, y, CHANGED);
378     make_site_treasure(x,y,difficulty());
379     break;
380   case 3:
381     print1("The statue hits you back!");
382     p_damage(random_range(difficulty()*5),UNSTOPPABLE,"a statue");
383     break;
384   case 4:
385     print1("The statue looks slightly pained. It speaks:");
386     morewait();
387     clearmsg();
388     hint();
389     break;
390   case 5:
391     if ((Current_Environment == Current_Dungeon) ||
392 	(Current_Environment == E_CITY)) {
393       print1("You hear the whirr of some mechanism.");
394       print2("The statue glides smoothly into the floor!");
395       /* WDT HACK: I shouldn't be making this choice on a level
396        * where no stairs can be (or perhaps I should, and I should
397        * implement a bonus level!). */
398       Level->site[x][y].locchar = STAIRS_DOWN;
399       Level->site[x][y].p_locf = L_NO_OP;
400       lset(x, y, CHANGED|STOPS);
401     }
402     break;
403   case 6:
404     print1("The statue was covered with contact cement!");
405     print2("You can't move....");
406     Player.status[IMMOBILE]+=random_range(6)+2;
407     break;
408   case 7:
409     print1("A strange radiation emanates from the statue!");
410     dispel(-1);
411     break;
412   case 8: /* I think this is particularly evil. Heh heh. */
413     if (Player.possessions[O_WEAPON_HAND] != NULL) {
414       print1("Your weapon sinks deeply into the statue and is sucked away!");
415       item = Player.possessions[O_WEAPON_HAND];
416       conform_lost_object(Player.possessions[O_WEAPON_HAND]);
417       item->blessing = -1-abs(item->blessing);
418       drop_at(x,y,item);
419     }
420     break;
421   case 9:
422     print1("The statue extends an arm. Beams of light illuminate the level!");
423     for(i=0;i<WIDTH;i++)
424       for(j=0;j<LENGTH;j++) {
425 	lset(i,j,SEEN);
426 	if (loc_statusp(i,j,SECRET)) {
427 	  lreset(i,j,SECRET);
428 	  lset(i,j,CHANGED);
429 	}
430       }
431     show_screen();
432     break;
433   }
434 }
435 
l_statue_wake()436 void l_statue_wake()
437 {
438   int i;
439   int x=Player.x,y=Player.y;
440   for(i=0;i<9;i++)
441     wake_statue(x+Dirs[0][i],y+Dirs[1][i],TRUE);
442 }
443 
wake_statue(x,y,first)444 void wake_statue(x,y,first)
445 int x,y,first;
446 {
447   int i;
448   pml tml;
449   if (Level->site[x][y].locchar == STATUE) {
450     if (! first) mprint("Another statue awakens!");
451     else mprint("A statue springs to life!");
452     Level->site[x][y].locchar = FLOOR;
453     lset(x, y, CHANGED);
454     tml = ((pml) checkmalloc(sizeof(mltype)));
455     tml->m =
456       (Level->site[x][y].creature = m_create(x,y,0,difficulty()+1));
457     m_status_set(Level->site[x][y].creature,HOSTILE);
458     tml->next = Level->mlist;
459     Level->mlist = tml;
460     for(i=0;i<8;i++) wake_statue(x+Dirs[0][i],y+Dirs[1][i],FALSE);
461   }
462 }
463 
464 
l_casino()465 void l_casino()
466 {
467   int i,done = FALSE,a,b,c,match;
468   char response;
469   print1("Rampart Mithril Nugget Casino.");
470   if (random_range(10)==1)
471     print2("Casino closed due to Grand Jury investigation.");
472   else {
473     while (! done) {
474       morewait();
475       clearmsg();
476       print1("a: Drop 100Au in the slots.");
477       print2("b: Risk 1000Au  at roulette.");
478       print3("ESCAPE: Leave this green baize hall.");
479       response = (char) mcigetc();
480       if (response == 'a') {
481 	if (Player.cash < 100) print3("No credit, jerk.");
482 	else {
483 	  Player.cash -= 100;
484 	  dataprint();
485 	  for(i=0;i<20;i++) {
486 	    if (i==19)
487 	      sleep(1);
488 	    else
489 	      usleep(250000);
490 	    a = random_range(10);
491 	    b = random_range(10);
492 	    c = random_range(10);
493 	    clearmsg1();
494 	    mprint(slotstr(a));
495 	    mprint(slotstr(b));
496 	    mprint(slotstr(c));
497 	  }
498 	  if (winnings > 0) do {
499 	    a = random_range(10);
500 	    b = random_range(10);
501 	    c = random_range(10);
502 	  } while ((a==b) || (a == c) || (b == c));
503 	  else {
504 	    a = random_range(10);
505 	    b = random_range(10);
506 	    c = random_range(10);
507 	  }
508 	  clearmsg();
509 	  mprint(slotstr(a));
510 	  mprint(slotstr(b));
511 	  mprint(slotstr(c));
512 	  if ((a==b) && (a==c)) {
513 	    print3("Jackpot Winner!");
514 	    winnings += (a+2)*(b+2)*(c+2)*5;
515 	    Player.cash += (a+2)*(b+2)*(c+2)*5;
516 	    dataprint();
517 	  }
518 	  else if (a==b) {
519 	    print3("Winner!");
520 	    Player.cash += (a+2)*(b+2)*5;
521 	    dataprint();
522 	    winnings += (a+2)*(b+2)*5;
523 	  }
524 	  else if (a==c) {
525 	    print3("Winner!");
526 	    Player.cash += (a+2)*(c+2)*5;
527 	    dataprint();
528 	    winnings += (a+2)*(c+2)*5;
529 	  }
530 	  else if (c==b) {
531 	    print3("Winner!");
532 	    Player.cash += (c+2)*(b+2)*5;
533 	    dataprint();
534 	    winnings += (c+2)*(b+2)*5;
535 	  }
536 	  else {
537 	    print3("Loser!");
538 	    winnings -= 100;
539 	  }
540 	}
541       }
542       else if (response == 'b') {
543 	if (Player.cash < 1000) mprint("No credit, jerk.");
544 	else {
545 	  Player.cash -= 1000;
546 	  dataprint();
547 	  print1("Red or Black? [rb]");
548 	  do response = (char) mcigetc();
549 	  while ((response != 'r') && (response != 'b'));
550 	  match = (response == 'r' ? 0 : 1);
551 	  for(i=0;i<20;i++) {
552 	    if (i==19)
553 	      sleep(1);
554 	    else
555 	      usleep(250000);
556 	    a = random_range(37);
557 	    b = a % 2;
558 	    if (a == 0) print1(" 0 ");
559 	    else if (a==1) print1(" 0 - 0 ");
560 	    else {
561 	      print1(( b == 0) ? "Red ": "Black ");
562 	      mnumprint(a-1);
563 	    }
564 	  }
565 	  if (winnings > 0) do {
566 	    a = random_range(37);
567 	    b = a % 2;
568 	  } while (b == match);
569 	  else {
570 	    a = random_range(37);
571 	    b = a % 2;
572 	  }
573 	  if (a == 0) print1(" 0 ");
574 	  else if (a==1) print1(" 0 - 0 ");
575 	  else {
576 	    print1((b == 0) ? "Red ": "Black ");
577 	    mnumprint(a-1);
578 	  }
579 	  if ((a > 1) && (b == match)){
580 	    print3(" Winner!");
581 	    winnings += 1000;
582 	    Player.cash += 2000;
583 	    dataprint();
584 	  }
585 	  else {
586 	    print3(" Loser!");
587 	    winnings -= 1000;
588 	    dataprint();
589 	  }
590 	}
591       }
592       else if (response == ESCAPE) done = TRUE;
593     }
594   }
595 }
596 
597 
598 
599 
600 
l_commandant()601 void l_commandant()
602 {
603   int num;
604   pob food;
605   print1("Commandant Sonder's Rampart-fried Lyzzard partes. Open 24 hrs.");
606   print2("Buy a bucket! Only 5 Au. Make a purchase? [yn] ");
607   if (ynq2()=='y') {
608     clearmsg();
609     print1("How many? ");
610     num = (int) parsenum();
611     if (num < 1) print3("Cute. Real cute.");
612     else if (num*5 > Player.cash)
613       print3("No handouts here, mac!");
614     else {
615       Player.cash -= num*5;
616       food = ((pob) checkmalloc(sizeof(objtype)));
617       *food = Objects[FOODID+0]; /* food ration */
618       food->number = num;
619       if (num == 1)
620 	print2("There you go, mac! One Lyzzard Bucket, coming up.");
621       else print2("A passel of Lyzzard Buckets, for your pleasure.");
622       morewait();
623       gain_item(food);
624     }
625   }
626   else print2("Don't blame the Commandant if you starve!");
627 }
628 
629 
l_diner()630 void l_diner()
631 {
632   print1("The Rampart Diner. All you can eat, 25Au.");
633   print2("Place an order? [yn] ");
634   if (ynq2()=='y') {
635     if (Player.cash < 25)
636       mprint("TANSTAAFL! Now git!");
637     else {
638       Player.cash -= 25;
639       dataprint();
640       Player.food = 44;
641       foodcheck();
642     }
643   }
644 }
645 
l_crap()646 void l_crap()
647 {
648   print1("Les Crapeuleaux. (****) ");
649   if ((hour() < 17) || (hour() > 23))
650     print2 ("So sorry, we are closed 'til the morrow...");
651   else {
652     print2("May I take your order? [yn] ");
653     if (ynq2()=='y') {
654       if (Player.cash < 1000)
655 	print2("So sorry, you have not the funds for dinner.");
656       else {
657 	print2("Hope you enjoyed your tres expensive meal, m'sieur...");
658 	Player.cash -= 1000;
659 	dataprint();
660 	Player.food += 8;
661 	foodcheck();
662       }
663     }
664   }
665 }
666 
l_tavern()667 void l_tavern()
668 {
669 #define hinthour tavern_hinthour
670   char response;
671   print1("The Centaur and Nymph -- J. Riley, prop.");
672   if (nighttime()) {
673     menuclear();
674     menuprint("Riley says: Whataya have?\n\n");
675     menuprint("a: Pint of Riley's ultra-dark 1Au\n");
676     menuprint("b: Shot of Tullimore Dew 10Au\n");
677     menuprint("c: Round for the House. 100Au\n");
678     menuprint("d: Bed and Breakfast. 25Au\n");
679     menuprint("ESCAPE: Leave this comfortable haven.\n");
680     showmenu();
681     do response = (char) mcigetc();
682     while ((response != 'a') &&
683 	   (response != 'b') &&
684 	   (response != 'c') &&
685 	   (response != 'd') &&
686 	   (response != ESCAPE));
687     switch (response) {
688     case 'a':
689       if (Player.cash < 1)
690 	print2("Aw hell, have one on me.");
691       else {
692 	Player.cash -= 1;
693 	dataprint();
694 	if (hinthour!=hour()) {
695 	  if (random_range(3)) {
696 	    print1("You overhear a rumor...");
697 	    hint();
698 	  }
699 	  else print1("You don't hear much of interest.");
700 	  hinthour = hour();
701 	}
702 	else print1("You just hear the same conversations again.");
703       }
704       break;
705     case 'b':
706       if (Player.cash < 10)
707 	print2("I don't serve the Dew on no tab, buddy!");
708       else {
709 	Player.cash -= 10;
710 	print1("Ahhhhh....");
711 	if (Player.status[POISONED] || Player.status[DISEASED])
712 	  print2("Phew! That's, er, smooth stuff!");
713 	Player.status[POISONED] = 0;
714 	Player.status[DISEASED] = 0;
715 	showflags();
716       }
717       break;
718     case 'c':
719       if (Player.cash < 100) {
720 	print1("Whatta feeb!");
721 	print2("Outta my establishment.... Now!");
722 	p_damage(random_range(20),UNSTOPPABLE,"Riley's right cross");
723 	morewait();
724       }
725       else {
726 	Player.cash -= 100;
727 	dataprint();
728 	print1("'What a guy!'"); morewait();
729 	print2("'Hey, thanks, fella.'"); morewait();
730 	print3("'Make mine a double...'"); morewait();
731 	clearmsg();
732 	switch(random_range(4)) {
733 	case 0:
734 	  print1("'You're a real pal. Say, have you heard.... ");
735 	  hint();
736 	  break;
737 	case 1:
738 	  print1("A wandering priest of Dionysus blesses you...");
739 	  if ((Player.patron == ODIN) || (Player.patron == ATHENA))
740 	    Player.alignment++;
741 	  else if ((Player.patron == HECATE) || (Player.patron == SET))
742 	    Player.alignment--;
743 	  else if (Player.alignment > 0) Player.alignment--;
744 	  else Player.alignment++;
745 	  break;
746 	case 2:
747 	  print1("A thirsty bard promises to put your name in a song!");
748 	  gain_experience(20);
749 	  break;
750 	case 3:
751 	  print1("Riley draws you a shot of his 'special reserve'");
752 	  print2("Drink it [yn]?");
753 	  if (ynq2()=='y') {
754 	    if (Player.con < random_range(20)) {
755 	      print1("<cough> Quite a kick!");
756 	      print2("You feel a fiery warmth in your tummy....");
757 	      Player.con++;
758 	      Player.maxcon++;
759 	    }
760 	    else print2("You toss it back nonchalantly.");
761 	  }
762 	}
763       }
764       break;
765     case 'd':
766       if (Player.cash < 25)
767 	print2("Pay in advance, mac!");
768       else {
769 	Player.cash -= 25;
770 	print2("How about a shot o' the dew for a nightcap?");
771 	morewait();
772 	Time += (6+random_range(4)) * 60;
773 	Player.status[POISONED] = 0;
774 	Player.status[DISEASED] = 0;
775 	Player.food = 40;
776 	/* reduce temporary stat gains to max stat levels */
777 	toggle_item_use(TRUE);
778 	Player.str = min(Player.str,Player.maxstr);
779 	Player.con = min(Player.con,Player.maxcon);
780 	Player.agi = min(Player.agi,Player.maxagi);
781 	Player.dex = min(Player.dex,Player.maxdex);
782 	Player.iq = min(Player.iq,Player.maxiq);
783 	Player.pow = min(Player.pow,Player.maxpow);
784 	toggle_item_use(FALSE);
785 	timeprint();
786 	dataprint();
787 	showflags();
788 	print1("The next day.....");
789 	if (hour() > 10) print2("Oh my! You overslept!");
790       }
791       break;
792     default:
793       print2("So? Just looking? Go on!");
794       break;
795     }
796   }
797   else print2("The pub don't open til dark, fella.");
798   xredraw();
799 }
800 #undef hinthour
801 
802 
l_alchemist()803 void l_alchemist()
804 {
805   int i,done=FALSE,mlevel;
806   char response;
807   pob obj;
808   print1("Ambrosias' Potions et cie.");
809   if (nighttime())
810     print2("Ambrosias doesn't seem to be in right now.");
811   else while (! done){
812     morewait();
813     clearmsg();
814     print1("a: Sell monster components.");
815     print2("b: Pay for transformation.");
816     print3("ESCAPE: Leave this place.");
817     response = (char) mcigetc();
818     if (response == 'a') {
819       clearmsg();
820       done = TRUE;
821       i = getitem(CORPSE);
822       if ((i != ABORT) && (Player.possessions[i] != NULL)){
823 	obj = Player.possessions[i];
824 	if (Monsters[obj->charge].transformid == -1) {
825 	  print1("I don't want such a thing.");
826 	  if (obj->basevalue > 0)
827 	    print2("You might be able to sell it to someone else, though.");
828 	}
829 	else {
830 	  clearmsg();
831 	  print1("I'll give you ");
832 	  mnumprint(obj->basevalue/3);
833 	  nprint1("Au for it. Take it? [yn] ");
834 	  if (ynq1()=='y') {
835 	    Player.cash += (obj->basevalue/3);
836 	    conform_lost_objects(1,obj);
837 	  }
838 	  else print2("Well, keep the smelly old thing, then!");
839 	}
840       }
841       else print2("So nu?");
842     }
843     else if (response == 'b') {
844       clearmsg();
845       done = TRUE;
846       i = getitem(CORPSE);
847       if ((i != ABORT) && (Player.possessions[i] != NULL)){
848 	obj = Player.possessions[i];
849 	if (Monsters[obj->charge].transformid == -1)
850 	  print1("Oy vey! You want me to transform such a thing?");
851 	else {
852 	  mlevel = Monsters[obj->charge].level;
853 	  print1("It'll cost you ");
854 	  mnumprint(max(10,obj->basevalue*2));
855 	  nprint1("Au for the transformation. Pay it? [yn] ");
856 	  if (ynq1()=='y') {
857 	    if (Player.cash < max(10,obj->basevalue*2))
858 	      print2("You can't afford it!");
859 	    else {
860 	      print1("Voila! A tap of the Philosopher's Stone...");
861 	      Player.cash -= max(10,obj->basevalue*2);
862 	      *obj = Objects[Monsters[obj->charge].transformid];
863 	      if ((obj->id >= STICKID) && (obj->id < STICKID+NUMSTICKS))
864 		obj->charge = 20;
865 	      if (obj->plus == 0) obj->plus = mlevel;
866 	      if (obj->blessing == 0) obj->blessing = 1;
867 	    }
868 	  }
869 	  else print2("I don't need your business, anyhow.");
870 	}
871       }
872       else print2("So nu?");
873     }
874     else if (response == ESCAPE) done = TRUE;
875   }
876 }
877 
l_dpw()878 void l_dpw()
879 {
880   print1("Rampart Department of Public Works.");
881   if (Date - LastDay < 7)
882     print2("G'wan! Get a job!");
883   else if (Player.cash < 100) {
884     print2("Do you want to go on the dole? [yn] ");
885     if (ynq2()=='y') {
886       print1("Well, ok, but spend it wisely.");
887       morewait();
888       print1("Please enter your name for our records:");
889       strcpy(Str1, msgscanstring());
890       if (Str1[0] >= 'a' && Str1[0] <= 'z')
891 	Str1[0] += 'A' - 'a';
892       if (Str1[0] == '\0')
893 	print1("Maybe you should come back when you've learned to write.");
894       else if (strcmp(Player.name,Str1) != 0) {
895 	print3("Aha! Welfare Fraud! It's off to gaol for you, lout!");
896 	morewait();
897 	send_to_jail();
898       }
899       else {
900 	print2("Here's your handout, layabout!");
901 	LastDay = Date;
902 	Player.cash = 99;
903 	dataprint();
904       }
905     }
906   }
907   else print2("You're too well off for us to help you!");
908 }
909 
l_library()910 void l_library()
911 {
912   char response;
913   int studied=FALSE;
914   int done=FALSE,fee = 1000;
915   print1("Rampart Public Library.");
916   if (nighttime())
917     print2("CLOSED");
918   else {
919     morewait();
920     print1("Library Research Fee: 1000Au.");
921     if (Player.maxiq < 18) {
922       print2("The Rampart student aid system has arranged a grant!");
923       morewait();
924       clearmsg();
925       print1("Your revised fee is: ");
926       mnumprint(fee=max(50,1000-(18-Player.maxiq)*125));
927       nprint1("Au.");
928     }
929     morewait();
930     while(! done) {
931       print1("Pay the fee? [yn] ");
932       if (ynq1()=='y') {
933 	if (Player.cash < fee) {
934 	  print2("No payee, No studee.");
935 	  done = TRUE;
936 	}
937 	else {
938 	  Player.cash -= fee;
939 	  do {
940 	    studied = TRUE;
941 	    dataprint();
942 	    menuclear();
943 	    menuprint("Peruse a scroll:\n");
944 	    menuprint("a: Omegan Theology\n");
945 	    menuprint("b: Guide to Rampart\n");
946 	    menuprint("c: High Magick\n");
947 	    menuprint("d: Odd Uncatalogued Document\n");
948 	    menuprint("e: Attempt Advanced Research\n");
949 	    menuprint("ESCAPE: Leave this font of learning.\n");
950 	    showmenu();
951 	    response = (char) mcigetc();
952 	    if (response == 'a') {
953 	      print1("You unfurl an ancient, yellowing scroll...");
954 	      morewait();
955 	      theologyfile();
956 	    }
957 	    else if (response == 'b') {
958 	      print1("You unroll a slick four-color document...");
959 	      morewait();
960 	      cityguidefile();
961 	    }
962 	    else if (response == 'c') {
963 	      print1("This scroll is written in a strange magical script...");
964 	      morewait();
965 	      wishfile();
966 	    }
967 	    else if (response == 'd') {
968 	      print1("You find a strange document, obviously misfiled");
969 	      print2("under the heading 'acrylic fungus painting technique'");
970 	      morewait();
971 	      adeptfile();
972 	    }
973 	    else if (response == 'e') {
974 	      if (random_range(30) > Player.iq)  {
975 		print2("You feel more knowledgeable!");
976 		Player.iq++;
977 		Player.maxiq++;
978 		dataprint();
979 		if (Player.maxiq < 19 &&
980 		  fee != max(50,1000-(18-Player.maxiq)*125))
981 		  {
982 		    morewait();
983 		    clearmsg();
984 		    print1("Your revised fee is: ");
985 		    mnumprint(fee=max(50,1000-(18-Player.maxiq)*125));
986 		    nprint1("Au.");
987 		    morewait();
988 		  }
989 	      }
990 	      else {
991 		clearmsg1();
992 		print1("You find advice in an ancient tome: ");
993 		morewait();
994 		hint();
995 		morewait();
996 	      }
997 	    }
998 	    else if (response == ESCAPE) {
999 	      done = TRUE;
1000 	      print1("That was an expensive browse...");
1001 	    }
1002 	    else
1003 	      studied = FALSE;
1004 	  } while (!studied);
1005 	}
1006       xredraw();
1007       }
1008       else {
1009 	done = TRUE;
1010 	if (studied)
1011 	  print2("Come back anytime we're open, 7am to 8pm.");
1012 	else
1013 	  print2("You philistine!");
1014       }
1015     }
1016   }
1017 }
1018 
1019 
l_pawn_shop()1020 void l_pawn_shop()
1021 {
1022   int i,j,k,limit,number,done = FALSE;
1023   char item,action;
1024 
1025   if (nighttime())
1026     print1("Shop Closed: Have a Nice (K)Night");
1027   else {
1028     limit = min(5,Date-Pawndate);
1029     Pawndate = Date;
1030     for(k=0;k<limit;k++) {
1031       if (Pawnitems[0] != NULL) {
1032 	if (Objects[Pawnitems[0]->id].uniqueness > UNIQUE_UNMADE)
1033 	  Objects[Pawnitems[0]->id].uniqueness = UNIQUE_UNMADE;
1034 	  /* could turn up anywhere, really :) */
1035 	free((char *) Pawnitems[0]);
1036 	Pawnitems[0] = NULL;
1037       }
1038       for (i=0;i<PAWNITEMS-1;i++)
1039 	Pawnitems[i] = Pawnitems[i+1];
1040       Pawnitems[PAWNITEMS-1] = NULL;
1041       for (i=0;i<PAWNITEMS;i++)
1042  	if (Pawnitems[i] == NULL)
1043           do {
1044             if (Pawnitems[i] != NULL)
1045               free(Pawnitems[i]);
1046             Pawnitems[i] = create_object(5);
1047             Pawnitems[i]->known = 2;
1048           } while ((Pawnitems[i]->objchar == CASH) ||
1049                    (Pawnitems[i]->objchar == ARTIFACT) ||
1050                    (true_item_value(Pawnitems[i]) <= 0));
1051     }
1052     while (! done) {
1053       print1("Knight's Pawn Shop:");
1054       print2("Buy item, Sell item, sell Pack contents, Leave [b,s,p,ESCAPE] ");
1055       menuclear();
1056       for(i=0;i<PAWNITEMS;i++)
1057 	if (Pawnitems[i] != NULL) {
1058 	  strcpy(Str3," :");
1059 	  Str3[0] = i+'a';
1060 	  strcat(Str3,itemid(Pawnitems[i]));
1061 	  menuprint(Str3);
1062 	  menuprint("\n");
1063 	}
1064       showmenu();
1065       action = (char) mcigetc();
1066       if (action == ESCAPE)
1067 	done = TRUE;
1068       else if (action == 'b') {
1069 	print2("Purchase which item? [ESCAPE to quit] ");
1070 	item = ' ';
1071 	while ((item != ESCAPE) &&
1072 	       ((item < 'a') || (item >= 'a' + PAWNITEMS)))
1073 	  item = (char) mcigetc();
1074 	if (item != ESCAPE) {
1075 	  i = item - 'a';
1076 	  if (Pawnitems[i] == NULL) print3("No such item!");
1077 	  else if (true_item_value(Pawnitems[i]) <= 0) {
1078 	    print1("Hmm, how did that junk get on my shelves?");
1079 	    print2("I'll just remove it.");
1080 	    free((char *) Pawnitems[i]);
1081 	    Pawnitems[i] = NULL;
1082 	  }
1083 	  else {
1084 	    clearmsg();
1085 	    print1("The low, low, cost is: ");
1086 	    mlongprint(Pawnitems[i]->number*true_item_value(Pawnitems[i]));
1087 	    nprint1(" Buy it? [ynq] ");
1088 	    if (ynq1() == 'y') {
1089 	      if (Player.cash <
1090 		  Pawnitems[i]->number *
1091 		  true_item_value(Pawnitems[i])) {
1092 		print2("No credit! Gwan, Beat it!");
1093 		morewait();
1094 	      }
1095 	      else {
1096 		Player.cash -=
1097 		  Pawnitems[i]->number*
1098 		    true_item_value(Pawnitems[i]);
1099 		Objects[Pawnitems[i]->id].known = 1;
1100 		gain_item(Pawnitems[i]);
1101 		Pawnitems[i] = NULL;
1102 	      }
1103 	    }
1104 	  }
1105 	}
1106       }
1107       else if (action == 's') {
1108 	menuclear();
1109 	print2("Sell which item: ");
1110 	i = getitem(NULL_ITEM);
1111 	if ((i != ABORT) && (Player.possessions[i] != NULL)) {
1112 	  if (cursed(Player.possessions[i])) {
1113 	    print1("No loans on cursed items! I been burned before....");
1114 	    morewait();
1115 	  }
1116 	  else if (true_item_value(Player.possessions[i]) <= 0) {
1117 	    print1("That looks like a worthless piece of junk to me.");
1118 	    morewait();
1119 	  }
1120 	  else {
1121 	    clearmsg();
1122 	    print1("You can get ");
1123 	    mlongprint(item_value(Player.possessions[i]) / 2);
1124 	    nprint1("Au each. Sell [yn]? ");
1125 	    if (ynq1() == 'y') {
1126 	      number = getnumber(Player.possessions[i]->number);
1127 	      if ((number >= Player.possessions[i]->number) &&
1128 		  Player.possessions[i]->used) {
1129 		Player.possessions[i]->used = FALSE;
1130 		item_use(Player.possessions[i]);
1131 	      }
1132 	      Player.cash += number * item_value(Player.possessions[i]) / 2;
1133 	      free((char *) Pawnitems[0]);
1134 	      for(j=0;j<PAWNITEMS - 1;j++)
1135 		Pawnitems[j] = Pawnitems[j+1];
1136 	      Pawnitems[PAWNITEMS - 1] = ((pob) checkmalloc(sizeof(objtype)));
1137 	      *(Pawnitems[PAWNITEMS - 1]) = *(Player.possessions[i]);
1138 	      Pawnitems[PAWNITEMS - 1]->number = number;
1139 	      Pawnitems[PAWNITEMS - 1]->known = 2;
1140 	      dispose_lost_objects(number,Player.possessions[i]);
1141 	      dataprint();
1142 	    }
1143 	  }
1144 	}
1145       }
1146       else if (action == 'p') {
1147 	for(i=0;i<Player.packptr;i++) {
1148 	  if (Player.pack[i]->blessing > -1 &&
1149 	      true_item_value(Player.pack[i]) > 0) {
1150 	    clearmsg();
1151 	    print1("Sell ");
1152 	    nprint1(itemid(Player.pack[i]));
1153 	    nprint1(" for ");
1154 	    mlongprint(item_value(Player.pack[i])/2);
1155 	    nprint1("Au each? [yn] ");
1156 	    if (ynq1()=='y') {
1157 	      number = getnumber(Player.pack[i]->number);
1158 	      if (number > 0) {
1159 		Player.cash += number * item_value(Player.pack[i]) / 2;
1160 		free((char *) Pawnitems[0]);
1161 		for(j=0;j<PAWNITEMS - 1;j++)
1162 		  Pawnitems[j] = Pawnitems[j+1];
1163 		Pawnitems[PAWNITEMS - 1] = ((pob) checkmalloc(sizeof(objtype)));
1164 		*(Pawnitems[PAWNITEMS - 1]) = *(Player.pack[i]);
1165 		Pawnitems[PAWNITEMS - 1]->number = number;
1166 		Pawnitems[PAWNITEMS - 1]->known = 2;
1167 		Player.pack[i]->number -= number;
1168 		if (Player.pack[i]->number < 1) {
1169 		  free((char *)Player.pack[i]);
1170 		  Player.pack[i] = NULL;
1171 		}
1172 		dataprint();
1173 	      }
1174 	    }
1175 	  }
1176 	}
1177 	fixpack();
1178       }
1179     }
1180   }
1181   calc_melee();
1182   xredraw();
1183 }
1184