7 static int fill(token_t, token_t);
9 static void state_change(long obj, long state)
10 /* Object must have a change-message list for this to be useful; only some do */
12 game.prop[obj] = state;
13 pspeak(obj, change, state, true);
16 static int attack(struct command_t *command)
17 /* Attack. Assume target if unambiguous. "Throw" also links here.
18 * Attackable objects fall into two categories: enemies (snake,
19 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
20 * enemies, or no enemies but 2 others. */
22 vocab_t verb = command->verb;
23 vocab_t obj = command->obj;
25 if (obj == NO_OBJECT ||
26 obj == INTRANSITIVE) {
28 if (atdwrf(game.loc) > 0) {
36 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
48 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
52 /* check for low-priority targets */
53 if (obj == NO_OBJECT) {
54 /* Can't attack bird or machine by throwing axe. */
55 if (HERE(BIRD) && verb != THROW) {
59 if (HERE(VEND) && verb != THROW) {
63 /* Clam and oyster both treated as clam for intransitive case;
65 if (HERE(CLAM) || HERE(OYSTER)) {
85 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
90 switch (game.prop[BEAR]) {
95 rspeak(BEAR_CONFUSED);
98 rspeak(BEAR_CONFUSED);
101 rspeak(ALREADY_DEAD);
106 if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
107 /* Fun stuff for dragon. If he insists on attacking it, win!
108 * Set game.prop to dead, move dragon to central loc (still
109 * fixed), move rug there (not fixed), and move him there,
110 * too. Then do a null motion to get new description. */
111 rspeak(BARE_HANDS_QUERY);
113 // FIXME: setting wd1 is a workaround for broken logic
114 command->wd1 = token_to_packed("Y");
116 // FIXME: setting wd1 is a workaround for broken logic
117 command->wd1 = token_to_packed("N");
120 state_change(DRAGON, DRAGON_DEAD);
121 game.prop[RUG] = RUG_FLOOR;
122 /* FIXME: Arithmetic on location values */
123 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
124 move(DRAGON + NOBJECTS, -1);
125 move(RUG + NOBJECTS, 0);
129 for (obj = 1; obj <= NOBJECTS; obj++) {
130 if (game.place[obj] == objects[DRAGON].plac ||
131 game.place[obj] == objects[DRAGON].fixd)
140 if (atdwrf(game.loc) == 0)
143 rspeak(KNIFE_THROWN);
146 for (int i = 1; i < PIRATE; i++) {
147 if (game.dloc[i] == game.loc) {
149 game.dloc[i] = LOC_LONGWEST;
150 game.dseen[i] = false;
153 rspeak((dwarves > 1) ?
165 rspeak(SHELL_IMPERVIOUS);
168 rspeak(SNAKE_WARNING);
174 rspeak(BARE_HANDS_QUERY);
177 rspeak(ALREADY_DEAD);
183 rspeak(actions[verb].message);
188 static int bigwords(token_t foo)
189 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
190 * Look up foo in special section of vocab to determine which word we've got.
191 * Last word zips the eggs back to the giant room (unless already there). */
193 char word[TOKLEN + 1];
194 packed_to_token(foo, word);
195 int k = (int) get_special_vocab_id(word);
196 if (game.foobar != 1 - k) {
197 if (game.foobar != 0 && game.loc == LOC_GIANTROOM) {
200 rspeak(NOTHING_HAPPENS);
210 if (game.place[EGGS] == objects[EGGS].plac ||
211 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
212 rspeak(NOTHING_HAPPENS);
215 /* Bring back troll if we steal the eggs back from him before
217 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
218 game.prop[TROLL] = TROLL_PAIDONCE;
222 if (game.loc == objects[EGGS].plac)
224 move(EGGS, objects[EGGS].plac);
225 pspeak(EGGS, look, k, true);
231 static void blast(void)
232 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
234 if (game.prop[ROD2] < 0 ||
236 rspeak(REQUIRES_DYNAMITE);
238 game.bonus = VICTORY_MESSAGE;
239 if (game.loc == LOC_NE)
240 game.bonus = DEFEAT_MESSAGE;
242 game.bonus = SPLATTER_MESSAGE;
248 static int vbreak(token_t verb, token_t obj)
249 /* Break. Only works for mirror in repository and, of course, the vase. */
253 rspeak(BREAK_MIRROR);
260 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
262 drop(VASE, game.loc);
263 state_change(VASE, VASE_BROKEN);
264 game.fixed[VASE] = -1;
267 rspeak(actions[verb].message);
268 return (GO_CLEAROBJ);
271 static int brief(void)
272 /* Brief. Intransitive only. Suppress long descriptions after first time. */
276 rspeak(BRIEF_CONFIRM);
280 static int vcarry(token_t verb, token_t obj)
281 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
282 * take one without the other). Liquids also special, since they depend on
283 * status of bottle. Also various side effects, etc. */
285 if (obj == INTRANSITIVE) {
286 /* Carry, no object given yet. OK if only one object present. */
287 if (game.atloc[game.loc] == 0 ||
288 game.link[game.atloc[game.loc]] != 0 ||
289 atdwrf(game.loc) > 0)
291 obj = game.atloc[game.loc];
295 rspeak(ALREADY_CARRYING);
300 rspeak(REMOVE_MESSAGE);
305 if (game.fixed[obj] != 0) {
306 if (obj == PLANT && game.prop[PLANT] <= 0) {
310 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
311 rspeak(BEAR_CHAINED);
314 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
315 rspeak(STILL_LOCKED);
323 rspeak(DOUGHNUT_HOLES);
330 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
335 rspeak(HAND_PASSTHROUGH);
346 if (TOTING(BOTTLE)) {
347 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
348 return (fill(verb, BOTTLE));
349 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
353 rspeak(NO_CONTAINER);
359 if (game.holdng >= INVLIMIT) {
365 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
366 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
372 rspeak(CANNOT_CARRY);
379 game.prop[BIRD] = BIRD_CAGED;
383 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
384 /* expression maps BIRD to CAGE and CAGE to BIRD */
385 carry(BIRD + CAGE - obj, game.loc);
386 carry(obj, game.loc);
387 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
388 game.place[LIQUID()] = CARRIED;
389 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
390 game.prop[obj] = STATE_FOUND;
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)) {
466 game.prop[obj] = STATE_IN_CAVITY;
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;
665 game.prop[AXE] = AXE_HERE;
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 if (wd == MOTION_WORD(XYZZY) ||
1114 wd == MOTION_WORD(PLUGH) ||
1115 wd == MOTION_WORD(PLOVER) ||
1116 wd == ACTION_WORD(GIANTWORDS) ||
1117 wd == ACTION_WORD(PART)) {
1118 /* FIXME: scribbles on the interpreter's command block */
1119 wordclear(&command->wd2);
1122 sspeak(OKEY_DOKEY, command->raw1);
1126 static int throw_support(long spk)
1129 drop(AXE, game.loc);
1133 static int throw (struct command_t *command)
1134 /* Throw. Same as discard unless axe. Then same as attack except
1135 * ignore bird, and if dwarf is present then one might be killed.
1136 * (Only way to do so!) Axe also special for dragon, bear, and
1137 * troll. Treasures special for troll. */
1139 if (!TOTING(command->obj)) {
1140 rspeak(actions[command->verb].message);
1143 if (objects[command->obj].is_treasure && AT(TROLL)) {
1144 /* Snarf a treasure for the troll. */
1145 drop(command->obj, LOC_NOWHERE);
1146 move(TROLL, LOC_NOWHERE);
1147 move(TROLL + NOBJECTS, LOC_NOWHERE);
1148 drop(TROLL2, objects[TROLL].plac);
1149 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1151 rspeak(TROLL_SATISFIED);
1154 if (command->obj == FOOD && HERE(BEAR)) {
1155 /* But throwing food is another story. */
1156 command->obj = BEAR;
1157 return (feed(command->verb, command->obj));
1159 if (command->obj != AXE)
1160 return (discard(command->verb, command->obj, false));
1162 if (atdwrf(game.loc) <= 0) {
1163 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1164 return throw_support(DRAGON_SCALES);
1166 return throw_support(TROLL_RETURNS);
1168 return throw_support(OGRE_DODGE);
1169 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1170 /* This'll teach him to throw the axe at the bear! */
1171 drop(AXE, game.loc);
1172 game.fixed[AXE] = -1;
1174 state_change(AXE, AXE_LOST);
1177 command->obj = NO_OBJECT;
1178 return (attack(command));
1181 if (randrange(NDWARVES + 1) < game.dflag) {
1182 return throw_support(DWARF_DODGES);
1184 long i = atdwrf(game.loc);
1185 game.dseen[i] = false;
1186 game.dloc[i] = LOC_NOWHERE;
1187 return throw_support((++game.dkill == 1) ?
1194 static int wake(token_t verb, token_t obj)
1195 /* Wake. Only use is to disturb the dwarves. */
1199 rspeak(actions[verb].message);
1203 return GO_DWARFWAKE;
1207 static int wave(token_t verb, token_t obj)
1208 /* Wave. No effect unless waving rod at fissure or at bird. */
1215 rspeak(((!TOTING(obj)) && (obj != ROD ||
1218 actions[verb].message);
1222 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1223 drop(JADE, game.loc);
1224 game.prop[JADE] = STATE_FOUND;
1226 rspeak(NECKLACE_FLY);
1230 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1233 return GO_DWARFWAKE;
1237 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1243 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1247 state_change(FISSURE,
1248 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1253 int action(struct command_t *command)
1254 /* Analyse a verb. Remember what it was, go back for object if second word
1255 * unless verb is "say", which snarfs arbitrary second word.
1258 if (command->part == unknown) {
1259 /* Analyse an object word. See if the thing is here, whether
1260 * we've got a verb yet, and so on. Object must be here
1261 * unless verb is "find" or "invent(ory)" (and no new verb
1262 * yet to be analysed). Water and oil are also funny, since
1263 * they are never actually dropped at any location, but might
1264 * be here inside the bottle or urn or as a feature of the
1266 if (HERE(command->obj))
1268 else if (command->obj == GRATE) {
1269 if (game.loc == LOC_START ||
1270 game.loc == LOC_VALLEY ||
1271 game.loc == LOC_SLIT) {
1272 command->obj = DPRSSN;
1274 if (game.loc == LOC_COBBLE ||
1275 game.loc == LOC_DEBRIS ||
1276 game.loc == LOC_AWKWARD ||
1277 game.loc == LOC_BIRD ||
1278 game.loc == LOC_PITTOP) {
1279 command->obj = ENTRNC;
1281 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1283 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1284 command->obj == LIQLOC(game.loc))
1286 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1289 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1290 command->obj = PLANT2;
1292 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1294 rspeak(KNIVES_VANISH);
1296 } else if (command->obj == ROD && HERE(ROD2)) {
1297 command->obj = ROD2;
1299 } else if ((command->verb == FIND ||
1300 command->verb == INVENTORY) && command->wd2 <= 0)
1303 sspeak(NO_SEE, command->raw1);
1307 if (command->wd2 > 0)
1309 if (command->verb != 0)
1310 command->part = transitive;
1313 switch (command->part) {
1315 if (command->wd2 > 0 && command->verb != SAY)
1317 if (command->verb == SAY)
1318 command->obj = command->wd2;
1319 if (command->obj == NO_OBJECT ||
1320 command->obj == INTRANSITIVE) {
1321 /* Analyse an intransitive verb (ie, no object given yet). */
1322 switch (command->verb) {
1324 return vcarry(command->verb, INTRANSITIVE);
1330 return lock(command->verb, INTRANSITIVE);
1333 return (GO_CLEAROBJ);
1336 return lock(command->verb, INTRANSITIVE);
1338 return light(command->verb, INTRANSITIVE);
1340 return extinguish(command->verb, INTRANSITIVE);
1346 rspeak(actions[command->verb].message);
1350 return attack(command);
1352 return pour(command->verb, command->obj);
1354 return eat(command->verb, INTRANSITIVE);
1356 return drink(command->verb, command->obj);
1370 return fill(command->verb, command->obj);
1378 return bigwords(command->wd1);
1382 command->obj = INTRANSITIVE;
1383 return read(*command);
1393 return fly(command->verb, INTRANSITIVE);
1399 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1404 /* Analyse a transitive verb. */
1405 switch (command->verb) {
1407 return vcarry(command->verb, command->obj);
1409 return discard(command->verb, command->obj, false);
1411 return say(command);
1413 return lock(command->verb, command->obj);
1416 return (GO_CLEAROBJ);
1419 return lock(command->verb, command->obj);
1421 return light(command->verb, command->obj);
1423 return extinguish(command->verb, command->obj);
1425 return wave(command->verb, command->obj);
1427 rspeak(actions[command->verb].message);
1431 rspeak(actions[command->verb].message);
1435 return attack(command);
1437 return pour(command->verb, command->obj);
1439 return eat(command->verb, command->obj);
1441 return drink(command->verb, command->obj);
1443 return rub(command->verb, command->obj);
1445 return throw (command);
1447 rspeak(actions[command->verb].message);
1451 return find(command->verb, command->obj);
1453 return find(command->verb, command->obj);
1455 return feed(command->verb, command->obj);
1457 return fill(command->verb, command->obj);
1462 rspeak(actions[command->verb].message);
1466 rspeak(actions[command->verb].message);
1470 rspeak(actions[command->verb].message);
1474 return read(*command);
1476 return vbreak(command->verb, command->obj);
1478 return wake(command->verb, command->obj);
1480 rspeak(actions[command->verb].message);
1484 rspeak(actions[command->verb].message);
1488 return fly(command->verb, command->obj);
1490 rspeak(actions[command->verb].message);
1496 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1499 /* Unknown verb, couldn't deduce object - might need hint */
1500 sspeak(WHAT_DO, command->raw1);
1501 return GO_CHECKHINT;
1503 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE