159a71cb7af3d3a7466bba04a4c70140e3f90b36
[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 int attack(struct command_t *command)
10 /*  Attack.  Assume target if unambiguous.  "Throw" also links here.
11  *  Attackable objects fall into two categories: enemies (snake,
12  *  dwarf, etc.)  and others (bird, clam, machine).  Ambiguous if 2
13  *  enemies, or no enemies but 2 others. */
14 {
15     vocab_t verb = command->verb;
16     obj_t obj = command->obj;
17
18     if (obj == NO_OBJECT ||
19         obj == INTRANSITIVE) {
20         int changes = 0;
21         if (atdwrf(game.loc) > 0) {
22             obj = DWARF;
23             ++changes;
24         }
25         if (HERE(SNAKE)) {
26             obj = SNAKE;
27             ++changes;
28         }
29         if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
30             obj = DRAGON;
31             ++changes;
32         }
33         if (AT(TROLL)) {
34             obj = TROLL;
35             ++changes;
36         }
37         if (AT(OGRE)) {
38             obj = OGRE;
39             ++changes;
40         }
41         if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
42             obj = BEAR;
43             ++changes;
44         }
45         /* check for low-priority targets */
46         if (obj == NO_OBJECT) {
47             /* Can't attack bird or machine by throwing axe. */
48             if (HERE(BIRD) && verb != THROW) {
49                 obj = BIRD;
50                 ++changes;
51             }
52             if (HERE(VEND) && verb != THROW) {
53                 obj = VEND;
54                 ++changes;
55             }
56             /* Clam and oyster both treated as clam for intransitive case;
57              * no harm done. */
58             if (HERE(CLAM) || HERE(OYSTER)) {
59                 obj = CLAM;
60                 ++changes;
61             }
62         }
63         if (changes >= 2)
64             return GO_UNKNOWN;
65     }
66
67     if (obj == BIRD) {
68         if (game.closed) {
69             rspeak(UNHAPPY_BIRD);
70         } else {
71             DESTROY(BIRD);
72             rspeak(BIRD_DEAD);
73         }
74         return GO_CLEAROBJ;
75     }
76     if (obj == VEND) {
77         state_change(VEND,
78                      game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
79         return GO_CLEAROBJ;
80     }
81
82     if (obj == BEAR) {
83         switch (game.prop[BEAR]) {
84         case UNTAMED_BEAR:
85             rspeak(BEAR_HANDS);
86             break;
87         case SITTING_BEAR:
88             rspeak(BEAR_CONFUSED);
89             break;
90         case CONTENTED_BEAR:
91             rspeak(BEAR_CONFUSED);
92             break;
93         case BEAR_DEAD:
94             rspeak(ALREADY_DEAD);
95             break;
96         }
97         return GO_CLEAROBJ;
98     }
99     if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
100         /*  Fun stuff for dragon.  If he insists on attacking it, win!
101          *  Set game.prop to dead, move dragon to central loc (still
102          *  fixed), move rug there (not fixed), and move him there,
103          *  too.  Then do a null motion to get new description. */
104         rspeak(BARE_HANDS_QUERY);
105         if (silent_yes()) {
106             // FIXME: setting wd1 is a workaround for broken logic
107             command->wd1 = token_to_packed("Y");
108         } else {
109             // FIXME: setting wd1 is a workaround for broken logic
110             command->wd1 = token_to_packed("N");
111             return GO_CHECKFOO;
112         }
113         state_change(DRAGON, DRAGON_DEAD);
114         game.prop[RUG] = RUG_FLOOR;
115         /* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.
116          * The way it was computed before was wirse; it depended on the
117          * two dragon locations being LOC_SECRET4 and LOC_SECRET6 and
118          * LOC_SECRET5 being right between them.
119          */
120         move(DRAGON + NOBJECTS, -1);
121         move(RUG + NOBJECTS, LOC_NOWHERE);
122         move(DRAGON, LOC_SECRET5);
123         move(RUG, LOC_SECRET5);
124         drop(BLOOD, LOC_SECRET5);
125         for (obj = 1; obj <= NOBJECTS; obj++) {
126             if (game.place[obj] == objects[DRAGON].plac ||
127                 game.place[obj] == objects[DRAGON].fixd)
128                 move(obj, LOC_SECRET5);
129         }
130         game.loc = LOC_SECRET5;
131         return GO_MOVE;
132     }
133
134     if (obj == OGRE) {
135         rspeak(OGRE_DODGE);
136         if (atdwrf(game.loc) == 0)
137             return GO_CLEAROBJ;
138
139         rspeak(KNIFE_THROWN);
140         DESTROY(OGRE);
141         int dwarves = 0;
142         for (int i = 1; i < PIRATE; i++) {
143             if (game.dloc[i] == game.loc) {
144                 ++dwarves;
145                 game.dloc[i] = LOC_LONGWEST;
146                 game.dseen[i] = false;
147             }
148         }
149         rspeak((dwarves > 1) ?
150                OGRE_PANIC1 :
151                OGRE_PANIC2);
152         return GO_CLEAROBJ;
153     }
154
155     switch (obj) {
156     case NO_OBJECT:
157         rspeak(NO_TARGET);
158         break;
159     case CLAM:
160     case OYSTER:
161         rspeak(SHELL_IMPERVIOUS);
162         break;
163     case SNAKE:
164         rspeak(SNAKE_WARNING);
165         break;
166     case DWARF:
167         if (game.closed) {
168             return GO_DWARFWAKE;
169         }
170         rspeak(BARE_HANDS_QUERY);
171         break;
172     case DRAGON:
173         rspeak(ALREADY_DEAD);
174         break;
175     case TROLL:
176         rspeak(ROCKY_TROLL);
177         break;
178     default:
179         speak(actions[verb].message);
180     }
181     return GO_CLEAROBJ;
182 }
183
184 static int bigwords(long id)
185 /*  FEE FIE FOE FOO (AND FUM).  Advance to next state if given in proper order.
186  *  Look up foo in special section of vocab to determine which word we've got.
187  *  Last word zips the eggs back to the giant room (unless already there). */
188 {
189     if ((game.foobar == WORD_EMPTY && id == ACTION_WORD(FEE)) ||
190         (game.foobar == ACTION_WORD(FEE) && id == ACTION_WORD(FIE)) ||
191         (game.foobar == ACTION_WORD(FIE) && id == ACTION_WORD(FOE)) ||
192         (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FOO)) ||
193         (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FUM))) {
194         game.foobar = id;
195         if ((id != ACTION_WORD(FOO)) && (id != ACTION_WORD(FUM))) {
196             rspeak(OK_MAN);
197             return GO_CLEAROBJ;
198         }
199         game.foobar = WORD_EMPTY;
200         if (game.place[EGGS] == objects[EGGS].plac ||
201             (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
202             rspeak(NOTHING_HAPPENS);
203             return GO_CLEAROBJ;
204         } else {
205             /*  Bring back troll if we steal the eggs back from him before
206              *  crossing. */
207             if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
208                 game.prop[TROLL] = TROLL_PAIDONCE;
209             int k = EGGS_DONE;
210             if (HERE(EGGS))
211                 k = EGGS_VANISHED;
212             if (game.loc == objects[EGGS].plac)
213                 k = EGGS_HERE;
214             move(EGGS, objects[EGGS].plac);
215             pspeak(EGGS, look, k, true);
216             return GO_CLEAROBJ;
217         }
218     } else {
219         if (game.loc == LOC_GIANTROOM) {
220             rspeak(START_OVER);
221         } else {
222             /* This is new begavior in Open Adventure - sounds better when
223              * player isn't in the Giant Room. */
224             rspeak(WELL_POINTLESS);
225         }
226         game.foobar = WORD_EMPTY;
227         return GO_CLEAROBJ;
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(vocab_t verb, obj_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     speak(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, obj_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, obj_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             speak(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                     int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
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] = IS_FIXED;
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, obj_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.place[WATER] = LOC_NOWHERE;
550         state_change(BOTTLE, EMPTY_BOTTLE);
551         return GO_CLEAROBJ;
552     }
553
554     speak(actions[verb].message);
555     return GO_CLEAROBJ;
556 }
557
558 static int eat(token_t verb, obj_t obj)
559 /*  Eat.  Intransitive: assume food if present, else ask what.  Transitive: food
560  *  ok, some things lose appetite, rest are ridiculous. */
561 {
562     if (obj == INTRANSITIVE) {
563         if (!HERE(FOOD))
564             return GO_UNKNOWN;
565         DESTROY(FOOD);
566         rspeak(THANKS_DELICIOUS);
567         return GO_CLEAROBJ;
568     }
569     if (obj == FOOD) {
570         DESTROY(FOOD);
571         rspeak(THANKS_DELICIOUS);
572         return GO_CLEAROBJ;
573     }
574     if (obj == BIRD ||
575         obj == SNAKE ||
576         obj == CLAM ||
577         obj == OYSTER ||
578         obj == DWARF ||
579         obj == DRAGON ||
580         obj == TROLL ||
581         obj == BEAR ||
582         obj == OGRE) {
583         rspeak(LOST_APPETITE);
584         return GO_CLEAROBJ;
585     }
586     speak(actions[verb].message);
587     return GO_CLEAROBJ;
588 }
589
590 static int extinguish(token_t verb, obj_t obj)
591 /* Extinguish.  Lamp, urn, dragon/volcano (nice try). */
592 {
593     if (obj == INTRANSITIVE) {
594         if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
595             obj = LAMP;
596         if (HERE(URN) && game.prop[URN] == URN_LIT)
597             obj = URN;
598         if (obj == INTRANSITIVE)
599             return GO_UNKNOWN;
600     }
601
602     if (obj == URN) {
603         if (game.prop[URN] != URN_EMPTY) {
604             state_change(URN, URN_DARK);
605         } else {
606             pspeak(URN, change, URN_DARK, true);
607         }
608         return GO_CLEAROBJ;
609     }
610
611     if (obj == LAMP) {
612         state_change(LAMP, LAMP_DARK);
613         rspeak(DARK(game.loc) ?
614                PITCH_DARK :
615                NO_MESSAGE);
616         return GO_CLEAROBJ;
617     }
618
619     if (obj == DRAGON ||
620         obj == VOLCANO) {
621         rspeak(BEYOND_POWER);
622         return GO_CLEAROBJ;
623     }
624
625     speak(actions[verb].message);
626     return GO_CLEAROBJ;
627 }
628
629 static int feed(token_t verb, obj_t obj)
630 /*  Feed.  If bird, no seed.  Snake, dragon, troll: quip.  If dwarf, make him
631  *  mad.  Bear, special. */
632 {
633     switch (obj) {
634     case BIRD:
635         rspeak(BIRD_PINING);
636         break;
637     case DRAGON:
638         if (game.prop[DRAGON] != DRAGON_BARS)
639             rspeak(RIDICULOUS_ATTEMPT);
640         else
641             rspeak(NOTHING_EDIBLE);
642         break;
643     case SNAKE:
644         if (!game.closed && HERE(BIRD)) {
645             DESTROY(BIRD);
646             rspeak(BIRD_DEVOURED);
647         } else
648             rspeak(NOTHING_EDIBLE);
649         break;
650     case TROLL:
651         rspeak(TROLL_VICES);
652         break;
653     case DWARF:
654         if (HERE(FOOD)) {
655             game.dflag += 2;
656             rspeak(REALLY_MAD);
657         } else
658             speak(actions[verb].message);
659         break;
660     case BEAR:
661         if (game.prop[BEAR] == BEAR_DEAD) {
662             rspeak(RIDICULOUS_ATTEMPT);
663             break;
664         }
665         if (game.prop[BEAR] == UNTAMED_BEAR) {
666             if (HERE(FOOD)) {
667                 DESTROY(FOOD);
668                 game.fixed[AXE] = IS_FREE;
669                 game.prop[AXE] = AXE_HERE;
670                 state_change(BEAR, SITTING_BEAR);
671             } else
672                 rspeak(NOTHING_EDIBLE);
673             break;
674         }
675         speak(actions[verb].message);
676         break;
677     case OGRE:
678         if (HERE(FOOD))
679             rspeak(OGRE_FULL);
680         else
681             speak(actions[verb].message);
682         break;
683     default:
684         rspeak(AM_GAME);
685     }
686     return GO_CLEAROBJ;
687 }
688
689 int fill(token_t verb, obj_t obj)
690 /*  Fill.  Bottle or urn must be empty, and liquid available.  (Vase
691  *  is nasty.) */
692 {
693     if (obj == VASE) {
694         if (LIQLOC(game.loc) == NO_OBJECT) {
695             rspeak(FILL_INVALID);
696             return GO_CLEAROBJ;
697         }
698         if (!TOTING(VASE)) {
699             rspeak(ARENT_CARRYING);
700             return GO_CLEAROBJ;
701         }
702         rspeak(SHATTER_VASE);
703         game.prop[VASE] = VASE_BROKEN;
704         game.fixed[VASE] = IS_FIXED;
705         return (discard(verb, VASE, true));
706     }
707
708     if (obj == URN) {
709         if (game.prop[URN] != URN_EMPTY) {
710             rspeak(FULL_URN);
711             return GO_CLEAROBJ;
712         }
713         if (!HERE(BOTTLE)) {
714             rspeak(FILL_INVALID);
715             return GO_CLEAROBJ;
716         }
717         int k = LIQUID();
718         switch (k) {
719         case WATER:
720             game.prop[BOTTLE] = EMPTY_BOTTLE;
721             rspeak(WATER_URN);
722             break;
723         case OIL:
724             game.prop[URN] = URN_DARK;
725             game.prop[BOTTLE] = EMPTY_BOTTLE;
726             rspeak(OIL_URN);
727             break;
728         case NO_OBJECT:
729         default:
730             rspeak(FILL_INVALID);
731             return GO_CLEAROBJ;
732         }
733         game.place[k] = LOC_NOWHERE;
734         return GO_CLEAROBJ;
735     }
736     if (obj != NO_OBJECT && obj != BOTTLE) {
737         speak(actions[verb].message);
738         return GO_CLEAROBJ;
739     }
740     if (obj == NO_OBJECT && !HERE(BOTTLE))
741         return GO_UNKNOWN;
742
743     if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
744         rspeak(URN_NOPOUR);
745         return GO_CLEAROBJ;
746     }
747     if (LIQUID() != NO_OBJECT) {
748         rspeak(BOTTLE_FULL);
749         return GO_CLEAROBJ;
750     }
751     if (LIQLOC(game.loc) == NO_OBJECT) {
752         rspeak(NO_LIQUID);
753         return GO_CLEAROBJ;
754     }
755
756     state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
757                  ? OIL_BOTTLE
758                  : WATER_BOTTLE);
759     if (TOTING(BOTTLE))
760         game.place[LIQUID()] = CARRIED;
761     return GO_CLEAROBJ;
762 }
763
764 static int find(token_t verb, obj_t obj)
765 /* Find.  Might be carrying it, or it might be here.  Else give caveat. */
766 {
767     if (TOTING(obj)) {
768         rspeak(ALREADY_CARRYING);
769         return GO_CLEAROBJ;
770     }
771
772     if (game.closed) {
773         rspeak(NEEDED_NEARBY);
774         return GO_CLEAROBJ;
775     }
776
777     if (AT(obj) ||
778         (LIQUID() == obj && AT(BOTTLE)) ||
779         obj == LIQLOC(game.loc) ||
780         (obj == DWARF && atdwrf(game.loc) > 0)) {
781         rspeak(YOU_HAVEIT);
782         return GO_CLEAROBJ;
783     }
784
785
786     speak(actions[verb].message);
787     return GO_CLEAROBJ;
788 }
789
790 static int fly(token_t verb, obj_t obj)
791 /* Fly.  Snide remarks unless hovering rug is here. */
792 {
793     if (obj == INTRANSITIVE) {
794         if (!HERE(RUG)) {
795             rspeak(FLAP_ARMS);
796             return GO_CLEAROBJ;
797         }
798         if (game.prop[RUG] != RUG_HOVER) {
799             rspeak(RUG_NOTHING2);
800             return GO_CLEAROBJ;
801         }
802         obj = RUG;
803     }
804
805     if (obj != RUG) {
806         speak(actions[verb].message);
807         return GO_CLEAROBJ;
808     }
809     if (game.prop[RUG] != RUG_HOVER) {
810         rspeak(RUG_NOTHING1);
811         return GO_CLEAROBJ;
812     }
813     game.oldlc2 = game.oldloc;
814     game.oldloc = game.loc;
815
816     if (game.prop[SAPPH] == STATE_NOTFOUND) {
817         game.newloc = game.place[SAPPH];
818         rspeak(RUG_GOES);
819     } else {
820         game.newloc = LOC_CLIFF;
821         rspeak(RUG_RETURNS);
822     }
823     return GO_TERMINATE;
824 }
825
826 static int inven(void)
827 /* Inventory. If object, treat same as find.  Else report on current burden. */
828 {
829     bool empty = true;
830     for (obj_t i = 1; i <= NOBJECTS; i++) {
831         if (i == BEAR ||
832             !TOTING(i))
833             continue;
834         if (empty) {
835             rspeak(NOW_HOLDING);
836             empty = false;
837         }
838         pspeak(i, touch, -1, false);
839     }
840     if (TOTING(BEAR))
841         rspeak(TAME_BEAR);
842     if (empty)
843         rspeak(NO_CARRY);
844     return GO_CLEAROBJ;
845 }
846
847 static int light(token_t verb, obj_t obj)
848 /*  Light.  Applicable only to lamp and urn. */
849 {
850     if (obj == INTRANSITIVE) {
851         if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
852             obj = LAMP;
853         if (HERE(URN) && game.prop[URN] == URN_DARK)
854             obj =  URN;
855         if (obj == INTRANSITIVE ||
856             (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
857              HERE(URN) && game.prop[URN] == URN_DARK))
858             return GO_UNKNOWN;
859     }
860
861     if (obj == URN) {
862         state_change(URN, game.prop[URN] == URN_EMPTY ?
863                      URN_EMPTY :
864                      URN_LIT);
865         return GO_CLEAROBJ;
866     } else {
867         if (obj != LAMP) {
868             speak(actions[verb].message);
869             return GO_CLEAROBJ;
870         }
871         if (game.limit < 0) {
872             rspeak(LAMP_OUT);
873             return GO_CLEAROBJ;
874         }
875         state_change(LAMP, LAMP_BRIGHT);
876         if (game.wzdark)
877             return GO_TOP;
878         else
879             return GO_CLEAROBJ;
880     }
881 }
882
883 static int listen(void)
884 /*  Listen.  Intransitive only.  Print stuff based on object sound proprties. */
885 {
886     long sound = locations[game.loc].sound;
887     if (sound != SILENT) {
888         rspeak(sound);
889         if (!locations[game.loc].loud)
890             rspeak(NO_MESSAGE);
891         return GO_CLEAROBJ;
892     }
893     for (obj_t i = 1; i <= NOBJECTS; i++) {
894         if (!HERE(i) ||
895             objects[i].sounds[0] == NULL ||
896             game.prop[i] < 0)
897             continue;
898         int mi =  game.prop[i];
899         /* FIXME: Weird magic on object states */
900         if (i == BIRD)
901             mi += 3 * game.blooded;
902         long packed_zzword = token_to_packed(game.zzword);
903         pspeak(i, hear, mi, true, packed_zzword);
904         rspeak(NO_MESSAGE);
905         if (i == BIRD && mi == BIRD_ENDSTATE)
906             DESTROY(BIRD);
907         return GO_CLEAROBJ;
908     }
909     rspeak(ALL_SILENT);
910     return GO_CLEAROBJ;
911 }
912
913 static int lock(token_t verb, obj_t obj)
914 /* Lock, unlock, no object given.  Assume various things if present. */
915 {
916     if (obj == INTRANSITIVE) {
917         if (HERE(CLAM))
918             obj = CLAM;
919         if (HERE(OYSTER))
920             obj = OYSTER;
921         if (AT(DOOR))
922             obj = DOOR;
923         if (AT(GRATE))
924             obj = GRATE;
925         if (HERE(CHAIN))
926             obj = CHAIN;
927         if (obj == INTRANSITIVE) {
928             rspeak(NOTHING_LOCKED);
929             return GO_CLEAROBJ;
930         }
931     }
932
933     /*  Lock, unlock object.  Special stuff for opening clam/oyster
934      *  and for chain. */
935
936     switch (obj) {
937     case CHAIN:
938         if (HERE(KEYS)) {
939             return chain(verb);
940         } else
941             rspeak(NO_KEYS);
942         break;
943     case GRATE:
944         if (HERE(KEYS)) {
945             if (game.closng) {
946                 rspeak(EXIT_CLOSED);
947                 if (!game.panic)
948                     game.clock2 = PANICTIME;
949                 game.panic = true;
950             } else {
951                 state_change(GRATE, (verb == LOCK) ?
952                              GRATE_CLOSED :
953                              GRATE_OPEN);
954             }
955         } else
956             rspeak(NO_KEYS);
957         break;
958     case CLAM:
959         if (verb == LOCK)
960             rspeak(HUH_MAN);
961         else if (!TOTING(TRIDENT))
962             rspeak(OYSTER_OPENER);
963         else {
964             DESTROY(CLAM);
965             drop(OYSTER, game.loc);
966             drop(PEARL, LOC_CULDESAC);
967             rspeak(PEARL_FALLS);
968         }
969         break;
970     case OYSTER:
971         if (verb == LOCK)
972             rspeak(HUH_MAN);
973         else
974             rspeak(OYSTER_OPENER);
975         break;
976     case DOOR:
977         rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
978         break;
979     case CAGE:
980         rspeak( NO_LOCK);
981         break;
982     case KEYS:
983         rspeak(CANNOT_UNLOCK);
984         break;
985     default:
986         speak(actions[verb].message);
987     }
988
989     return GO_CLEAROBJ;
990 }
991
992 static int pour(token_t verb, obj_t obj)
993 /*  Pour.  If no object, or object is bottle, assume contents of bottle.
994  *  special tests for pouring water or oil on plant or rusty door. */
995 {
996     if (obj == BOTTLE ||
997         obj == NO_OBJECT)
998         obj = LIQUID();
999     if (obj == NO_OBJECT)
1000         return GO_UNKNOWN;
1001     if (!TOTING(obj)) {
1002         speak(actions[verb].message);
1003         return GO_CLEAROBJ;
1004     }
1005
1006     if (obj != OIL && obj != WATER) {
1007         rspeak(CANT_POUR);
1008         return GO_CLEAROBJ;
1009     }
1010     if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1011         return fill(verb, URN);
1012     game.prop[BOTTLE] = EMPTY_BOTTLE;
1013     game.place[obj] = LOC_NOWHERE;
1014     if (!(AT(PLANT) ||
1015           AT(DOOR))) {
1016         rspeak(GROUND_WET);
1017         return GO_CLEAROBJ;
1018     }
1019     if (!AT(DOOR)) {
1020         if (obj == WATER) {
1021             /* cycle through the three plant states */
1022             state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1023             game.prop[PLANT2] = game.prop[PLANT];
1024             return GO_MOVE;
1025         } else {
1026             rspeak(SHAKING_LEAVES);
1027             return GO_CLEAROBJ;
1028         }
1029     } else {
1030         state_change(DOOR, (obj == OIL) ?
1031                      DOOR_UNRUSTED :
1032                      DOOR_RUSTED);
1033         return GO_CLEAROBJ;
1034     }
1035 }
1036
1037 static int quit(void)
1038 /*  Quit.  Intransitive only.  Verify intent and exit if that's what he wants. */
1039 {
1040     if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1041         terminate(quitgame);
1042     return GO_CLEAROBJ;
1043 }
1044
1045 static int read(struct command_t command)
1046 /*  Read.  Print stuff based on objtxt.  Oyster (?) is special case. */
1047 {
1048     if (command.obj == INTRANSITIVE) {
1049         command.obj = NO_OBJECT;
1050         for (int i = 1; i <= NOBJECTS; i++) {
1051             if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1052                 command.obj = command.obj * NOBJECTS + i;
1053         }
1054         if (command.obj > NOBJECTS ||
1055             command.obj == NO_OBJECT ||
1056             DARK(game.loc))
1057             return GO_UNKNOWN;
1058     }
1059
1060     if (DARK(game.loc)) {
1061         sspeak(NO_SEE, command.raw1);
1062     } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1063         game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1064     } else if (objects[command.obj].texts[0] == NULL ||
1065                game.prop[command.obj] == STATE_NOTFOUND) {
1066         speak(actions[command.verb].message);
1067     } else
1068         pspeak(command.obj, study, game.prop[command.obj], true);
1069     return GO_CLEAROBJ;
1070 }
1071
1072 static int reservoir(void)
1073 /*  Z'ZZZ (word gets recomputed at startup; different each game). */
1074 {
1075     if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1076         rspeak(NOTHING_HAPPENS);
1077         return GO_CLEAROBJ;
1078     } else {
1079         state_change(RESER,
1080                      game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1081         if (AT(RESER))
1082             return GO_CLEAROBJ;
1083         else {
1084             game.oldlc2 = game.loc;
1085             game.newloc = LOC_NOWHERE;
1086             rspeak(NOT_BRIGHT);
1087             return GO_TERMINATE;
1088         }
1089     }
1090 }
1091
1092 static int rub(token_t verb, obj_t obj)
1093 /* Rub.  Yields various snide remarks except for lit urn. */
1094 {
1095     if (obj == URN && game.prop[URN] == URN_LIT) {
1096         DESTROY(URN);
1097         drop(AMBER, game.loc);
1098         game.prop[AMBER] = AMBER_IN_ROCK;
1099         --game.tally;
1100         drop(CAVITY, game.loc);
1101         rspeak(URN_GENIES);
1102     } else if (obj != LAMP) {
1103         rspeak(PECULIAR_NOTHING);
1104     } else {
1105         speak(actions[verb].message);
1106     }
1107     return GO_CLEAROBJ;
1108 }
1109
1110 static int say(struct command_t *command)
1111 /* Say.  Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).)  Magic words override. */
1112 {
1113     if (command->wd2 > 0) {
1114         command->wd1 = command->wd2;
1115         strcpy(command->raw1, command->raw2);
1116     }
1117     char word1[TOKLEN + 1];
1118     packed_to_token(command->wd1, word1);
1119     int wd = (int) get_vocab_id(word1);
1120     if (wd == MOTION_WORD(XYZZY) ||
1121         wd == MOTION_WORD(PLUGH) ||
1122         wd == MOTION_WORD(PLOVER) ||
1123         wd == ACTION_WORD(FEE) ||
1124         wd == ACTION_WORD(FIE) ||
1125         wd == ACTION_WORD(FOE) ||
1126         wd == ACTION_WORD(FOO) ||
1127         wd == ACTION_WORD(FUM) ||
1128         wd == ACTION_WORD(PART)) {
1129         /* FIXME: scribbles on the interpreter's command block */
1130         wordclear(&command->wd2);
1131         return GO_LOOKUP;
1132     }
1133     sspeak(OKEY_DOKEY, command->raw1);
1134     return GO_CLEAROBJ;
1135 }
1136
1137 static int throw_support(long spk)
1138 {
1139     rspeak(spk);
1140     drop(AXE, game.loc);
1141     return GO_MOVE;
1142 }
1143
1144 static int throw (struct command_t *command)
1145 /*  Throw.  Same as discard unless axe.  Then same as attack except
1146  *  ignore bird, and if dwarf is present then one might be killed.
1147  *  (Only way to do so!)  Axe also special for dragon, bear, and
1148  *  troll.  Treasures special for troll. */
1149 {
1150     if (!TOTING(command->obj)) {
1151         speak(actions[command->verb].message);
1152         return GO_CLEAROBJ;
1153     }
1154     if (objects[command->obj].is_treasure && AT(TROLL)) {
1155         /*  Snarf a treasure for the troll. */
1156         drop(command->obj, LOC_NOWHERE);
1157         move(TROLL, LOC_NOWHERE);
1158         move(TROLL + NOBJECTS, LOC_NOWHERE);
1159         drop(TROLL2, objects[TROLL].plac);
1160         drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1161         juggle(CHASM);
1162         rspeak(TROLL_SATISFIED);
1163         return GO_CLEAROBJ;
1164     }
1165     if (command->obj == FOOD && HERE(BEAR)) {
1166         /* But throwing food is another story. */
1167         command->obj = BEAR;
1168         return (feed(command->verb, command->obj));
1169     }
1170     if (command->obj != AXE)
1171         return (discard(command->verb, command->obj, false));
1172     else {
1173         if (atdwrf(game.loc) <= 0) {
1174             if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1175                 return throw_support(DRAGON_SCALES);
1176             if (AT(TROLL))
1177                 return throw_support(TROLL_RETURNS);
1178             else if (AT(OGRE))
1179                 return throw_support(OGRE_DODGE);
1180             else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1181                 /* This'll teach him to throw the axe at the bear! */
1182                 drop(AXE, game.loc);
1183                 game.fixed[AXE] = IS_FIXED;
1184                 juggle(BEAR);
1185                 state_change(AXE, AXE_LOST);
1186                 return GO_CLEAROBJ;
1187             }
1188             command->obj = NO_OBJECT;
1189             return (attack(command));
1190         }
1191
1192         if (randrange(NDWARVES + 1) < game.dflag) {
1193             return throw_support(DWARF_DODGES);
1194         } else {
1195             long i = atdwrf(game.loc);
1196             game.dseen[i] = false;
1197             game.dloc[i] = LOC_NOWHERE;
1198             return throw_support((++game.dkill == 1) ?
1199                                  DWARF_SMOKE :
1200                                  KILLED_DWARF);
1201         }
1202     }
1203 }
1204
1205 static int wake(token_t verb, obj_t obj)
1206 /* Wake.  Only use is to disturb the dwarves. */
1207 {
1208     if (obj != DWARF ||
1209         !game.closed) {
1210         speak(actions[verb].message);
1211         return GO_CLEAROBJ;
1212     } else {
1213         rspeak(PROD_DWARF);
1214         return GO_DWARFWAKE;
1215     }
1216 }
1217
1218 static int wave(token_t verb, obj_t obj)
1219 /* Wave.  No effect unless waving rod at fissure or at bird. */
1220 {
1221     if (obj != ROD ||
1222         !TOTING(obj) ||
1223         (!HERE(BIRD) &&
1224          (game.closng ||
1225           !AT(FISSURE)))) {
1226         speak(((!TOTING(obj)) && (obj != ROD ||
1227                                   !TOTING(ROD2))) ?
1228               arbitrary_messages[ARENT_CARRYING] :
1229               actions[verb].message);
1230         return GO_CLEAROBJ;
1231     }
1232
1233     if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1234         drop(JADE, game.loc);
1235         game.prop[JADE] = STATE_FOUND;
1236         --game.tally;
1237         rspeak(NECKLACE_FLY);
1238         return GO_CLEAROBJ;
1239     } else {
1240         if (game.closed) {
1241             rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1242                    CAGE_FLY :
1243                    FREE_FLY);
1244             return GO_DWARFWAKE;
1245         }
1246         if (game.closng ||
1247             !AT(FISSURE)) {
1248             rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1249                    CAGE_FLY :
1250                    FREE_FLY);
1251             return GO_CLEAROBJ;
1252         }
1253         if (HERE(BIRD))
1254             rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1255                    CAGE_FLY :
1256                    FREE_FLY);
1257
1258         state_change(FISSURE,
1259                      game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1260         return GO_CLEAROBJ;
1261     }
1262 }
1263
1264 int action(struct command_t *command)
1265 /*  Analyse a verb.  Remember what it was, go back for object if second word
1266  *  unless verb is "say", which snarfs arbitrary second word.
1267  */
1268 {
1269     if (command->part == unknown) {
1270         /*  Analyse an object word.  See if the thing is here, whether
1271          *  we've got a verb yet, and so on.  Object must be here
1272          *  unless verb is "find" or "invent(ory)" (and no new verb
1273          *  yet to be analysed).  Water and oil are also funny, since
1274          *  they are never actually dropped at any location, but might
1275          *  be here inside the bottle or urn or as a feature of the
1276          *  location. */
1277         if (HERE(command->obj))
1278             /* FALL THROUGH */;
1279         else if (command->obj == GRATE) {
1280             if (game.loc == LOC_START ||
1281                 game.loc == LOC_VALLEY ||
1282                 game.loc == LOC_SLIT) {
1283                 command->obj = DPRSSN;
1284             }
1285             if (game.loc == LOC_COBBLE ||
1286                 game.loc == LOC_DEBRIS ||
1287                 game.loc == LOC_AWKWARD ||
1288                 game.loc == LOC_BIRD ||
1289                 game.loc == LOC_PITTOP) {
1290                 command->obj = ENTRNC;
1291             }
1292         } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1293             /* FALL THROUGH */;
1294         else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1295                  command->obj == LIQLOC(game.loc))
1296             /* FALL THROUGH */;
1297         else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1298             command->obj = URN;
1299             /* FALL THROUGH */;
1300         } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1301             command->obj = PLANT2;
1302             /* FALL THROUGH */;
1303         } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1304             game.knfloc = -1;
1305             rspeak(KNIVES_VANISH);
1306             return GO_CLEAROBJ;
1307         } else if (command->obj == ROD && HERE(ROD2)) {
1308             command->obj = ROD2;
1309             /* FALL THROUGH */;
1310         } else if ((command->verb == FIND ||
1311                     command->verb == INVENTORY) && command->wd2 <= 0)
1312             /* FALL THROUGH */;
1313         else {
1314             sspeak(NO_SEE, command->raw1);
1315             return GO_CLEAROBJ;
1316         }
1317
1318         if (command->wd2 > 0)
1319             return GO_WORD2;
1320         if (command->verb != 0)
1321             command->part = transitive;
1322     }
1323
1324     switch (command->part) {
1325     case intransitive:
1326         if (command->wd2 > 0 && command->verb != SAY)
1327             return GO_WORD2;
1328         if (command->verb == SAY)
1329             command->obj = command->wd2;
1330         if (command->obj == NO_OBJECT ||
1331             command->obj == INTRANSITIVE) {
1332             /*  Analyse an intransitive verb (ie, no object given yet). */
1333             switch (command->verb) {
1334             case CARRY:
1335                 return vcarry(command->verb, INTRANSITIVE);
1336             case  DROP:
1337                 return GO_UNKNOWN;
1338             case  SAY:
1339                 return GO_UNKNOWN;
1340             case  UNLOCK:
1341                 return lock(command->verb, INTRANSITIVE);
1342             case  NOTHING: {
1343                 rspeak(OK_MAN);
1344                 return (GO_CLEAROBJ);
1345             }
1346             case  LOCK:
1347                 return lock(command->verb, INTRANSITIVE);
1348             case  LIGHT:
1349                 return light(command->verb, INTRANSITIVE);
1350             case  EXTINGUISH:
1351                 return extinguish(command->verb, INTRANSITIVE);
1352             case  WAVE:
1353                 return GO_UNKNOWN;
1354             case  TAME:
1355                 return GO_UNKNOWN;
1356             case GO: {
1357                 speak(actions[command->verb].message);
1358                 return GO_CLEAROBJ;
1359             }
1360             case ATTACK:
1361                 return attack(command);
1362             case POUR:
1363                 return pour(command->verb, command->obj);
1364             case EAT:
1365                 return eat(command->verb, INTRANSITIVE);
1366             case DRINK:
1367                 return drink(command->verb, command->obj);
1368             case RUB:
1369                 return GO_UNKNOWN;
1370             case THROW:
1371                 return GO_UNKNOWN;
1372             case QUIT:
1373                 return quit();
1374             case FIND:
1375                 return GO_UNKNOWN;
1376             case INVENTORY:
1377                 return inven();
1378             case FEED:
1379                 return GO_UNKNOWN;
1380             case FILL:
1381                 return fill(command->verb, command->obj);
1382             case BLAST:
1383                 blast();
1384                 return GO_CLEAROBJ;
1385             case SCORE:
1386                 score(scoregame);
1387                 return GO_CLEAROBJ;
1388             case FEE:
1389             case FIE:
1390             case FOE:
1391             case FOO:
1392             case FUM:
1393                 return bigwords(command->id1);
1394             case BRIEF:
1395                 return brief();
1396             case READ:
1397                 command->obj = INTRANSITIVE;
1398                 return read(*command);
1399             case BREAK:
1400                 return GO_UNKNOWN;
1401             case WAKE:
1402                 return GO_UNKNOWN;
1403             case SAVE:
1404                 return suspend();
1405             case RESUME:
1406                 return resume();
1407             case FLY:
1408                 return fly(command->verb, INTRANSITIVE);
1409             case LISTEN:
1410                 return listen();
1411             case PART:
1412                 return reservoir();
1413             default:
1414                 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1415             }
1416         }
1417     /* FALLTHRU */
1418     case transitive:
1419         /*  Analyse a transitive verb. */
1420         switch (command->verb) {
1421         case  CARRY:
1422             return vcarry(command->verb, command->obj);
1423         case  DROP:
1424             return discard(command->verb, command->obj, false);
1425         case  SAY:
1426             return say(command);
1427         case  UNLOCK:
1428             return lock(command->verb, command->obj);
1429         case  NOTHING: {
1430             rspeak(OK_MAN);
1431             return (GO_CLEAROBJ);
1432         }
1433         case  LOCK:
1434             return lock(command->verb, command->obj);
1435         case LIGHT:
1436             return light(command->verb, command->obj);
1437         case EXTINGUISH:
1438             return extinguish(command->verb, command->obj);
1439         case WAVE:
1440             return wave(command->verb, command->obj);
1441         case TAME: {
1442             speak(actions[command->verb].message);
1443             return GO_CLEAROBJ;
1444         }
1445         case GO: {
1446             speak(actions[command->verb].message);
1447             return GO_CLEAROBJ;
1448         }
1449         case ATTACK:
1450             return attack(command);
1451         case POUR:
1452             return pour(command->verb, command->obj);
1453         case EAT:
1454             return eat(command->verb, command->obj);
1455         case DRINK:
1456             return drink(command->verb, command->obj);
1457         case RUB:
1458             return rub(command->verb, command->obj);
1459         case THROW:
1460             return throw (command);
1461         case QUIT: {
1462             speak(actions[command->verb].message);
1463             return GO_CLEAROBJ;
1464         }
1465         case FIND:
1466             return find(command->verb, command->obj);
1467         case INVENTORY:
1468             return find(command->verb, command->obj);
1469         case FEED:
1470             return feed(command->verb, command->obj);
1471         case FILL:
1472             return fill(command->verb, command->obj);
1473         case BLAST:
1474             blast();
1475             return GO_CLEAROBJ;
1476         case SCORE: {
1477             speak(actions[command->verb].message);
1478             return GO_CLEAROBJ;
1479         }
1480         case FEE:
1481         case FIE:
1482         case FOE:
1483         case FOO:
1484         case FUM: {
1485             speak(actions[command->verb].message);
1486             return GO_CLEAROBJ;
1487         }
1488         case BRIEF: {
1489             speak(actions[command->verb].message);
1490             return GO_CLEAROBJ;
1491         }
1492         case READ:
1493             return read(*command);
1494         case BREAK:
1495             return vbreak(command->verb, command->obj);
1496         case WAKE:
1497             return wake(command->verb, command->obj);
1498         case SAVE: {
1499             speak(actions[command->verb].message);
1500             return GO_CLEAROBJ;
1501         }
1502         case RESUME: {
1503             speak(actions[command->verb].message);
1504             return GO_CLEAROBJ;
1505         }
1506         case FLY:
1507             return fly(command->verb, command->obj);
1508         case LISTEN: {
1509             speak(actions[command->verb].message);
1510             return GO_CLEAROBJ;
1511         }
1512         case PART:
1513             return reservoir();
1514         default:
1515             BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1516         }
1517     case unknown:
1518         /* Unknown verb, couldn't deduce object - might need hint */
1519         sspeak(WHAT_DO, command->raw1);
1520         return GO_CHECKHINT;
1521     default:
1522         BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE
1523     }
1524 }