Add explanatory comment.
[open-adventure.git] / actions.c
1 /*
2  * Actions for the dungeon-running code.
3  *
4  * Copyright (c) 1977, 2005 by Will Crowther and Don Woods
5  * Copyright (c) 2017 by Eric S. Raymond
6  * SPDX-License-Identifier: BSD-2-clause
7  */
8
9 #include <stdlib.h>
10 #include <stdbool.h>
11 #include <string.h>
12 #include "advent.h"
13 #include "dungeon.h"
14 #include <inttypes.h>
15
16 static phase_codes_t fill(verb_t, obj_t);
17
18 static phase_codes_t attack(command_t command)
19 /*  Attack.  Assume target if unambiguous.  "Throw" also links here.
20  *  Attackable objects fall into two categories: enemies (snake,
21  *  dwarf, etc.)  and others (bird, clam, machine).  Ambiguous if 2
22  *  enemies, or no enemies but 2 others. */
23 {
24     verb_t verb = command.verb;
25     obj_t obj = command.obj;
26
27     if (obj == INTRANSITIVE) {
28         int changes = 0;
29         if (atdwrf(game.loc) > 0) {
30             obj = DWARF;
31             ++changes;
32         }
33         if (HERE(SNAKE)) {
34             obj = SNAKE;
35             ++changes;
36         }
37         if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
38             obj = DRAGON;
39             ++changes;
40         }
41         if (AT(TROLL)) {
42             obj = TROLL;
43             ++changes;
44         }
45         if (AT(OGRE)) {
46             obj = OGRE;
47             ++changes;
48         }
49         if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
50             obj = BEAR;
51             ++changes;
52         }
53         /* check for low-priority targets */
54         if (obj == INTRANSITIVE) {
55             /* Can't attack bird or machine by throwing axe. */
56             if (HERE(BIRD) && verb != THROW) {
57                 obj = BIRD;
58                 ++changes;
59             }
60             if (HERE(VEND) && verb != THROW) {
61                 obj = VEND;
62                 ++changes;
63             }
64             /* Clam and oyster both treated as clam for intransitive case;
65              * no harm done. */
66             if (HERE(CLAM) || HERE(OYSTER)) {
67                 obj = CLAM;
68                 ++changes;
69             }
70         }
71         if (changes >= 2)
72             return GO_UNKNOWN;
73     }
74
75     if (obj == BIRD) {
76         if (game.closed) {
77             rspeak(UNHAPPY_BIRD);
78         } else {
79             DESTROY(BIRD);
80             rspeak(BIRD_DEAD);
81         }
82         return GO_CLEAROBJ;
83     }
84     if (obj == VEND) {
85         state_change(VEND,
86                      game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
87
88         return GO_CLEAROBJ;
89     }
90
91     if (obj == BEAR) {
92         switch (game.prop[BEAR]) {
93         case UNTAMED_BEAR:
94             rspeak(BEAR_HANDS);
95             break;
96         case SITTING_BEAR:
97             rspeak(BEAR_CONFUSED);
98             break;
99         case CONTENTED_BEAR:
100             rspeak(BEAR_CONFUSED);
101             break;
102         case BEAR_DEAD:
103             rspeak(ALREADY_DEAD);
104             break;
105         }
106         return GO_CLEAROBJ;
107     }
108     if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
109         /*  Fun stuff for dragon.  If he insists on attacking it, win!
110          *  Set game.prop to dead, move dragon to central loc (still
111          *  fixed), move rug there (not fixed), and move him there,
112          *  too.  Then do a null motion to get new description. */
113         rspeak(BARE_HANDS_QUERY);
114         if (!silent_yes_or_no()) {
115             speak(arbitrary_messages[NASTY_DRAGON]);
116             return GO_MOVE;
117         }
118         state_change(DRAGON, DRAGON_DEAD);
119         game.prop[RUG] = RUG_FLOOR;
120         /* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.
121          * The way it was computed before was worse; it depended on the
122          * two dragon locations being LOC_SECRET4 and LOC_SECRET6 and
123          * LOC_SECRET5 being right between them.
124          */
125         move(DRAGON + NOBJECTS, IS_FIXED);
126         move(RUG + NOBJECTS, IS_FREE);
127         move(DRAGON, LOC_SECRET5);
128         move(RUG, LOC_SECRET5);
129         drop(BLOOD, LOC_SECRET5);
130         for (obj_t i = 1; i <= NOBJECTS; i++) {
131             if (game.place[i] == objects[DRAGON].plac ||
132                 game.place[i] == objects[DRAGON].fixd)
133                 move(i, LOC_SECRET5);
134         }
135         game.loc = LOC_SECRET5;
136         return GO_MOVE;
137     }
138
139     if (obj == OGRE) {
140         rspeak(OGRE_DODGE);
141         if (atdwrf(game.loc) == 0)
142             return GO_CLEAROBJ;
143
144         rspeak(KNIFE_THROWN);
145         DESTROY(OGRE);
146         int dwarves = 0;
147         for (int i = 1; i < PIRATE; i++) {
148             if (game.dloc[i] == game.loc) {
149                 ++dwarves;
150                 game.dloc[i] = LOC_LONGWEST;
151                 game.dseen[i] = false;
152             }
153         }
154         rspeak((dwarves > 1) ?
155                OGRE_PANIC1 :
156                OGRE_PANIC2);
157         return GO_CLEAROBJ;
158     }
159
160     switch (obj) {
161     case INTRANSITIVE:
162         rspeak(NO_TARGET);
163         break;
164     case CLAM:
165     case OYSTER:
166         rspeak(SHELL_IMPERVIOUS);
167         break;
168     case SNAKE:
169         rspeak(SNAKE_WARNING);
170         break;
171     case DWARF:
172         if (game.closed) {
173             return GO_DWARFWAKE;
174         }
175         rspeak(BARE_HANDS_QUERY);
176         break;
177     case DRAGON:
178         rspeak(ALREADY_DEAD);
179         break;
180     case TROLL:
181         rspeak(ROCKY_TROLL);
182         break;
183     default:
184         speak(actions[verb].message);
185     }
186     return GO_CLEAROBJ;
187 }
188
189 static phase_codes_t bigwords(vocab_t id)
190 /* Only called on FEE FIE FOE FOO (AND FUM).  Advance to next state if given
191  * in proper order. Look up foo in special section of vocab to determine which
192  * word we've got. Last word zips the eggs back to the giant room (unless
193  * already there). */
194 {
195     int foobar = abs(game.foobar);
196
197     /* Only FEE can start a magic-word sequence. */
198     if ((foobar == WORD_EMPTY) && (id == FIE || id == FOE || id == FOO || id == FUM)) {
199         rspeak(NOTHING_HAPPENS);
200         return GO_CLEAROBJ;
201     }
202     
203     if ((foobar == WORD_EMPTY && id == FEE) ||
204         (foobar == FEE && id == FIE) ||
205         (foobar == FIE && id == FOE) ||
206         (foobar == FOE && id == FOO)) {
207         game.foobar = id;
208         if (id != FOO) {
209             rspeak(OK_MAN);
210             return GO_CLEAROBJ;
211         }
212         game.foobar = WORD_EMPTY;
213         if (game.place[EGGS] == objects[EGGS].plac ||
214             (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
215             rspeak(NOTHING_HAPPENS);
216             return GO_CLEAROBJ;
217         } else {
218             /*  Bring back troll if we steal the eggs back from him before
219              *  crossing. */
220             if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
221                 game.prop[TROLL] = TROLL_PAIDONCE;
222             if (HERE(EGGS))
223                 pspeak(EGGS, look, true, EGGS_VANISHED);
224             else if (game.loc == objects[EGGS].plac)
225                 pspeak(EGGS, look, true, EGGS_HERE);
226             else
227                 pspeak(EGGS, look, true, EGGS_DONE);
228             move(EGGS, objects[EGGS].plac);
229
230             return GO_CLEAROBJ;
231         }
232     } else {
233         /* Magic-word sequebce was started but is incorrect */
234         rspeak(START_OVER);
235         game.foobar = WORD_EMPTY;
236         return GO_CLEAROBJ;
237     }
238 }
239
240 static void blast(void)
241 /*  Blast.  No effect unless you've got dynamite, which is a neat trick! */
242 {
243     if (game.prop[ROD2] == STATE_NOTFOUND ||
244         !game.closed)
245         rspeak(REQUIRES_DYNAMITE);
246     else {
247         if (HERE(ROD2)) {
248             game.bonus = splatter;
249             rspeak(SPLATTER_MESSAGE);
250         } else if (game.loc == LOC_NE) {
251             game.bonus = defeat;
252             rspeak(DEFEAT_MESSAGE);
253         } else {
254             game.bonus = victory;
255             rspeak(VICTORY_MESSAGE);
256         }
257         terminate(endgame);
258     }
259 }
260
261 static phase_codes_t vbreak(verb_t verb, obj_t obj)
262 /*  Break.  Only works for mirror in repository and, of course, the vase. */
263 {
264     switch (obj) {
265     case MIRROR:
266         if (game.closed) {
267             state_change(MIRROR, MIRROR_BROKEN);
268             return GO_DWARFWAKE;
269         } else {
270             rspeak(TOO_FAR);
271             break;
272         }
273     case VASE:
274         if (game.prop[VASE] == VASE_WHOLE) {
275             if (TOTING(VASE))
276                 drop(VASE, game.loc);
277             state_change(VASE, VASE_BROKEN);
278             game.fixed[VASE] = IS_FIXED;
279             break;
280         }
281     /* FALLTHRU */
282     default:
283         speak(actions[verb].message);
284     }
285     return (GO_CLEAROBJ);
286 }
287
288 static phase_codes_t brief(void)
289 /*  Brief.  Intransitive only.  Suppress full descriptions after first time. */
290 {
291     game.abbnum = 10000;
292     game.detail = 3;
293     rspeak(BRIEF_CONFIRM);
294     return GO_CLEAROBJ;
295 }
296
297 static phase_codes_t vcarry(verb_t verb, obj_t obj)
298 /*  Carry an object.  Special cases for bird and cage (if bird in cage, can't
299  *  take one without the other).  Liquids also special, since they depend on
300  *  status of bottle.  Also various side effects, etc. */
301 {
302     if (obj == INTRANSITIVE) {
303         /*  Carry, no object given yet.  OK if only one object present. */
304         if (game.atloc[game.loc] == NO_OBJECT ||
305             game.link[game.atloc[game.loc]] != 0 ||
306             atdwrf(game.loc) > 0)
307             return GO_UNKNOWN;
308         obj = game.atloc[game.loc];
309     }
310
311     if (TOTING(obj)) {
312         speak(actions[verb].message);
313         return GO_CLEAROBJ;
314     }
315
316     if (obj == MESSAG) {
317         rspeak(REMOVE_MESSAGE);
318         DESTROY(MESSAG);
319         return GO_CLEAROBJ;
320     }
321
322     if (game.fixed[obj] != IS_FREE) {
323         switch (obj) {
324         case PLANT:
325             /* Next guard tests whether plant is tiny or stashed */
326             rspeak(game.prop[PLANT] <= PLANT_THIRSTY ? DEEP_ROOTS : YOU_JOKING);
327             break;
328         case BEAR:
329             rspeak( game.prop[BEAR] == SITTING_BEAR ? BEAR_CHAINED : YOU_JOKING);
330             break;
331         case CHAIN:
332             rspeak( game.prop[BEAR] != UNTAMED_BEAR ? STILL_LOCKED : YOU_JOKING);
333             break;
334         case RUG:
335             rspeak(game.prop[RUG] == RUG_HOVER ? RUG_HOVERS : YOU_JOKING);
336             break;
337         case URN:
338             rspeak(URN_NOBUDGE);
339             break;
340         case CAVITY:
341             rspeak(DOUGHNUT_HOLES);
342             break;
343         case BLOOD:
344             rspeak(FEW_DROPS);
345             break;
346         case SIGN:
347             rspeak(HAND_PASSTHROUGH);
348             break;
349         default:
350             rspeak(YOU_JOKING);
351         }
352         return GO_CLEAROBJ;
353     }
354
355     if (obj == WATER ||
356         obj == OIL) {
357         if (!HERE(BOTTLE) ||
358             LIQUID() != obj) {
359             if (!TOTING(BOTTLE)) {
360                 rspeak(NO_CONTAINER);
361                 return GO_CLEAROBJ;
362             }
363             if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
364                 return (fill(verb, BOTTLE));
365             } else
366                 rspeak(BOTTLE_FULL);
367             return GO_CLEAROBJ;
368         }
369         obj = BOTTLE;
370     }
371
372     if (game.holdng >= INVLIMIT) {
373         rspeak(CARRY_LIMIT);
374         return GO_CLEAROBJ;
375
376     }
377
378     if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
379         if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
380             DESTROY(BIRD);
381             rspeak(BIRD_CRAP);
382             return GO_CLEAROBJ;
383         }
384         if (!TOTING(CAGE)) {
385             rspeak(CANNOT_CARRY);
386             return GO_CLEAROBJ;
387         }
388         if (TOTING(ROD)) {
389             rspeak(BIRD_EVADES);
390             return GO_CLEAROBJ;
391         }
392         game.prop[BIRD] = BIRD_CAGED;
393     }
394     if ((obj == BIRD ||
395          obj == CAGE) &&
396         (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) {
397         /* expression maps BIRD to CAGE and CAGE to BIRD */
398         carry(BIRD + CAGE - obj, game.loc);
399     }
400
401     carry(obj, game.loc);
402
403     if (obj == BOTTLE && LIQUID() != NO_OBJECT)
404         game.place[LIQUID()] = CARRIED;
405
406     if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
407         game.prop[obj] = STATE_FOUND;
408         game.prop[CAVITY] = CAVITY_EMPTY;
409     }
410     rspeak(OK_MAN);
411     return GO_CLEAROBJ;
412 }
413
414 static int chain(verb_t verb)
415 /* Do something to the bear's chain */
416 {
417     if (verb != LOCK) {
418         if (game.prop[BEAR] == UNTAMED_BEAR) {
419             rspeak(BEAR_BLOCKS);
420             return GO_CLEAROBJ;
421         }
422         if (game.prop[CHAIN] == CHAIN_HEAP) {
423             rspeak(ALREADY_UNLOCKED);
424             return GO_CLEAROBJ;
425         }
426         game.prop[CHAIN] = CHAIN_HEAP;
427         game.fixed[CHAIN] = IS_FREE;
428         if (game.prop[BEAR] != BEAR_DEAD)
429             game.prop[BEAR] = CONTENTED_BEAR;
430
431         switch (game.prop[BEAR]) {
432         // LCOV_EXCL_START
433         case BEAR_DEAD:
434             /* Can't be reached until the bear can die in some way other
435              * than a bridge collapse. Leave in in case this changes, but
436              * exclude from coverage testing. */
437             game.fixed[BEAR] = IS_FIXED;
438             break;
439         // LCOV_EXCL_STOP
440         default:
441             game.fixed[BEAR] = IS_FREE;
442         }
443         rspeak(CHAIN_UNLOCKED);
444         return GO_CLEAROBJ;
445     }
446
447     if (game.prop[CHAIN] != CHAIN_HEAP) {
448         rspeak(ALREADY_LOCKED);
449         return GO_CLEAROBJ;
450     }
451     if (game.loc != objects[CHAIN].plac) {
452         rspeak(NO_LOCKSITE);
453         return GO_CLEAROBJ;
454     }
455
456     game.prop[CHAIN] = CHAIN_FIXED;
457
458     if (TOTING(CHAIN))
459         drop(CHAIN, game.loc);
460     game.fixed[CHAIN] = IS_FIXED;
461
462     rspeak(CHAIN_LOCKED);
463     return GO_CLEAROBJ;
464 }
465
466 static phase_codes_t discard(verb_t verb, obj_t obj)
467 /*  Discard object.  "Throw" also comes here for most objects.  Special cases for
468  *  bird (might attack snake or dragon) and cage (might contain bird) and vase.
469  *  Drop coins at vending machine for extra batteries. */
470 {
471     if (obj == ROD && !TOTING(ROD) && TOTING(ROD2)) {
472         obj = ROD2;
473     }
474
475     if (!TOTING(obj)) {
476         speak(actions[verb].message);
477         return GO_CLEAROBJ;
478     }
479
480     if (GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL) {
481         rspeak(GEM_FITS);
482         game.prop[obj] = STATE_IN_CAVITY;
483         game.prop[CAVITY] = CAVITY_FULL;
484         if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
485                           (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
486             if (obj == RUBY)
487                 rspeak(RUG_SETTLES);
488             else if (TOTING(RUG))
489                 rspeak(RUG_WIGGLES);
490             else
491                 rspeak(RUG_RISES);
492             if (!TOTING(RUG) || obj == RUBY) {
493                 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
494                 game.prop[RUG] = k;
495                 if (k == RUG_HOVER)
496                     k = objects[SAPPH].plac;
497                 move(RUG + NOBJECTS, k);
498             }
499         }
500         drop(obj, game.loc);
501         return GO_CLEAROBJ;
502     }
503
504     if (obj == COINS && HERE(VEND)) {
505         DESTROY(COINS);
506         drop(BATTERY, game.loc);
507         pspeak(BATTERY, look, true, FRESH_BATTERIES);
508         return GO_CLEAROBJ;
509     }
510
511     if (LIQUID() == obj)
512         obj = BOTTLE;
513     if (obj == BOTTLE && LIQUID() != NO_OBJECT) {
514         game.place[LIQUID()] = LOC_NOWHERE;
515     }
516
517     if (obj == BEAR && AT(TROLL)) {
518         state_change(TROLL, TROLL_GONE);
519         move(TROLL, LOC_NOWHERE);
520         move(TROLL + NOBJECTS, IS_FREE);
521         move(TROLL2, objects[TROLL].plac);
522         move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
523         juggle(CHASM);
524         drop(obj, game.loc);
525         return GO_CLEAROBJ;
526     }
527
528     if (obj == VASE) {
529         if (game.loc != objects[PILLOW].plac) {
530             state_change(VASE, AT(PILLOW)
531                          ? VASE_WHOLE
532                          : VASE_DROPPED);
533             if (game.prop[VASE] != VASE_WHOLE)
534                 game.fixed[VASE] = IS_FIXED;
535             drop(obj, game.loc);
536             return GO_CLEAROBJ;
537         }
538     }
539
540     if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) {
541         drop(BIRD, game.loc);
542     }
543
544     if (obj == BIRD) {
545         if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
546             rspeak(BIRD_BURNT);
547             DESTROY(BIRD);
548             return GO_CLEAROBJ;
549         }
550         if (HERE(SNAKE)) {
551             rspeak(BIRD_ATTACKS);
552             if (game.closed)
553                 return GO_DWARFWAKE;
554             DESTROY(SNAKE);
555             /* Set game.prop for use by travel options */
556             game.prop[SNAKE] = SNAKE_CHASED;
557         } else
558             rspeak(OK_MAN);
559
560         game.prop[BIRD] = FOREST(game.loc) ? BIRD_FOREST_UNCAGED : BIRD_UNCAGED;
561         drop(obj, game.loc);
562         return GO_CLEAROBJ;
563     }
564
565     rspeak(OK_MAN);
566     drop(obj, game.loc);
567     return GO_CLEAROBJ;
568 }
569
570 static phase_codes_t drink(verb_t verb, obj_t obj)
571 /*  Drink.  If no object, assume water and look for it here.  If water is in
572  *  the bottle, drink that, else must be at a water loc, so drink stream. */
573 {
574     if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
575         (LIQUID() != WATER || !HERE(BOTTLE))) {
576         return GO_UNKNOWN;
577     }
578
579     if (obj == BLOOD) {
580         DESTROY(BLOOD);
581         state_change(DRAGON, DRAGON_BLOODLESS);
582         game.blooded = true;
583         return GO_CLEAROBJ;
584     }
585
586     if (obj != INTRANSITIVE && obj != WATER) {
587         rspeak(RIDICULOUS_ATTEMPT);
588         return GO_CLEAROBJ;
589     }
590     if (LIQUID() == WATER && HERE(BOTTLE)) {
591         game.place[WATER] = LOC_NOWHERE;
592         state_change(BOTTLE, EMPTY_BOTTLE);
593         return GO_CLEAROBJ;
594     }
595
596     speak(actions[verb].message);
597     return GO_CLEAROBJ;
598 }
599
600 static phase_codes_t eat(verb_t verb, obj_t obj)
601 /*  Eat.  Intransitive: assume food if present, else ask what.  Transitive: food
602  *  ok, some things lose appetite, rest are ridiculous. */
603 {
604     switch (obj) {
605     case INTRANSITIVE:
606         if (!HERE(FOOD))
607             return GO_UNKNOWN;
608     /* FALLTHRU */
609     case FOOD:
610         DESTROY(FOOD);
611         rspeak(THANKS_DELICIOUS);
612         break;
613     case BIRD:
614     case SNAKE:
615     case CLAM:
616     case OYSTER:
617     case DWARF:
618     case DRAGON:
619     case TROLL:
620     case BEAR:
621     case OGRE:
622         rspeak(LOST_APPETITE);
623         break;
624     default:
625         speak(actions[verb].message);
626     }
627     return GO_CLEAROBJ;
628 }
629
630 static phase_codes_t extinguish(verb_t verb, obj_t obj)
631 /* Extinguish.  Lamp, urn, dragon/volcano (nice try). */
632 {
633     if (obj == INTRANSITIVE) {
634         if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
635             obj = LAMP;
636         if (HERE(URN) && game.prop[URN] == URN_LIT)
637             obj = URN;
638         if (obj == INTRANSITIVE)
639             return GO_UNKNOWN;
640     }
641
642     switch (obj) {
643     case URN:
644         if (game.prop[URN] != URN_EMPTY) {
645             state_change(URN, URN_DARK);
646         } else {
647             pspeak(URN, change, true, URN_DARK);
648         }
649         break;
650     case LAMP:
651         state_change(LAMP, LAMP_DARK);
652         rspeak(DARK(game.loc) ?
653                PITCH_DARK :
654                NO_MESSAGE);
655         break;
656     case DRAGON:
657     case VOLCANO:
658         rspeak(BEYOND_POWER);
659         break;
660     default:
661         speak(actions[verb].message);
662     }
663     return GO_CLEAROBJ;
664 }
665
666 static phase_codes_t feed(verb_t verb, obj_t obj)
667 /*  Feed.  If bird, no seed.  Snake, dragon, troll: quip.  If dwarf, make him
668  *  mad.  Bear, special. */
669 {
670     switch (obj) {
671     case BIRD:
672         rspeak(BIRD_PINING);
673         break;
674     case DRAGON:
675         if (game.prop[DRAGON] != DRAGON_BARS)
676             rspeak(RIDICULOUS_ATTEMPT);
677         else
678             rspeak(NOTHING_EDIBLE);
679         break;
680     case SNAKE:
681         if (!game.closed && HERE(BIRD)) {
682             DESTROY(BIRD);
683             rspeak(BIRD_DEVOURED);
684         } else
685             rspeak(NOTHING_EDIBLE);
686         break;
687     case TROLL:
688         rspeak(TROLL_VICES);
689         break;
690     case DWARF:
691         if (HERE(FOOD)) {
692             game.dflag += 2;
693             rspeak(REALLY_MAD);
694         } else
695             speak(actions[verb].message);
696         break;
697     case BEAR:
698         if (game.prop[BEAR] == BEAR_DEAD) {
699             rspeak(RIDICULOUS_ATTEMPT);
700             break;
701         }
702         if (game.prop[BEAR] == UNTAMED_BEAR) {
703             if (HERE(FOOD)) {
704                 DESTROY(FOOD);
705                 game.fixed[AXE] = IS_FREE;
706                 game.prop[AXE] = AXE_HERE;
707                 state_change(BEAR, SITTING_BEAR);
708             } else
709                 rspeak(NOTHING_EDIBLE);
710             break;
711         }
712         speak(actions[verb].message);
713         break;
714     case OGRE:
715         if (HERE(FOOD))
716             rspeak(OGRE_FULL);
717         else
718             speak(actions[verb].message);
719         break;
720     default:
721         rspeak(AM_GAME);
722     }
723     return GO_CLEAROBJ;
724 }
725
726 phase_codes_t fill(verb_t verb, obj_t obj)
727 /*  Fill.  Bottle or urn must be empty, and liquid available.  (Vase
728  *  is nasty.) */
729 {
730     if (obj == VASE) {
731         if (LIQLOC(game.loc) == NO_OBJECT) {
732             rspeak(FILL_INVALID);
733             return GO_CLEAROBJ;
734         }
735         if (!TOTING(VASE)) {
736             rspeak(ARENT_CARRYING);
737             return GO_CLEAROBJ;
738         }
739         rspeak(SHATTER_VASE);
740         game.prop[VASE] = VASE_BROKEN;
741         game.fixed[VASE] = IS_FIXED;
742         drop(VASE, game.loc);
743         return GO_CLEAROBJ;
744     }
745
746     if (obj == URN) {
747         if (game.prop[URN] != URN_EMPTY) {
748             rspeak(FULL_URN);
749             return GO_CLEAROBJ;
750         }
751         if (!HERE(BOTTLE)) {
752             rspeak(FILL_INVALID);
753             return GO_CLEAROBJ;
754         }
755         int k = LIQUID();
756         switch (k) {
757         case WATER:
758             game.prop[BOTTLE] = EMPTY_BOTTLE;
759             rspeak(WATER_URN);
760             break;
761         case OIL:
762             game.prop[URN] = URN_DARK;
763             game.prop[BOTTLE] = EMPTY_BOTTLE;
764             rspeak(OIL_URN);
765             break;
766         case NO_OBJECT:
767         default:
768             rspeak(FILL_INVALID);
769             return GO_CLEAROBJ;
770         }
771         game.place[k] = LOC_NOWHERE;
772         return GO_CLEAROBJ;
773     }
774     if (obj != INTRANSITIVE && obj != BOTTLE) {
775         speak(actions[verb].message);
776         return GO_CLEAROBJ;
777     }
778     if (obj == INTRANSITIVE && !HERE(BOTTLE))
779         return GO_UNKNOWN;
780
781     if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
782         rspeak(URN_NOPOUR);
783         return GO_CLEAROBJ;
784     }
785     if (LIQUID() != NO_OBJECT) {
786         rspeak(BOTTLE_FULL);
787         return GO_CLEAROBJ;
788     }
789     if (LIQLOC(game.loc) == NO_OBJECT) {
790         rspeak(NO_LIQUID);
791         return GO_CLEAROBJ;
792     }
793
794     state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
795                  ? OIL_BOTTLE
796                  : WATER_BOTTLE);
797     if (TOTING(BOTTLE))
798         game.place[LIQUID()] = CARRIED;
799     return GO_CLEAROBJ;
800 }
801
802 static phase_codes_t find(verb_t verb, obj_t obj)
803 /* Find.  Might be carrying it, or it might be here.  Else give caveat. */
804 {
805     if (TOTING(obj)) {
806         rspeak(ALREADY_CARRYING);
807         return GO_CLEAROBJ;
808     }
809
810     if (game.closed) {
811         rspeak(NEEDED_NEARBY);
812         return GO_CLEAROBJ;
813     }
814
815     if (AT(obj) ||
816         (LIQUID() == obj && AT(BOTTLE)) ||
817         obj == LIQLOC(game.loc) ||
818         (obj == DWARF && atdwrf(game.loc) > 0)) {
819         rspeak(YOU_HAVEIT);
820         return GO_CLEAROBJ;
821     }
822
823
824     speak(actions[verb].message);
825     return GO_CLEAROBJ;
826 }
827
828 static phase_codes_t fly(verb_t verb, obj_t obj)
829 /* Fly.  Snide remarks unless hovering rug is here. */
830 {
831     if (obj == INTRANSITIVE) {
832         if (!HERE(RUG)) {
833             rspeak(FLAP_ARMS);
834             return GO_CLEAROBJ;
835         }
836         if (game.prop[RUG] != RUG_HOVER) {
837             rspeak(RUG_NOTHING2);
838             return GO_CLEAROBJ;
839         }
840         obj = RUG;
841     }
842
843     if (obj != RUG) {
844         speak(actions[verb].message);
845         return GO_CLEAROBJ;
846     }
847     if (game.prop[RUG] != RUG_HOVER) {
848         rspeak(RUG_NOTHING1);
849         return GO_CLEAROBJ;
850     }
851
852     if (game.loc == LOC_CLIFF) {
853         game.oldlc2 = game.oldloc;
854         game.oldloc = game.loc;
855         game.newloc = LOC_LEDGE;
856         rspeak(RUG_GOES);
857     } else if (game.loc == LOC_LEDGE) {
858         game.oldlc2 = game.oldloc;
859         game.oldloc = game.loc;
860         game.newloc = LOC_CLIFF;
861         rspeak(RUG_RETURNS);
862     } else {
863 // LCOV_EXCL_START
864         /* should never happen */
865         rspeak(NOTHING_HAPPENS);
866 // LCOV_EXCL_STOP
867     }
868     return GO_TERMINATE;
869 }
870
871 static phase_codes_t inven(void)
872 /* Inventory. If object, treat same as find.  Else report on current burden. */
873 {
874     bool empty = true;
875     for (obj_t i = 1; i <= NOBJECTS; i++) {
876         if (i == BEAR ||
877             !TOTING(i))
878             continue;
879         if (empty) {
880             rspeak(NOW_HOLDING);
881             empty = false;
882         }
883         pspeak(i, touch, false, -1);
884     }
885     if (TOTING(BEAR))
886         rspeak(TAME_BEAR);
887     if (empty)
888         rspeak(NO_CARRY);
889     return GO_CLEAROBJ;
890 }
891
892 static phase_codes_t light(verb_t verb, obj_t obj)
893 /*  Light.  Applicable only to lamp and urn. */
894 {
895     if (obj == INTRANSITIVE) {
896         int selects = 0;
897         if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
898             obj = LAMP;
899             selects++;
900         }
901         if (HERE(URN) && game.prop[URN] == URN_DARK) {
902             obj =  URN;
903             selects++;
904         }
905         if (selects != 1)
906             return GO_UNKNOWN;
907     }
908
909     switch (obj) {
910     case URN:
911         state_change(URN, game.prop[URN] == URN_EMPTY ?
912                      URN_EMPTY :
913                      URN_LIT);
914         break;
915     case LAMP:
916         if (game.limit < 0) {
917             rspeak(LAMP_OUT);
918             break;
919         }
920         state_change(LAMP, LAMP_BRIGHT);
921         if (game.wzdark)
922             return GO_TOP;
923         break;
924     default:
925         speak(actions[verb].message);
926     }
927     return GO_CLEAROBJ;
928 }
929
930 static phase_codes_t listen(void)
931 /*  Listen.  Intransitive only.  Print stuff based on object sound properties. */
932 {
933     bool soundlatch = false;
934     vocab_t sound = locations[game.loc].sound;
935     if (sound != SILENT) {
936         rspeak(sound);
937         if (!locations[game.loc].loud)
938             rspeak(NO_MESSAGE);
939         soundlatch = true;
940     }
941     for (obj_t i = 1; i <= NOBJECTS; i++) {
942         if (!HERE(i) ||
943             objects[i].sounds[0] == NULL ||
944             game.prop[i] < 0)
945             continue;
946         int mi =  game.prop[i];
947         /* (ESR) Some unpleasant magic on object states here. Ideally
948          * we'd have liked the bird to be a normal object that we can
949          * use state_change() on; can't do it, because there are
950          * actually two different series of per-state birdsounds
951          * depending on whether player has drunk dragon's blood. */
952         if (i == BIRD)
953             mi += 3 * game.blooded;
954         pspeak(i, hear, true, mi, game.zzword);
955         rspeak(NO_MESSAGE);
956         if (i == BIRD && mi == BIRD_ENDSTATE)
957             DESTROY(BIRD);
958         soundlatch = true;
959     }
960     if (!soundlatch)
961         rspeak(ALL_SILENT);
962     return GO_CLEAROBJ;
963 }
964
965 static phase_codes_t lock(verb_t verb, obj_t obj)
966 /* Lock, unlock, no object given.  Assume various things if present. */
967 {
968     if (obj == INTRANSITIVE) {
969         if (HERE(CLAM))
970             obj = CLAM;
971         if (HERE(OYSTER))
972             obj = OYSTER;
973         if (AT(DOOR))
974             obj = DOOR;
975         if (AT(GRATE))
976             obj = GRATE;
977         if (HERE(CHAIN))
978             obj = CHAIN;
979         if (obj == INTRANSITIVE) {
980             rspeak(NOTHING_LOCKED);
981             return GO_CLEAROBJ;
982         }
983     }
984
985     /*  Lock, unlock object.  Special stuff for opening clam/oyster
986      *  and for chain. */
987
988     switch (obj) {
989     case CHAIN:
990         if (HERE(KEYS)) {
991             return chain(verb);
992         } else
993             rspeak(NO_KEYS);
994         break;
995     case GRATE:
996         if (HERE(KEYS)) {
997             if (game.closng) {
998                 rspeak(EXIT_CLOSED);
999                 if (!game.panic)
1000                     game.clock2 = PANICTIME;
1001                 game.panic = true;
1002             } else {
1003                 state_change(GRATE, (verb == LOCK) ?
1004                              GRATE_CLOSED :
1005                              GRATE_OPEN);
1006             }
1007         } else
1008             rspeak(NO_KEYS);
1009         break;
1010     case CLAM:
1011         if (verb == LOCK)
1012             rspeak(HUH_MAN);
1013         else if (TOTING(CLAM))
1014             rspeak(DROP_CLAM);
1015         else if (!TOTING(TRIDENT))
1016             rspeak(CLAM_OPENER);
1017         else {
1018             DESTROY(CLAM);
1019             drop(OYSTER, game.loc);
1020             drop(PEARL, LOC_CULDESAC);
1021             rspeak(PEARL_FALLS);
1022         }
1023         break;
1024     case OYSTER:
1025         if (verb == LOCK)
1026             rspeak(HUH_MAN);
1027         else if (TOTING(OYSTER))
1028             rspeak(DROP_OYSTER);
1029         else if (!TOTING(TRIDENT))
1030             rspeak(OYSTER_OPENER);
1031         else
1032             rspeak(OYSTER_OPENS);
1033         break;
1034     case DOOR:
1035         rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
1036         break;
1037     case CAGE:
1038         rspeak( NO_LOCK);
1039         break;
1040     case KEYS:
1041         rspeak(CANNOT_UNLOCK);
1042         break;
1043     default:
1044         speak(actions[verb].message);
1045     }
1046
1047     return GO_CLEAROBJ;
1048 }
1049
1050 static phase_codes_t pour(verb_t verb, obj_t obj)
1051 /*  Pour.  If no object, or object is bottle, assume contents of bottle.
1052  *  special tests for pouring water or oil on plant or rusty door. */
1053 {
1054     if (obj == BOTTLE ||
1055         obj == INTRANSITIVE)
1056         obj = LIQUID();
1057     if (obj == NO_OBJECT)
1058         return GO_UNKNOWN;
1059     if (!TOTING(obj)) {
1060         speak(actions[verb].message);
1061         return GO_CLEAROBJ;
1062     }
1063
1064     if (obj != OIL && obj != WATER) {
1065         rspeak(CANT_POUR);
1066         return GO_CLEAROBJ;
1067     }
1068     if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1069         return fill(verb, URN);
1070     game.prop[BOTTLE] = EMPTY_BOTTLE;
1071     game.place[obj] = LOC_NOWHERE;
1072     if (!(AT(PLANT) ||
1073           AT(DOOR))) {
1074         rspeak(GROUND_WET);
1075         return GO_CLEAROBJ;
1076     }
1077     if (!AT(DOOR)) {
1078         if (obj == WATER) {
1079             /* cycle through the three plant states */
1080             state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1081             game.prop[PLANT2] = game.prop[PLANT];
1082             return GO_MOVE;
1083         } else {
1084             rspeak(SHAKING_LEAVES);
1085             return GO_CLEAROBJ;
1086         }
1087     } else {
1088         state_change(DOOR, (obj == OIL) ?
1089                      DOOR_UNRUSTED :
1090                      DOOR_RUSTED);
1091         return GO_CLEAROBJ;
1092     }
1093 }
1094
1095 static phase_codes_t quit(void)
1096 /*  Quit.  Intransitive only.  Verify intent and exit if that's what he wants. */
1097 {
1098     if (yes_or_no(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1099         terminate(quitgame);
1100     return GO_CLEAROBJ;
1101 }
1102
1103 static phase_codes_t read(command_t command)
1104 /*  Read.  Print stuff based on objtxt.  Oyster (?) is special case. */
1105 {
1106     if (command.obj == INTRANSITIVE) {
1107         command.obj = NO_OBJECT;
1108         for (int i = 1; i <= NOBJECTS; i++) {
1109             if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1110                 command.obj = command.obj * NOBJECTS + i;
1111         }
1112         if (command.obj > NOBJECTS ||
1113             command.obj == NO_OBJECT ||
1114             DARK(game.loc))
1115             return GO_UNKNOWN;
1116     }
1117
1118     if (DARK(game.loc)) {
1119         sspeak(NO_SEE, command.word[0].raw);
1120     } else if (command.obj == OYSTER) {
1121         if (!TOTING(OYSTER) || !game.closed) {
1122             rspeak(DONT_UNDERSTAND);
1123         } else if (!game.clshnt) {
1124             game.clshnt = yes_or_no(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1125         } else {
1126             pspeak(OYSTER, hear, true, 1);      // Not really a sound, but oh well.
1127         }
1128     } else if (objects[command.obj].texts[0] == NULL ||
1129                game.prop[command.obj] == STATE_NOTFOUND) {
1130         speak(actions[command.verb].message);
1131     } else
1132         pspeak(command.obj, study, true, game.prop[command.obj]);
1133     return GO_CLEAROBJ;
1134 }
1135
1136 static phase_codes_t reservoir(void)
1137 /*  Z'ZZZ (word gets recomputed at startup; different each game). */
1138 {
1139     if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1140         rspeak(NOTHING_HAPPENS);
1141         return GO_CLEAROBJ;
1142     } else {
1143         state_change(RESER,
1144                      game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1145         if (AT(RESER))
1146             return GO_CLEAROBJ;
1147         else {
1148             game.oldlc2 = game.loc;
1149             game.newloc = LOC_NOWHERE;
1150             rspeak(NOT_BRIGHT);
1151             return GO_TERMINATE;
1152         }
1153     }
1154 }
1155
1156 static phase_codes_t rub(verb_t verb, obj_t obj)
1157 /* Rub.  Yields various snide remarks except for lit urn. */
1158 {
1159     if (obj == URN && game.prop[URN] == URN_LIT) {
1160         DESTROY(URN);
1161         drop(AMBER, game.loc);
1162         game.prop[AMBER] = AMBER_IN_ROCK;
1163         --game.tally;
1164         drop(CAVITY, game.loc);
1165         rspeak(URN_GENIES);
1166     } else if (obj != LAMP) {
1167         rspeak(PECULIAR_NOTHING);
1168     } else {
1169         speak(actions[verb].message);
1170     }
1171     return GO_CLEAROBJ;
1172 }
1173
1174 static phase_codes_t say(command_t command)
1175 /* Say.  Echo WD2. Magic words override. */
1176 {
1177     if (command.word[1].type == MOTION &&
1178         (command.word[1].id == XYZZY ||
1179          command.word[1].id == PLUGH ||
1180          command.word[1].id == PLOVER)) {
1181         return GO_WORD2;
1182     }
1183     if (command.word[1].type == ACTION && command.word[1].id == PART)
1184         return reservoir();
1185
1186     if (command.word[1].type == ACTION &&
1187         (command.word[1].id == FEE ||
1188          command.word[1].id == FIE ||
1189          command.word[1].id == FOE ||
1190          command.word[1].id == FOO ||
1191          command.word[1].id == FUM ||
1192          command.word[1].id == PART)) {
1193         return bigwords(command.word[1].id);
1194     }
1195     sspeak(OKEY_DOKEY, command.word[1].raw);
1196     return GO_CLEAROBJ;
1197 }
1198
1199 static phase_codes_t throw_support(vocab_t spk)
1200 {
1201     rspeak(spk);
1202     drop(AXE, game.loc);
1203     return GO_MOVE;
1204 }
1205
1206 static phase_codes_t throwit(command_t command)
1207 /*  Throw.  Same as discard unless axe.  Then same as attack except
1208  *  ignore bird, and if dwarf is present then one might be killed.
1209  *  (Only way to do so!)  Axe also special for dragon, bear, and
1210  *  troll.  Treasures special for troll. */
1211 {
1212     if (!TOTING(command.obj)) {
1213         speak(actions[command.verb].message);
1214         return GO_CLEAROBJ;
1215     }
1216     if (objects[command.obj].is_treasure && AT(TROLL)) {
1217         /*  Snarf a treasure for the troll. */
1218         drop(command.obj, LOC_NOWHERE);
1219         move(TROLL, LOC_NOWHERE);
1220         move(TROLL + NOBJECTS, IS_FREE);
1221         drop(TROLL2, objects[TROLL].plac);
1222         drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1223         juggle(CHASM);
1224         rspeak(TROLL_SATISFIED);
1225         return GO_CLEAROBJ;
1226     }
1227     if (command.obj == FOOD && HERE(BEAR)) {
1228         /* But throwing food is another story. */
1229         command.obj = BEAR;
1230         return (feed(command.verb, command.obj));
1231     }
1232     if (command.obj != AXE)
1233         return (discard(command.verb, command.obj));
1234     else {
1235         if (atdwrf(game.loc) <= 0) {
1236             if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1237                 return throw_support(DRAGON_SCALES);
1238             if (AT(TROLL))
1239                 return throw_support(TROLL_RETURNS);
1240             if (AT(OGRE))
1241                 return throw_support(OGRE_DODGE);
1242             if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1243                 /* This'll teach him to throw the axe at the bear! */
1244                 drop(AXE, game.loc);
1245                 game.fixed[AXE] = IS_FIXED;
1246                 juggle(BEAR);
1247                 state_change(AXE, AXE_LOST);
1248                 return GO_CLEAROBJ;
1249             }
1250             command.obj = INTRANSITIVE;
1251             return (attack(command));
1252         }
1253
1254         if (randrange(NDWARVES + 1) < game.dflag) {
1255             return throw_support(DWARF_DODGES);
1256         } else {
1257             int i = atdwrf(game.loc);
1258             game.dseen[i] = false;
1259             game.dloc[i] = LOC_NOWHERE;
1260             return throw_support((++game.dkill == 1) ?
1261                                  DWARF_SMOKE :
1262                                  KILLED_DWARF);
1263         }
1264     }
1265 }
1266
1267 static phase_codes_t wake(verb_t verb, obj_t obj)
1268 /* Wake.  Only use is to disturb the dwarves. */
1269 {
1270     if (obj != DWARF ||
1271         !game.closed) {
1272         speak(actions[verb].message);
1273         return GO_CLEAROBJ;
1274     } else {
1275         rspeak(PROD_DWARF);
1276         return GO_DWARFWAKE;
1277     }
1278 }
1279
1280 static phase_codes_t seed(verb_t verb, const char *arg)
1281 /* Set seed */
1282 {
1283     int32_t seed = strtol(arg, NULL, 10);
1284     speak(actions[verb].message, seed);
1285     set_seed(seed);
1286     --game.turns;
1287     return GO_TOP;
1288 }
1289
1290 static phase_codes_t waste(verb_t verb, turn_t turns)
1291 /* Burn turns */
1292 {
1293     game.limit -= turns;
1294     speak(actions[verb].message, (int)game.limit);
1295     return GO_TOP;
1296 }
1297
1298 static phase_codes_t wave(verb_t verb, obj_t obj)
1299 /* Wave.  No effect unless waving rod at fissure or at bird. */
1300 {
1301     if (obj != ROD ||
1302         !TOTING(obj) ||
1303         (!HERE(BIRD) &&
1304          (game.closng ||
1305           !AT(FISSURE)))) {
1306         speak(((!TOTING(obj)) && (obj != ROD ||
1307                                   !TOTING(ROD2))) ?
1308               arbitrary_messages[ARENT_CARRYING] :
1309               actions[verb].message);
1310         return GO_CLEAROBJ;
1311     }
1312
1313     if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1314         drop(JADE, game.loc);
1315         game.prop[JADE] = STATE_FOUND;
1316         --game.tally;
1317         rspeak(NECKLACE_FLY);
1318         return GO_CLEAROBJ;
1319     } else {
1320         if (game.closed) {
1321             rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1322                    CAGE_FLY :
1323                    FREE_FLY);
1324             return GO_DWARFWAKE;
1325         }
1326         if (game.closng ||
1327             !AT(FISSURE)) {
1328             rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1329                    CAGE_FLY :
1330                    FREE_FLY);
1331             return GO_CLEAROBJ;
1332         }
1333         if (HERE(BIRD))
1334             rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1335                    CAGE_FLY :
1336                    FREE_FLY);
1337
1338         state_change(FISSURE,
1339                      game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1340         return GO_CLEAROBJ;
1341     }
1342 }
1343
1344 phase_codes_t action(command_t command)
1345 /*  Analyse a verb.  Remember what it was, go back for object if second word
1346  *  unless verb is "say", which snarfs arbitrary second word.
1347  */
1348 {
1349     /* Previously, actions that result in a message, but don't do anything
1350      * further were called "specials". Now they're handled here as normal
1351      * actions. If noaction is true, then we spit out the message and return */
1352     if (actions[command.verb].noaction) {
1353         speak(actions[command.verb].message);
1354         return GO_CLEAROBJ;
1355     }
1356
1357     if (command.part == unknown) {
1358         /*  Analyse an object word.  See if the thing is here, whether
1359          *  we've got a verb yet, and so on.  Object must be here
1360          *  unless verb is "find" or "invent(ory)" (and no new verb
1361          *  yet to be analysed).  Water and oil are also funny, since
1362          *  they are never actually dropped at any location, but might
1363          *  be here inside the bottle or urn or as a feature of the
1364          *  location. */
1365         if (HERE(command.obj))
1366             /* FALL THROUGH */;
1367         else if (command.obj == DWARF && atdwrf(game.loc) > 0)
1368             /* FALL THROUGH */;
1369         else if (!game.closed && ((LIQUID() == command.obj && HERE(BOTTLE)) ||
1370                                   command.obj == LIQLOC(game.loc)))
1371             /* FALL THROUGH */;
1372         else if (command.obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1373             command.obj = URN;
1374             /* FALL THROUGH */;
1375         } else if (command.obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1376             command.obj = PLANT2;
1377             /* FALL THROUGH */;
1378         } else if (command.obj == KNIFE && game.knfloc == game.loc) {
1379             game.knfloc = -1;
1380             rspeak(KNIVES_VANISH);
1381             return GO_CLEAROBJ;
1382         } else if (command.obj == ROD && HERE(ROD2)) {
1383             command.obj = ROD2;
1384             /* FALL THROUGH */;
1385         } else if ((command.verb == FIND ||
1386                     command.verb == INVENTORY) && (command.word[1].id == WORD_EMPTY || command.word[1].id == WORD_NOT_FOUND))
1387             /* FALL THROUGH */;
1388         else {
1389             sspeak(NO_SEE, command.word[0].raw);
1390             return GO_CLEAROBJ;
1391         }
1392
1393         if (command.verb != 0)
1394             command.part = transitive;
1395     }
1396
1397     switch (command.part) {
1398     case intransitive:
1399         if (command.word[1].raw[0] != '\0' && command.verb != SAY)
1400             return GO_WORD2;
1401         if (command.verb == SAY)
1402             /* KEYS is not special, anything not NO_OBJECT or INTRANSITIVE
1403              * will do here. We're preventing interpretation as an intransitive
1404              * verb when the word is unknown. */
1405             command.obj = command.word[1].raw[0] != '\0' ? KEYS : NO_OBJECT;
1406         if (command.obj == NO_OBJECT ||
1407             command.obj == INTRANSITIVE) {
1408             /*  Analyse an intransitive verb (ie, no object given yet). */
1409             switch (command.verb) {
1410             case CARRY:
1411                 return vcarry(command.verb, INTRANSITIVE);
1412             case  DROP:
1413                 return GO_UNKNOWN;
1414             case  SAY:
1415                 return GO_UNKNOWN;
1416             case  UNLOCK:
1417                 return lock(command.verb, INTRANSITIVE);
1418             case  NOTHING: {
1419                 rspeak(OK_MAN);
1420                 return (GO_CLEAROBJ);
1421             }
1422             case  LOCK:
1423                 return lock(command.verb, INTRANSITIVE);
1424             case  LIGHT:
1425                 return light(command.verb, INTRANSITIVE);
1426             case  EXTINGUISH:
1427                 return extinguish(command.verb, INTRANSITIVE);
1428             case  WAVE:
1429                 return GO_UNKNOWN;
1430             case  TAME:
1431                 return GO_UNKNOWN;
1432             case GO: {
1433                 speak(actions[command.verb].message);
1434                 return GO_CLEAROBJ;
1435             }
1436             case ATTACK:
1437                 command.obj = INTRANSITIVE;
1438                 return attack(command);
1439             case POUR:
1440                 return pour(command.verb, INTRANSITIVE);
1441             case EAT:
1442                 return eat(command.verb, INTRANSITIVE);
1443             case DRINK:
1444                 return drink(command.verb, INTRANSITIVE);
1445             case RUB:
1446                 return GO_UNKNOWN;
1447             case THROW:
1448                 return GO_UNKNOWN;
1449             case QUIT:
1450                 return quit();
1451             case FIND:
1452                 return GO_UNKNOWN;
1453             case INVENTORY:
1454                 return inven();
1455             case FEED:
1456                 return GO_UNKNOWN;
1457             case FILL:
1458                 return fill(command.verb, INTRANSITIVE);
1459             case BLAST:
1460                 blast();
1461                 return GO_CLEAROBJ;
1462             case SCORE:
1463                 score(scoregame);
1464                 return GO_CLEAROBJ;
1465             case FEE:
1466             case FIE:
1467             case FOE:
1468             case FOO:
1469             case FUM:
1470                 return bigwords(command.word[0].id);
1471             case BRIEF:
1472                 return brief();
1473             case READ:
1474                 command.obj = INTRANSITIVE;
1475                 return read(command);
1476             case BREAK:
1477                 return GO_UNKNOWN;
1478             case WAKE:
1479                 return GO_UNKNOWN;
1480             case SAVE:
1481                 return suspend();
1482             case RESUME:
1483                 return resume();
1484             case FLY:
1485                 return fly(command.verb, INTRANSITIVE);
1486             case LISTEN:
1487                 return listen();
1488             case PART:
1489                 return reservoir();
1490             case SEED:
1491             case WASTE:
1492                 rspeak(NUMERIC_REQUIRED);
1493                 return GO_TOP;
1494             default: // LCOV_EXCL_LINE
1495                 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1496             }
1497         }
1498     /* FALLTHRU */
1499     case transitive:
1500         /*  Analyse a transitive verb. */
1501         switch (command.verb) {
1502         case  CARRY:
1503             return vcarry(command.verb, command.obj);
1504         case  DROP:
1505             return discard(command.verb, command.obj);
1506         case  SAY:
1507             return say(command);
1508         case  UNLOCK:
1509             return lock(command.verb, command.obj);
1510         case  NOTHING: {
1511             rspeak(OK_MAN);
1512             return (GO_CLEAROBJ);
1513         }
1514         case  LOCK:
1515             return lock(command.verb, command.obj);
1516         case LIGHT:
1517             return light(command.verb, command.obj);
1518         case EXTINGUISH:
1519             return extinguish(command.verb, command.obj);
1520         case WAVE:
1521             return wave(command.verb, command.obj);
1522         case TAME: {
1523             speak(actions[command.verb].message);
1524             return GO_CLEAROBJ;
1525         }
1526         case GO: {
1527             speak(actions[command.verb].message);
1528             return GO_CLEAROBJ;
1529         }
1530         case ATTACK:
1531             return attack(command);
1532         case POUR:
1533             return pour(command.verb, command.obj);
1534         case EAT:
1535             return eat(command.verb, command.obj);
1536         case DRINK:
1537             return drink(command.verb, command.obj);
1538         case RUB:
1539             return rub(command.verb, command.obj);
1540         case THROW:
1541             return throwit(command);
1542         case QUIT: {
1543             speak(actions[command.verb].message);
1544             return GO_CLEAROBJ;
1545         }
1546         case FIND:
1547             return find(command.verb, command.obj);
1548         case INVENTORY:
1549             return find(command.verb, command.obj);
1550         case FEED:
1551             return feed(command.verb, command.obj);
1552         case FILL:
1553             return fill(command.verb, command.obj);
1554         case BLAST:
1555             blast();
1556             return GO_CLEAROBJ;
1557         case SCORE: {
1558             speak(actions[command.verb].message);
1559             return GO_CLEAROBJ;
1560         }
1561         case FEE:
1562         case FIE:
1563         case FOE:
1564         case FOO:
1565         case FUM: {
1566             speak(actions[command.verb].message);
1567             return GO_CLEAROBJ;
1568         }
1569         case BRIEF: {
1570             speak(actions[command.verb].message);
1571             return GO_CLEAROBJ;
1572         }
1573         case READ:
1574             return read(command);
1575         case BREAK:
1576             return vbreak(command.verb, command.obj);
1577         case WAKE:
1578             return wake(command.verb, command.obj);
1579         case SAVE: {
1580             speak(actions[command.verb].message);
1581             return GO_CLEAROBJ;
1582         }
1583         case RESUME: {
1584             speak(actions[command.verb].message);
1585             return GO_CLEAROBJ;
1586         }
1587         case FLY:
1588             return fly(command.verb, command.obj);
1589         case LISTEN: {
1590             speak(actions[command.verb].message);
1591             return GO_CLEAROBJ;
1592         }
1593         // LCOV_EXCL_START
1594         // This case should never happen - here only as placeholder
1595         case PART:
1596             return reservoir();
1597         // LCOV_EXCL_STOP
1598         case SEED:
1599             return seed(command.verb, command.word[1].raw);
1600         case WASTE:
1601             return waste(command.verb, (turn_t)atol(command.word[1].raw));
1602         default: // LCOV_EXCL_LINE
1603             BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1604         }
1605     case unknown:
1606         /* Unknown verb, couldn't deduce object - might need hint */
1607         sspeak(WHAT_DO, command.word[0].raw);
1608         return GO_CHECKHINT;
1609     default: // LCOV_EXCL_LINE
1610         BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE
1611     }
1612 }