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. */
627 int spk = actions[verb].message;
631 } else if (obj == SNAKE ||
634 spk = NOTHING_EDIBLE;
635 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
636 spk = RIDICULOUS_ATTEMPT;
639 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
643 } else if (obj == DWARF) {
648 } else if (obj == BEAR) {
649 if (game.prop[BEAR] == UNTAMED_BEAR)
650 spk = NOTHING_EDIBLE;
651 if (game.prop[BEAR] == BEAR_DEAD)
652 spk = RIDICULOUS_ATTEMPT;
655 game.prop[BEAR] = SITTING_BEAR;
656 game.fixed[AXE] = IS_FREE;
657 game.prop[AXE] = AXE_HERE;
660 } else if (obj == OGRE) {
670 int fill(token_t verb, token_t obj)
671 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
675 if (LIQLOC(game.loc) == NO_OBJECT) {
676 rspeak(FILL_INVALID);
680 rspeak(ARENT_CARRYING);
683 rspeak(SHATTER_VASE);
684 game.prop[VASE] = VASE_BROKEN;
685 game.fixed[VASE] = IS_FIXED;
686 return (discard(verb, VASE, true));
690 if (game.prop[URN] != URN_EMPTY) {
695 rspeak(FILL_INVALID);
701 game.prop[BOTTLE] = EMPTY_BOTTLE;
705 game.prop[URN] = URN_DARK;
706 game.prop[BOTTLE] = EMPTY_BOTTLE;
711 rspeak(FILL_INVALID);
714 game.place[k] = LOC_NOWHERE;
717 if (obj != NO_OBJECT && obj != BOTTLE) {
718 rspeak(actions[verb].message);
721 if (obj == NO_OBJECT && !HERE(BOTTLE))
724 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
728 if (LIQUID() != NO_OBJECT) {
732 if (LIQLOC(game.loc) == NO_OBJECT) {
737 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
741 game.place[LIQUID()] = CARRIED;
745 static int find(token_t verb, token_t obj)
746 /* Find. Might be carrying it, or it might be here. Else give caveat. */
749 rspeak(ALREADY_CARRYING);
754 rspeak(NEEDED_NEARBY);
759 (LIQUID() == obj && AT(BOTTLE)) ||
760 obj == LIQLOC(game.loc) ||
761 (obj == DWARF && atdwrf(game.loc) > 0)) {
767 rspeak(actions[verb].message);
771 static int fly(token_t verb, token_t obj)
772 /* Fly. Snide remarks unless hovering rug is here. */
774 if (obj == INTRANSITIVE) {
779 if (game.prop[RUG] != RUG_HOVER) {
780 rspeak(RUG_NOTHING2);
787 rspeak(actions[verb].message);
790 if (game.prop[RUG] != RUG_HOVER) {
791 rspeak(RUG_NOTHING1);
794 game.oldlc2 = game.oldloc;
795 game.oldloc = game.loc;
796 /* FIXME: Arithmetic on location values */
797 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
799 if (game.prop[SAPPH] == STATE_NOTFOUND) {
807 static int inven(void)
808 /* Inventory. If object, treat same as find. Else report on current burden. */
811 for (int i = 1; i <= NOBJECTS; i++) {
819 pspeak(i, touch, -1, false);
828 static int light(token_t verb, token_t obj)
829 /* Light. Applicable only to lamp and urn. */
831 if (obj == INTRANSITIVE) {
832 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
834 if (HERE(URN) && game.prop[URN] == URN_DARK)
836 if (obj == INTRANSITIVE ||
837 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
838 HERE(URN) && game.prop[URN] == URN_DARK))
843 state_change(URN, game.prop[URN] == URN_EMPTY ?
849 rspeak(actions[verb].message);
852 if (game.limit < 0) {
856 state_change(LAMP, LAMP_BRIGHT);
864 static int listen(void)
865 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
867 long sound = locations[game.loc].sound;
868 if (sound != SILENT) {
870 if (!locations[game.loc].loud)
874 for (int i = 1; i <= NOBJECTS; i++) {
876 objects[i].sounds[0] == NULL ||
879 int mi = game.prop[i];
881 mi += 3 * game.blooded;
882 long packed_zzword = token_to_packed(game.zzword);
883 pspeak(i, hear, mi, true, packed_zzword);
885 if (i == BIRD && mi == BIRD_ENDSTATE)
893 static int lock(token_t verb, token_t obj)
894 /* Lock, unlock, no object given. Assume various things if present. */
896 if (obj == INTRANSITIVE) {
907 if (obj == INTRANSITIVE) {
908 rspeak(NOTHING_LOCKED);
913 /* Lock, unlock object. Special stuff for opening clam/oyster
923 game.clock2 = PANICTIME;
927 state_change(GRATE, (verb == LOCK) ?
941 else if (!TOTING(TRIDENT))
942 rspeak(OYSTER_OPENER);
945 drop(OYSTER, game.loc);
946 drop(PEARL, LOC_CULDESAC);
954 rspeak(OYSTER_OPENER);
958 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
964 rspeak(CANNOT_UNLOCK);
967 rspeak(actions[verb].message);
973 static int pour(token_t verb, token_t obj)
974 /* Pour. If no object, or object is bottle, assume contents of bottle.
975 * special tests for pouring water or oil on plant or rusty door. */
980 if (obj == NO_OBJECT)
983 rspeak(actions[verb].message);
987 if (obj != OIL && obj != WATER) {
991 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
992 return fill(verb, URN);
993 game.prop[BOTTLE] = EMPTY_BOTTLE;
994 game.place[obj] = LOC_NOWHERE;
1002 /* cycle through the three plant states */
1003 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1004 game.prop[PLANT2] = game.prop[PLANT];
1007 rspeak(SHAKING_LEAVES);
1011 state_change(DOOR, (obj == OIL) ?
1018 static int quit(void)
1019 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1021 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1022 terminate(quitgame);
1026 static int read(struct command_t command)
1027 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1029 if (command.obj == INTRANSITIVE) {
1031 for (int i = 1; i <= NOBJECTS; i++) {
1032 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1033 command.obj = command.obj * NOBJECTS + i;
1035 if (command.obj > NOBJECTS ||
1041 if (DARK(game.loc)) {
1042 sspeak(NO_SEE, command.raw1);
1043 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1044 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1045 } else if (objects[command.obj].texts[0] == NULL ||
1046 game.prop[command.obj] < 0) {
1047 rspeak(actions[command.verb].message);
1049 pspeak(command.obj, study, game.prop[command.obj], true);
1053 static int reservoir(void)
1054 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1056 /* FIXME: Arithmetic on state numbers */
1057 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
1058 rspeak(NOTHING_HAPPENS);
1062 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1066 game.oldlc2 = game.loc;
1067 game.newloc = LOC_NOWHERE;
1069 return GO_TERMINATE;
1074 static int rub(token_t verb, token_t obj)
1075 /* Rub. Yields various snide remarks except for lit urn. */
1077 if (obj == URN && game.prop[URN] == URN_LIT) {
1079 drop(AMBER, game.loc);
1080 game.prop[AMBER] = AMBER_IN_ROCK;
1082 drop(CAVITY, game.loc);
1084 } else if (obj != LAMP) {
1085 rspeak(PECULIAR_NOTHING);
1087 rspeak(actions[verb].message);
1092 static int say(struct command_t *command)
1093 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1095 if (command->wd2 > 0) {
1096 command->wd1 = command->wd2;
1097 strcpy(command->raw1, command->raw2);
1099 char word1[TOKLEN + 1];
1100 packed_to_token(command->wd1, word1);
1101 int wd = (int) get_vocab_id(word1);
1102 if (wd == MOTION_WORD(XYZZY) ||
1103 wd == MOTION_WORD(PLUGH) ||
1104 wd == MOTION_WORD(PLOVER) ||
1105 wd == ACTION_WORD(GIANTWORDS) ||
1106 wd == ACTION_WORD(PART)) {
1107 /* FIXME: scribbles on the interpreter's command block */
1108 wordclear(&command->wd2);
1111 sspeak(OKEY_DOKEY, command->raw1);
1115 static int throw_support(long spk)
1118 drop(AXE, game.loc);
1122 static int throw (struct command_t *command)
1123 /* Throw. Same as discard unless axe. Then same as attack except
1124 * ignore bird, and if dwarf is present then one might be killed.
1125 * (Only way to do so!) Axe also special for dragon, bear, and
1126 * troll. Treasures special for troll. */
1128 if (!TOTING(command->obj)) {
1129 rspeak(actions[command->verb].message);
1132 if (objects[command->obj].is_treasure && AT(TROLL)) {
1133 /* Snarf a treasure for the troll. */
1134 drop(command->obj, LOC_NOWHERE);
1135 move(TROLL, LOC_NOWHERE);
1136 move(TROLL + NOBJECTS, LOC_NOWHERE);
1137 drop(TROLL2, objects[TROLL].plac);
1138 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1140 rspeak(TROLL_SATISFIED);
1143 if (command->obj == FOOD && HERE(BEAR)) {
1144 /* But throwing food is another story. */
1145 command->obj = BEAR;
1146 return (feed(command->verb, command->obj));
1148 if (command->obj != AXE)
1149 return (discard(command->verb, command->obj, false));
1151 if (atdwrf(game.loc) <= 0) {
1152 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1153 return throw_support(DRAGON_SCALES);
1155 return throw_support(TROLL_RETURNS);
1157 return throw_support(OGRE_DODGE);
1158 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1159 /* This'll teach him to throw the axe at the bear! */
1160 drop(AXE, game.loc);
1161 game.fixed[AXE] = IS_FIXED;
1163 state_change(AXE, AXE_LOST);
1166 command->obj = NO_OBJECT;
1167 return (attack(command));
1170 if (randrange(NDWARVES + 1) < game.dflag) {
1171 return throw_support(DWARF_DODGES);
1173 long i = atdwrf(game.loc);
1174 game.dseen[i] = false;
1175 game.dloc[i] = LOC_NOWHERE;
1176 return throw_support((++game.dkill == 1) ?
1183 static int wake(token_t verb, token_t obj)
1184 /* Wake. Only use is to disturb the dwarves. */
1188 rspeak(actions[verb].message);
1192 return GO_DWARFWAKE;
1196 static int wave(token_t verb, token_t obj)
1197 /* Wave. No effect unless waving rod at fissure or at bird. */
1204 rspeak(((!TOTING(obj)) && (obj != ROD ||
1207 actions[verb].message);
1211 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1212 drop(JADE, game.loc);
1213 game.prop[JADE] = STATE_FOUND;
1215 rspeak(NECKLACE_FLY);
1219 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1222 return GO_DWARFWAKE;
1226 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1232 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1236 state_change(FISSURE,
1237 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1242 int action(struct command_t *command)
1243 /* Analyse a verb. Remember what it was, go back for object if second word
1244 * unless verb is "say", which snarfs arbitrary second word.
1247 if (command->part == unknown) {
1248 /* Analyse an object word. See if the thing is here, whether
1249 * we've got a verb yet, and so on. Object must be here
1250 * unless verb is "find" or "invent(ory)" (and no new verb
1251 * yet to be analysed). Water and oil are also funny, since
1252 * they are never actually dropped at any location, but might
1253 * be here inside the bottle or urn or as a feature of the
1255 if (HERE(command->obj))
1257 else if (command->obj == GRATE) {
1258 if (game.loc == LOC_START ||
1259 game.loc == LOC_VALLEY ||
1260 game.loc == LOC_SLIT) {
1261 command->obj = DPRSSN;
1263 if (game.loc == LOC_COBBLE ||
1264 game.loc == LOC_DEBRIS ||
1265 game.loc == LOC_AWKWARD ||
1266 game.loc == LOC_BIRD ||
1267 game.loc == LOC_PITTOP) {
1268 command->obj = ENTRNC;
1270 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1272 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1273 command->obj == LIQLOC(game.loc))
1275 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1278 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1279 command->obj = PLANT2;
1281 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1283 rspeak(KNIVES_VANISH);
1285 } else if (command->obj == ROD && HERE(ROD2)) {
1286 command->obj = ROD2;
1288 } else if ((command->verb == FIND ||
1289 command->verb == INVENTORY) && command->wd2 <= 0)
1292 sspeak(NO_SEE, command->raw1);
1296 if (command->wd2 > 0)
1298 if (command->verb != 0)
1299 command->part = transitive;
1302 switch (command->part) {
1304 if (command->wd2 > 0 && command->verb != SAY)
1306 if (command->verb == SAY)
1307 command->obj = command->wd2;
1308 if (command->obj == NO_OBJECT ||
1309 command->obj == INTRANSITIVE) {
1310 /* Analyse an intransitive verb (ie, no object given yet). */
1311 switch (command->verb) {
1313 return vcarry(command->verb, INTRANSITIVE);
1319 return lock(command->verb, INTRANSITIVE);
1322 return (GO_CLEAROBJ);
1325 return lock(command->verb, INTRANSITIVE);
1327 return light(command->verb, INTRANSITIVE);
1329 return extinguish(command->verb, INTRANSITIVE);
1335 rspeak(actions[command->verb].message);
1339 return attack(command);
1341 return pour(command->verb, command->obj);
1343 return eat(command->verb, INTRANSITIVE);
1345 return drink(command->verb, command->obj);
1359 return fill(command->verb, command->obj);
1367 return bigwords(command->wd1);
1371 command->obj = INTRANSITIVE;
1372 return read(*command);
1382 return fly(command->verb, INTRANSITIVE);
1388 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1393 /* Analyse a transitive verb. */
1394 switch (command->verb) {
1396 return vcarry(command->verb, command->obj);
1398 return discard(command->verb, command->obj, false);
1400 return say(command);
1402 return lock(command->verb, command->obj);
1405 return (GO_CLEAROBJ);
1408 return lock(command->verb, command->obj);
1410 return light(command->verb, command->obj);
1412 return extinguish(command->verb, command->obj);
1414 return wave(command->verb, command->obj);
1416 rspeak(actions[command->verb].message);
1420 rspeak(actions[command->verb].message);
1424 return attack(command);
1426 return pour(command->verb, command->obj);
1428 return eat(command->verb, command->obj);
1430 return drink(command->verb, command->obj);
1432 return rub(command->verb, command->obj);
1434 return throw (command);
1436 rspeak(actions[command->verb].message);
1440 return find(command->verb, command->obj);
1442 return find(command->verb, command->obj);
1444 return feed(command->verb, command->obj);
1446 return fill(command->verb, command->obj);
1451 rspeak(actions[command->verb].message);
1455 rspeak(actions[command->verb].message);
1459 rspeak(actions[command->verb].message);
1463 return read(*command);
1465 return vbreak(command->verb, command->obj);
1467 return wake(command->verb, command->obj);
1469 rspeak(actions[command->verb].message);
1473 rspeak(actions[command->verb].message);
1477 return fly(command->verb, command->obj);
1479 rspeak(actions[command->verb].message);
1485 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1488 /* Unknown verb, couldn't deduce object - might need hint */
1489 sspeak(WHAT_DO, command->raw1);
1490 return GO_CHECKHINT;
1492 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE