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