void die(int entry) /* label 90 */ { int i; if (entry != 99) { rspeak(23); oldlc2 = loc; } if (closng) { /* 99 */ rspeak(131); numdie++; done(2); } yea = yes(81 + numdie * 2, 82 + numdie * 2, 54); numdie++; if (numdie == maxdie || !yea) done(2); place[water] = 0; place[oil] = 0; if (toting(lamp)) prop[lamp] = 0; for (i = 100; i >= 1; i--) { if (!toting(i)) continue; k = oldlc2; if (i == lamp) k = 1; drop(i, k); } loc = 3; oldloc = loc; }
/* WAVE etc. */ vwave() { if (!toting(object) && (object != ROD || !toting(ROD2))) rspeak(29); else if (object != ROD || !at(FISSURE) || !toting(object) || closing) actspk(verb); else { prop[FISSURE] = 1-prop[FISSURE]; pspeak(FISSURE,2-prop[FISSURE]); } }
/* READ etc. */ vread() { int msg; msg = 0; if (dark()) { printf("I see no %s here.\n",probj(object)); return; } switch(object) { case MAGAZINE: msg = 190; break; case TABLET: msg = 196; break; case MESSAGE: msg = 191; break; case OYSTER: if (!toting(OYSTER) || !closed) break; yes(192,193,54); return; default: ; } if (msg) rspeak(msg); else actspk(verb); }
/* Routine to describe visible items */ void descitem() { int i, state; for (i = 1; i < MAXOBJ; ++i) { if (at(i)) { if (i == STEPS && toting(NUGGET)) continue; if (g.prop[i] < 0) { if (g.closed) continue; else { g.prop[i] = 0; if (i == RUG || i == CHAIN || i == SWORD || i == CASK) g.prop[i] = 1; if (i == CLOAK || i == RING) g.prop[i] = 2; --g.tally; } } if (i == STEPS && g.loc == g.fixed[STEPS]) state = 1; else state = g.prop[i] % 8; pspeak(i, state); lookin(i); } } /* If remaining treasures too elusive, zap his lamp */ if (g.tally == g.tally2 && g.tally != 0 && g.limit > 35) g.limit = 35; return; }
/* POUR */ vpour() { if (object == BOTTLE || object == 0) object = liq(); if (object == 0) { needobj(); return; } if (!toting(object)) { actspk(verb); return; } if (object != OIL && object != WATER) { rspeak(78); return; } prop[BOTTLE] = 1; place[object] = 0; if (at(PLANT)) { if (object != WATER) rspeak(112); else { pspeak(PLANT,prop[PLANT]+1); prop[PLANT] = (prop[PLANT]+2)%6; prop[PLANT2] = prop[PLANT]/2; describe(); } } else if (at(DOOR)) { prop[DOOR] = (object == OIL ? 1 : 0); rspeak(113+prop[DOOR]); } else rspeak(77); }
/* pirate stuff */ void dopirate() { int j; boolean k; if (g.newloc == g.chloc || g.prop[CHEST] >= 0) return; k = FALSE; /* Pirate won't take pyramid from plover room or dark room (too easy! ) */ for (j = 1; j < MAXOBJ; ++j) if (treasr(j) && !(j == CASK && liq(CASK) == WINE) && !(j == PYRAMID && (g.newloc == g.place[PYRAMID] || g.newloc == g.place[EMERALD]))) { if (toting(j) && athand(j)) goto stealit; if (here(j)) k = TRUE; } if (g.tally == g.tally2 + 1 && k == FALSE && g.place[CHEST] == 0 && athand(LAMP) && g.prop[LAMP] == 1) { rspeak(186); move(CHEST, g.chloc); move(MESSAGE, g.chloc2); g.dloc[DWARFMAX] = g.chloc; g.odloc[DWARFMAX] = g.chloc; g.dseen[DWARFMAX] = 0; return; } if (g.odloc[DWARFMAX] != g.dloc[DWARFMAX] && pct(30)) rspeak(127); return; stealit: rspeak(128); /* don't steal chest back from troll! */ if (g.place[MESSAGE] == 0) move(CHEST, g.chloc); move(MESSAGE, g.chloc2); for (j = 1; j < MAXOBJ; ++j) { if (!treasr(j) || !athand(j) || (j == PYRAMID && (g.newloc == plac[PYRAMID] || g.newloc == plac[EMERALD])) || (j == CASK && (liq(CASK) != WINE))) continue; if (enclosed(j)) extract(j); if (wearng(j)) { g.prop[j] = 0; bitoff(j, WEARBT); } insert(j, CHEST); } g.dloc[DWARFMAX] = g.chloc; g.odloc[DWARFMAX] = g.chloc; g.dseen[DWARFMAX] = FALSE; return; }
/* Routine to handle the passing on of one of the player's incarnations... */ void death() { int yea, j; if (!g.closing) { if (g.limit < 0) { rspeak(185); normend(); return; } yea = yes(81 + g.numdie * 2, 82 + g.numdie * 2, 54); if (++g.numdie >= MAXDIE || !yea) normend(); if (g.chase) { g.chase = FALSE; g.prop[WUMPUS] = 0; move(WUMPUS, 174); } if (toting(LAMP)) g.prop[LAMP] = 0; for (j = 1; j < MAXOBJ; ++j) { if (toting(j)) drop(j, j == LAMP ? 1 : g.oldloc2); if (wearng(j)) { g.prop[j] = 0; bitoff(j, WEARBT); } } g.newloc = 3; g.oldloc = g.loc; g.health = 100; return; } /* Closing -- no resurrection... */ rspeak(131); ++g.numdie; normend(); return; }
/* FILL */ vfill() { int msg; int i; switch(object) { case BOTTLE: if (liq() != 0) msg = 105; else if (liqloc(loc) == 0) msg = 106; else { prop[BOTTLE] = cond[loc] & WATOIL; i = liq(); if (toting(BOTTLE)) place[i] = -1; msg = (i == OIL ? 108 : 107); } break; case VASE: if (liqloc(loc) == 0) { msg = 144; break; } if (!toting(VASE)) { msg = 29; break; } rspeak(145); vdrop(); return; default: msg = 29; } rspeak(msg); }
/* Routine to describe current location */ void describe() { if (toting(BEAR)) rspeak(141); if (dark()) rspeak(16); else if ((g.terse && verb != LOOK) || g.visited[g.loc] % g.abbnum) descsh(g.loc); else desclg(g.loc); if (g.loc == 33 && pct(25) && !g.closing) rspeak(8); if (g.loc == 147 && !g.visited[g.loc]) rspeak(216); return; }
/* INVENTORY, FIND etc. */ vfind() { int msg; if (toting(object)) msg = 24; else if (closed) msg = 138; else if (dcheck() && dflag >= 2 && object == DWARF) msg = 94; else if (at(object) || (liq() == object && here(BOTTLE)) || object == liqloc(loc)) msg = 94; else { actspk(verb); return; } rspeak(msg); }
/* Handle fee fie foe foo... */ void ivfoo() { int k; int msg; k = VAL(vocab(vtxt[vrbx], MISC)); if (g.foobar != 1 - k) { if (g.foobar == 0) msg = 42; else msg = 151; rspeak(msg); return; } g.foobar = k; if (k != 4) return; g.foobar = 0; if (g.place[EGGS] == plac[EGGS] || (toting(EGGS) && g.loc == plac[EGGS])) { rspeak(42); return; } /* Bring back troll if we steal the eggs back from him before crossing */ if (g.place[EGGS] == 0 && g.place[TROLL] == 0 && g.prop[TROLL] == 0) g.prop[TROLL] = 1; if (here(EGGS)) k = 1; else if (g.loc == plac[EGGS]) k = 0; else k = 2; move(EGGS, plac[EGGS]); pspeak(EGGS, k); return; }
/* BREAK etc. */ vbreak() { int msg; if (object == MIRROR) { msg = 148; if (closed) { rspeak(197); dwarfend(); } } else if (object == VASE && prop[VASE] == 0) { msg = 198; if (toting(VASE)) drop(VASE,loc); prop[VASE] = 2; fixed[VASE] = -1; } else { actspk(verb); return; } rspeak(msg); }
/* Routine to take 1 turn */ void turn() { int i, hint; static int waste = 0; if (newtravel) { /* If closing, then he can't leave except via the main office. */ if (outside(g.newloc) && g.newloc != 0 && g.closing) { rspeak(130); g.newloc = g.loc; if (!g.panic) g.clock2 = 15; g.panic = TRUE; } /* See if a dwarf has seen him and has come from where he wants to go. */ if (g.newloc != g.loc && !forced(g.loc) && g.loc_attrib[g.loc] & NOPIRAT == 0) for (i = 1; i < (DWARFMAX - 1); ++i) if (g.odloc[i] == g.newloc && g.dseen[i]) { g.newloc = g.loc; rspeak(2); break; } g.loc = g.newloc; dwarves(); /* & special dwarf(pirate who steals) */ /* Check for death */ if (g.loc == 0) { death(); return; } /* Check for forced move */ if (forced(g.loc)) { desclg(g.loc); ++g.visited[g.loc]; domove(); return; } /* Check for wandering in dark */ if (g.wzdark && dark() && pct(35)) { rspeak(23); g.oldloc2 = g.loc; death(); return; } /* see if he is wasting his batteies out in the open */ if (outside(g.loc) && g.prop[LAMP]) { waste++; if (waste > 11) { rspeak(324); waste = 0; } } else waste = 0; /* If wumpus is chasing stooge, see if wumpus gets him */ if (g.chase) { g.chase++; g.prop[WUMPUS] = g.chase / 2; move(WUMPUS, g.loc); if (g.chase >= 10) { if (dark()) rspeak(270); pspeak(WUMPUS, 5); death(); return; } } /* check for radiation poisoning. */ g.health += (outside(g.loc)) ? 3 : 1; if (g.health > 100) g.health = 100; if (here(RADIUM) && (g.place[RADIUM] != -SHIELD || ajar(SHIELD))) g.health -= 7; if (g.health < 60) { rspeak(391 + (60 - g.health) / 10); if (g.health < 0) { death(); return; } } if ((g.oldloc == 188) && (g.loc != 188 && g.loc != 189) && (g.prop[BOOTH] == 1)) { move(GNOME, 0); g.prop[BOOTH] = 0; } /* Describe his situation */ describe(); if (!blind()) { ++g.visited[g.loc]; descitem(); } } /* end of newtravel start for second entry point */ /* Check if this location is eligible for any hints. If been here long enough, branch to help section. Ignore "hints" < HNTMIN (special stuff, see database notes. */ for (hint = HNTMIN; hint <= HNTMAX; hint++) { if (g.hinted[hint]) continue; if (g.loc_attrib[g.loc] / 256 != hint - 6) g.hintlc[hint] = -1; g.hintlc[hint]++; if (g.hintlc[hint] >= g.hints[hint][1]) do_hint(hint); } if (g.closed) { if (g.prop[OYSTER] < 0 && toting(OYSTER)) pspeak(OYSTER, 1); for (i = 1; i < MAXOBJ; ++i) if (toting(i) && g.prop[i] < 0) g.prop[i] = -1 - g.prop[i]; } g.wzdark = dark(); if (g.knfloc > 0 && g.knfloc != g.loc) g.knfloc = 0; ++g.turns; i = rand(); if (stimer()) /* as the grains of sand slip by */ return; while (!english()) /* retrieve player instructions */ ; vrbx = 1; objx = objs[1] ? 1 : 0; iobx = iobjs[1] ? 1 : 0; verb = VAL(verbs[vrbx]); do { object = objx ? objs[objx] : 0; iobj = iobx ? iobjs[iobx] : 0; if (object && (objs[2] || iobjs[2])) { pspeak(object, -1); printf(" "); } switch (CLASS(verbs[vrbx])) { case MOTION: motion = verb; domove(); break; case NOUN: bug(22); case ACTION: if (object || iobj) trverb(); else itverb(); break; case MISC: rspeak(verb); if (verb == 51) g.hinted[1] = TRUE; break; default: bug(22); } if (objx) { objx++; if (objs[objx] == 0) objx = 0; } if ((!objx || !objs[objx]) && iobx) { iobx++; if (iobjs[iobx] == 0) iobx = 0; if (iobx && iobjs[1]) objx = 1; } } while (objx || iobx); return; }
/* CARRY TAKE etc. */ vtake() { int msg; int i; if (toting(object)) { actspk(verb); return; } /* special case objects and fixed objects */ msg = 25; if (object == PLANT && prop[PLANT] <= 0) msg = 115; if (object == BEAR && prop[BEAR] == 1) msg = 169; if (object == CHAIN && prop[BEAR] != 0) msg = 170; if (fixed[object]) { rspeak(msg); return; } /* special case for liquids */ if (object == WATER || object == OIL) { if (!here(BOTTLE) || liq() != object) { object = BOTTLE; if (toting(BOTTLE)&&prop[BOTTLE] == 1){ vfill(); return; } if (prop[BOTTLE] != 1) msg = 105; if (!toting(BOTTLE)) msg = 104; rspeak(msg); return; } object = BOTTLE; } if (holding >= 7) { rspeak(92); return; } /* special case for bird. */ if (object == BIRD && prop[BIRD] == 0) { if (toting(ROD)) { rspeak(26); return; } if (!toting(CAGE)) { rspeak(27); return; } prop[BIRD] = 1; } if ( (object == BIRD || object == CAGE) && prop[BIRD] != 0) carry((BIRD+CAGE)-object,loc); carry(object,loc); /* handle liquid in bottle */ i = liq(); if (object == BOTTLE && i != 0) place[i] = -1; rspeak(54); }
int main(int argc, char *argv[]) { int i; int rval, ll; struct text *kk; init(); /* Initialize everything */ signal(SIGINT, trapdel); if (argc > 1) { /* Restore file specified */ /* Restart is label 8305 (Fortran) */ i = restore(argv[1]); /* See what we've got */ switch (i) { case 0: /* The restore worked fine */ yea = Start(); k = null; unlink(argv[1]);/* Don't re-use the save */ goto l8; /* Get where we're going */ case 1: /* Couldn't open it */ errx(1, "can't open file"); /* So give up */ case 2: /* Oops -- file was altered */ rspeak(202); /* You dissolve */ exit(2); /* File could be non-adventure */ } /* So don't unlink it. */ } startup(); /* prepare for a user */ for (;;) { /* main command loop (label 2) */ if (newloc < 9 && newloc != 0 && closng) { rspeak(130); /* if closing leave only by */ newloc = loc; /* main office */ if (!panic) clock2 = 15; panic = TRUE; } rval = fdwarf(); /* dwarf stuff */ if (rval == 99) die(99); l2000: if (loc == 0) die(99); /* label 2000 */ kk = &stext[loc]; if ((abb[loc] % abbnum) ==0 || kk->seekadr == 0) kk = <ext[loc]; if (!forced(loc) && dark()) { if (wzdark && pct(35)) { die(90); goto l2000; } kk = &rtext[16]; } l2001: if (toting(bear)) rspeak(141); /* 2001 */ speak(kk); k = 1; if (forced(loc)) goto l8; if (loc == 33 && pct(25) && !closng) rspeak(8); if (!dark()) { abb[loc]++; for (i = atloc[loc]; i != 0; i = linkx[i]) { /*2004*/ obj = i; if (obj > 100) obj -= 100; if (obj == steps && toting(nugget)) continue; if (prop[obj] < 0) { if (closed) continue; prop[obj] = 0; if (obj == rug || obj == chain) prop[obj] = 1; tally--; if (tally == tally2 && tally != 0) if (limit > 35) limit = 35; } ll = prop[obj]; /* 2006 */ if (obj == steps && loc == fixed[steps]) ll = 1; pspeak(obj, ll); } /* 2008 */ goto l2012; l2009: k = 54; /* 2009 */ l2010: spk = k; l2011: rspeak(spk); } l2012: verb = 0; /* 2012 */ obj = 0; l2600: checkhints(); /* to 2600-2602 */ if (closed) { if (prop[oyster] < 0 && toting(oyster)) pspeak(oyster, 1); for (i = 1; i < 100; i++) if (toting(i) && prop[i] < 0) /* 2604 */ prop[i] = -1 - prop[i]; } wzdark = dark(); /* 2605 */ if (knfloc > 0 && knfloc != loc) knfloc = 1; getin(wd1, sizeof(wd1), wd2, sizeof(wd2)); if (delhit) { /* user typed a DEL */ delhit = 0; /* reset counter */ /* pretend he's quitting */ strlcpy(wd1, "quit", sizeof(wd1)); wd2[0] = 0; } l2608: if ((foobar = -foobar) > 0) foobar = 0; /* 2608 */ /* should check here for "magic mode" */ turns++; if (demo && turns >= SHORT) done(1); /* to 13000 */ if (verb == say && wd2[0] != 0) verb = 0; if (verb == say) goto l4090; if (tally == 0 && loc >= 15 && loc != 33) clock1--; if (clock1 == 0) { closing(); /* to 10000 */ goto l19999; } if (clock1 < 0) clock2--; if (clock2 == 0) { caveclose(); /* to 11000 */ continue; /* back to 2 */ } if (prop[lamp] == 1) limit--; if (limit <= 30 && here(batter) && prop[batter] == 0 && here(lamp)) { rspeak(188); /* 12000 */ prop[batter] = 1; if (toting(batter)) drop(batter, loc); limit += 2500; lmwarn = FALSE; goto l19999; } if (limit == 0) { limit = -1; /* 12400 */ prop[lamp] = 0; rspeak(184); goto l19999; } if (limit < 0 && loc <= 8) { rspeak(185); /* 12600 */ gaveup = TRUE; done(2); /* to 20000 */ } if (limit <= 30) { if (lmwarn || !here(lamp)) goto l19999; /*12200*/ lmwarn = TRUE; spk = 187; if (place[batter] == 0) spk = 183; if (prop[batter] == 1) spk = 189; rspeak(spk); } l19999: k = 43; if (liqloc(loc) == water) k = 70; if (weq(wd1, "enter") && (weq(wd2, "strea") || weq(wd2, "water"))) goto l2010; if (weq(wd1, "enter") && *wd2 != 0) goto l2800; if ((!weq(wd1, "water") && !weq(wd1, "oil")) || (!weq(wd2, "plant") && !weq(wd2, "door"))) goto l2610; if (at(vocab(wd2, 1, 0))) strlcpy(wd2, "pour", sizeof(wd2)); l2610: if (weq(wd1, "west")) if (++iwest == 10) rspeak(17); l2630: i = vocab(wd1, -1, 0); if (i== -1) { spk = 60; /* 3000 */ if (pct(20)) spk = 61; if (pct(20)) spk = 13; rspeak(spk); goto l2600; } k = i % 1000; kq = i / 1000 + 1; switch (kq) { case 1: goto l8; case 2: goto l5000; case 3: goto l4000; case 4: goto l2010; default: bug(22); } l8: switch (march()) { case 2: continue; /* i.e. goto l2 */ case 99: die(99); goto l2000; default: bug(110); } l2800: strlcpy(wd1, wd2, sizeof(wd1)); wd2[0] = 0; goto l2610; l4000: verb = k; spk = actspk[verb]; if (wd2[0] != 0 && verb != say) goto l2800; if (verb == say) obj = wd2[0]; if (obj != 0) goto l4090; l4080: switch (verb) { case 1: /* take = 8010 */ if (atloc[loc] == 0 || linkx[atloc[loc]] != 0) goto l8000; for (i = 1; i <= 5; i++) if (dloc[i] == loc && dflag >= 2) goto l8000; obj = atloc[loc]; goto l9010; case 2: case 3: case 9: /* 8000 : drop, say, wave */ case 10: case 16: case 17: /* calm, rub, toss */ case 19: case 21: case 28: /* find, feed, break */ case 29: /* wake */ l8000: printf("%s what?\n", wd1); obj = 0; goto l2600; case 4: case 6: /* 8040 open, lock */ spk = 28; if (here(clam)) obj = clam; if (here(oyster)) obj = oyster; if (at(door)) obj = door; if (at(grate)) obj = grate; if (obj != 0 && here(chain)) goto l8000; if (here(chain)) obj = chain; if (obj == 0) goto l2011; goto l9040; case 5: goto l2009; /* nothing */ case 7: goto l9070; /* on */ case 8: goto l9080; /* off */ case 11: goto l8000; /* walk */ case 12: goto l9120; /* kill */ case 13: goto l9130; /* pour */ case 14: /* eat: 8140 */ if (!here(food)) goto l8000; l8142: dstroy(food); spk = 72; goto l2011; case 15: goto l9150; /* drink */ case 18: /* quit: 8180 */ gaveup = yes(22, 54, 54); if (gaveup) done(2); /* 8185 */ goto l2012; case 20: /* invent = 8200 */ spk = 98; for (i = 1; i <= 100; i++) { if (i != bear && toting(i)) { if (spk == 98) rspeak(99); blklin = FALSE; pspeak(i, -1); blklin = TRUE; spk = 0; } } if (toting(bear)) spk = 141; goto l2011; case 22: goto l9220; /* fill */ case 23: goto l9230; /* blast */ case 24: /* score: 8240 */ scorng = TRUE; printf("If you were to quit now, you would score"); printf(" %d out of a possible ", score()); printf("%d.", mxscor); scorng = FALSE; gaveup = yes(143, 54, 54); if (gaveup) done(2); goto l2012; case 25: /* foo: 8250 */ k = vocab(wd1, 3, 0); spk = 42; if (foobar == 1 - k) goto l8252; if (foobar != 0) spk = 151; goto l2011; l8252: foobar = k; if (k != 4) goto l2009; foobar = 0; if (place[eggs] == plac[eggs] || (toting(eggs) && loc == plac[eggs])) goto l2011; if (place[eggs] == 0 && place[troll] == 0 && prop[troll] == 0) prop[troll] = 1; k = 2; if (here(eggs)) k = 1; if (loc == plac[eggs]) k = 0; move(eggs, plac[eggs]); pspeak(eggs, k); goto l2012; case 26: /* brief = 8260 */ spk = 156; abbnum = 10000; detail = 3; goto l2011; case 27: /* read = 8270 */ if (here(magzin)) obj = magzin; if (here(tablet)) obj = obj * 100 + tablet; if (here(messag)) obj = obj * 100 + messag; if (closed && toting(oyster)) obj = oyster; if (obj > 100 || obj == 0 || dark()) goto l8000; goto l9270; case 30: /* suspend = 8300 */ spk = 201; if (demo) goto l2011; printf("I can suspend your adventure for you so"); printf(" you can resume later, but\n"); printf("you will have to wait at least"); printf(" %d minutes before continuing.", latncy); if (!yes(200, 54, 54)) goto l2012; time(&savet); ciao(); /* Do we quit? */ continue; /* Maybe not */ case 31: /* hours = 8310 */ printf("Colossal cave is closed 9am-5pm Mon "); printf("through Fri except holidays.\n"); goto l2012; default: bug(23); } l4090: switch (verb) { case 1: /* take = 9010 */ l9010: switch (trtake()) { case 2011: goto l2011; case 9220: goto l9220; case 2009: goto l2009; case 2012: goto l2012; default: bug(102); } l9020: case 2: /* drop = 9020 */ switch (trdrop()) { case 2011: goto l2011; case 19000: done(3); case 2012: goto l2012; default: bug(105); } l9030: case 3: switch (trsay()) { case 2012: goto l2012; case 2630: goto l2630; default: bug(107); } l9040: case 4: case 6: /* open, close */ switch (tropen()) { case 2011: goto l2011; case 2010: goto l2010; default: bug(106); } case 5: goto l2009; /* nothing */ case 7: /* on 9070 */ l9070: if (!here(lamp)) goto l2011; spk = 184; if (limit < 0) goto l2011; prop[lamp] = 1; rspeak(39); if (wzdark) goto l2000; goto l2012; case 8: /* off */ l9080: if (!here(lamp)) goto l2011; prop[lamp] = 0; rspeak(40); if (dark()) rspeak(16); goto l2012; case 9: /* wave */ if ((!toting(obj)) && (obj != rod || !toting(rod2))) spk = 29; if (obj != rod || !at(fissur)||!toting(obj) || closng) goto l2011; prop[fissur] = 1-prop[fissur]; pspeak(fissur, 2-prop[fissur]); goto l2012; case 10: case 11: case 18: /* calm, walk, quit */ case 24: case 25: case 26: /* score, foo, brief */ case 30: case 31: /* suspend, hours */ goto l2011; l9120: case 12: /* kill */ switch (trkill()) { case 8000: goto l8000; case 8: goto l8; case 2011: goto l2011; case 2608: goto l2608; case 19000: done(3); default: bug(112); } l9130: case 13: /* pour */ if (obj == bottle || obj == 0) obj = liq(); if (obj == 0) goto l8000; if (!toting(obj)) goto l2011; spk = 78; if (obj != oil && obj != water) goto l2011; prop[bottle] = 1; place[obj] = 0; spk = 77; if (!(at(plant) || at(door))) goto l2011; if (at(door)) { prop[door] = 0; /* 9132 */ if (obj == oil) prop[door] = 1; spk = 113 + prop[door]; goto l2011; } spk = 112; if (obj != water) goto l2011; pspeak(plant, prop[plant] + 1); prop[plant] = (prop[plant] + 2) % 6; prop[plant2] = prop[plant] / 2; k = null; goto l8; case 14: /* 9140 - eat */ if (obj == food) goto l8142; if (obj == bird || obj == snake || obj == clam || obj == oyster || obj == dwarf || obj == dragon || obj == troll || obj == bear) spk = 71; goto l2011; l9150: case 15: /* 9150 - drink */ if (obj == 0 && liqloc(loc) != water && (liq() != water || !here(bottle))) goto l8000; if (obj != 0 && obj != water) spk = 110; if (spk == 110 || liq() != water || !here(bottle)) goto l2011; prop[bottle] = 1; place[water] = 0; spk = 74; goto l2011; case 16: /* 9160: rub */ if (obj != lamp) spk = 76; goto l2011; case 17: /* 9170: throw */ switch (trtoss()) { case 2011: goto l2011; case 9020: goto l9020; case 9120: goto l9120; case 8: goto l8; case 9210: goto l9210; default: bug(113); } case 19: case 20: /* 9190: find, invent */ if (at(obj) || (liq() == obj && at(bottle)) || k == liqloc(loc)) spk = 94; for (i = 1; i <= 5; i++) if (dloc[i] == loc && dflag >= 2 && obj == dwarf) spk = 94; if (closed) spk = 138; if (toting(obj)) spk = 24; goto l2011; l9210: case 21: /* feed */ switch (trfeed()) { case 2011: goto l2011; default: bug(114); } l9220: case 22: /* fill */ switch (trfill()) { case 2011: goto l2011; case 8000: goto l8000; case 9020: goto l9020; default: bug(115); } l9230: case 23: /* blast */ if (prop[rod2] < 0 || !closed) goto l2011; bonus = 133; if (loc == 115) bonus = 134; if (here(rod2)) bonus = 135; rspeak(bonus); done(2); l9270: case 27: /* read */ if (dark()) goto l5190; if (obj == magzin) spk = 190; if (obj == tablet) spk = 196; if (obj == messag) spk = 191; if (obj == oyster && hinted[2] && toting(oyster)) spk = 194; if (obj != oyster || hinted[2] || !toting(oyster) || !closed) goto l2011; hinted[2] = yes(192, 193, 54); goto l2012; l9280: case 28: /* break */ if (obj == mirror) spk = 148; if (obj == vase && prop[vase] == 0) { spk = 198; if (toting(vase)) drop(vase, loc); prop[vase] = 2; fixed[vase] = -1; goto l2011; } if (obj != mirror||!closed) goto l2011; rspeak(197); done(3); l9290: case 29: /* wake */ if (obj != dwarf||!closed) goto l2011; rspeak(199); done(3); default: bug(24); } l5000: obj = k; if (fixed[k] != loc && !here(k)) goto l5100; l5010: if (wd2[0] != 0) goto l2800; if (verb != 0) goto l4090; printf("What do you want to do with the %s?\n", wd1); goto l2600; l5100: if (k != grate) goto l5110; if (loc == 1 || loc == 4 || loc == 7) k = dprssn; if (loc > 9 && loc < 15) k = entrnc; if (k != grate) goto l8; l5110: if (k != dwarf) goto l5120; for (i = 1; i <= 5; i++) if (dloc[i] == loc && dflag >= 2) goto l5010; l5120: if ((liq() == k && here(bottle)) || k == liqloc(loc)) goto l5010; if (obj != plant || !at(plant2) || prop[plant2] == 0) goto l5130; obj = plant2; goto l5010; l5130: if (obj != knife || knfloc != loc) goto l5140; knfloc = -1; spk = 116; goto l2011; l5140: if (obj != rod || !here(rod2)) goto l5190; obj = rod2; goto l5010; l5190: if ((verb == find || verb == invent) && wd2[0] == 0) goto l5010; printf("I see no %s here\n", wd1); goto l2012; } }
/* DROP etc. */ vdrop() { int i; /* check for dynamite */ if (toting(ROD2) && object == ROD && !toting(ROD)) object = ROD2; if (!toting(object)){ actspk(verb); return; } /* snake and bird */ if (object == BIRD && here(SNAKE)) { rspeak(30); if (closed) dwarfend(); dstroy(SNAKE); prop[SNAKE] = -1; } /* coins and vending machine */ else if (object == COINS && here(VEND)) { dstroy(COINS); drop(BATTERIES,loc); pspeak(BATTERIES,0); return; } /* bird and dragon (ouch!!) */ else if (object == BIRD && at(DRAGON) && prop[DRAGON] == 0){ rspeak(154); dstroy(BIRD); prop[BIRD] = 0; if (place[SNAKE] != 0) ++tally2; return; } /* Bear and troll */ if (object == BEAR && at(TROLL)) { rspeak(163); move(TROLL,0); move((TROLL+MAXOBJ),0); move(TROLL2,117); move((TROLL2+MAXOBJ),122); juggle(CHASM); prop[TROLL] = 2; } /* vase */ else if (object == VASE) { if (loc == 96) rspeak(54); else { prop[VASE] = at(PILLOW) ? 0 : 2; pspeak(VASE,prop[VASE]+1); if (prop[VASE] != 0) fixed[VASE] = -1; } } /* handle liquid and bottle */ i = liq(); if (i == object) object = BOTTLE; if (object == BOTTLE && i != 0) place[i] = 0; /* handle bird and cage */ if (object == CAGE && prop[BIRD] != 0) drop(BIRD,loc); if (object == BIRD) prop[BIRD] = 0; drop(object,loc); }
/* LOCK, UNLOCK, OPEN, CLOSE etc. */ vopen() { int msg, oyclam; switch(object) { case CLAM: case OYSTER: oyclam = (object == OYSTER ? 1 : 0); if (verb == LOCK) msg = 61; else if (!toting(TRIDENT)) msg = 122+oyclam; else if (toting(object)) msg = 120+oyclam; else { msg = 124+oyclam; dstroy(CLAM); drop(OYSTER,loc); drop(PEARL,105); } break; case DOOR: msg = (prop[DOOR] == 1 ? 54 : 111); break; case CAGE: msg = 32; break; case KEYS: msg = 55; break; case CHAIN: if (!here(KEYS)) msg = 31; else if (verb == LOCK) { if (prop[CHAIN] != 0) msg = 34; else if (loc != 130) msg = 173; else { prop[CHAIN] = 2; if (toting(CHAIN)) drop(CHAIN,loc); fixed[CHAIN] = -1; msg = 172; } } else { if (prop[BEAR] == 0) msg = 41; else if (prop[CHAIN] == 0) msg = 37; else { prop[CHAIN] = 0; fixed[CHAIN] = 0; if (prop[BEAR] != 3) prop[BEAR] = 2; fixed[BEAR] = 2-prop[BEAR]; msg = 171; } } break; case GRATE: if (!here(KEYS)) msg = 31; else if (closing) { if (!panic) { clock2 = 15; ++panic; } msg = 130; } else { msg = 34+prop[GRATE]; prop[GRATE] = (verb == LOCK ? 0 : 1); msg += 2*prop[GRATE]; } break; default: msg = 33; } rspeak(msg); }
/* THROW etc. */ vthrow() { int msg; int i; if (toting(ROD2) && object == ROD && !toting(ROD)) object = ROD2; if (!toting(object)) { actspk(verb); return; } /* treasure to troll */ if (at(TROLL) && object >= 50 && object<MAXOBJ) { rspeak(159); drop(object,0); move(TROLL,0); move((TROLL+MAXOBJ),0); drop(TROLL2,117); drop((TROLL2+MAXOBJ),122); juggle(CHASM); return; } /* feed the bears... */ if (object == FOOD && here(BEAR)) { object = BEAR; vfeed(); return; } /* if not axe, same as drop... */ if (object != AXE) { vdrop(); return; } /* AXE is THROWN */ /* at a dwarf... */ if (i = dcheck()) { msg = 48; if (pct(33)) { dseen[i] = dloc[i] = 0; msg = 47; ++dkill; if (dkill == 1) msg = 149; } } /* at a dragon... */ else if (at(DRAGON) && prop[DRAGON] == 0) msg = 152; /* at the troll... */ else if (at(TROLL)) msg = 158; /* at the bear... */ else if (here(BEAR) && prop[BEAR] == 0) { rspeak(164); drop(AXE,loc); fixed[AXE] = -1; prop[AXE] = 1; juggle(BEAR); return; } /* otherwise it is an attack */ else { verb = KILL; object = 0; itverb(); return; } /* handle the left over axe... */ rspeak(msg); drop(AXE,loc); describe(); }
/* special time limit stuff... */ int stimer() { int i, spk; static int clock3; g.foobar = g.foobar > 0 ? -g.foobar : 0; g.combo = g.combo > 0 ? -g.combo : 0; if (g.turns > 310 && g.abbnum != 10000 && !g.terse) rspeak(273); /* Bump all the right clocks for reconning battery life and closing */ if (g.closed) { clock3--; if (clock3 == 0) { g.prop[PHONE] = 0; g.prop[BOOTH] = 0; rspeak(284); } else if (clock3 < -7) { rspeak(254); normend(); return (TRUE); } } if (g.tally == 0 && inside(g.loc) && g.loc != Y2) --g.clock; if (g.clock == 0) { /* Start closing the cave */ g.prop[GRATE] = 0; biton(GRATE, LOCKBT); bitoff(GRATE, OPENBT); g.prop[FISSURE] = 0; g.prop[TDOOR] = 0; biton(TDOOR, LOCKBT); bitoff(TDOOR, OPENBT); g.prop[TDOOR2] = 0; biton(TDOOR2, LOCKBT); bitoff(TDOOR2, OPENBT); for (i = 1; i <= DWARFMAX; ++i) { g.dseen[i] = FALSE; g.dloc[i] = 0; } move(TROLL, 0); move((TROLL + MAXOBJ), 0); move(TROLL2, plac[TROLL]); move((TROLL2 + MAXOBJ), fixd[TROLL]); juggle(CHASM); if (g.prop[BEAR] != 3) destroy(BEAR); g.prop[CHAIN] = 0; g.fixed[CHAIN] = 0; g.prop[AXE] = 0; g.fixed[AXE] = 0; rspeak(129); g.clock = -1; g.closing = TRUE; return (FALSE); } if (g.clock < 0) --g.clock2; if (g.clock2 == 0) { /* Set up storage room... and close the cave... */ g.prop[BOTTLE] = put(BOTTLE, 115, 8); g.holder[BOTTLE] = WATER; g.place[WATER] = -BOTTLE; g.hlink[WATER] = 0; bitoff(BOTTLE, OPENBT); g.prop[PLANT] = put(PLANT, 115, 0); g.prop[OYSTER] = put(OYSTER, 115, 0); g.prop[LAMP] = put(LAMP, 115, 0); g.prop[ROD] = put(ROD, 115, 0); g.prop[DWARF] = put(DWARF, 115, 0); g.loc = 115; g.oldloc = 115; g.newloc = 115; /* Leave the grate with normal (non-negative property). */ put(GRATE, 116, 0); biton(GRATE, LOCKBT); bitoff(GRATE, OPENBT); g.prop[SNAKE] = put(SNAKE, 116, 1); g.prop[BIRD] = put(BIRD, 116, 1); g.prop[CAGE] = put(CAGE, 116, 0); g.prop[ROD2] = put(ROD2, 116, 0); g.prop[PILLOW] = put(PILLOW, 116, 0); g.prop[BOOTH] = put(BOOTH, 116, -3); g.fixed[BOOTH] = 115; g.prop[PHONE] = put(PHONE, 212, -4); g.prop[MIRROR] = put(MIRROR, 115, 0); g.fixed[MIRROR] = 116; g.prop[BOOK2] = put(BOOK2, 115, 0); for (i = 1; i < MAXOBJ; ++i) { if (toting(i) && enclosed(i)) extract(i); if (toting(i)) destroy(i); } rspeak(132); g.closed = TRUE; clock3 = 20 + ranz(20); newtravel = TRUE; return (TRUE); } if (g.prop[LAMP] == 1) --g.limit; if (g.limit == 0) { --g.limit; g.prop[LAMP] = 0; if (here(LAMP)) rspeak(184); return (FALSE); } if (g.limit < 0 && outside(g.loc)) { rspeak(185); normend(); return (TRUE); } if (g.limit <= 40) { if (g.lmwarn || !here(LAMP)) return (FALSE); g.lmwarn = TRUE; spk = 187; if (g.prop[BATTERIES] == 1) spk = 323; if (g.place[BATTERIES] == 0) spk = 183; if (g.prop[VEND] == 1) spk = 189; rspeak(spk); return (FALSE); } return (FALSE); }
/* Routine to tell if an item is present. */ int here(int item) { return(place[item] == loc || toting(item)); }