7 static int fill(token_t, token_t);
9 static int attack(struct command_t *command)
10 /* Attack. Assume target if unambiguous. "Throw" also links here.
11 * Attackable objects fall into two categories: enemies (snake,
12 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
13 * enemies, or no enemies but 2 others. */
15 vocab_t verb = command->verb;
16 vocab_t obj = command->obj;
18 if (obj == NO_OBJECT ||
19 obj == INTRANSITIVE) {
21 if (atdwrf(game.loc) > 0) {
29 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
41 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
45 /* check for low-priority targets */
46 if (obj == NO_OBJECT) {
47 /* Can't attack bird or machine by throwing axe. */
48 if (HERE(BIRD) && verb != THROW) {
52 if (HERE(VEND) && verb != THROW) {
56 /* Clam and oyster both treated as clam for intransitive case;
58 if (HERE(CLAM) || HERE(OYSTER)) {
78 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
83 switch (game.prop[BEAR]) {
88 rspeak(BEAR_CONFUSED);
91 rspeak(BEAR_CONFUSED);
99 if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
100 /* Fun stuff for dragon. If he insists on attacking it, win!
101 * Set game.prop to dead, move dragon to central loc (still
102 * fixed), move rug there (not fixed), and move him there,
103 * too. Then do a null motion to get new description. */
104 rspeak(BARE_HANDS_QUERY);
106 // FIXME: setting wd1 is a workaround for broken logic
107 command->wd1 = token_to_packed("Y");
109 // FIXME: setting wd1 is a workaround for broken logic
110 command->wd1 = token_to_packed("N");
113 state_change(DRAGON, DRAGON_DEAD);
114 game.prop[RUG] = RUG_FLOOR;
115 /* FIXME: Arithmetic on location values */
116 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
117 move(DRAGON + NOBJECTS, -1);
118 move(RUG + NOBJECTS, 0);
122 for (obj = 1; obj <= NOBJECTS; obj++) {
123 if (game.place[obj] == objects[DRAGON].plac ||
124 game.place[obj] == objects[DRAGON].fixd)
133 if (atdwrf(game.loc) == 0)
136 rspeak(KNIFE_THROWN);
139 for (int i = 1; i < PIRATE; i++) {
140 if (game.dloc[i] == game.loc) {
142 game.dloc[i] = LOC_LONGWEST;
143 game.dseen[i] = false;
146 rspeak((dwarves > 1) ?
158 rspeak(SHELL_IMPERVIOUS);
161 rspeak(SNAKE_WARNING);
167 rspeak(BARE_HANDS_QUERY);
170 rspeak(ALREADY_DEAD);
176 rspeak(actions[verb].message);
181 static int bigwords(token_t foo)
182 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
183 * Look up foo in special section of vocab to determine which word we've got.
184 * Last word zips the eggs back to the giant room (unless already there). */
186 char word[TOKLEN + 1];
187 packed_to_token(foo, word);
188 int k = (int) get_special_vocab_id(word);
189 if (game.foobar != 1 - k) {
190 if (game.foobar != 0 && game.loc == LOC_GIANTROOM) {
193 rspeak(NOTHING_HAPPENS);
203 if (game.place[EGGS] == objects[EGGS].plac ||
204 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
205 rspeak(NOTHING_HAPPENS);
208 /* Bring back troll if we steal the eggs back from him before
210 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
211 game.prop[TROLL] = TROLL_PAIDONCE;
215 if (game.loc == objects[EGGS].plac)
217 move(EGGS, objects[EGGS].plac);
218 pspeak(EGGS, look, k, true);
224 static void blast(void)
225 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
227 if (game.prop[ROD2] < 0 ||
229 rspeak(REQUIRES_DYNAMITE);
231 game.bonus = VICTORY_MESSAGE;
232 if (game.loc == LOC_NE)
233 game.bonus = DEFEAT_MESSAGE;
235 game.bonus = SPLATTER_MESSAGE;
241 static int vbreak(token_t verb, token_t obj)
242 /* Break. Only works for mirror in repository and, of course, the vase. */
246 rspeak(BREAK_MIRROR);
253 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
255 drop(VASE, game.loc);
256 state_change(VASE, VASE_BROKEN);
257 game.fixed[VASE] = IS_FIXED;
260 rspeak(actions[verb].message);
261 return (GO_CLEAROBJ);
264 static int brief(void)
265 /* Brief. Intransitive only. Suppress long descriptions after first time. */
269 rspeak(BRIEF_CONFIRM);
273 static int vcarry(token_t verb, token_t obj)
274 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
275 * take one without the other). Liquids also special, since they depend on
276 * status of bottle. Also various side effects, etc. */
278 if (obj == INTRANSITIVE) {
279 /* Carry, no object given yet. OK if only one object present. */
280 if (game.atloc[game.loc] == 0 ||
281 game.link[game.atloc[game.loc]] != 0 ||
282 atdwrf(game.loc) > 0)
284 obj = game.atloc[game.loc];
288 rspeak(ALREADY_CARRYING);
293 rspeak(REMOVE_MESSAGE);
298 if (game.fixed[obj] != IS_FREE) {
299 /* Next guard tests whether plant is tiny or stashed */
300 if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
304 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
305 rspeak(BEAR_CHAINED);
308 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
309 rspeak(STILL_LOCKED);
317 rspeak(DOUGHNUT_HOLES);
324 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
329 rspeak(HAND_PASSTHROUGH);
340 if (TOTING(BOTTLE)) {
341 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
342 return (fill(verb, BOTTLE));
343 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
347 rspeak(NO_CONTAINER);
353 if (game.holdng >= INVLIMIT) {
359 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
360 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
366 rspeak(CANNOT_CARRY);
373 game.prop[BIRD] = BIRD_CAGED;
377 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
378 /* expression maps BIRD to CAGE and CAGE to BIRD */
379 carry(BIRD + CAGE - obj, game.loc);
380 carry(obj, game.loc);
381 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
382 game.place[LIQUID()] = CARRIED;
383 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
384 game.prop[obj] = STATE_FOUND;
385 game.prop[CAVITY] = CAVITY_EMPTY;
391 static int chain(token_t verb)
392 /* Do something to the bear's chain */
395 if (game.prop[BEAR] == UNTAMED_BEAR) {
399 if (game.prop[CHAIN] == CHAIN_HEAP) {
400 rspeak(ALREADY_UNLOCKED);
403 game.prop[CHAIN] = CHAIN_HEAP;
404 game.fixed[CHAIN] = IS_FREE;
405 if (game.prop[BEAR] != BEAR_DEAD)
406 game.prop[BEAR] = CONTENTED_BEAR;
408 switch (game.prop[BEAR]) {
410 game.fixed[BEAR] = IS_FIXED;
413 game.fixed[BEAR] = IS_FREE;
415 rspeak(CHAIN_UNLOCKED);
419 if (game.prop[CHAIN] != CHAIN_HEAP) {
420 rspeak(ALREADY_LOCKED);
423 if (game.loc != objects[CHAIN].plac) {
428 game.prop[CHAIN] = CHAIN_FIXED;
431 drop(CHAIN, game.loc);
432 game.fixed[CHAIN] = IS_FIXED;
434 rspeak(CHAIN_LOCKED);
438 static int discard(token_t verb, token_t obj, bool just_do_it)
439 /* Discard object. "Throw" also comes here for most objects. Special cases for
440 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
441 * Drop coins at vending machine for extra batteries. */
444 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
447 rspeak(actions[verb].message);
450 if (obj == BIRD && HERE(SNAKE)) {
451 rspeak(BIRD_ATTACKS);
455 /* Set game.prop for use by travel options */
456 game.prop[SNAKE] = SNAKE_CHASED;
458 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
460 game.prop[obj] = STATE_IN_CAVITY;
461 game.prop[CAVITY] = CAVITY_FULL;
462 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
463 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
470 if (spk != RUG_WIGGLES) {
471 /* FIXME: Arithmetic on state numbers */
472 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
475 k = objects[SAPPH].plac;
476 move(RUG + NOBJECTS, k);
479 } else if (obj == COINS && HERE(VEND)) {
481 drop(BATTERY, game.loc);
482 pspeak(BATTERY, look, FRESH_BATTERIES, true);
484 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
488 } else if (obj == BEAR && AT(TROLL)) {
489 state_change(TROLL, TROLL_GONE);
490 move(TROLL, LOC_NOWHERE);
491 move(TROLL + NOBJECTS, LOC_NOWHERE);
492 move(TROLL2, objects[TROLL].plac);
493 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
495 } else if (obj != VASE ||
496 game.loc == objects[PILLOW].plac) {
499 state_change(VASE, AT(PILLOW)
502 if (game.prop[VASE] != VASE_WHOLE)
503 game.fixed[VASE] = IS_FIXED;
509 if (obj == BOTTLE && k != NO_OBJECT)
510 game.place[k] = LOC_NOWHERE;
511 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
512 drop(BIRD, game.loc);
516 game.prop[BIRD] = BIRD_UNCAGED;
517 if (FOREST(game.loc))
518 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
522 static int drink(token_t verb, token_t obj)
523 /* Drink. If no object, assume water and look for it here. If water is in
524 * the bottle, drink that, else must be at a water loc, so drink stream. */
526 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
527 (LIQUID() != WATER || !HERE(BOTTLE))) {
533 state_change(DRAGON, DRAGON_BLOODLESS);
538 if (obj != NO_OBJECT && obj != WATER) {
539 rspeak(RIDICULOUS_ATTEMPT);
542 if (LIQUID() == WATER && HERE(BOTTLE)) {
543 game.place[WATER] = LOC_NOWHERE;
544 state_change(BOTTLE, EMPTY_BOTTLE);
548 rspeak(actions[verb].message);
552 static int eat(token_t verb, token_t obj)
553 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
554 * ok, some things lose appetite, rest are ridiculous. */
556 if (obj == INTRANSITIVE) {
560 rspeak(THANKS_DELICIOUS);
565 rspeak(THANKS_DELICIOUS);
577 rspeak(LOST_APPETITE);
580 rspeak(actions[verb].message);
584 static int extinguish(token_t verb, int obj)
585 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
587 if (obj == INTRANSITIVE) {
588 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
590 if (HERE(URN) && game.prop[URN] == URN_LIT)
592 if (obj == INTRANSITIVE)
597 if (game.prop[URN] != URN_EMPTY) {
598 state_change(URN, URN_DARK);
600 pspeak(URN, change, URN_DARK, true);
606 state_change(LAMP, LAMP_DARK);
607 rspeak(DARK(game.loc) ?
615 rspeak(BEYOND_POWER);
619 rspeak(actions[verb].message);
623 static int feed(token_t verb, token_t obj)
624 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
625 * mad. Bear, special. */
633 if (game.prop[DRAGON] != DRAGON_BARS)
634 rspeak(RIDICULOUS_ATTEMPT);
636 rspeak(NOTHING_EDIBLE);
639 if (!game.closed && HERE(BIRD)) {
641 rspeak(BIRD_DEVOURED);
643 rspeak(NOTHING_EDIBLE);
653 rspeak(actions[verb].message);
656 if (game.prop[BEAR] == BEAR_DEAD) {
657 rspeak(RIDICULOUS_ATTEMPT);
660 if (game.prop[BEAR] == UNTAMED_BEAR) {
663 game.fixed[AXE] = IS_FREE;
664 game.prop[AXE] = AXE_HERE;
665 state_change(BEAR, SITTING_BEAR);
667 rspeak(NOTHING_EDIBLE);
674 rspeak(actions[verb].message);
682 int fill(token_t verb, token_t obj)
683 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
687 if (LIQLOC(game.loc) == NO_OBJECT) {
688 rspeak(FILL_INVALID);
692 rspeak(ARENT_CARRYING);
695 rspeak(SHATTER_VASE);
696 game.prop[VASE] = VASE_BROKEN;
697 game.fixed[VASE] = IS_FIXED;
698 return (discard(verb, VASE, true));
702 if (game.prop[URN] != URN_EMPTY) {
707 rspeak(FILL_INVALID);
713 game.prop[BOTTLE] = EMPTY_BOTTLE;
717 game.prop[URN] = URN_DARK;
718 game.prop[BOTTLE] = EMPTY_BOTTLE;
723 rspeak(FILL_INVALID);
726 game.place[k] = LOC_NOWHERE;
729 if (obj != NO_OBJECT && obj != BOTTLE) {
730 rspeak(actions[verb].message);
733 if (obj == NO_OBJECT && !HERE(BOTTLE))
736 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
740 if (LIQUID() != NO_OBJECT) {
744 if (LIQLOC(game.loc) == NO_OBJECT) {
749 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
753 game.place[LIQUID()] = CARRIED;
757 static int find(token_t verb, token_t obj)
758 /* Find. Might be carrying it, or it might be here. Else give caveat. */
761 rspeak(ALREADY_CARRYING);
766 rspeak(NEEDED_NEARBY);
771 (LIQUID() == obj && AT(BOTTLE)) ||
772 obj == LIQLOC(game.loc) ||
773 (obj == DWARF && atdwrf(game.loc) > 0)) {
779 rspeak(actions[verb].message);
783 static int fly(token_t verb, token_t obj)
784 /* Fly. Snide remarks unless hovering rug is here. */
786 if (obj == INTRANSITIVE) {
791 if (game.prop[RUG] != RUG_HOVER) {
792 rspeak(RUG_NOTHING2);
799 rspeak(actions[verb].message);
802 if (game.prop[RUG] != RUG_HOVER) {
803 rspeak(RUG_NOTHING1);
806 game.oldlc2 = game.oldloc;
807 game.oldloc = game.loc;
808 /* FIXME: Arithmetic on location values */
809 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
811 if (game.prop[SAPPH] == STATE_NOTFOUND) {
819 static int inven(void)
820 /* Inventory. If object, treat same as find. Else report on current burden. */
823 for (int i = 1; i <= NOBJECTS; i++) {
831 pspeak(i, touch, -1, false);
840 static int light(token_t verb, token_t obj)
841 /* Light. Applicable only to lamp and urn. */
843 if (obj == INTRANSITIVE) {
844 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
846 if (HERE(URN) && game.prop[URN] == URN_DARK)
848 if (obj == INTRANSITIVE ||
849 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
850 HERE(URN) && game.prop[URN] == URN_DARK))
855 state_change(URN, game.prop[URN] == URN_EMPTY ?
861 rspeak(actions[verb].message);
864 if (game.limit < 0) {
868 state_change(LAMP, LAMP_BRIGHT);
876 static int listen(void)
877 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
879 long sound = locations[game.loc].sound;
880 if (sound != SILENT) {
882 if (!locations[game.loc].loud)
886 for (int i = 1; i <= NOBJECTS; i++) {
888 objects[i].sounds[0] == NULL ||
891 int mi = game.prop[i];
893 mi += 3 * game.blooded;
894 long packed_zzword = token_to_packed(game.zzword);
895 pspeak(i, hear, mi, true, packed_zzword);
897 if (i == BIRD && mi == BIRD_ENDSTATE)
905 static int lock(token_t verb, token_t obj)
906 /* Lock, unlock, no object given. Assume various things if present. */
908 if (obj == INTRANSITIVE) {
919 if (obj == INTRANSITIVE) {
920 rspeak(NOTHING_LOCKED);
925 /* Lock, unlock object. Special stuff for opening clam/oyster
935 game.clock2 = PANICTIME;
939 state_change(GRATE, (verb == LOCK) ?
953 else if (!TOTING(TRIDENT))
954 rspeak(OYSTER_OPENER);
957 drop(OYSTER, game.loc);
958 drop(PEARL, LOC_CULDESAC);
966 rspeak(OYSTER_OPENER);
970 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
976 rspeak(CANNOT_UNLOCK);
979 rspeak(actions[verb].message);
985 static int pour(token_t verb, token_t obj)
986 /* Pour. If no object, or object is bottle, assume contents of bottle.
987 * special tests for pouring water or oil on plant or rusty door. */
992 if (obj == NO_OBJECT)
995 rspeak(actions[verb].message);
999 if (obj != OIL && obj != WATER) {
1003 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1004 return fill(verb, URN);
1005 game.prop[BOTTLE] = EMPTY_BOTTLE;
1006 game.place[obj] = LOC_NOWHERE;
1014 /* cycle through the three plant states */
1015 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1016 game.prop[PLANT2] = game.prop[PLANT];
1019 rspeak(SHAKING_LEAVES);
1023 state_change(DOOR, (obj == OIL) ?
1030 static int quit(void)
1031 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1033 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1034 terminate(quitgame);
1038 static int read(struct command_t command)
1039 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1041 if (command.obj == INTRANSITIVE) {
1043 for (int i = 1; i <= NOBJECTS; i++) {
1044 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1045 command.obj = command.obj * NOBJECTS + i;
1047 if (command.obj > NOBJECTS ||
1053 if (DARK(game.loc)) {
1054 sspeak(NO_SEE, command.raw1);
1055 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1056 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1057 } else if (objects[command.obj].texts[0] == NULL ||
1058 game.prop[command.obj] < 0) {
1059 rspeak(actions[command.verb].message);
1061 pspeak(command.obj, study, game.prop[command.obj], true);
1065 static int reservoir(void)
1066 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1068 /* FIXME: Arithmetic on state numbers */
1069 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
1070 rspeak(NOTHING_HAPPENS);
1074 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1078 game.oldlc2 = game.loc;
1079 game.newloc = LOC_NOWHERE;
1081 return GO_TERMINATE;
1086 static int rub(token_t verb, token_t obj)
1087 /* Rub. Yields various snide remarks except for lit urn. */
1089 if (obj == URN && game.prop[URN] == URN_LIT) {
1091 drop(AMBER, game.loc);
1092 game.prop[AMBER] = AMBER_IN_ROCK;
1094 drop(CAVITY, game.loc);
1096 } else if (obj != LAMP) {
1097 rspeak(PECULIAR_NOTHING);
1099 rspeak(actions[verb].message);
1104 static int say(struct command_t *command)
1105 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1107 if (command->wd2 > 0) {
1108 command->wd1 = command->wd2;
1109 strcpy(command->raw1, command->raw2);
1111 char word1[TOKLEN + 1];
1112 packed_to_token(command->wd1, word1);
1113 int wd = (int) get_vocab_id(word1);
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(command->obj)) {
1141 rspeak(actions[command->verb].message);
1144 if (objects[command->obj].is_treasure && AT(TROLL)) {
1145 /* Snarf a treasure for the troll. */
1146 drop(command->obj, LOC_NOWHERE);
1147 move(TROLL, LOC_NOWHERE);
1148 move(TROLL + NOBJECTS, LOC_NOWHERE);
1149 drop(TROLL2, objects[TROLL].plac);
1150 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1152 rspeak(TROLL_SATISFIED);
1155 if (command->obj == FOOD && HERE(BEAR)) {
1156 /* But throwing food is another story. */
1157 command->obj = BEAR;
1158 return (feed(command->verb, command->obj));
1160 if (command->obj != AXE)
1161 return (discard(command->verb, command->obj, false));
1163 if (atdwrf(game.loc) <= 0) {
1164 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1165 return throw_support(DRAGON_SCALES);
1167 return throw_support(TROLL_RETURNS);
1169 return throw_support(OGRE_DODGE);
1170 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1171 /* This'll teach him to throw the axe at the bear! */
1172 drop(AXE, game.loc);
1173 game.fixed[AXE] = IS_FIXED;
1175 state_change(AXE, AXE_LOST);
1178 command->obj = NO_OBJECT;
1179 return (attack(command));
1182 if (randrange(NDWARVES + 1) < game.dflag) {
1183 return throw_support(DWARF_DODGES);
1185 long i = atdwrf(game.loc);
1186 game.dseen[i] = false;
1187 game.dloc[i] = LOC_NOWHERE;
1188 return throw_support((++game.dkill == 1) ?
1195 static int wake(token_t verb, token_t obj)
1196 /* Wake. Only use is to disturb the dwarves. */
1200 rspeak(actions[verb].message);
1204 return GO_DWARFWAKE;
1208 static int wave(token_t verb, token_t obj)
1209 /* Wave. No effect unless waving rod at fissure or at bird. */
1216 rspeak(((!TOTING(obj)) && (obj != ROD ||
1219 actions[verb].message);
1223 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1224 drop(JADE, game.loc);
1225 game.prop[JADE] = STATE_FOUND;
1227 rspeak(NECKLACE_FLY);
1231 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1234 return GO_DWARFWAKE;
1238 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1244 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1248 state_change(FISSURE,
1249 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1254 int action(struct command_t *command)
1255 /* Analyse a verb. Remember what it was, go back for object if second word
1256 * unless verb is "say", which snarfs arbitrary second word.
1259 if (command->part == unknown) {
1260 /* Analyse an object word. See if the thing is here, whether
1261 * we've got a verb yet, and so on. Object must be here
1262 * unless verb is "find" or "invent(ory)" (and no new verb
1263 * yet to be analysed). Water and oil are also funny, since
1264 * they are never actually dropped at any location, but might
1265 * be here inside the bottle or urn or as a feature of the
1267 if (HERE(command->obj))
1269 else if (command->obj == GRATE) {
1270 if (game.loc == LOC_START ||
1271 game.loc == LOC_VALLEY ||
1272 game.loc == LOC_SLIT) {
1273 command->obj = DPRSSN;
1275 if (game.loc == LOC_COBBLE ||
1276 game.loc == LOC_DEBRIS ||
1277 game.loc == LOC_AWKWARD ||
1278 game.loc == LOC_BIRD ||
1279 game.loc == LOC_PITTOP) {
1280 command->obj = ENTRNC;
1282 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1284 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1285 command->obj == LIQLOC(game.loc))
1287 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1290 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1291 command->obj = PLANT2;
1293 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1295 rspeak(KNIVES_VANISH);
1297 } else if (command->obj == ROD && HERE(ROD2)) {
1298 command->obj = ROD2;
1300 } else if ((command->verb == FIND ||
1301 command->verb == INVENTORY) && command->wd2 <= 0)
1304 sspeak(NO_SEE, command->raw1);
1308 if (command->wd2 > 0)
1310 if (command->verb != 0)
1311 command->part = transitive;
1314 switch (command->part) {
1316 if (command->wd2 > 0 && command->verb != SAY)
1318 if (command->verb == SAY)
1319 command->obj = command->wd2;
1320 if (command->obj == NO_OBJECT ||
1321 command->obj == INTRANSITIVE) {
1322 /* Analyse an intransitive verb (ie, no object given yet). */
1323 switch (command->verb) {
1325 return vcarry(command->verb, INTRANSITIVE);
1331 return lock(command->verb, INTRANSITIVE);
1334 return (GO_CLEAROBJ);
1337 return lock(command->verb, INTRANSITIVE);
1339 return light(command->verb, INTRANSITIVE);
1341 return extinguish(command->verb, INTRANSITIVE);
1347 rspeak(actions[command->verb].message);
1351 return attack(command);
1353 return pour(command->verb, command->obj);
1355 return eat(command->verb, INTRANSITIVE);
1357 return drink(command->verb, command->obj);
1371 return fill(command->verb, command->obj);
1379 return bigwords(command->wd1);
1383 command->obj = INTRANSITIVE;
1384 return read(*command);
1394 return fly(command->verb, INTRANSITIVE);
1400 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1405 /* Analyse a transitive verb. */
1406 switch (command->verb) {
1408 return vcarry(command->verb, command->obj);
1410 return discard(command->verb, command->obj, false);
1412 return say(command);
1414 return lock(command->verb, command->obj);
1417 return (GO_CLEAROBJ);
1420 return lock(command->verb, command->obj);
1422 return light(command->verb, command->obj);
1424 return extinguish(command->verb, command->obj);
1426 return wave(command->verb, command->obj);
1428 rspeak(actions[command->verb].message);
1432 rspeak(actions[command->verb].message);
1436 return attack(command);
1438 return pour(command->verb, command->obj);
1440 return eat(command->verb, command->obj);
1442 return drink(command->verb, command->obj);
1444 return rub(command->verb, command->obj);
1446 return throw (command);
1448 rspeak(actions[command->verb].message);
1452 return find(command->verb, command->obj);
1454 return find(command->verb, command->obj);
1456 return feed(command->verb, command->obj);
1458 return fill(command->verb, command->obj);
1463 rspeak(actions[command->verb].message);
1467 rspeak(actions[command->verb].message);
1471 rspeak(actions[command->verb].message);
1475 return read(*command);
1477 return vbreak(command->verb, command->obj);
1479 return wake(command->verb, command->obj);
1481 rspeak(actions[command->verb].message);
1485 rspeak(actions[command->verb].message);
1489 return fly(command->verb, command->obj);
1491 rspeak(actions[command->verb].message);
1497 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1500 /* Unknown verb, couldn't deduce object - might need hint */
1501 sspeak(WHAT_DO, command->raw1);
1502 return GO_CHECKHINT;
1504 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE