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