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