6 static int fill(token_t, token_t);
8 static void state_change(long obj, long state)
10 game.prop[obj] = state;
11 pspeak(obj, change, state, true);
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. */
20 vocab_t verb = command->verb;
21 vocab_t obj = command->obj;
23 long spk = actions[verb].message;
24 if (obj == NO_OBJECT || obj == INTRANSITIVE) {
26 if (atdwrf(game.loc) > 0) {
34 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
46 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
50 /* check for low-priority targets */
51 if (obj == NO_OBJECT) {
52 /* Can't attack bird or machine by throwing axe. */
53 if (HERE(BIRD) && verb != THROW) {
57 if (HERE(VEND) && verb != THROW) {
61 /* Clam and oyster both treated as clam for intransitive case;
63 if (HERE(CLAM) || HERE(OYSTER)) {
79 } else if (obj == VEND) {
81 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
87 if (obj == CLAM || obj == OYSTER)
88 spk = SHELL_IMPERVIOUS;
92 spk = BARE_HANDS_QUERY;
93 if (obj == DWARF && game.closed)
101 if (obj == OGRE && atdwrf(game.loc) > 0) {
103 rspeak(KNIFE_THROWN);
106 for (int i = 1; i < PIRATE; i++) {
107 if (game.dloc[i] == game.loc) {
109 game.dloc[i] = LOC_LONGWEST;
110 game.dseen[i] = false;
113 spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2;
114 } else if (obj == BEAR) {
115 switch (game.prop[BEAR]) {
129 } else if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
130 /* Fun stuff for dragon. If he insists on attacking it, win!
131 * Set game.prop to dead, move dragon to central loc (still
132 * fixed), move rug there (not fixed), and move him there,
133 * too. Then do a null motion to get new description. */
134 rspeak(BARE_HANDS_QUERY);
136 // FIXME: setting wd1 is a workaround for broken logic
137 command->wd1 = token_to_packed("Y");
139 // FIXME: setting wd1 is a workaround for broken logic
140 command->wd1 = token_to_packed("N");
143 state_change(DRAGON, DRAGON_DEAD);
144 game.prop[RUG] = RUG_FLOOR;
145 /* FIXME: Arithmetic on location values */
146 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
147 move(DRAGON + NOBJECTS, -1);
148 move(RUG + NOBJECTS, 0);
152 for (obj = 1; obj <= NOBJECTS; obj++) {
153 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
164 static int bigwords(token_t foo)
165 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
166 * Look up foo in special section of vocab to determine which word we've got.
167 * Last word zips the eggs back to the giant room (unless already there). */
170 packed_to_token(foo, word);
171 int k = (int) get_special_vocab_id(word);
172 int spk = NOTHING_HAPPENS;
173 if (game.foobar != 1 - k) {
174 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)
185 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
189 /* Bring back troll if we steal the eggs back from him before
191 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
192 game.prop[TROLL] = TROLL_PAIDONCE;
196 if (game.loc == objects[EGGS].plac)
198 move(EGGS, objects[EGGS].plac);
199 pspeak(EGGS, look, k, true);
205 static int bivalve(token_t verb, token_t obj)
206 /* Clam/oyster actions */
209 bool is_oyster = (obj == OYSTER);
210 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
212 spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
213 if (!TOTING(TRIDENT))
214 spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
217 if (spk == PEARL_FALLS) {
219 drop(OYSTER, game.loc);
220 drop(PEARL, LOC_CULDESAC);
226 static void blast(void)
227 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
229 if (game.prop[ROD2] < 0 || !game.closed)
230 rspeak(REQUIRES_DYNAMITE);
232 game.bonus = VICTORY_MESSAGE;
233 if (game.loc == LOC_NE)
234 game.bonus = DEFEAT_MESSAGE;
236 game.bonus = SPLATTER_MESSAGE;
242 static int vbreak(token_t verb, token_t obj)
243 /* Break. Only works for mirror in repository and, of course, the vase. */
247 rspeak(BREAK_MIRROR);
254 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
256 drop(VASE, game.loc);
257 state_change(VASE, VASE_BROKEN);
258 game.fixed[VASE] = -1;
261 rspeak(actions[verb].message);
262 return (GO_CLEAROBJ);
265 static int brief(void)
266 /* Brief. Intransitive only. Suppress long descriptions after first time. */
270 rspeak(BRIEF_CONFIRM);
274 static int vcarry(token_t verb, token_t obj)
275 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
276 * take one without the other). Liquids also special, since they depend on
277 * status of bottle. Also various side effects, etc. */
280 if (obj == INTRANSITIVE) {
281 /* Carry, no object given yet. OK if only one object present. */
282 if (game.atloc[game.loc] == 0 ||
283 game.link[game.atloc[game.loc]] != 0 ||
284 atdwrf(game.loc) > 0)
286 obj = game.atloc[game.loc];
290 rspeak(ALREADY_CARRYING);
294 if (obj == PLANT && game.prop[PLANT] <= 0)
296 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
298 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
303 spk = DOUGHNUT_HOLES;
306 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
309 spk = HAND_PASSTHROUGH;
311 rspeak(REMOVE_MESSAGE);
315 if (game.fixed[obj] != 0) {
319 if (obj == WATER || obj == OIL) {
320 if (!HERE(BOTTLE) || LIQUID() != obj) {
321 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
322 return (fill(verb, BOTTLE));
324 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
336 if (game.holdng >= INVLIMIT) {
339 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
340 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
349 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
353 game.prop[BIRD] = BIRD_CAGED;
355 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
356 carry(BIRD + CAGE - obj, game.loc);
357 carry(obj, game.loc);
358 if (obj == BOTTLE && LIQUID() != 0)
359 game.place[LIQUID()] = CARRIED;
360 if (GSTONE(obj) && game.prop[obj] != 0) {
361 game.prop[obj] = STATE_GROUND;
362 game.prop[CAVITY] = CAVITY_EMPTY;
368 static int chain(token_t verb)
369 /* Do something to the bear's chain */
373 spk = CHAIN_UNLOCKED;
374 if (game.prop[BEAR] == UNTAMED_BEAR)
376 if (game.prop[CHAIN] == CHAIN_HEAP)
377 spk = ALREADY_UNLOCKED;
378 if (spk != CHAIN_UNLOCKED) {
382 game.prop[CHAIN] = CHAIN_HEAP;
383 game.fixed[CHAIN] = CHAIN_HEAP;
384 if (game.prop[BEAR] != BEAR_DEAD)
385 game.prop[BEAR] = CONTENTED_BEAR;
386 /* FIXME: Arithmetic on state numbers */
387 game.fixed[BEAR] = 2 - game.prop[BEAR];
390 if (game.prop[CHAIN] != CHAIN_HEAP)
391 spk = ALREADY_LOCKED;
392 if (game.loc != objects[CHAIN].plac)
394 if (spk != CHAIN_LOCKED) {
398 game.prop[CHAIN] = CHAIN_FIXED;
400 drop(CHAIN, game.loc);
401 game.fixed[CHAIN] = -1;
407 static int discard(token_t verb, token_t obj, bool just_do_it)
408 /* Discard object. "Throw" also comes here for most objects. Special cases for
409 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
410 * Drop coins at vending machine for extra batteries. */
412 int spk = actions[verb].message;
414 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
420 if (obj == BIRD && HERE(SNAKE)) {
421 rspeak(BIRD_ATTACKS);
425 /* Set game.prop for use by travel options */
426 game.prop[SNAKE] = SNAKE_CHASED;
428 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
431 game.prop[CAVITY] = CAVITY_FULL;
432 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || (obj == RUBY &&
433 game.prop[RUG] == RUG_HOVER))) {
440 if (spk != RUG_WIGGLES) {
441 /* FIXME: Arithmetic on state numbers */
442 int k = 2 - game.prop[RUG];
445 k = objects[SAPPH].plac;
446 move(RUG + NOBJECTS, k);
449 } else if (obj == COINS && HERE(VEND)) {
451 drop(BATTERY, game.loc);
452 pspeak(BATTERY, look, FRESH_BATTERIES, true);
454 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
458 } else if (obj == BEAR && AT(TROLL)) {
459 rspeak(TROLL_SCAMPERS);
460 move(TROLL, LOC_NOWHERE);
461 move(TROLL + NOBJECTS, LOC_NOWHERE);
462 move(TROLL2, objects[TROLL].plac);
463 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
465 game.prop[TROLL] = TROLL_GONE;
466 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
469 game.prop[VASE] = VASE_BROKEN;
471 game.prop[VASE] = VASE_WHOLE;
472 pspeak(VASE, look, game.prop[VASE] + 1, true);
473 if (game.prop[VASE] != VASE_WHOLE)
474 game.fixed[VASE] = -1;
480 if (obj == BOTTLE && k != 0)
481 game.place[k] = LOC_NOWHERE;
482 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
483 drop(BIRD, game.loc);
487 game.prop[BIRD] = BIRD_UNCAGED;
488 if (FOREST(game.loc))
489 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
493 static int drink(token_t verb, token_t obj)
494 /* Drink. If no object, assume water and look for it here. If water is in
495 * the bottle, drink that, else must be at a water loc, so drink stream. */
497 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
500 if (obj != NO_OBJECT && obj != WATER) {
501 rspeak(RIDICULOUS_ATTEMPT);
502 } else if (LIQUID() == WATER && HERE(BOTTLE)) {
503 game.prop[BOTTLE] = EMPTY_BOTTLE;
504 game.place[WATER] = LOC_NOWHERE;
505 rspeak(BOTTLE_EMPTY);
507 rspeak(actions[verb].message);
511 state_change(DRAGON, DRAGON_BLOODLESS);
517 static int eat(token_t verb, token_t obj)
518 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
519 * ok, some things lose appetite, rest are ridiculous. */
521 if (obj == INTRANSITIVE) {
525 rspeak(THANKS_DELICIOUS);
530 rspeak(THANKS_DELICIOUS);
533 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
534 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
536 rspeak(LOST_APPETITE);
539 rspeak(actions[verb].message);
543 static int extinguish(token_t verb, int obj)
544 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
546 if (obj == INTRANSITIVE) {
547 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
549 if (HERE(URN) && game.prop[URN] == URN_LIT)
551 if (obj == INTRANSITIVE ||
552 (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT &&
553 HERE(URN) && game.prop[URN] == URN_LIT))
558 if (game.prop[URN] != URN_EMPTY) {
559 state_change(URN, URN_DARK);
561 pspeak(URN, change, URN_DARK, true);
564 } else if (obj == LAMP) {
565 state_change(LAMP, LAMP_DARK);
566 rspeak(DARK(game.loc) ? PITCH_DARK : NO_MESSAGE);
567 } else if (obj == DRAGON || obj == VOLCANO) {
568 rspeak(BEYOND_POWER);
571 rspeak(actions[verb].message);
576 static int feed(token_t verb, token_t obj)
577 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
578 * mad. Bear, special. */
580 int spk = actions[verb].message;
584 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
585 spk = NOTHING_EDIBLE;
586 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
587 spk = RIDICULOUS_ATTEMPT;
590 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
594 } else if (obj == DWARF) {
599 } else if (obj == BEAR) {
600 if (game.prop[BEAR] == UNTAMED_BEAR)
601 spk = NOTHING_EDIBLE;
602 if (game.prop[BEAR] == BEAR_DEAD)
603 spk = RIDICULOUS_ATTEMPT;
606 game.prop[BEAR] = SITTING_BEAR;
611 } else if (obj == OGRE) {
621 int fill(token_t verb, token_t obj)
622 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
626 int spk = actions[verb].message;
628 spk = ARENT_CARRYING;
629 if (LIQLOC(game.loc) == 0)
631 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
635 rspeak(SHATTER_VASE);
636 game.prop[VASE] = VASE_BROKEN;
637 game.fixed[VASE] = -1;
638 return (discard(verb, obj, true));
639 } else if (obj == URN) {
641 if (game.prop[URN] != URN_EMPTY) {
647 if (k == 0 || !HERE(BOTTLE)) {
651 game.place[k] = LOC_NOWHERE;
652 game.prop[BOTTLE] = EMPTY_BOTTLE;
654 game.prop[URN] = URN_DARK;
655 spk = WATER_URN + game.prop[URN];
658 } else if (obj != NO_OBJECT && obj != BOTTLE) {
661 } else if (obj == NO_OBJECT && !HERE(BOTTLE))
664 if (LIQLOC(game.loc) == 0)
666 if (HERE(URN) && game.prop[URN] != URN_EMPTY)
670 if (spk == BOTTLED_WATER) {
671 /* FIXME: Arithmetic on property values */
672 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
675 game.place[k] = CARRIED;
683 static int find(token_t verb, token_t obj)
684 /* Find. Might be carrying it, or it might be here. Else give caveat. */
686 int spk = actions[verb].message;
688 (LIQUID() == obj && AT(BOTTLE)) ||
689 obj == LIQLOC(game.loc) ||
690 (obj == DWARF && atdwrf(game.loc) > 0))
695 spk = ALREADY_CARRYING;
700 static int fly(token_t verb, token_t obj)
701 /* Fly. Snide remarks unless hovering rug is here. */
703 int spk = actions[verb].message;
704 if (obj == INTRANSITIVE) {
705 if (game.prop[RUG] != RUG_HOVER)
709 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
721 if (game.prop[RUG] != RUG_HOVER) {
725 game.oldlc2 = game.oldloc;
726 game.oldloc = game.loc;
727 /* FIXME: Arithmetic on location values */
728 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
730 if (game.prop[SAPPH] >= 0)
736 static int inven(void)
737 /* Inventory. If object, treat same as find. Else report on current burden. */
740 for (int i = 1; i <= NOBJECTS; i++) {
741 if (i == BEAR || !TOTING(i))
745 pspeak(i, touch, -1, false);
754 static int light(token_t verb, token_t obj)
755 /* Light. Applicable only to lamp and urn. */
757 if (obj == INTRANSITIVE) {
758 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
760 if (HERE(URN) && game.prop[URN] == URN_DARK)
762 if (obj == INTRANSITIVE ||
763 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
764 HERE(URN) && game.prop[URN] == URN_DARK))
769 state_change(URN, game.prop[URN] == URN_EMPTY ? URN_EMPTY : URN_LIT);
773 rspeak(actions[verb].message);
776 if (game.limit < 0) {
780 state_change(LAMP, LAMP_BRIGHT);
788 static int listen(void)
789 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
791 long sound = locations[game.loc].sound;
792 if (sound != SILENT) {
794 if (!locations[game.loc].loud)
798 for (int i = 1; i <= NOBJECTS; i++) {
799 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
801 int mi = game.prop[i];
803 mi += 3 * game.blooded;
804 long packed_zzword = token_to_packed(game.zzword);
805 pspeak(i, hear, mi, true, packed_zzword);
807 /* FIXME: Magic number, sensitive to bird state logic */
808 if (i == BIRD && game.prop[i] == 5)
816 static int lock(token_t verb, token_t obj)
817 /* Lock, unlock, no object given. Assume various things if present. */
819 if (obj == INTRANSITIVE) {
830 if (obj == NO_OBJECT || obj == INTRANSITIVE) {
831 rspeak(NOTHING_LOCKED);
836 /* Lock, unlock object. Special stuff for opening clam/oyster
838 int spk = actions[verb].message;
839 if (obj == CLAM || obj == OYSTER)
840 return bivalve(verb, obj);
842 spk = (game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR;
847 if (obj == GRATE || obj == CHAIN) {
855 game.clock2 = PANICTIME;
858 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
867 static int pour(token_t verb, token_t obj)
868 /* Pour. If no object, or object is bottle, assume contents of bottle.
869 * special tests for pouring water or oil on plant or rusty door. */
871 if (obj == BOTTLE || obj == NO_OBJECT)
873 if (obj == NO_OBJECT)
876 rspeak(actions[verb].message);
880 if (obj != OIL && obj != WATER) {
884 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
885 return fill(verb, URN);
886 game.prop[BOTTLE] = EMPTY_BOTTLE;
887 game.place[obj] = LOC_NOWHERE;
888 if (!(AT(PLANT) || AT(DOOR))) {
894 rspeak(SHAKING_LEAVES);
897 pspeak(PLANT, look, game.prop[PLANT] + 3, true);
898 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
899 game.prop[PLANT2] = game.prop[PLANT];
902 state_change(DOOR, (obj == OIL) ? DOOR_UNRUSTED : DOOR_RUSTED);
907 static int quit(void)
908 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
910 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
915 static int read(struct command_t command)
916 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
918 if (command.obj == INTRANSITIVE) {
920 for (int i = 1; i <= NOBJECTS; i++) {
921 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
922 command.obj = command.obj * NOBJECTS + i;
924 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
928 if (DARK(game.loc)) {
929 rspeak(NO_SEE, command.wd1, command.wd1x);
930 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
931 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
932 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
933 rspeak(actions[command.verb].message);
935 pspeak(command.obj, study, game.prop[command.obj], true);
939 static int reservoir(void)
940 /* Z'ZZZ (word gets recomputed at startup; different each game). */
942 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
943 rspeak(NOTHING_HAPPENS);
946 pspeak(RESER, look, game.prop[RESER] + 1, true);
947 game.prop[RESER] = 1 - game.prop[RESER];
951 game.oldlc2 = game.loc;
959 static int rub(token_t verb, token_t obj)
960 /* Rub. Yields various snide remarks except for lit urn. */
962 if (obj == URN && game.prop[URN] == URN_LIT) {
964 drop(AMBER, game.loc);
965 game.prop[AMBER] = AMBER_IN_ROCK;
967 drop(CAVITY, game.loc);
969 } else if (obj != LAMP) {
970 rspeak(PECULIAR_NOTHING);
972 rspeak(actions[verb].message);
977 static int say(struct command_t *command)
978 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
980 long a = command->wd1, b = command->wd1x;
981 if (command->wd2 > 0) {
984 command->wd1 = command->wd2;
987 packed_to_token(command->wd1, word1);
988 int wd = (int) get_vocab_id(word1);
989 /* FIXME: magic numbers */
990 if (wd == MOTION_WORD(XYZZY) || wd == MOTION_WORD(PLUGH) || wd == MOTION_WORD(PLOVER) || wd == ACTION_WORD(GIANTWORDS) || wd == ACTION_WORD(PART)) {
991 /* FIXME: scribbles on the interpreter's command block */
992 wordclear(&command->wd2);
995 rspeak(OKEY_DOKEY, a, b);
999 static int throw_support(long spk)
1002 drop(AXE, game.loc);
1006 static int throw (struct command_t *command)
1007 /* Throw. Same as discard unless axe. Then same as attack except
1008 * ignore bird, and if dwarf is present then one might be killed.
1009 * (Only way to do so!) Axe also special for dragon, bear, and
1010 * troll. Treasures special for troll. */
1012 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1013 command->obj = ROD2;
1014 if (!TOTING(command->obj)) {
1015 rspeak(actions[command->verb].message);
1018 if (objects[command->obj].is_treasure && AT(TROLL)) {
1019 /* Snarf a treasure for the troll. */
1020 drop(command->obj, LOC_NOWHERE);
1021 move(TROLL, LOC_NOWHERE);
1022 move(TROLL + NOBJECTS, LOC_NOWHERE);
1023 drop(TROLL2, objects[TROLL].plac);
1024 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1026 rspeak(TROLL_SATISFIED);
1029 if (command->obj == FOOD && HERE(BEAR)) {
1030 /* But throwing food is another story. */
1031 command->obj = BEAR;
1032 return (feed(command->verb, command->obj));
1034 if (command->obj != AXE)
1035 return (discard(command->verb, command->obj, false));
1037 if (atdwrf(game.loc) <= 0) {
1038 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1039 return throw_support(DRAGON_SCALES);
1041 return throw_support(TROLL_RETURNS);
1043 return throw_support(OGRE_DODGE);
1044 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1045 /* This'll teach him to throw the axe at the bear! */
1046 drop(AXE, game.loc);
1047 game.fixed[AXE] = -1;
1049 state_change(AXE, AXE_LOST);
1052 command->obj = NO_OBJECT;
1053 return (attack(command));
1056 if (randrange(NDWARVES + 1) < game.dflag) {
1057 return throw_support(DWARF_DODGES);
1059 long i = atdwrf(game.loc);
1060 game.dseen[i] = false;
1062 return throw_support((++game.dkill == 1)
1063 ? DWARF_SMOKE : KILLED_DWARF);
1068 static int wake(token_t verb, token_t obj)
1069 /* Wake. Only use is to disturb the dwarves. */
1071 if (obj != DWARF || !game.closed) {
1072 rspeak(actions[verb].message);
1076 return GO_DWARFWAKE;
1080 static int wave(token_t verb, token_t obj)
1081 /* Wave. No effect unless waving rod at fissure or at bird. */
1085 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1086 rspeak(((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2))) ? ARENT_CARRYING : actions[verb].message);
1090 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1091 drop(JADE, game.loc);
1092 game.prop[JADE] = 0;
1094 rspeak(NECKLACE_FLY);
1098 rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY);
1099 return GO_DWARFWAKE;
1101 if (game.closng || !AT(FISSURE)) {
1102 rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY);
1106 rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY);
1108 /* FIXME: Arithemetic on property values */
1109 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1110 pspeak(FISSURE, look, 2 - game.prop[FISSURE], true);
1115 int action(struct command_t *command)
1116 /* Analyse a verb. Remember what it was, go back for object if second word
1117 * unless verb is "say", which snarfs arbitrary second word.
1120 if (command->part == unknown) {
1121 /* Analyse an object word. See if the thing is here, whether
1122 * we've got a verb yet, and so on. Object must be here
1123 * unless verb is "find" or "invent(ory)" (and no new verb
1124 * yet to be analysed). Water and oil are also funny, since
1125 * they are never actually dropped at any location, but might
1126 * be here inside the bottle or urn or as a feature of the
1128 if (HERE(command->obj))
1130 else if (command->obj == GRATE) {
1131 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1132 command->obj = DPRSSN;
1133 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1134 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1135 command->obj = ENTRNC;
1136 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1138 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1140 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1143 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1144 command->obj = PLANT2;
1146 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1148 rspeak(KNIVES_VANISH);
1150 } else if (command->obj == ROD && HERE(ROD2)) {
1151 command->obj = ROD2;
1153 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1156 rspeak(NO_SEE, command->wd1, command->wd1x);
1160 if (command->wd2 > 0)
1162 if (command->verb != 0)
1163 command->part = transitive;
1166 switch (command->part) {
1168 if (command->wd2 > 0 && command->verb != SAY)
1170 if (command->verb == SAY)
1171 command->obj = command->wd2;
1172 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1173 /* Analyse an intransitive verb (ie, no object given yet). */
1174 switch (command->verb) {
1176 return vcarry(command->verb, INTRANSITIVE);
1182 return lock(command->verb, INTRANSITIVE);
1185 return (GO_CLEAROBJ);
1188 return lock(command->verb, INTRANSITIVE);
1190 return light(command->verb, INTRANSITIVE);
1192 return extinguish(command->verb, INTRANSITIVE);
1198 rspeak(actions[command->verb].message);
1202 return attack(command);
1204 return pour(command->verb, command->obj);
1206 return eat(command->verb, INTRANSITIVE);
1208 return drink(command->verb, command->obj);
1222 return fill(command->verb, command->obj);
1230 return bigwords(command->wd1);
1234 command->obj = INTRANSITIVE;
1235 return read(*command);
1245 return fly(command->verb, INTRANSITIVE);
1251 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1256 /* Analyse a transitive verb. */
1257 switch (command->verb) {
1259 return vcarry(command->verb, command->obj);
1261 return discard(command->verb, command->obj, false);
1263 return say(command);
1265 return lock(command->verb, command->obj);
1268 return (GO_CLEAROBJ);
1271 return lock(command->verb, command->obj);
1273 return light(command->verb, command->obj);
1275 return extinguish(command->verb, command->obj);
1277 return wave(command->verb, command->obj);
1279 rspeak(actions[command->verb].message);
1283 rspeak(actions[command->verb].message);
1287 return attack(command);
1289 return pour(command->verb, command->obj);
1291 return eat(command->verb, command->obj);
1293 return drink(command->verb, command->obj);
1295 return rub(command->verb, command->obj);
1297 return throw (command);
1299 rspeak(actions[command->verb].message);
1303 return find(command->verb, command->obj);
1305 return find(command->verb, command->obj);
1307 return feed(command->verb, command->obj);
1309 return fill(command->verb, command->obj);
1314 rspeak(actions[command->verb].message);
1318 rspeak(actions[command->verb].message);
1322 rspeak(actions[command->verb].message);
1326 return read(*command);
1328 return vbreak(command->verb, command->obj);
1330 return wake(command->verb, command->obj);
1332 rspeak(actions[command->verb].message);
1336 rspeak(actions[command->verb].message);
1340 return fly(command->verb, command->obj);
1342 rspeak(actions[command->verb].message);
1348 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1351 /* Unknown verb, couldn't deduce object - might need hint */
1352 rspeak(WHAT_DO, command->wd1, command->wd1x);
1353 return GO_CHECKHINT;
1355 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE