7 static int fill(token_t, token_t);
9 static void state_change(long obj, long state)
11 game.prop[obj] = state;
12 pspeak(obj, change, state, true);
15 static int attack(struct command_t *command)
16 /* Attack. Assume target if unambiguous. "Throw" also links here.
17 * Attackable objects fall into two categories: enemies (snake,
18 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
19 * enemies, or no enemies but 2 others. */
21 vocab_t verb = command->verb;
22 vocab_t obj = command->obj;
24 if (obj == NO_OBJECT ||
25 obj == INTRANSITIVE) {
27 if (atdwrf(game.loc) > 0) {
35 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
47 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
51 /* check for low-priority targets */
52 if (obj == NO_OBJECT) {
53 /* Can't attack bird or machine by throwing axe. */
54 if (HERE(BIRD) && verb != THROW) {
58 if (HERE(VEND) && verb != THROW) {
62 /* Clam and oyster both treated as clam for intransitive case;
64 if (HERE(CLAM) || HERE(OYSTER)) {
84 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
89 switch (game.prop[BEAR]) {
94 rspeak(BEAR_CONFUSED);
97 rspeak(BEAR_CONFUSED);
100 rspeak(ALREADY_DEAD);
105 if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
106 /* Fun stuff for dragon. If he insists on attacking it, win!
107 * Set game.prop to dead, move dragon to central loc (still
108 * fixed), move rug there (not fixed), and move him there,
109 * too. Then do a null motion to get new description. */
110 rspeak(BARE_HANDS_QUERY);
112 // FIXME: setting wd1 is a workaround for broken logic
113 command->wd1 = token_to_packed("Y");
115 // FIXME: setting wd1 is a workaround for broken logic
116 command->wd1 = token_to_packed("N");
119 state_change(DRAGON, DRAGON_DEAD);
120 game.prop[RUG] = RUG_FLOOR;
121 /* FIXME: Arithmetic on location values */
122 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
123 move(DRAGON + NOBJECTS, -1);
124 move(RUG + NOBJECTS, 0);
128 for (obj = 1; obj <= NOBJECTS; obj++) {
129 if (game.place[obj] == objects[DRAGON].plac ||
130 game.place[obj] == objects[DRAGON].fixd)
139 if (atdwrf(game.loc) == 0)
142 rspeak(KNIFE_THROWN);
145 for (int i = 1; i < PIRATE; i++) {
146 if (game.dloc[i] == game.loc) {
148 game.dloc[i] = LOC_LONGWEST;
149 game.dseen[i] = false;
152 rspeak((dwarves > 1) ?
164 rspeak(SHELL_IMPERVIOUS);
167 rspeak(SNAKE_WARNING);
173 rspeak(BARE_HANDS_QUERY);
176 rspeak(ALREADY_DEAD);
182 rspeak(actions[verb].message);
187 static int bigwords(token_t foo)
188 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
189 * Look up foo in special section of vocab to determine which word we've got.
190 * Last word zips the eggs back to the giant room (unless already there). */
192 char word[TOKLEN + 1];
193 packed_to_token(foo, word);
194 int k = (int) get_special_vocab_id(word);
195 if (game.foobar != 1 - k) {
196 if (game.foobar != 0 && game.loc == LOC_GIANTROOM) {
199 rspeak(NOTHING_HAPPENS);
209 if (game.place[EGGS] == objects[EGGS].plac ||
210 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
211 rspeak(NOTHING_HAPPENS);
214 /* Bring back troll if we steal the eggs back from him before
216 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
217 game.prop[TROLL] = TROLL_PAIDONCE;
221 if (game.loc == objects[EGGS].plac)
223 move(EGGS, objects[EGGS].plac);
224 pspeak(EGGS, look, k, true);
230 static void blast(void)
231 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
233 if (game.prop[ROD2] < 0 ||
235 rspeak(REQUIRES_DYNAMITE);
237 game.bonus = VICTORY_MESSAGE;
238 if (game.loc == LOC_NE)
239 game.bonus = DEFEAT_MESSAGE;
241 game.bonus = SPLATTER_MESSAGE;
247 static int vbreak(token_t verb, token_t obj)
248 /* Break. Only works for mirror in repository and, of course, the vase. */
252 rspeak(BREAK_MIRROR);
259 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
261 drop(VASE, game.loc);
262 state_change(VASE, VASE_BROKEN);
263 game.fixed[VASE] = -1;
266 rspeak(actions[verb].message);
267 return (GO_CLEAROBJ);
270 static int brief(void)
271 /* Brief. Intransitive only. Suppress long descriptions after first time. */
275 rspeak(BRIEF_CONFIRM);
279 static int vcarry(token_t verb, token_t obj)
280 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
281 * take one without the other). Liquids also special, since they depend on
282 * status of bottle. Also various side effects, etc. */
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)
290 obj = game.atloc[game.loc];
294 rspeak(ALREADY_CARRYING);
299 rspeak(REMOVE_MESSAGE);
304 if (game.fixed[obj] != 0) {
305 if (obj == PLANT && game.prop[PLANT] <= 0) {
309 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
310 rspeak(BEAR_CHAINED);
313 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
314 rspeak(STILL_LOCKED);
322 rspeak(DOUGHNUT_HOLES);
329 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
334 rspeak(HAND_PASSTHROUGH);
345 if (TOTING(BOTTLE)) {
346 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
347 return (fill(verb, BOTTLE));
348 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
352 rspeak(NO_CONTAINER);
358 if (game.holdng >= INVLIMIT) {
364 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
365 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
371 rspeak(CANNOT_CARRY);
378 game.prop[BIRD] = BIRD_CAGED;
380 /* FIXME: Arithmetic on state numbers */
383 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
384 carry(BIRD + CAGE - obj, game.loc);
385 carry(obj, game.loc);
386 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
387 game.place[LIQUID()] = CARRIED;
388 if (GSTONE(obj) && game.prop[obj] != 0) {
391 game.prop[CAVITY] = CAVITY_EMPTY;
397 static int chain(token_t verb)
398 /* Do something to the bear's chain */
401 if (game.prop[BEAR] == UNTAMED_BEAR) {
405 if (game.prop[CHAIN] == CHAIN_HEAP) {
406 rspeak(ALREADY_UNLOCKED);
409 game.prop[CHAIN] = CHAIN_HEAP;
410 game.fixed[CHAIN] = CHAIN_HEAP;
411 if (game.prop[BEAR] != BEAR_DEAD)
412 game.prop[BEAR] = CONTENTED_BEAR;
414 switch (game.prop[BEAR]) {
416 game.fixed[BEAR] = -1;
419 game.fixed[BEAR] = 0;
421 rspeak(CHAIN_UNLOCKED);
425 if (game.prop[CHAIN] != CHAIN_HEAP) {
426 rspeak(ALREADY_LOCKED);
429 if (game.loc != objects[CHAIN].plac) {
434 game.prop[CHAIN] = CHAIN_FIXED;
437 drop(CHAIN, game.loc);
438 game.fixed[CHAIN] = -1;
440 rspeak(CHAIN_LOCKED);
444 static int discard(token_t verb, token_t obj, bool just_do_it)
445 /* Discard object. "Throw" also comes here for most objects. Special cases for
446 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
447 * Drop coins at vending machine for extra batteries. */
450 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
453 rspeak(actions[verb].message);
456 if (obj == BIRD && HERE(SNAKE)) {
457 rspeak(BIRD_ATTACKS);
461 /* Set game.prop for use by travel options */
462 game.prop[SNAKE] = SNAKE_CHASED;
464 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
467 game.prop[CAVITY] = CAVITY_FULL;
468 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
469 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
476 if (spk != RUG_WIGGLES) {
477 /* FIXME: Arithmetic on state numbers */
478 int k = 2 - game.prop[RUG];
481 k = objects[SAPPH].plac;
482 move(RUG + NOBJECTS, k);
485 } else if (obj == COINS && HERE(VEND)) {
487 drop(BATTERY, game.loc);
488 pspeak(BATTERY, look, FRESH_BATTERIES, true);
490 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
494 } else if (obj == BEAR && AT(TROLL)) {
495 state_change(TROLL, TROLL_GONE);
496 move(TROLL, LOC_NOWHERE);
497 move(TROLL + NOBJECTS, LOC_NOWHERE);
498 move(TROLL2, objects[TROLL].plac);
499 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
501 } else if (obj != VASE ||
502 game.loc == objects[PILLOW].plac) {
505 game.prop[VASE] = VASE_BROKEN;
507 game.prop[VASE] = VASE_WHOLE;
508 pspeak(VASE, look, game.prop[VASE] + 1, true);
509 if (game.prop[VASE] != VASE_WHOLE)
510 game.fixed[VASE] = -1;
516 if (obj == BOTTLE && k != NO_OBJECT)
517 game.place[k] = LOC_NOWHERE;
518 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
519 drop(BIRD, game.loc);
523 game.prop[BIRD] = BIRD_UNCAGED;
524 if (FOREST(game.loc))
525 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
529 static int drink(token_t verb, token_t obj)
530 /* Drink. If no object, assume water and look for it here. If water is in
531 * the bottle, drink that, else must be at a water loc, so drink stream. */
533 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
534 (LIQUID() != WATER || !HERE(BOTTLE))) {
540 state_change(DRAGON, DRAGON_BLOODLESS);
545 if (obj != NO_OBJECT && obj != WATER) {
546 rspeak(RIDICULOUS_ATTEMPT);
549 if (LIQUID() == WATER && HERE(BOTTLE)) {
550 game.prop[BOTTLE] = EMPTY_BOTTLE;
551 game.place[WATER] = LOC_NOWHERE;
552 rspeak(BOTTLE_EMPTY);
556 rspeak(actions[verb].message);
560 static int eat(token_t verb, token_t obj)
561 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
562 * ok, some things lose appetite, rest are ridiculous. */
564 if (obj == INTRANSITIVE) {
568 rspeak(THANKS_DELICIOUS);
573 rspeak(THANKS_DELICIOUS);
585 rspeak(LOST_APPETITE);
588 rspeak(actions[verb].message);
592 static int extinguish(token_t verb, int obj)
593 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
595 if (obj == INTRANSITIVE) {
596 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
598 if (HERE(URN) && game.prop[URN] == URN_LIT)
600 if (obj == INTRANSITIVE)
605 if (game.prop[URN] != URN_EMPTY) {
606 state_change(URN, URN_DARK);
608 pspeak(URN, change, URN_DARK, true);
614 state_change(LAMP, LAMP_DARK);
615 rspeak(DARK(game.loc) ?
623 rspeak(BEYOND_POWER);
627 rspeak(actions[verb].message);
631 static int feed(token_t verb, token_t obj)
632 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
633 * mad. Bear, special. */
635 int spk = actions[verb].message;
639 } else if (obj == SNAKE ||
642 spk = NOTHING_EDIBLE;
643 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
644 spk = RIDICULOUS_ATTEMPT;
647 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
651 } else if (obj == DWARF) {
656 } else if (obj == BEAR) {
657 if (game.prop[BEAR] == UNTAMED_BEAR)
658 spk = NOTHING_EDIBLE;
659 if (game.prop[BEAR] == BEAR_DEAD)
660 spk = RIDICULOUS_ATTEMPT;
663 game.prop[BEAR] = SITTING_BEAR;
668 } else if (obj == OGRE) {
678 int fill(token_t verb, token_t obj)
679 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
683 if (LIQLOC(game.loc) == NO_OBJECT) {
684 rspeak(FILL_INVALID);
688 rspeak(ARENT_CARRYING);
691 rspeak(SHATTER_VASE);
692 game.prop[VASE] = VASE_BROKEN;
693 game.fixed[VASE] = -1;
694 return (discard(verb, VASE, true));
698 if (game.prop[URN] != URN_EMPTY) {
703 rspeak(FILL_INVALID);
709 game.prop[BOTTLE] = EMPTY_BOTTLE;
713 game.prop[URN] = URN_DARK;
714 game.prop[BOTTLE] = EMPTY_BOTTLE;
719 rspeak(FILL_INVALID);
722 game.place[k] = LOC_NOWHERE;
725 if (obj != NO_OBJECT && obj != BOTTLE) {
726 rspeak(actions[verb].message);
729 if (obj == NO_OBJECT && !HERE(BOTTLE))
732 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
736 if (LIQUID() != NO_OBJECT) {
740 if (LIQLOC(game.loc) == NO_OBJECT) {
745 game.prop[BOTTLE] = (LIQLOC(game.loc) == OIL) ? OIL_BOTTLE : WATER_BOTTLE;
747 game.place[LIQUID()] = CARRIED;
751 rspeak(BOTTLED_WATER);
755 static int find(token_t verb, token_t obj)
756 /* Find. Might be carrying it, or it might be here. Else give caveat. */
759 rspeak(ALREADY_CARRYING);
764 rspeak(NEEDED_NEARBY);
769 (LIQUID() == obj && AT(BOTTLE)) ||
770 obj == LIQLOC(game.loc) ||
771 (obj == DWARF && atdwrf(game.loc) > 0)) {
777 rspeak(actions[verb].message);
781 static int fly(token_t verb, token_t obj)
782 /* Fly. Snide remarks unless hovering rug is here. */
784 if (obj == INTRANSITIVE) {
789 if (game.prop[RUG] != RUG_HOVER) {
790 rspeak(RUG_NOTHING2);
797 rspeak(actions[verb].message);
800 if (game.prop[RUG] != RUG_HOVER) {
801 rspeak(RUG_NOTHING1);
804 game.oldlc2 = game.oldloc;
805 game.oldloc = game.loc;
806 /* FIXME: Arithmetic on location values */
807 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
809 if (game.prop[SAPPH] >= 0) {
817 static int inven(void)
818 /* Inventory. If object, treat same as find. Else report on current burden. */
821 for (int i = 1; i <= NOBJECTS; i++) {
829 pspeak(i, touch, -1, false);
838 static int light(token_t verb, token_t obj)
839 /* Light. Applicable only to lamp and urn. */
841 if (obj == INTRANSITIVE) {
842 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
844 if (HERE(URN) && game.prop[URN] == URN_DARK)
846 if (obj == INTRANSITIVE ||
847 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
848 HERE(URN) && game.prop[URN] == URN_DARK))
853 state_change(URN, game.prop[URN] == URN_EMPTY ?
859 rspeak(actions[verb].message);
862 if (game.limit < 0) {
866 state_change(LAMP, LAMP_BRIGHT);
874 static int listen(void)
875 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
877 long sound = locations[game.loc].sound;
878 if (sound != SILENT) {
880 if (!locations[game.loc].loud)
884 for (int i = 1; i <= NOBJECTS; i++) {
886 objects[i].sounds[0] == NULL ||
889 int mi = game.prop[i];
891 mi += 3 * game.blooded;
892 long packed_zzword = token_to_packed(game.zzword);
893 pspeak(i, hear, mi, true, packed_zzword);
895 /* FIXME: Magic number, sensitive to bird state logic */
896 if (i == BIRD && game.prop[i] == 5)
904 static int lock(token_t verb, token_t obj)
905 /* Lock, unlock, no object given. Assume various things if present. */
907 if (obj == INTRANSITIVE) {
918 if (obj == INTRANSITIVE) {
919 rspeak(NOTHING_LOCKED);
924 /* Lock, unlock object. Special stuff for opening clam/oyster
934 game.clock2 = PANICTIME;
938 state_change(GRATE, (verb == LOCK) ?
952 else if (!TOTING(TRIDENT))
953 rspeak(OYSTER_OPENER);
956 drop(OYSTER, game.loc);
957 drop(PEARL, LOC_CULDESAC);
965 rspeak(OYSTER_OPENER);
969 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
975 rspeak(CANNOT_UNLOCK);
978 rspeak(actions[verb].message);
984 static int pour(token_t verb, token_t obj)
985 /* Pour. If no object, or object is bottle, assume contents of bottle.
986 * special tests for pouring water or oil on plant or rusty door. */
991 if (obj == NO_OBJECT)
994 rspeak(actions[verb].message);
998 if (obj != OIL && obj != WATER) {
1002 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1003 return fill(verb, URN);
1004 game.prop[BOTTLE] = EMPTY_BOTTLE;
1005 game.place[obj] = LOC_NOWHERE;
1013 /* cycle through the three plant states */
1014 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1015 game.prop[PLANT2] = game.prop[PLANT];
1018 rspeak(SHAKING_LEAVES);
1022 state_change(DOOR, (obj == OIL) ?
1029 static int quit(void)
1030 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1032 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1033 terminate(quitgame);
1037 static int read(struct command_t command)
1038 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1040 if (command.obj == INTRANSITIVE) {
1042 for (int i = 1; i <= NOBJECTS; i++) {
1043 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1044 command.obj = command.obj * NOBJECTS + i;
1046 if (command.obj > NOBJECTS ||
1052 if (DARK(game.loc)) {
1053 sspeak(NO_SEE, command.raw1);
1054 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1055 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1056 } else if (objects[command.obj].texts[0] == NULL ||
1057 game.prop[command.obj] < 0) {
1058 rspeak(actions[command.verb].message);
1060 pspeak(command.obj, study, game.prop[command.obj], true);
1064 static int reservoir(void)
1065 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1067 /* FIXME: Arithmetic on state numbers */
1068 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
1069 rspeak(NOTHING_HAPPENS);
1073 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1077 game.oldlc2 = game.loc;
1078 game.newloc = LOC_NOWHERE;
1080 return GO_TERMINATE;
1085 static int rub(token_t verb, token_t obj)
1086 /* Rub. Yields various snide remarks except for lit urn. */
1088 if (obj == URN && game.prop[URN] == URN_LIT) {
1090 drop(AMBER, game.loc);
1091 game.prop[AMBER] = AMBER_IN_ROCK;
1093 drop(CAVITY, game.loc);
1095 } else if (obj != LAMP) {
1096 rspeak(PECULIAR_NOTHING);
1098 rspeak(actions[verb].message);
1103 static int say(struct command_t *command)
1104 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1106 if (command->wd2 > 0) {
1107 command->wd1 = command->wd2;
1108 strcpy(command->raw1, command->raw2);
1110 char word1[TOKLEN + 1];
1111 packed_to_token(command->wd1, word1);
1112 int wd = (int) get_vocab_id(word1);
1113 /* FIXME: magic numbers */
1114 if (wd == MOTION_WORD(XYZZY) ||
1115 wd == MOTION_WORD(PLUGH) ||
1116 wd == MOTION_WORD(PLOVER) ||
1117 wd == ACTION_WORD(GIANTWORDS) ||
1118 wd == ACTION_WORD(PART)) {
1119 /* FIXME: scribbles on the interpreter's command block */
1120 wordclear(&command->wd2);
1123 sspeak(OKEY_DOKEY, command->raw1);
1127 static int throw_support(long spk)
1130 drop(AXE, game.loc);
1134 static int throw (struct command_t *command)
1135 /* Throw. Same as discard unless axe. Then same as attack except
1136 * ignore bird, and if dwarf is present then one might be killed.
1137 * (Only way to do so!) Axe also special for dragon, bear, and
1138 * troll. Treasures special for troll. */
1140 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1141 command->obj = ROD2;
1142 if (!TOTING(command->obj)) {
1143 rspeak(actions[command->verb].message);
1146 if (objects[command->obj].is_treasure && AT(TROLL)) {
1147 /* Snarf a treasure for the troll. */
1148 drop(command->obj, LOC_NOWHERE);
1149 move(TROLL, LOC_NOWHERE);
1150 move(TROLL + NOBJECTS, LOC_NOWHERE);
1151 drop(TROLL2, objects[TROLL].plac);
1152 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1154 rspeak(TROLL_SATISFIED);
1157 if (command->obj == FOOD && HERE(BEAR)) {
1158 /* But throwing food is another story. */
1159 command->obj = BEAR;
1160 return (feed(command->verb, command->obj));
1162 if (command->obj != AXE)
1163 return (discard(command->verb, command->obj, false));
1165 if (atdwrf(game.loc) <= 0) {
1166 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1167 return throw_support(DRAGON_SCALES);
1169 return throw_support(TROLL_RETURNS);
1171 return throw_support(OGRE_DODGE);
1172 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1173 /* This'll teach him to throw the axe at the bear! */
1174 drop(AXE, game.loc);
1175 game.fixed[AXE] = -1;
1177 state_change(AXE, AXE_LOST);
1180 command->obj = NO_OBJECT;
1181 return (attack(command));
1184 if (randrange(NDWARVES + 1) < game.dflag) {
1185 return throw_support(DWARF_DODGES);
1187 long i = atdwrf(game.loc);
1188 game.dseen[i] = false;
1189 game.dloc[i] = LOC_NOWHERE;
1190 return throw_support((++game.dkill == 1) ?
1197 static int wake(token_t verb, token_t obj)
1198 /* Wake. Only use is to disturb the dwarves. */
1202 rspeak(actions[verb].message);
1206 return GO_DWARFWAKE;
1210 static int wave(token_t verb, token_t obj)
1211 /* Wave. No effect unless waving rod at fissure or at bird. */
1218 rspeak(((!TOTING(obj)) && (obj != ROD ||
1221 actions[verb].message);
1225 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1226 drop(JADE, game.loc);
1227 game.prop[JADE] = 0;
1229 rspeak(NECKLACE_FLY);
1233 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1236 return GO_DWARFWAKE;
1240 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1246 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1250 state_change(FISSURE,
1251 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1256 int action(struct command_t *command)
1257 /* Analyse a verb. Remember what it was, go back for object if second word
1258 * unless verb is "say", which snarfs arbitrary second word.
1261 if (command->part == unknown) {
1262 /* Analyse an object word. See if the thing is here, whether
1263 * we've got a verb yet, and so on. Object must be here
1264 * unless verb is "find" or "invent(ory)" (and no new verb
1265 * yet to be analysed). Water and oil are also funny, since
1266 * they are never actually dropped at any location, but might
1267 * be here inside the bottle or urn or as a feature of the
1269 if (HERE(command->obj))
1271 else if (command->obj == GRATE) {
1272 if (game.loc == LOC_START ||
1273 game.loc == LOC_VALLEY ||
1274 game.loc == LOC_SLIT) {
1275 command->obj = DPRSSN;
1277 if (game.loc == LOC_COBBLE ||
1278 game.loc == LOC_DEBRIS ||
1279 game.loc == LOC_AWKWARD ||
1280 game.loc == LOC_BIRD ||
1281 game.loc == LOC_PITTOP) {
1282 command->obj = ENTRNC;
1284 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1286 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1287 command->obj == LIQLOC(game.loc))
1289 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1292 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1293 command->obj = PLANT2;
1295 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1297 rspeak(KNIVES_VANISH);
1299 } else if (command->obj == ROD && HERE(ROD2)) {
1300 command->obj = ROD2;
1302 } else if ((command->verb == FIND ||
1303 command->verb == INVENTORY) && command->wd2 <= 0)
1306 sspeak(NO_SEE, command->raw1);
1310 if (command->wd2 > 0)
1312 if (command->verb != 0)
1313 command->part = transitive;
1316 switch (command->part) {
1318 if (command->wd2 > 0 && command->verb != SAY)
1320 if (command->verb == SAY)
1321 command->obj = command->wd2;
1322 if (command->obj == NO_OBJECT ||
1323 command->obj == INTRANSITIVE) {
1324 /* Analyse an intransitive verb (ie, no object given yet). */
1325 switch (command->verb) {
1327 return vcarry(command->verb, INTRANSITIVE);
1333 return lock(command->verb, INTRANSITIVE);
1336 return (GO_CLEAROBJ);
1339 return lock(command->verb, INTRANSITIVE);
1341 return light(command->verb, INTRANSITIVE);
1343 return extinguish(command->verb, INTRANSITIVE);
1349 rspeak(actions[command->verb].message);
1353 return attack(command);
1355 return pour(command->verb, command->obj);
1357 return eat(command->verb, INTRANSITIVE);
1359 return drink(command->verb, command->obj);
1373 return fill(command->verb, command->obj);
1381 return bigwords(command->wd1);
1385 command->obj = INTRANSITIVE;
1386 return read(*command);
1396 return fly(command->verb, INTRANSITIVE);
1402 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1407 /* Analyse a transitive verb. */
1408 switch (command->verb) {
1410 return vcarry(command->verb, command->obj);
1412 return discard(command->verb, command->obj, false);
1414 return say(command);
1416 return lock(command->verb, command->obj);
1419 return (GO_CLEAROBJ);
1422 return lock(command->verb, command->obj);
1424 return light(command->verb, command->obj);
1426 return extinguish(command->verb, command->obj);
1428 return wave(command->verb, command->obj);
1430 rspeak(actions[command->verb].message);
1434 rspeak(actions[command->verb].message);
1438 return attack(command);
1440 return pour(command->verb, command->obj);
1442 return eat(command->verb, command->obj);
1444 return drink(command->verb, command->obj);
1446 return rub(command->verb, command->obj);
1448 return throw (command);
1450 rspeak(actions[command->verb].message);
1454 return find(command->verb, command->obj);
1456 return find(command->verb, command->obj);
1458 return feed(command->verb, command->obj);
1460 return fill(command->verb, command->obj);
1465 rspeak(actions[command->verb].message);
1469 rspeak(actions[command->verb].message);
1473 rspeak(actions[command->verb].message);
1477 return read(*command);
1479 return vbreak(command->verb, command->obj);
1481 return wake(command->verb, command->obj);
1483 rspeak(actions[command->verb].message);
1487 rspeak(actions[command->verb].message);
1491 return fly(command->verb, command->obj);
1493 rspeak(actions[command->verb].message);
1499 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1502 /* Unknown verb, couldn't deduce object - might need hint */
1503 sspeak(WHAT_DO, command->raw1);
1504 return GO_CHECKHINT;
1506 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE