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