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