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