- * while inside the cave). When it hits zero, we branch to 10000 to
- * start closing the cave, and then sit back and wait for him to try
- * to get out. If he doesn't within clock2 turns, we close the cave;
- * if he does try, we assume he panics, and give him a few additional
- * turns to get frantic before we close. When clock2 hits zero, we
- * transport him into the final puzzle. Note that the puzzle depends
- * upon all sorts of random things. For instance, there must be no
- * water or oil, since there are beanstalks which we don't want to be
- * able to water, since the code can't handle it. Also, we can have
- * no keys, since there is a grate (having moved the fixed object!)
- * there separating him from all the treasures. Most of these
- * problems arise from the use of negative prop numbers to suppress
- * the object descriptions until he's actually moved the objects. */
-{
- /* If a turn threshold has been met, apply penalties and tell
- * the player about it. */
- for (int i = 0; i < NTHRESHOLDS; ++i) {
- if (game.turns == turn_thresholds[i].threshold + 1) {
- game.trnluz += turn_thresholds[i].point_loss;
- speak(turn_thresholds[i].message);
- }
- }
-
- /* Don't tick game.clock1 unless well into cave (and not at Y2). */
- if (game.tally == 0 && INDEEP(game.loc) && game.loc != LOC_Y2)
- --game.clock1;
-
- /* When the first warning comes, we lock the grate, destroy
- * the bridge, kill all the dwarves (and the pirate), remove
- * the troll and bear (unless dead), and set "closng" to
- * true. Leave the dragon; too much trouble to move it.
- * from now until clock2 runs out, he cannot unlock the
- * grate, move to any location outside the cave, or create
- * the bridge. Nor can he be resurrected if he dies. Note
- * that the snake is already gone, since he got to the
- * treasure accessible only via the hall of the mountain
- * king. Also, he's been in giant room (to get eggs), so we
- * can refer to it. Also also, he's gotten the pearl, so we
- * know the bivalve is an oyster. *And*, the dwarves must
- * have been activated, since we've found chest. */
- if (game.clock1 == 0) {
- game.prop[GRATE] = GRATE_CLOSED;
- game.prop[FISSURE] = UNBRIDGED;
- for (int i = 1; i <= NDWARVES; i++) {
- game.dseen[i] = false;
- game.dloc[i] = LOC_NOWHERE;
- }
- move(TROLL, LOC_NOWHERE);
- move(TROLL + NOBJECTS, IS_FREE);
- move(TROLL2, objects[TROLL].plac);
- move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
- juggle(CHASM);
- if (game.prop[BEAR] != BEAR_DEAD)
- DESTROY(BEAR);
- game.prop[CHAIN] = CHAIN_HEAP;
- game.fixed[CHAIN] = IS_FREE;
- game.prop[AXE] = AXE_HERE;
- game.fixed[AXE] = IS_FREE;
- rspeak(CAVE_CLOSING);
- game.clock1 = -1;
- game.closng = true;
- return game.closed;
- } else if (game.clock1 < 0)
- --game.clock2;
- if (game.clock2 == 0) {
- /* Once he's panicked, and clock2 has run out, we come here
- * to set up the storage room. The room has two locs,
- * hardwired as LOC_NE and LOC_SW. At the ne end, we
- * place empty bottles, a nursery of plants, a bed of
- * oysters, a pile of lamps, rods with stars, sleeping
- * dwarves, and him. At the sw end we place grate over
- * treasures, snake pit, covey of caged birds, more rods, and
- * pillows. A mirror stretches across one wall. Many of the
- * objects come from known locations and/or states (e.g. the
- * snake is known to have been destroyed and needn't be
- * carried away from its old "place"), making the various
- * objects be handled differently. We also drop all other
- * objects he might be carrying (lest he have some which
- * could cause trouble, such as the keys). We describe the
- * flash of light and trundle back. */
- game.prop[BOTTLE] = put(BOTTLE, LOC_NE, EMPTY_BOTTLE);
- game.prop[PLANT] = put(PLANT, LOC_NE, PLANT_THIRSTY);
- game.prop[OYSTER] = put(OYSTER, LOC_NE, STATE_FOUND);
- game.prop[LAMP] = put(LAMP, LOC_NE, LAMP_DARK);
- game.prop[ROD] = put(ROD, LOC_NE, STATE_FOUND);
- game.prop[DWARF] = put(DWARF, LOC_NE, 0);
- game.loc = LOC_NE;
- game.oldloc = LOC_NE;
- game.newloc = LOC_NE;
- /* Leave the grate with normal (non-negative) property.
- * Reuse sign. */
- put(GRATE, LOC_SW, 0);
- put(SIGN, LOC_SW, 0);
- game.prop[SIGN] = ENDGAME_SIGN;
- game.prop[SNAKE] = put(SNAKE, LOC_SW, SNAKE_CHASED);
- game.prop[BIRD] = put(BIRD, LOC_SW, BIRD_CAGED);
- game.prop[CAGE] = put(CAGE, LOC_SW, STATE_FOUND);
- game.prop[ROD2] = put(ROD2, LOC_SW, STATE_FOUND);
- game.prop[PILLOW] = put(PILLOW, LOC_SW, STATE_FOUND);
-
- game.prop[MIRROR] = put(MIRROR, LOC_NE, STATE_FOUND);
- game.fixed[MIRROR] = LOC_SW;
-
- for (int i = 1; i <= NOBJECTS; i++) {
- if (TOTING(i))
- DESTROY(i);
- }
-
- rspeak(CAVE_CLOSED);
- game.closed = true;
- return game.closed;
- }
-
- lampcheck();
- return false;
-}
-
-static void listobjects(void)
-/* Print out descriptions of objects at this location. If
- * not closing and property value is negative, tally off
- * another treasure. Rug is special case; once seen, its
- * game.prop is RUG_DRAGON (dragon on it) till dragon is killed.
- * Similarly for chain; game.prop is initially CHAINING_BEAR (locked to
- * bear). These hacks are because game.prop=0 is needed to
- * get full score. */
-{
- if (!DARK(game.loc)) {
- ++game.abbrev[game.loc];
- for (int i = game.atloc[game.loc]; i != 0; i = game.link[i]) {
- obj_t obj = i;
- if (obj > NOBJECTS)
- obj = obj - NOBJECTS;
- if (obj == STEPS && TOTING(NUGGET))
- continue;
- if (game.prop[obj] < 0) {
- if (game.closed)
- continue;
- game.prop[obj] = STATE_FOUND;
- if (obj == RUG)
- game.prop[RUG] = RUG_DRAGON;
- if (obj == CHAIN)
- game.prop[CHAIN] = CHAINING_BEAR;
- --game.tally;
- /* Note: There used to be a test here to see whether the
- * player had blown it so badly that he could never ever see
- * the remaining treasures, and if so the lamp was zapped to
- * 35 turns. But the tests were too simple-minded; things
- * like killing the bird before the snake was gone (can never
- * see jewelry), and doing it "right" was hopeless. E.G.,
- * could cross troll bridge several times, using up all
- * available treasures, breaking vase, using coins to buy
- * batteries, etc., and eventually never be able to get
- * across again. If bottle were left on far side, could then
- * never get eggs or trident, and the effects propagate. So
- * the whole thing was flushed. anyone who makes such a
- * gross blunder isn't likely to find everything else anyway
- * (so goes the rationalisation). */
- }
- int kk = game.prop[obj];
- if (obj == STEPS)
- kk = (game.loc == game.fixed[STEPS])
- ? STEPS_UP
- : STEPS_DOWN;
- pspeak(obj, look, true, kk);
- }
- }
-}
-
-void clear_command(command_t *cmd)
-{
- cmd->verb = ACT_NULL;
- game.oldobj = cmd->obj;
- cmd->obj = NO_OBJECT;
+ * while inside the cave). When it hits zero, we start closing the
+ * cave, and then sit back and wait for him to try to get out. If he
+ * doesn't within clock2 turns, we close the cave; if he does try, we
+ * assume he panics, and give him a few additional turns to get
+ * frantic before we close. When clock2 hits zero, we transport him
+ * into the final puzzle. Note that the puzzle depends upon all
+ * sorts of random things. For instance, there must be no water or
+ * oil, since there are beanstalks which we don't want to be able to
+ * water, since the code can't handle it. Also, we can have no keys,
+ * since there is a grate (having moved the fixed object!) there
+ * separating him from all the treasures. Most of these problems
+ * arise from the use of negative prop numbers to suppress the object
+ * descriptions until he's actually moved the objects. */
+static bool closecheck(void) {
+ /* If a turn threshold has been met, apply penalties and tell
+ * the player about it. */
+ for (int i = 0; i < NTHRESHOLDS; ++i) {
+ if (game.turns == turn_thresholds[i].threshold + 1) {
+ game.trnluz += turn_thresholds[i].point_loss;
+ speak(turn_thresholds[i].message);
+ }
+ }
+
+ /* Don't tick game.clock1 unless well into cave (and not at Y2). */
+ if (game.tally == 0 && INDEEP(game.loc) && game.loc != LOC_Y2) {
+ --game.clock1;
+ }
+
+ /* When the first warning comes, we lock the grate, destroy
+ * the bridge, kill all the dwarves (and the pirate), remove
+ * the troll and bear (unless dead), and set "closng" to
+ * true. Leave the dragon; too much trouble to move it.
+ * from now until clock2 runs out, he cannot unlock the
+ * grate, move to any location outside the cave, or create
+ * the bridge. Nor can he be resurrected if he dies. Note
+ * that the snake is already gone, since he got to the
+ * treasure accessible only via the hall of the mountain
+ * king. Also, he's been in giant room (to get eggs), so we
+ * can refer to it. Also also, he's gotten the pearl, so we
+ * know the bivalve is an oyster. *And*, the dwarves must
+ * have been activated, since we've found chest. */
+ if (game.clock1 == 0) {
+ game.objects[GRATE].prop = GRATE_CLOSED;
+ game.objects[FISSURE].prop = UNBRIDGED;
+ for (int i = 1; i <= NDWARVES; i++) {
+ game.dwarves[i].seen = false;
+ game.dwarves[i].loc = LOC_NOWHERE;
+ }
+ DESTROY(TROLL);
+ move(TROLL + NOBJECTS, IS_FREE);
+ move(TROLL2, objects[TROLL].plac);
+ move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
+ juggle(CHASM);
+ if (game.objects[BEAR].prop != BEAR_DEAD) {
+ DESTROY(BEAR);
+ }
+ game.objects[CHAIN].prop = CHAIN_HEAP;
+ game.objects[CHAIN].fixed = IS_FREE;
+ game.objects[AXE].prop = AXE_HERE;
+ game.objects[AXE].fixed = IS_FREE;
+ rspeak(CAVE_CLOSING);
+ game.clock1 = -1;
+ game.closng = true;
+ return game.closed;
+ } else if (game.clock1 < 0) {
+ --game.clock2;
+ }
+ if (game.clock2 == 0) {
+ /* Once he's panicked, and clock2 has run out, we come here
+ * to set up the storage room. The room has two locs,
+ * hardwired as LOC_NE and LOC_SW. At the ne end, we
+ * place empty bottles, a nursery of plants, a bed of
+ * oysters, a pile of lamps, rods with stars, sleeping
+ * dwarves, and him. At the sw end we place grate over
+ * treasures, snake pit, covey of caged birds, more rods, and
+ * pillows. A mirror stretches across one wall. Many of the
+ * objects come from known locations and/or states (e.g. the
+ * snake is known to have been destroyed and needn't be
+ * carried away from its old "place"), making the various
+ * objects be handled differently. We also drop all other
+ * objects he might be carrying (lest he has some which
+ * could cause trouble, such as the keys). We describe the
+ * flash of light and trundle back. */
+ put(BOTTLE, LOC_NE, EMPTY_BOTTLE);
+ put(PLANT, LOC_NE, PLANT_THIRSTY);
+ put(OYSTER, LOC_NE, STATE_FOUND);
+ put(LAMP, LOC_NE, LAMP_DARK);
+ put(ROD, LOC_NE, STATE_FOUND);
+ put(DWARF, LOC_NE, STATE_FOUND);
+ game.loc = LOC_NE;
+ game.oldloc = LOC_NE;
+ game.newloc = LOC_NE;
+ /* Leave the grate with normal (non-negative) property.
+ * Reuse sign. */
+ move(GRATE, LOC_SW);
+ move(SIGN, LOC_SW);
+ game.objects[SIGN].prop = ENDGAME_SIGN;
+ put(SNAKE, LOC_SW, SNAKE_CHASED);
+ put(BIRD, LOC_SW, BIRD_CAGED);
+ put(CAGE, LOC_SW, STATE_FOUND);
+ put(ROD2, LOC_SW, STATE_FOUND);
+ put(PILLOW, LOC_SW, STATE_FOUND);
+
+ put(MIRROR, LOC_NE, STATE_FOUND);
+ game.objects[MIRROR].fixed = LOC_SW;
+
+ for (int i = 1; i <= NOBJECTS; i++) {
+ if (TOTING(i)) {
+ DESTROY(i);
+ }
+ }
+
+ rspeak(CAVE_CLOSED);
+ game.closed = true;
+ return game.closed;
+ }
+
+ lampcheck();
+ return false;