1 /* $OpenBSD: subr.c,v 1.9 2004/07/09 15:59:26 deraadt Exp $ */ 2 /* $NetBSD: subr.c,v 1.2 1995/03/21 12:05:11 cgd Exp $ */ 3 4 /*- 5 * Copyright (c) 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * The game adventure was originally written in Fortran by Will Crowther 9 * and Don Woods. It was later translated to C and enhanced by Jim 10 * Gillogly. This code is derived from software contributed to Berkeley 11 * by Jim Gillogly at The Rand Corporation. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 3. Neither the name of the University nor the names of its contributors 22 * may be used to endorse or promote products derived from this software 23 * without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 */ 37 38 #ifndef lint 39 #if 0 40 static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 5/31/93"; 41 #else 42 static char rcsid[] = "$OpenBSD: subr.c,v 1.9 2004/07/09 15:59:26 deraadt Exp $"; 43 #endif 44 #endif /* not lint */ 45 46 /* Re-coding of advent in C: subroutines from main */ 47 48 #include <stdio.h> 49 #include <stdlib.h> 50 #include "hdr.h" 51 #include "extern.h" 52 53 /* Statement functions */ 54 int 55 toting(int objj) 56 { 57 if (place[objj] == -1) 58 return (TRUE); 59 return (FALSE); 60 } 61 62 int 63 here(int objj) 64 { 65 if (place[objj] == loc || toting(objj)) 66 return (TRUE); 67 return (FALSE); 68 } 69 70 int 71 at(int objj) 72 { 73 if (place[objj] == loc || fixed[objj] == loc) 74 return (TRUE); 75 else 76 return (FALSE); 77 } 78 79 int 80 liq2(int pbotl) 81 { 82 return ((1 - pbotl) * water + (pbotl / 2) * (water + oil)); 83 } 84 85 int 86 liq(void) 87 { 88 int i; 89 90 i = prop[bottle]; 91 if (i > -1 - i) 92 return (liq2(i)); 93 return (liq2(-1 - i)); 94 } 95 96 int 97 liqloc(int locc) /* may want to clean this one up a bit */ 98 { 99 int i, j, l; 100 101 i = cond[locc] / 2; 102 j = ((i * 2) % 8) - 5; 103 l = cond[locc] / 4; 104 l = l % 2; 105 return (liq2(j * l + 1)); 106 } 107 108 int 109 bitset(int l, int n) 110 { 111 if (cond[l] & setbit[n]) 112 return (TRUE); 113 return (FALSE); 114 } 115 116 int 117 forced(int locc) 118 { 119 if (cond[locc] == 2) 120 return (TRUE); 121 return (FALSE); 122 } 123 124 int 125 dark(void) 126 { 127 if ((cond[loc] % 2) == 0 && (prop[lamp] == 0 || !here(lamp))) 128 return (TRUE); 129 return (FALSE); 130 } 131 132 int 133 pct(int n) 134 { 135 if (ran(100) < n) 136 return (TRUE); 137 return (FALSE); 138 } 139 140 141 int 142 fdwarf(void) /* 71 */ 143 { 144 int i, j; 145 struct travlist *kk; 146 147 if (newloc != loc && !forced(loc) && !bitset(loc, 3)) { 148 for (i = 1; i <= 5; i++) { 149 if (odloc[i] != newloc || !dseen[i]) 150 continue; 151 newloc = loc; 152 rspeak(2); 153 break; 154 } 155 } 156 loc = newloc; /* 74 */ 157 if (loc == 0 || forced(loc) || bitset(newloc, 3)) 158 return (2000); 159 if (dflag == 0) { 160 if (loc >= 15) 161 dflag = 1; 162 return (2000); 163 } 164 if (dflag == 1) { /* 6000 */ 165 if (loc < 15 || pct(95)) 166 return (2000); 167 dflag = 2; 168 for (i = 1; i <= 2; i++) { 169 j = 1 + ran(5); 170 if (pct(50) && saved == -1) 171 dloc[j] = 0; /* 6001 */ 172 } 173 for (i = 1; i <= 5; i++) { 174 if (dloc[i] == loc) 175 dloc[i] = daltlc; 176 odloc[i] = dloc[i]; /* 6002 */ 177 } 178 rspeak(3); 179 drop(axe, loc); 180 return (2000); 181 } 182 dtotal = attack = stick = 0; /* 6010 */ 183 for (i = 1; i <= 6; i++) { /* loop to 6030 */ 184 if (dloc[i] == 0) 185 continue; 186 j = 1; 187 for (kk = travel[dloc[i]]; kk != 0; kk = kk->next) { 188 newloc = kk->tloc; 189 if (newloc > 300 || newloc < 15 || newloc == odloc[i] 190 || (j > 1 && newloc == tk[j-1]) || j >= 20 191 || newloc == dloc[i] || forced(newloc) 192 || (i == 6 && bitset(newloc, 3)) 193 || kk->conditions == 100) 194 continue; 195 tk[j++] = newloc; 196 } 197 tk[j] = odloc[i]; /* 6016 */ 198 if (j >= 2) 199 j--; 200 j = 1 + ran(j); 201 odloc[i] = dloc[i]; 202 dloc[i] = tk[j]; 203 dseen[i] = (dseen[i] && loc >= 15) || (dloc[i] == loc || odloc[i] == loc); 204 if (!dseen[i]) 205 continue; /* i.e. goto 6030 */ 206 dloc[i] = loc; 207 if (i == 6) { /* pirate's spotted him */ 208 if (loc == chloc || prop[chest] >= 0) 209 continue; 210 k = 0; 211 for (j = 50; j <= maxtrs; j++) { /* loop to 6020 */ 212 if (j == pyram && (loc == plac[pyram] 213 || loc == plac[emrald])) 214 goto l6020; 215 if (toting(j)) 216 goto l6022; 217 l6020: if (here(j)) 218 k = 1; 219 } /* 6020 */ 220 if (tally == tally2 + 1 && k == 0 && place[chest] == 0 221 && here(lamp) && prop[lamp] == 1) 222 goto l6025; 223 if (odloc[6] != dloc[6] && pct(20)) 224 rspeak(127); 225 continue; /* to 6030 */ 226 l6022: rspeak(128); 227 if (place[messag] == 0) 228 move(chest, chloc); 229 move(messag, chloc2); 230 for (j = 50; j <= maxtrs; j++) { /* loop to 6023 */ 231 if (j == pyram && (loc == plac[pyram] 232 || loc == plac[emrald])) 233 continue; 234 if (at(j) && fixed[j] == 0) 235 carry(j, loc); 236 if (toting(j)) 237 drop(j, chloc); 238 } 239 l6024: dloc[6] = odloc[6] = chloc; 240 dseen[6] = FALSE; 241 continue; 242 l6025: rspeak(186); 243 move(chest, chloc); 244 move(messag, chloc2); 245 goto l6024; 246 } 247 dtotal++; /* 6027 */ 248 if (odloc[i] != dloc[i]) 249 continue; 250 attack++; 251 if (knfloc >= 0) 252 knfloc = loc; 253 if (ran(1000) < 95 * (dflag - 2)) 254 stick++; 255 } /* 6030 */ 256 if (dtotal == 0) 257 return (2000); 258 if (dtotal != 1) { 259 printf("There are %d threatening little dwarves ", dtotal); 260 printf("in the room with you.\n"); 261 } 262 else 263 rspeak(4); 264 if (attack == 0) 265 return (2000); 266 if (dflag == 2) 267 dflag = 3; 268 if (saved != -1) 269 dflag = 20; 270 if (attack != 1) { 271 printf("%d of them throw knives at you!\n", attack); 272 k = 6; 273 l82: if (stick <= 1) { /* 82 */ 274 rspeak(k + stick); 275 if (stick == 0) 276 return (2000); 277 } else 278 printf("%d of them get you!\n", stick); /* 83 */ 279 oldlc2 = loc; 280 return (99); 281 } 282 rspeak(5); 283 k = 52; 284 goto l82; 285 } 286 287 288 int 289 march(void) /* label 8 */ 290 { 291 int ll1, ll2; 292 293 if ((tkk = travel[newloc = loc]) == 0) 294 bug(26); 295 if (k == null) 296 return (2); 297 if (k == cave) { /* 40 */ 298 if (loc < 8) 299 rspeak(57); 300 if (loc >= 8) 301 rspeak(58); 302 return (2); 303 } 304 if (k == look) { /* 30 */ 305 if (detail++ < 3) 306 rspeak(15); 307 wzdark = FALSE; 308 abb[loc] = 0; 309 return (2); 310 } 311 if (k == back) { /* 20 */ 312 switch(mback()) { 313 case 2: return (2); 314 case 9: goto l9; 315 default: bug(100); 316 } 317 } 318 oldlc2 = oldloc; 319 oldloc = loc; 320 l9: 321 for (; tkk != 0; tkk = tkk->next) 322 if (tkk->tverb == 1 || tkk->tverb == k) 323 break; 324 if (tkk == 0) { 325 badmove(); 326 return (2); 327 } 328 l11: ll1 = tkk->conditions; /* 11 */ 329 ll2 = tkk->tloc; 330 newloc = ll1; /* newloc = conditions */ 331 k = newloc % 100; /* k used for prob */ 332 if (newloc <= 300) { 333 if (newloc <= 100) { /* 13 */ 334 if (newloc != 0 && !pct(newloc)) 335 goto l12; /* 14 */ 336 l16: newloc = ll2; /* newloc = location */ 337 if (newloc <= 300) 338 return (2); 339 if (newloc <= 500) 340 switch (specials()) { /* to 30000 */ 341 case 2: return (2); 342 case 12: goto l12; 343 case 99: return (99); 344 default: bug(101); 345 } 346 rspeak(newloc - 500); 347 newloc = loc; 348 return (2); 349 } 350 if (toting(k) || (newloc > 200 && at(k))) 351 goto l16; 352 goto l12; 353 } 354 if (prop[k] != (newloc / 100) - 3) 355 goto l16; /* newloc still conditions */ 356 l12: /* alternative to probability move */ 357 for (; tkk != 0; tkk = tkk->next) 358 if (tkk->tloc != ll2 || tkk->conditions != ll1) 359 break; 360 if (tkk == 0) 361 bug(25); 362 goto l11; 363 } 364 365 366 int 367 mback(void) /* 20 */ 368 { 369 struct travlist *tk2,*j; 370 int ll; 371 372 if (forced(k = oldloc)) 373 k = oldlc2; /* k = location */ 374 oldlc2 = oldloc; 375 oldloc = loc; 376 tk2 = 0; 377 if (k == loc) { 378 rspeak(91); 379 return (2); 380 } 381 for (; tkk != 0; tkk = tkk->next) { /* 21 */ 382 ll = tkk->tloc; 383 if (ll == k) { 384 k = tkk->tverb; /* k back to verb */ 385 tkk = travel[loc]; 386 return (9); 387 } 388 if (ll <= 300) { 389 j = travel[loc]; 390 if (forced(ll) && k == j->tloc) 391 tk2 = tkk; 392 } 393 } 394 tkk = tk2; /* 23 */ 395 if (tkk != 0) { 396 k = tkk->tverb; 397 tkk = travel[loc]; 398 return (9); 399 } 400 rspeak(140); 401 return (2); 402 } 403 404 405 int 406 specials(void) /* 30000 */ 407 { 408 switch(newloc -= 300) { 409 case 1: /* 30100 */ 410 newloc = 99 + 100 - loc; 411 if (holdng == 0 || (holdng == 1 && toting(emrald))) 412 return (2); 413 newloc = loc; 414 rspeak(117); 415 return (2); 416 case 2: /* 30200 */ 417 drop(emrald, loc); 418 return (12); 419 case 3: /* to 30300 */ 420 return (trbridge()); 421 default: 422 bug(29); 423 } 424 } 425 426 427 int 428 trbridge(void) /* 30300 */ 429 { 430 if (prop[troll] == 1) { 431 pspeak(troll, 1); 432 prop[troll] = 0; 433 move(troll2, 0); 434 move(troll2 + 100, 0); 435 move(troll, plac[troll]); 436 move(troll + 100, fixd[troll]); 437 juggle(chasm); 438 newloc = loc; 439 return (2); 440 } 441 newloc = plac[troll] + fixd[troll] - loc; /* 30310 */ 442 if (prop[troll] == 0) 443 prop[troll] = 1; 444 if (!toting(bear)) 445 return (2); 446 rspeak(162); 447 prop[chasm] = 1; 448 prop[troll] = 2; 449 drop(bear, newloc); 450 fixed[bear] = -1; 451 prop[bear] = 3; 452 if (prop[spices] < 0) 453 tally2++; 454 oldlc2 = newloc; 455 return (99); 456 } 457 458 459 void 460 badmove(void) /* 20 */ 461 { 462 spk = 12; 463 if (k >= 43 && k <= 50) 464 spk = 9; 465 if (k == 29 || k == 30) 466 spk = 9; 467 if (k == 7 || k == 36 || k == 37) 468 spk = 10; 469 if (k == 11 || k == 19) 470 spk = 11; 471 if (verb == find || verb == invent) 472 spk = 59; 473 if (k == 62 || k == 65) 474 spk = 42; 475 if (k == 17) 476 spk = 80; 477 rspeak(spk); 478 } 479 480 void 481 bug(int n) 482 { 483 /* printf("Please tell jim@rand.org that fatal bug %d happened.\n",n); */ 484 fprintf(stderr, 485 "Please use sendbug to report that bug %d happened in adventure.\n", n); 486 exit(n); 487 } 488 489 490 void 491 checkhints(void) /* 2600 &c */ 492 { 493 int hint; 494 495 for (hint = 4; hint <= hntmax; hint++) { 496 if (hinted[hint]) 497 continue; 498 if (!bitset(loc, hint)) 499 hintlc[hint] = -1; 500 hintlc[hint]++; 501 if (hintlc[hint] < hints[hint][1]) 502 continue; 503 switch (hint) { 504 case 4: /* 40400 */ 505 if (prop[grate] == 0 && !here(keys)) 506 goto l40010; 507 goto l40020; 508 case 5: /* 40500 */ 509 if (here(bird) && toting(rod) && obj == bird) 510 goto l40010; 511 continue; /* i.e. goto l40030 */ 512 case 6: /* 40600 */ 513 if (here(snake) && !here(bird)) 514 goto l40010; 515 goto l40020; 516 case 7: /* 40700 */ 517 if (atloc[loc] == 0 && atloc[oldloc] == 0 518 && atloc[oldlc2] == 0 && holdng > 1) 519 goto l40010; 520 goto l40020; 521 case 8: /* 40800 */ 522 if (prop[emrald] != -1 && prop[pyram] == -1) 523 goto l40010; 524 goto l40020; 525 case 9: 526 goto l40010; /* 40900 */ 527 default: 528 bug(27); 529 } 530 l40010: hintlc[hint] = 0; 531 if (!yes(hints[hint][3], 0, 54)) 532 continue; 533 printf("I am prepared to give you a hint, but it will "); 534 printf("cost you %d points.\n", hints[hint][2]); 535 hinted[hint] = yes(175, hints[hint][4], 54); 536 l40020: hintlc[hint] = 0; 537 } 538 } 539 540 541 int 542 trsay(void) /* 9030 */ 543 { 544 int i; 545 546 if (wd2[0] != 0) 547 strlcpy(wd1, wd2, sizeof(wd1)); 548 i = vocab(wd1, -1, 0); 549 if (i == 62 || i == 65 || i == 71 || i == 2025) { 550 wd2[0] = 0; 551 obj = 0; 552 return (2630); 553 } 554 printf("\nOkay, \"%s\".\n", wd2); 555 return (2012); 556 } 557 558 559 int 560 trtake(void) /* 9010 */ 561 { 562 if (toting(obj)) 563 return (2011); /* 9010 */ 564 spk = 25; 565 if (obj == plant && prop[plant] <= 0) 566 spk = 115; 567 if (obj == bear && prop[bear] == 1) 568 spk = 169; 569 if (obj == chain && prop[bear] != 0) 570 spk = 170; 571 if (fixed[obj] != 0) 572 return (2011); 573 if (obj == water || obj == oil) { 574 if (here(bottle) && liq() == obj) { 575 obj = bottle; 576 goto l9017; 577 } 578 obj = bottle; 579 if (toting(bottle) && prop[bottle] == 1) 580 return (9220); 581 if (prop[bottle] != 1) 582 spk = 105; 583 if (!toting(bottle)) 584 spk = 104; 585 return (2011); 586 } 587 l9017: if (holdng >= 7) { 588 rspeak(92); 589 return (2012); 590 } 591 if (obj == bird) { 592 if (prop[bird] != 0) 593 goto l9014; 594 if (toting(rod)) { 595 rspeak(26); 596 return (2012); 597 } 598 if (!toting(cage)) { /* 9013 */ 599 rspeak(27); 600 return (2012); 601 } 602 prop[bird] = 1; /* 9015 */ 603 } 604 l9014: if ((obj == bird || obj == cage) && prop[bird] != 0) 605 carry(bird + cage - obj, loc); 606 carry(obj, loc); 607 k = liq(); 608 if (obj == bottle && k != 0) 609 place[k] = -1; 610 return (2009); 611 } 612 613 614 int 615 dropper(void) /* 9021 */ 616 { 617 k = liq(); 618 if (k == obj) 619 obj = bottle; 620 if (obj == bottle && k != 0) 621 place[k] = 0; 622 if (obj == cage && prop[bird] != 0) 623 drop(bird, loc); 624 if (obj == bird) 625 prop[bird] = 0; 626 drop(obj, loc); 627 return (2012); 628 } 629 630 int 631 trdrop(void) /* 9020 */ 632 { 633 if (toting(rod2) && obj == rod && !toting(rod)) 634 obj = rod2; 635 if (!toting(obj)) 636 return (2011); 637 if (obj == bird && here(snake)) { 638 rspeak(30); 639 if (closed) 640 return (19000); 641 dstroy(snake); 642 prop[snake] = 1; 643 return (dropper()); 644 } 645 if (obj == coins && here(vend)) { /* 9024 */ 646 dstroy(coins); 647 drop(batter, loc); 648 pspeak(batter, 0); 649 return (2012); 650 } 651 if (obj == bird && at(dragon) && prop[dragon] == 0) { /* 9025 */ 652 rspeak(154); 653 dstroy(bird); 654 prop[bird] = 0; 655 if (place[snake] == plac[snake]) 656 tally2--; 657 return (2012); 658 } 659 if (obj == bear && at(troll)) { /* 9026 */ 660 rspeak(163); 661 move(troll, 0); 662 move(troll + 100, 0); 663 move(troll2, plac[troll]); 664 move(troll2 + 100, fixd[troll]); 665 juggle(chasm); 666 prop[troll] = 2; 667 return (dropper()); 668 } 669 if (obj != vase || loc == plac[pillow]) { /* 9027 */ 670 rspeak(54); 671 return (dropper()); 672 } 673 prop[vase] = 2; /* 9028 */ 674 if (at(pillow)) 675 prop[vase] = 0; 676 pspeak(vase, prop[vase] + 1); 677 if (prop[vase] != 0) 678 fixed[vase] = -1; 679 return (dropper()); 680 } 681 682 683 int 684 tropen(void) /* 9040 */ 685 { 686 if (obj == clam || obj == oyster) { 687 k = 0; /* 9046 */ 688 if (obj == oyster) 689 k = 1; 690 spk = 124 + k; 691 if (toting(obj)) 692 spk = 120 + k; 693 if (!toting(tridnt)) 694 spk = 122 + k; 695 if (verb == lock) 696 spk = 61; 697 if (spk != 124) 698 return (2011); 699 dstroy(clam); 700 drop(oyster, loc); 701 drop(pearl, 105); 702 return (2011); 703 } 704 if (obj == door) 705 spk = 111; 706 if (obj == door && prop[door] == 1) 707 spk = 54; 708 if (obj == cage) 709 spk = 32; 710 if (obj == keys) 711 spk = 55; 712 if (obj == grate || obj == chain) 713 spk = 31; 714 if (spk != 31||!here(keys)) 715 return (2011); 716 if (obj == chain) { 717 if (verb == lock) { 718 spk = 172; /* 9049: lock */ 719 if (prop[chain] != 0) 720 spk = 34; 721 if (loc != plac[chain]) 722 spk = 173; 723 if (spk != 172) 724 return (2011); 725 prop[chain] = 2; 726 if (toting(chain)) 727 drop(chain, loc); 728 fixed[chain] = -1; 729 return (2011); 730 } 731 spk = 171; 732 if (prop[bear] == 0) 733 spk = 41; 734 if (prop[chain] == 0) 735 spk = 37; 736 if (spk != 171) 737 return (2011); 738 prop[chain] = 0; 739 fixed[chain] = 0; 740 if (prop[bear] != 3) 741 prop[bear] = 2; 742 fixed[bear] = 2 - prop[bear]; 743 return (2011); 744 } 745 if (closng) { 746 k = 130; 747 if (!panic) 748 clock2 = 15; 749 panic = TRUE; 750 return (2010); 751 } 752 k = 34 + prop[grate]; /* 9043 */ 753 prop[grate] = 1; 754 if (verb == lock) 755 prop[grate] = 0; 756 k = k + 2 * prop[grate]; 757 return (2010); 758 } 759 760 761 int 762 trkill(void) /* 9120 */ 763 { 764 int i; 765 766 for (i = 1; i <= 5; i++) 767 if (dloc[i] == loc && dflag >= 2) 768 break; 769 if (i == 6) 770 i = 0; 771 if (obj == 0) { /* 9122 */ 772 if (i != 0) 773 obj = dwarf; 774 if (here(snake)) 775 obj = obj * 100 + snake; 776 if (at(dragon) && prop[dragon] == 0) 777 obj = obj * 100 + dragon; 778 if (at(troll)) 779 obj = obj * 100 + troll; 780 if (here(bear) && prop[bear] == 0) 781 obj = obj * 100 + bear; 782 if (obj > 100) 783 return (8000); 784 if (obj == 0) { 785 if (here(bird) && verb != throw) 786 obj = bird; 787 if (here(clam) || here(oyster)) 788 obj = 100 * obj + clam; 789 if (obj > 100) 790 return (8000); 791 } 792 } 793 if (obj == bird) { /* 9124 */ 794 spk = 137; 795 if (closed) 796 return (2011); 797 dstroy(bird); 798 prop[bird] = 0; 799 if (place[snake] == plac[snake]) 800 tally2++; 801 spk = 45; 802 } 803 if (obj == 0) 804 spk = 44; /* 9125 */ 805 if (obj == clam || obj == oyster) 806 spk = 150; 807 if (obj == snake) 808 spk = 46; 809 if (obj == dwarf) 810 spk = 49; 811 if (obj == dwarf && closed) 812 return (19000); 813 if (obj == dragon) 814 spk = 147; 815 if (obj == troll) 816 spk = 157; 817 if (obj == bear) 818 spk = 165 + (prop[bear] + 1) / 2; 819 if (obj != dragon || prop[dragon] != 0) 820 return (2011); 821 rspeak(49); 822 verb = 0; 823 obj = 0; 824 getin(wd1, sizeof(wd1), wd2, sizeof(wd2)); 825 if (!weq(wd1, "y") && !weq(wd1, "yes")) 826 return (2608); 827 pspeak(dragon, 1); 828 prop[dragon] = 2; 829 prop[rug] = 0; 830 k = (plac[dragon] + fixd[dragon]) / 2; 831 move(dragon + 100, -1); 832 move(rug + 100, 0); 833 move(dragon, k); 834 move(rug, k); 835 for (obj = 1; obj <= 100; obj++) 836 if (place[obj] == plac[dragon] || place[obj] == fixd[dragon]) 837 move(obj, k); 838 loc = k; 839 k = null; 840 return (8); 841 } 842 843 844 int 845 trtoss(void) /* 9170: throw */ 846 { 847 int i; 848 849 if (toting(rod2) && obj == rod && !toting(rod)) 850 obj = rod2; 851 if (!toting(obj)) 852 return (2011); 853 if (obj >= 50 && obj <= maxtrs && at(troll)) { 854 spk = 159; /* 9178 */ 855 drop(obj, 0); 856 move(troll, 0); 857 move(troll + 100, 0); 858 drop(troll2, plac[troll]); 859 drop(troll2 + 100, fixd[troll]); 860 juggle(chasm); 861 return (2011); 862 } 863 if (obj == food && here(bear)) { 864 obj = bear; /* 9177 */ 865 return (9210); 866 } 867 if (obj != axe) 868 return (9020); 869 for (i = 1; i <= 5; i++) { 870 if (dloc[i] == loc) { 871 spk = 48; /* 9172 */ 872 if (ran(3) == 0 || saved != -1) { 873 l9175: 874 rspeak(spk); 875 drop(axe, loc); 876 k = null; 877 return (8); 878 } 879 dseen[i] = FALSE; 880 dloc[i] = 0; 881 spk = 47; 882 dkill++; 883 if (dkill == 1) 884 spk = 149; 885 goto l9175; 886 } 887 } 888 spk = 152; 889 if (at(dragon) && prop[dragon] == 0) 890 goto l9175; 891 spk = 158; 892 if (at(troll)) 893 goto l9175; 894 if (here(bear) && prop[bear] == 0) { 895 spk = 164; 896 drop(axe, loc); 897 fixed[axe] = -1; 898 prop[axe] = 1; 899 juggle(bear); 900 return (2011); 901 } 902 obj = 0; 903 return (9120); 904 } 905 906 907 int 908 trfeed(void) /* 9210 */ 909 { 910 if (obj == bird) { 911 spk = 100; 912 return (2011); 913 } 914 if (obj == snake || obj == dragon || obj == troll) { 915 spk = 102; 916 if (obj == dragon && prop[dragon] != 0) 917 spk = 110; 918 if (obj == troll) 919 spk = 182; 920 if (obj != snake || closed || !here(bird)) 921 return (2011); 922 spk = 101; 923 dstroy(bird); 924 prop[bird] = 0; 925 tally2++; 926 return (2011); 927 } 928 if (obj == dwarf) { 929 if (!here(food)) 930 return (2011); 931 spk = 103; 932 dflag++; 933 return (2011); 934 } 935 if (obj == bear) { 936 if (prop[bear] == 0) 937 spk = 102; 938 if (prop[bear] == 3) 939 spk = 110; 940 if (!here(food)) 941 return (2011); 942 dstroy(food); 943 prop[bear] = 1; 944 fixed[axe] = 0; 945 prop[axe] = 0; 946 spk = 168; 947 return (2011); 948 } 949 spk = 14; 950 return (2011); 951 } 952 953 954 int 955 trfill(void) /* 9220 */ 956 { 957 if (obj == vase) { 958 spk = 29; 959 if (liqloc(loc) == 0) 960 spk = 144; 961 if (liqloc(loc) == 0 || !toting(vase)) 962 return (2011); 963 rspeak(145); 964 prop[vase] = 2; 965 fixed[vase] = -1; 966 return (9020); /* advent/10 goes to 9024 */ 967 } 968 if (obj != 0 && obj != bottle) 969 return (2011); 970 if (obj == 0 && !here(bottle)) 971 return (8000); 972 spk = 107; 973 if (liqloc(loc) == 0) 974 spk = 106; 975 if (liq() != 0) 976 spk = 105; 977 if (spk != 107) 978 return (2011); 979 prop[bottle] = ((cond[loc] % 4) / 2) * 2; 980 k = liq(); 981 if (toting(bottle)) 982 place[k] = -1; 983 if (k == oil) 984 spk = 108; 985 return (2011); 986 } 987 988 989 void 990 closing(void) /* 10000 */ 991 { 992 int i; 993 994 prop[grate] = prop[fissur] = 0; 995 for (i = 1; i <= 6; i++) { 996 dseen[i] = FALSE; 997 dloc[i] = 0; 998 } 999 move(troll, 0); 1000 move(troll + 100, 0); 1001 move(troll2, plac[troll]); 1002 move(troll2 + 100, fixd[troll]); 1003 juggle(chasm); 1004 if (prop[bear] != 3) 1005 dstroy(bear); 1006 prop[chain] = 0; 1007 fixed[chain] = 0; 1008 prop[axe] = 0; 1009 fixed[axe] = 0; 1010 rspeak(129); 1011 clock1 = -1; 1012 closng = TRUE; 1013 } 1014 1015 1016 void 1017 caveclose(void) /* 11000 */ 1018 { 1019 int i; 1020 1021 prop[bottle] = put(bottle, 115, 1); 1022 prop[plant] = put(plant, 115, 0); 1023 prop[oyster] = put(oyster, 115, 0); 1024 prop[lamp] = put(lamp, 115, 0); 1025 prop[rod] = put(rod, 115, 0); 1026 prop[dwarf] = put(dwarf, 115, 0); 1027 loc = 115; 1028 oldloc = 115; 1029 newloc = 115; 1030 1031 put(grate, 116, 0); 1032 prop[snake] = put(snake, 116, 1); 1033 prop[bird] = put(bird, 116, 1); 1034 prop[cage] = put(cage, 116, 0); 1035 prop[rod2] = put(rod2, 116, 0); 1036 prop[pillow] = put(pillow, 116, 0); 1037 1038 prop[mirror] = put(mirror, 115, 0); 1039 fixed[mirror] = 116; 1040 1041 for (i = 1; i <= 100; i++) 1042 if (toting(i)) 1043 dstroy(i); 1044 rspeak(132); 1045 closed = TRUE; 1046 } 1047