59ec428f506127b5b2612f282ca34e5da5b31c44
[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] = -1;
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] != 0) {
306         if (obj == PLANT && game.prop[PLANT] <= 0) {
307             rspeak(DEEP_ROOTS);
308             return GO_CLEAROBJ;
309         }
310         if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
311             rspeak(BEAR_CHAINED);
312             return GO_CLEAROBJ;
313         }
314         if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
315             rspeak(STILL_LOCKED);
316             return GO_CLEAROBJ;
317         }
318         if (obj == URN) {
319             rspeak(URN_NOBUDGE);
320             return GO_CLEAROBJ;
321         }
322         if (obj == CAVITY) {
323             rspeak(DOUGHNUT_HOLES);
324             return GO_CLEAROBJ;
325         }
326         if (obj == BLOOD) {
327             rspeak(FEW_DROPS);
328             return GO_CLEAROBJ;
329         }
330         if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
331             rspeak(RUG_HOVERS);
332             return GO_CLEAROBJ;
333         }
334         if (obj == SIGN) {
335             rspeak(HAND_PASSTHROUGH);
336             return GO_CLEAROBJ;
337         }
338         rspeak(YOU_JOKING);
339         return GO_CLEAROBJ;
340     }
341
342     if (obj == WATER ||
343         obj == OIL) {
344         if (!HERE(BOTTLE) ||
345             LIQUID() != obj) {
346             if (TOTING(BOTTLE)) {
347                 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
348                     return (fill(verb, BOTTLE));
349                 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
350                     rspeak(BOTTLE_FULL);
351                 return GO_CLEAROBJ;
352             }
353             rspeak(NO_CONTAINER);
354             return GO_CLEAROBJ;
355         }
356         obj = BOTTLE;
357     }
358
359     if (game.holdng >= INVLIMIT) {
360         rspeak(CARRY_LIMIT);
361         return GO_CLEAROBJ;
362
363     }
364
365     if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
366         if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
367             DESTROY(BIRD);
368             rspeak(BIRD_CRAP);
369             return GO_CLEAROBJ;
370         }
371         if (!TOTING(CAGE)) {
372             rspeak(CANNOT_CARRY);
373             return GO_CLEAROBJ;
374         }
375         if (TOTING(ROD)) {
376             rspeak(BIRD_EVADES);
377             return GO_CLEAROBJ;
378         }
379         game.prop[BIRD] = BIRD_CAGED;
380     }
381     if ((obj == BIRD ||
382          obj == CAGE) &&
383         (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
384         /* expression maps BIRD to CAGE and CAGE to BIRD */
385         carry(BIRD + CAGE - obj, game.loc);
386     carry(obj, game.loc);
387     if (obj == BOTTLE && LIQUID() != NO_OBJECT)
388         game.place[LIQUID()] = CARRIED;
389     if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
390         game.prop[obj] = STATE_FOUND;
391         game.prop[CAVITY] = CAVITY_EMPTY;
392     }
393     rspeak(OK_MAN);
394     return GO_CLEAROBJ;
395 }
396
397 static int chain(token_t verb)
398 /* Do something to the bear's chain */
399 {
400     if (verb != LOCK) {
401         if (game.prop[BEAR] == UNTAMED_BEAR) {
402             rspeak(BEAR_BLOCKS);
403             return GO_CLEAROBJ;
404         }
405         if (game.prop[CHAIN] == CHAIN_HEAP) {
406             rspeak(ALREADY_UNLOCKED);
407             return GO_CLEAROBJ;
408         }
409         game.prop[CHAIN] = CHAIN_HEAP;
410         game.fixed[CHAIN] = CHAIN_HEAP;
411         if (game.prop[BEAR] != BEAR_DEAD)
412             game.prop[BEAR] = CONTENTED_BEAR;
413
414         switch (game.prop[BEAR]) {
415         case BEAR_DEAD:
416             game.fixed[BEAR] = -1;
417             break;
418         default:
419             game.fixed[BEAR] = 0;
420         }
421         rspeak(CHAIN_UNLOCKED);
422         return GO_CLEAROBJ;
423     }
424
425     if (game.prop[CHAIN] != CHAIN_HEAP) {
426         rspeak(ALREADY_LOCKED);
427         return GO_CLEAROBJ;
428     }
429     if (game.loc != objects[CHAIN].plac) {
430         rspeak(NO_LOCKSITE);
431         return GO_CLEAROBJ;
432     }
433
434     game.prop[CHAIN] = CHAIN_FIXED;
435
436     if (TOTING(CHAIN))
437         drop(CHAIN, game.loc);
438     game.fixed[CHAIN] = -1;
439
440     rspeak(CHAIN_LOCKED);
441     return GO_CLEAROBJ;
442 }
443
444 static int discard(token_t verb, token_t obj, bool just_do_it)
445 /*  Discard object.  "Throw" also comes here for most objects.  Special cases for
446  *  bird (might attack snake or dragon) and cage (might contain bird) and vase.
447  *  Drop coins at vending machine for extra batteries. */
448 {
449     if (!just_do_it) {
450         if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
451             obj = ROD2;
452         if (!TOTING(obj)) {
453             rspeak(actions[verb].message);
454             return GO_CLEAROBJ;
455         }
456         if (obj == BIRD && HERE(SNAKE)) {
457             rspeak(BIRD_ATTACKS);
458             if (game.closed)
459                 return GO_DWARFWAKE;
460             DESTROY(SNAKE);
461             /* Set game.prop for use by travel options */
462             game.prop[SNAKE] = SNAKE_CHASED;
463
464         } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
465             rspeak(GEM_FITS);
466             game.prop[obj] = STATE_IN_CAVITY;
467             game.prop[CAVITY] = CAVITY_FULL;
468             if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
469                               (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
470                 int spk = RUG_RISES;
471                 if (TOTING(RUG))
472                     spk = RUG_WIGGLES;
473                 if (obj == RUBY)
474                     spk = RUG_SETTLES;
475                 rspeak(spk);
476                 if (spk != RUG_WIGGLES) {
477                     /* FIXME: Arithmetic on state numbers */
478                     int k = 2 - game.prop[RUG];
479                     game.prop[RUG] = k;
480                     if (k == RUG_HOVER)
481                         k = objects[SAPPH].plac;
482                     move(RUG + NOBJECTS, k);
483                 }
484             }
485         } else if (obj == COINS && HERE(VEND)) {
486             DESTROY(COINS);
487             drop(BATTERY, game.loc);
488             pspeak(BATTERY, look, FRESH_BATTERIES, true);
489             return GO_CLEAROBJ;
490         } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
491             rspeak(BIRD_BURNT);
492             DESTROY(BIRD);
493             return GO_CLEAROBJ;
494         } else if (obj == BEAR && AT(TROLL)) {
495             state_change(TROLL, TROLL_GONE);
496             move(TROLL, LOC_NOWHERE);
497             move(TROLL + NOBJECTS, LOC_NOWHERE);
498             move(TROLL2, objects[TROLL].plac);
499             move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
500             juggle(CHASM);
501         } else if (obj != VASE ||
502                    game.loc == objects[PILLOW].plac) {
503             rspeak(OK_MAN);
504         } else {
505             state_change(VASE, AT(PILLOW)
506                          ? VASE_WHOLE
507                          : VASE_DROPPED);
508             if (game.prop[VASE] != VASE_WHOLE)
509                 game.fixed[VASE] = -1;
510         }
511     }
512     int k = LIQUID();
513     if (k == obj)
514         obj = BOTTLE;
515     if (obj == BOTTLE && k != NO_OBJECT)
516         game.place[k] = LOC_NOWHERE;
517     if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
518         drop(BIRD, game.loc);
519     drop(obj, game.loc);
520     if (obj != BIRD)
521         return GO_CLEAROBJ;
522     game.prop[BIRD] = BIRD_UNCAGED;
523     if (FOREST(game.loc))
524         game.prop[BIRD] = BIRD_FOREST_UNCAGED;
525     return GO_CLEAROBJ;
526 }
527
528 static int drink(token_t verb, token_t obj)
529 /*  Drink.  If no object, assume water and look for it here.  If water is in
530  *  the bottle, drink that, else must be at a water loc, so drink stream. */
531 {
532     if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
533         (LIQUID() != WATER || !HERE(BOTTLE))) {
534         return GO_UNKNOWN;
535     }
536
537     if (obj == BLOOD) {
538         DESTROY(BLOOD);
539         state_change(DRAGON, DRAGON_BLOODLESS);
540         game.blooded = true;
541         return GO_CLEAROBJ;
542     }
543
544     if (obj != NO_OBJECT && obj != WATER) {
545         rspeak(RIDICULOUS_ATTEMPT);
546         return GO_CLEAROBJ;
547     }
548     if (LIQUID() == WATER && HERE(BOTTLE)) {
549         game.prop[BOTTLE] = EMPTY_BOTTLE;
550         game.place[WATER] = LOC_NOWHERE;
551         rspeak(BOTTLE_EMPTY);
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] = 0;
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] = -1;
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     game.prop[BOTTLE] = (LIQLOC(game.loc) == OIL) ? OIL_BOTTLE : WATER_BOTTLE;
745     if (TOTING(BOTTLE))
746         game.place[LIQUID()] = CARRIED;
747     if (LIQUID() == OIL)
748         rspeak(BOTTLED_OIL);
749     else
750         rspeak(BOTTLED_WATER);
751     return GO_CLEAROBJ;
752 }
753
754 static int find(token_t verb, token_t obj)
755 /* Find.  Might be carrying it, or it might be here.  Else give caveat. */
756 {
757     if (TOTING(obj)) {
758         rspeak(ALREADY_CARRYING);
759         return GO_CLEAROBJ;
760     }
761
762     if (game.closed) {
763         rspeak(NEEDED_NEARBY);
764         return GO_CLEAROBJ;
765     }
766
767     if (AT(obj) ||
768         (LIQUID() == obj && AT(BOTTLE)) ||
769         obj == LIQLOC(game.loc) ||
770         (obj == DWARF && atdwrf(game.loc) > 0)) {
771         rspeak(YOU_HAVEIT);
772         return GO_CLEAROBJ;
773     }
774
775
776     rspeak(actions[verb].message);
777     return GO_CLEAROBJ;
778 }
779
780 static int fly(token_t verb, token_t obj)
781 /* Fly.  Snide remarks unless hovering rug is here. */
782 {
783     if (obj == INTRANSITIVE) {
784         if (!HERE(RUG)) {
785             rspeak(FLAP_ARMS);
786             return GO_CLEAROBJ;
787         }
788         if (game.prop[RUG] != RUG_HOVER) {
789             rspeak(RUG_NOTHING2);
790             return GO_CLEAROBJ;
791         }
792         obj = RUG;
793     }
794
795     if (obj != RUG) {
796         rspeak(actions[verb].message);
797         return GO_CLEAROBJ;
798     }
799     if (game.prop[RUG] != RUG_HOVER) {
800         rspeak(RUG_NOTHING1);
801         return GO_CLEAROBJ;
802     }
803     game.oldlc2 = game.oldloc;
804     game.oldloc = game.loc;
805     /* FIXME: Arithmetic on location values */
806     game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
807
808     if (game.prop[SAPPH] >= 0) {
809         rspeak(RUG_RETURNS);
810     } else {
811         rspeak(RUG_GOES);
812     }
813     return GO_TERMINATE;
814 }
815
816 static int inven(void)
817 /* Inventory. If object, treat same as find.  Else report on current burden. */
818 {
819     bool empty = true;
820     for (int i = 1; i <= NOBJECTS; i++) {
821         if (i == BEAR ||
822             !TOTING(i))
823             continue;
824         if (empty) {
825             rspeak(NOW_HOLDING);
826             empty = false;
827         }
828         pspeak(i, touch, -1, false);
829     }
830     if (TOTING(BEAR))
831         rspeak(TAME_BEAR);
832     if (empty)
833         rspeak(NO_CARRY);
834     return GO_CLEAROBJ;
835 }
836
837 static int light(token_t verb, token_t obj)
838 /*  Light.  Applicable only to lamp and urn. */
839 {
840     if (obj == INTRANSITIVE) {
841         if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
842             obj = LAMP;
843         if (HERE(URN) && game.prop[URN] == URN_DARK)
844             obj =  URN;
845         if (obj == INTRANSITIVE ||
846             (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
847              HERE(URN) && game.prop[URN] == URN_DARK))
848             return GO_UNKNOWN;
849     }
850
851     if (obj == URN) {
852         state_change(URN, game.prop[URN] == URN_EMPTY ?
853                      URN_EMPTY :
854                      URN_LIT);
855         return GO_CLEAROBJ;
856     } else {
857         if (obj != LAMP) {
858             rspeak(actions[verb].message);
859             return GO_CLEAROBJ;
860         }
861         if (game.limit < 0) {
862             rspeak(LAMP_OUT);
863             return GO_CLEAROBJ;
864         }
865         state_change(LAMP, LAMP_BRIGHT);
866         if (game.wzdark)
867             return GO_TOP;
868         else
869             return GO_CLEAROBJ;
870     }
871 }
872
873 static int listen(void)
874 /*  Listen.  Intransitive only.  Print stuff based on objsnd/locsnd. */
875 {
876     long sound = locations[game.loc].sound;
877     if (sound != SILENT) {
878         rspeak(sound);
879         if (!locations[game.loc].loud)
880             rspeak(NO_MESSAGE);
881         return GO_CLEAROBJ;
882     }
883     for (int i = 1; i <= NOBJECTS; i++) {
884         if (!HERE(i) ||
885             objects[i].sounds[0] == NULL ||
886             game.prop[i] < 0)
887             continue;
888         int mi =  game.prop[i];
889         if (i == BIRD)
890             mi += 3 * game.blooded;
891         long packed_zzword = token_to_packed(game.zzword);
892         pspeak(i, hear, mi, true, packed_zzword);
893         rspeak(NO_MESSAGE);
894         /* FIXME: Magic number, sensitive to bird state logic */
895         if (i == BIRD && game.prop[i] == 5)
896             DESTROY(BIRD);
897         return GO_CLEAROBJ;
898     }
899     rspeak(ALL_SILENT);
900     return GO_CLEAROBJ;
901 }
902
903 static int lock(token_t verb, token_t obj)
904 /* Lock, unlock, no object given.  Assume various things if present. */
905 {
906     if (obj == INTRANSITIVE) {
907         if (HERE(CLAM))
908             obj = CLAM;
909         if (HERE(OYSTER))
910             obj = OYSTER;
911         if (AT(DOOR))
912             obj = DOOR;
913         if (AT(GRATE))
914             obj = GRATE;
915         if (HERE(CHAIN))
916             obj = CHAIN;
917         if (obj == INTRANSITIVE) {
918             rspeak(NOTHING_LOCKED);
919             return GO_CLEAROBJ;
920         }
921     }
922
923     /*  Lock, unlock object.  Special stuff for opening clam/oyster
924      *  and for chain. */
925     if (obj == GRATE ||
926         obj == CHAIN) {
927         if (HERE(KEYS)) {
928             if (obj == CHAIN)
929                 return chain(verb);
930             if (game.closng) {
931                 rspeak(EXIT_CLOSED);
932                 if (!game.panic)
933                     game.clock2 = PANICTIME;
934                 game.panic = true;
935                 return GO_CLEAROBJ ;
936             } else {
937                 state_change(GRATE, (verb == LOCK) ?
938                              GRATE_CLOSED :
939                              GRATE_OPEN);
940                 return GO_CLEAROBJ;
941             }
942         }
943         rspeak(NO_KEYS);
944         return GO_CLEAROBJ;
945     }
946
947     switch (obj) {
948     case CLAM:
949         if (verb == LOCK)
950             rspeak(HUH_MAN);
951         else if (!TOTING(TRIDENT))
952             rspeak(OYSTER_OPENER);
953         else {
954             DESTROY(CLAM);
955             drop(OYSTER, game.loc);
956             drop(PEARL, LOC_CULDESAC);
957             rspeak(PEARL_FALLS);
958         }
959         return GO_CLEAROBJ;
960     case OYSTER:
961         if (verb == LOCK)
962             rspeak(HUH_MAN);
963         else
964             rspeak(OYSTER_OPENER);
965
966         return GO_CLEAROBJ;
967     case DOOR:
968         rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
969         break;
970     case CAGE:
971         rspeak( NO_LOCK);
972         break;
973     case KEYS:
974         rspeak(CANNOT_UNLOCK);
975         break;
976     default:
977         rspeak(actions[verb].message);
978     }
979
980     return GO_CLEAROBJ;
981 }
982
983 static int pour(token_t verb, token_t obj)
984 /*  Pour.  If no object, or object is bottle, assume contents of bottle.
985  *  special tests for pouring water or oil on plant or rusty door. */
986 {
987     if (obj == BOTTLE ||
988         obj == NO_OBJECT)
989         obj = LIQUID();
990     if (obj == NO_OBJECT)
991         return GO_UNKNOWN;
992     if (!TOTING(obj)) {
993         rspeak(actions[verb].message);
994         return GO_CLEAROBJ;
995     }
996
997     if (obj != OIL && obj != WATER) {
998         rspeak(CANT_POUR);
999         return GO_CLEAROBJ;
1000     }
1001     if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1002         return fill(verb, URN);
1003     game.prop[BOTTLE] = EMPTY_BOTTLE;
1004     game.place[obj] = LOC_NOWHERE;
1005     if (!(AT(PLANT) ||
1006           AT(DOOR))) {
1007         rspeak(GROUND_WET);
1008         return GO_CLEAROBJ;
1009     }
1010     if (!AT(DOOR)) {
1011         if (obj == WATER) {
1012             /* cycle through the three plant states */
1013             state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1014             game.prop[PLANT2] = game.prop[PLANT];
1015             return GO_MOVE;
1016         } else {
1017             rspeak(SHAKING_LEAVES);
1018             return GO_CLEAROBJ;
1019         }
1020     } else {
1021         state_change(DOOR, (obj == OIL) ?
1022                      DOOR_UNRUSTED :
1023                      DOOR_RUSTED);
1024         return GO_CLEAROBJ;
1025     }
1026 }
1027
1028 static int quit(void)
1029 /*  Quit.  Intransitive only.  Verify intent and exit if that's what he wants. */
1030 {
1031     if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1032         terminate(quitgame);
1033     return GO_CLEAROBJ;
1034 }
1035
1036 static int read(struct command_t command)
1037 /*  Read.  Print stuff based on objtxt.  Oyster (?) is special case. */
1038 {
1039     if (command.obj == INTRANSITIVE) {
1040         command.obj = 0;
1041         for (int i = 1; i <= NOBJECTS; i++) {
1042             if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1043                 command.obj = command.obj * NOBJECTS + i;
1044         }
1045         if (command.obj > NOBJECTS ||
1046             command.obj == 0 ||
1047             DARK(game.loc))
1048             return GO_UNKNOWN;
1049     }
1050
1051     if (DARK(game.loc)) {
1052         sspeak(NO_SEE, command.raw1);
1053     } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1054         game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1055     } else if (objects[command.obj].texts[0] == NULL ||
1056                game.prop[command.obj] < 0) {
1057         rspeak(actions[command.verb].message);
1058     } else
1059         pspeak(command.obj, study, game.prop[command.obj], true);
1060     return GO_CLEAROBJ;
1061 }
1062
1063 static int reservoir(void)
1064 /*  Z'ZZZ (word gets recomputed at startup; different each game). */
1065 {
1066     /* FIXME: Arithmetic on state numbers */
1067     if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
1068         rspeak(NOTHING_HAPPENS);
1069         return GO_CLEAROBJ;
1070     } else {
1071         state_change(RESER,
1072                      game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1073         if (AT(RESER))
1074             return GO_CLEAROBJ;
1075         else {
1076             game.oldlc2 = game.loc;
1077             game.newloc = LOC_NOWHERE;
1078             rspeak(NOT_BRIGHT);
1079             return GO_TERMINATE;
1080         }
1081     }
1082 }
1083
1084 static int rub(token_t verb, token_t obj)
1085 /* Rub.  Yields various snide remarks except for lit urn. */
1086 {
1087     if (obj == URN && game.prop[URN] == URN_LIT) {
1088         DESTROY(URN);
1089         drop(AMBER, game.loc);
1090         game.prop[AMBER] = AMBER_IN_ROCK;
1091         --game.tally;
1092         drop(CAVITY, game.loc);
1093         rspeak(URN_GENIES);
1094     } else if (obj != LAMP) {
1095         rspeak(PECULIAR_NOTHING);
1096     } else {
1097         rspeak(actions[verb].message);
1098     }
1099     return GO_CLEAROBJ;
1100 }
1101
1102 static int say(struct command_t *command)
1103 /* Say.  Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).)  Magic words override. */
1104 {
1105     if (command->wd2 > 0) {
1106         command->wd1 = command->wd2;
1107         strcpy(command->raw1, command->raw2);
1108     }
1109     char word1[TOKLEN + 1];
1110     packed_to_token(command->wd1, word1);
1111     int wd = (int) get_vocab_id(word1);
1112     if (wd == MOTION_WORD(XYZZY) ||
1113         wd == MOTION_WORD(PLUGH) ||
1114         wd == MOTION_WORD(PLOVER) ||
1115         wd == ACTION_WORD(GIANTWORDS) ||
1116         wd == ACTION_WORD(PART)) {
1117         /* FIXME: scribbles on the interpreter's command block */
1118         wordclear(&command->wd2);
1119         return GO_LOOKUP;
1120     }
1121     sspeak(OKEY_DOKEY, command->raw1);
1122     return GO_CLEAROBJ;
1123 }
1124
1125 static int throw_support(long spk)
1126 {
1127     rspeak(spk);
1128     drop(AXE, game.loc);
1129     return GO_MOVE;
1130 }
1131
1132 static int throw (struct command_t *command)
1133 /*  Throw.  Same as discard unless axe.  Then same as attack except
1134  *  ignore bird, and if dwarf is present then one might be killed.
1135  *  (Only way to do so!)  Axe also special for dragon, bear, and
1136  *  troll.  Treasures special for troll. */
1137 {
1138     if (!TOTING(command->obj)) {
1139         rspeak(actions[command->verb].message);
1140         return GO_CLEAROBJ;
1141     }
1142     if (objects[command->obj].is_treasure && AT(TROLL)) {
1143         /*  Snarf a treasure for the troll. */
1144         drop(command->obj, LOC_NOWHERE);
1145         move(TROLL, LOC_NOWHERE);
1146         move(TROLL + NOBJECTS, LOC_NOWHERE);
1147         drop(TROLL2, objects[TROLL].plac);
1148         drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1149         juggle(CHASM);
1150         rspeak(TROLL_SATISFIED);
1151         return GO_CLEAROBJ;
1152     }
1153     if (command->obj == FOOD && HERE(BEAR)) {
1154         /* But throwing food is another story. */
1155         command->obj = BEAR;
1156         return (feed(command->verb, command->obj));
1157     }
1158     if (command->obj != AXE)
1159         return (discard(command->verb, command->obj, false));
1160     else {
1161         if (atdwrf(game.loc) <= 0) {
1162             if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1163                 return throw_support(DRAGON_SCALES);
1164             if (AT(TROLL))
1165                 return throw_support(TROLL_RETURNS);
1166             else if (AT(OGRE))
1167                 return throw_support(OGRE_DODGE);
1168             else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1169                 /* This'll teach him to throw the axe at the bear! */
1170                 drop(AXE, game.loc);
1171                 game.fixed[AXE] = -1;
1172                 juggle(BEAR);
1173                 state_change(AXE, AXE_LOST);
1174                 return GO_CLEAROBJ;
1175             }
1176             command->obj = NO_OBJECT;
1177             return (attack(command));
1178         }
1179
1180         if (randrange(NDWARVES + 1) < game.dflag) {
1181             return throw_support(DWARF_DODGES);
1182         } else {
1183             long i = atdwrf(game.loc);
1184             game.dseen[i] = false;
1185             game.dloc[i] = LOC_NOWHERE;
1186             return throw_support((++game.dkill == 1) ?
1187                                  DWARF_SMOKE :
1188                                  KILLED_DWARF);
1189         }
1190     }
1191 }
1192
1193 static int wake(token_t verb, token_t obj)
1194 /* Wake.  Only use is to disturb the dwarves. */
1195 {
1196     if (obj != DWARF ||
1197         !game.closed) {
1198         rspeak(actions[verb].message);
1199         return GO_CLEAROBJ;
1200     } else {
1201         rspeak(PROD_DWARF);
1202         return GO_DWARFWAKE;
1203     }
1204 }
1205
1206 static int wave(token_t verb, token_t obj)
1207 /* Wave.  No effect unless waving rod at fissure or at bird. */
1208 {
1209     if (obj != ROD ||
1210         !TOTING(obj) ||
1211         (!HERE(BIRD) &&
1212          (game.closng ||
1213           !AT(FISSURE)))) {
1214         rspeak(((!TOTING(obj)) && (obj != ROD ||
1215                                    !TOTING(ROD2))) ?
1216                ARENT_CARRYING :
1217                actions[verb].message);
1218         return GO_CLEAROBJ;
1219     }
1220
1221     if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1222         drop(JADE, game.loc);
1223         game.prop[JADE] = STATE_FOUND;
1224         --game.tally;
1225         rspeak(NECKLACE_FLY);
1226         return GO_CLEAROBJ;
1227     } else {
1228         if (game.closed) {
1229             rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1230                    CAGE_FLY :
1231                    FREE_FLY);
1232             return GO_DWARFWAKE;
1233         }
1234         if (game.closng ||
1235             !AT(FISSURE)) {
1236             rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1237                    CAGE_FLY :
1238                    FREE_FLY);
1239             return GO_CLEAROBJ;
1240         }
1241         if (HERE(BIRD))
1242             rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1243                    CAGE_FLY :
1244                    FREE_FLY);
1245
1246         state_change(FISSURE,
1247                      game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1248         return GO_CLEAROBJ;
1249     }
1250 }
1251
1252 int action(struct command_t *command)
1253 /*  Analyse a verb.  Remember what it was, go back for object if second word
1254  *  unless verb is "say", which snarfs arbitrary second word.
1255  */
1256 {
1257     if (command->part == unknown) {
1258         /*  Analyse an object word.  See if the thing is here, whether
1259          *  we've got a verb yet, and so on.  Object must be here
1260          *  unless verb is "find" or "invent(ory)" (and no new verb
1261          *  yet to be analysed).  Water and oil are also funny, since
1262          *  they are never actually dropped at any location, but might
1263          *  be here inside the bottle or urn or as a feature of the
1264          *  location. */
1265         if (HERE(command->obj))
1266             /* FALL THROUGH */;
1267         else if (command->obj == GRATE) {
1268             if (game.loc == LOC_START ||
1269                 game.loc == LOC_VALLEY ||
1270                 game.loc == LOC_SLIT) {
1271                 command->obj = DPRSSN;
1272             }
1273             if (game.loc == LOC_COBBLE ||
1274                 game.loc == LOC_DEBRIS ||
1275                 game.loc == LOC_AWKWARD ||
1276                 game.loc == LOC_BIRD ||
1277                 game.loc == LOC_PITTOP) {
1278                 command->obj = ENTRNC;
1279             }
1280         } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1281             /* FALL THROUGH */;
1282         else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1283                  command->obj == LIQLOC(game.loc))
1284             /* FALL THROUGH */;
1285         else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1286             command->obj = URN;
1287             /* FALL THROUGH */;
1288         } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1289             command->obj = PLANT2;
1290             /* FALL THROUGH */;
1291         } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1292             game.knfloc = -1;
1293             rspeak(KNIVES_VANISH);
1294             return GO_CLEAROBJ;
1295         } else if (command->obj == ROD && HERE(ROD2)) {
1296             command->obj = ROD2;
1297             /* FALL THROUGH */;
1298         } else if ((command->verb == FIND ||
1299                     command->verb == INVENTORY) && command->wd2 <= 0)
1300             /* FALL THROUGH */;
1301         else {
1302             sspeak(NO_SEE, command->raw1);
1303             return GO_CLEAROBJ;
1304         }
1305
1306         if (command->wd2 > 0)
1307             return GO_WORD2;
1308         if (command->verb != 0)
1309             command->part = transitive;
1310     }
1311
1312     switch (command->part) {
1313     case intransitive:
1314         if (command->wd2 > 0 && command->verb != SAY)
1315             return GO_WORD2;
1316         if (command->verb == SAY)
1317             command->obj = command->wd2;
1318         if (command->obj == NO_OBJECT ||
1319             command->obj == INTRANSITIVE) {
1320             /*  Analyse an intransitive verb (ie, no object given yet). */
1321             switch (command->verb) {
1322             case CARRY:
1323                 return vcarry(command->verb, INTRANSITIVE);
1324             case  DROP:
1325                 return GO_UNKNOWN;
1326             case  SAY:
1327                 return GO_UNKNOWN;
1328             case  UNLOCK:
1329                 return lock(command->verb, INTRANSITIVE);
1330             case  NOTHING: {
1331                 rspeak(OK_MAN);
1332                 return (GO_CLEAROBJ);
1333             }
1334             case  LOCK:
1335                 return lock(command->verb, INTRANSITIVE);
1336             case  LIGHT:
1337                 return light(command->verb, INTRANSITIVE);
1338             case  EXTINGUISH:
1339                 return extinguish(command->verb, INTRANSITIVE);
1340             case  WAVE:
1341                 return GO_UNKNOWN;
1342             case  TAME:
1343                 return GO_UNKNOWN;
1344             case GO: {
1345                 rspeak(actions[command->verb].message);
1346                 return GO_CLEAROBJ;
1347             }
1348             case ATTACK:
1349                 return attack(command);
1350             case POUR:
1351                 return pour(command->verb, command->obj);
1352             case EAT:
1353                 return eat(command->verb, INTRANSITIVE);
1354             case DRINK:
1355                 return drink(command->verb, command->obj);
1356             case RUB:
1357                 return GO_UNKNOWN;
1358             case THROW:
1359                 return GO_UNKNOWN;
1360             case QUIT:
1361                 return quit();
1362             case FIND:
1363                 return GO_UNKNOWN;
1364             case INVENTORY:
1365                 return inven();
1366             case FEED:
1367                 return GO_UNKNOWN;
1368             case FILL:
1369                 return fill(command->verb, command->obj);
1370             case BLAST:
1371                 blast();
1372                 return GO_CLEAROBJ;
1373             case SCORE:
1374                 score(scoregame);
1375                 return GO_CLEAROBJ;
1376             case GIANTWORDS:
1377                 return bigwords(command->wd1);
1378             case BRIEF:
1379                 return brief();
1380             case READ:
1381                 command->obj = INTRANSITIVE;
1382                 return read(*command);
1383             case BREAK:
1384                 return GO_UNKNOWN;
1385             case WAKE:
1386                 return GO_UNKNOWN;
1387             case SAVE:
1388                 return suspend();
1389             case RESUME:
1390                 return resume();
1391             case FLY:
1392                 return fly(command->verb, INTRANSITIVE);
1393             case LISTEN:
1394                 return listen();
1395             case PART:
1396                 return reservoir();
1397             default:
1398                 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1399             }
1400         }
1401     /* FALLTHRU */
1402     case transitive:
1403         /*  Analyse a transitive verb. */
1404         switch (command->verb) {
1405         case  CARRY:
1406             return vcarry(command->verb, command->obj);
1407         case  DROP:
1408             return discard(command->verb, command->obj, false);
1409         case  SAY:
1410             return say(command);
1411         case  UNLOCK:
1412             return lock(command->verb, command->obj);
1413         case  NOTHING: {
1414             rspeak(OK_MAN);
1415             return (GO_CLEAROBJ);
1416         }
1417         case  LOCK:
1418             return lock(command->verb, command->obj);
1419         case LIGHT:
1420             return light(command->verb, command->obj);
1421         case EXTINGUISH:
1422             return extinguish(command->verb, command->obj);
1423         case WAVE:
1424             return wave(command->verb, command->obj);
1425         case TAME: {
1426             rspeak(actions[command->verb].message);
1427             return GO_CLEAROBJ;
1428         }
1429         case GO: {
1430             rspeak(actions[command->verb].message);
1431             return GO_CLEAROBJ;
1432         }
1433         case ATTACK:
1434             return attack(command);
1435         case POUR:
1436             return pour(command->verb, command->obj);
1437         case EAT:
1438             return eat(command->verb, command->obj);
1439         case DRINK:
1440             return drink(command->verb, command->obj);
1441         case RUB:
1442             return rub(command->verb, command->obj);
1443         case THROW:
1444             return throw (command);
1445         case QUIT: {
1446             rspeak(actions[command->verb].message);
1447             return GO_CLEAROBJ;
1448         }
1449         case FIND:
1450             return find(command->verb, command->obj);
1451         case INVENTORY:
1452             return find(command->verb, command->obj);
1453         case FEED:
1454             return feed(command->verb, command->obj);
1455         case FILL:
1456             return fill(command->verb, command->obj);
1457         case BLAST:
1458             blast();
1459             return GO_CLEAROBJ;
1460         case SCORE: {
1461             rspeak(actions[command->verb].message);
1462             return GO_CLEAROBJ;
1463         }
1464         case GIANTWORDS: {
1465             rspeak(actions[command->verb].message);
1466             return GO_CLEAROBJ;
1467         }
1468         case BRIEF: {
1469             rspeak(actions[command->verb].message);
1470             return GO_CLEAROBJ;
1471         }
1472         case READ:
1473             return read(*command);
1474         case BREAK:
1475             return vbreak(command->verb, command->obj);
1476         case WAKE:
1477             return wake(command->verb, command->obj);
1478         case SAVE: {
1479             rspeak(actions[command->verb].message);
1480             return GO_CLEAROBJ;
1481         }
1482         case RESUME: {
1483             rspeak(actions[command->verb].message);
1484             return GO_CLEAROBJ;
1485         }
1486         case FLY:
1487             return fly(command->verb, command->obj);
1488         case LISTEN: {
1489             rspeak(actions[command->verb].message);
1490             return GO_CLEAROBJ;
1491         }
1492         case PART:
1493             return reservoir();
1494         default:
1495             BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1496         }
1497     case unknown:
1498         /* Unknown verb, couldn't deduce object - might need hint */
1499         sspeak(WHAT_DO, command->raw1);
1500         return GO_CHECKHINT;
1501     default:
1502         BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE
1503     }
1504 }