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