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. */
632 if (game.prop[DRAGON] != DRAGON_BARS)
633 rspeak(RIDICULOUS_ATTEMPT);
635 rspeak(NOTHING_EDIBLE);
638 if (!game.closed && HERE(BIRD)) {
640 rspeak(BIRD_DEVOURED);
642 rspeak(NOTHING_EDIBLE);
652 rspeak(actions[verb].message);
655 if (game.prop[BEAR] == BEAR_DEAD) {
656 rspeak(RIDICULOUS_ATTEMPT);
659 if (game.prop[BEAR] == UNTAMED_BEAR) {
662 game.fixed[AXE] = IS_FREE;
663 game.prop[AXE] = AXE_HERE;
664 state_change(BEAR, SITTING_BEAR);
666 rspeak(NOTHING_EDIBLE);
669 rspeak(actions[verb].message);
675 rspeak(actions[verb].message);
683 int fill(token_t verb, token_t obj)
684 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
688 if (LIQLOC(game.loc) == NO_OBJECT) {
689 rspeak(FILL_INVALID);
693 rspeak(ARENT_CARRYING);
696 rspeak(SHATTER_VASE);
697 game.prop[VASE] = VASE_BROKEN;
698 game.fixed[VASE] = IS_FIXED;
699 return (discard(verb, VASE, true));
703 if (game.prop[URN] != URN_EMPTY) {
708 rspeak(FILL_INVALID);
714 game.prop[BOTTLE] = EMPTY_BOTTLE;
718 game.prop[URN] = URN_DARK;
719 game.prop[BOTTLE] = EMPTY_BOTTLE;
724 rspeak(FILL_INVALID);
727 game.place[k] = LOC_NOWHERE;
730 if (obj != NO_OBJECT && obj != BOTTLE) {
731 rspeak(actions[verb].message);
734 if (obj == NO_OBJECT && !HERE(BOTTLE))
737 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
741 if (LIQUID() != NO_OBJECT) {
745 if (LIQLOC(game.loc) == NO_OBJECT) {
750 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
754 game.place[LIQUID()] = CARRIED;
758 static int find(token_t verb, token_t obj)
759 /* Find. Might be carrying it, or it might be here. Else give caveat. */
762 rspeak(ALREADY_CARRYING);
767 rspeak(NEEDED_NEARBY);
772 (LIQUID() == obj && AT(BOTTLE)) ||
773 obj == LIQLOC(game.loc) ||
774 (obj == DWARF && atdwrf(game.loc) > 0)) {
780 rspeak(actions[verb].message);
784 static int fly(token_t verb, token_t obj)
785 /* Fly. Snide remarks unless hovering rug is here. */
787 if (obj == INTRANSITIVE) {
792 if (game.prop[RUG] != RUG_HOVER) {
793 rspeak(RUG_NOTHING2);
800 rspeak(actions[verb].message);
803 if (game.prop[RUG] != RUG_HOVER) {
804 rspeak(RUG_NOTHING1);
807 game.oldlc2 = game.oldloc;
808 game.oldloc = game.loc;
809 /* FIXME: Arithmetic on location values */
810 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
812 if (game.prop[SAPPH] == STATE_NOTFOUND) {
820 static int inven(void)
821 /* Inventory. If object, treat same as find. Else report on current burden. */
824 for (int i = 1; i <= NOBJECTS; i++) {
832 pspeak(i, touch, -1, false);
841 static int light(token_t verb, token_t obj)
842 /* Light. Applicable only to lamp and urn. */
844 if (obj == INTRANSITIVE) {
845 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
847 if (HERE(URN) && game.prop[URN] == URN_DARK)
849 if (obj == INTRANSITIVE ||
850 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
851 HERE(URN) && game.prop[URN] == URN_DARK))
856 state_change(URN, game.prop[URN] == URN_EMPTY ?
862 rspeak(actions[verb].message);
865 if (game.limit < 0) {
869 state_change(LAMP, LAMP_BRIGHT);
877 static int listen(void)
878 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
880 long sound = locations[game.loc].sound;
881 if (sound != SILENT) {
883 if (!locations[game.loc].loud)
887 for (int i = 1; i <= NOBJECTS; i++) {
889 objects[i].sounds[0] == NULL ||
892 int mi = game.prop[i];
894 mi += 3 * game.blooded;
895 long packed_zzword = token_to_packed(game.zzword);
896 pspeak(i, hear, mi, true, packed_zzword);
898 if (i == BIRD && mi == BIRD_ENDSTATE)
906 static int lock(token_t verb, token_t obj)
907 /* Lock, unlock, no object given. Assume various things if present. */
909 if (obj == INTRANSITIVE) {
920 if (obj == INTRANSITIVE) {
921 rspeak(NOTHING_LOCKED);
926 /* Lock, unlock object. Special stuff for opening clam/oyster
936 game.clock2 = PANICTIME;
940 state_change(GRATE, (verb == LOCK) ?
954 else if (!TOTING(TRIDENT))
955 rspeak(OYSTER_OPENER);
958 drop(OYSTER, game.loc);
959 drop(PEARL, LOC_CULDESAC);
967 rspeak(OYSTER_OPENER);
971 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
977 rspeak(CANNOT_UNLOCK);
980 rspeak(actions[verb].message);
986 static int pour(token_t verb, token_t obj)
987 /* Pour. If no object, or object is bottle, assume contents of bottle.
988 * special tests for pouring water or oil on plant or rusty door. */
993 if (obj == NO_OBJECT)
996 rspeak(actions[verb].message);
1000 if (obj != OIL && obj != WATER) {
1004 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1005 return fill(verb, URN);
1006 game.prop[BOTTLE] = EMPTY_BOTTLE;
1007 game.place[obj] = LOC_NOWHERE;
1015 /* cycle through the three plant states */
1016 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1017 game.prop[PLANT2] = game.prop[PLANT];
1020 rspeak(SHAKING_LEAVES);
1024 state_change(DOOR, (obj == OIL) ?
1031 static int quit(void)
1032 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1034 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1035 terminate(quitgame);
1039 static int read(struct command_t command)
1040 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1042 if (command.obj == INTRANSITIVE) {
1044 for (int i = 1; i <= NOBJECTS; i++) {
1045 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1046 command.obj = command.obj * NOBJECTS + i;
1048 if (command.obj > NOBJECTS ||
1054 if (DARK(game.loc)) {
1055 sspeak(NO_SEE, command.raw1);
1056 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1057 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1058 } else if (objects[command.obj].texts[0] == NULL ||
1059 game.prop[command.obj] < 0) {
1060 rspeak(actions[command.verb].message);
1062 pspeak(command.obj, study, game.prop[command.obj], true);
1066 static int reservoir(void)
1067 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1069 /* FIXME: Arithmetic on state numbers */
1070 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
1071 rspeak(NOTHING_HAPPENS);
1075 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1079 game.oldlc2 = game.loc;
1080 game.newloc = LOC_NOWHERE;
1082 return GO_TERMINATE;
1087 static int rub(token_t verb, token_t obj)
1088 /* Rub. Yields various snide remarks except for lit urn. */
1090 if (obj == URN && game.prop[URN] == URN_LIT) {
1092 drop(AMBER, game.loc);
1093 game.prop[AMBER] = AMBER_IN_ROCK;
1095 drop(CAVITY, game.loc);
1097 } else if (obj != LAMP) {
1098 rspeak(PECULIAR_NOTHING);
1100 rspeak(actions[verb].message);
1105 static int say(struct command_t *command)
1106 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1108 if (command->wd2 > 0) {
1109 command->wd1 = command->wd2;
1110 strcpy(command->raw1, command->raw2);
1112 char word1[TOKLEN + 1];
1113 packed_to_token(command->wd1, word1);
1114 int wd = (int) get_vocab_id(word1);
1115 if (wd == MOTION_WORD(XYZZY) ||
1116 wd == MOTION_WORD(PLUGH) ||
1117 wd == MOTION_WORD(PLOVER) ||
1118 wd == ACTION_WORD(GIANTWORDS) ||
1119 wd == ACTION_WORD(PART)) {
1120 /* FIXME: scribbles on the interpreter's command block */
1121 wordclear(&command->wd2);
1124 sspeak(OKEY_DOKEY, command->raw1);
1128 static int throw_support(long spk)
1131 drop(AXE, game.loc);
1135 static int throw (struct command_t *command)
1136 /* Throw. Same as discard unless axe. Then same as attack except
1137 * ignore bird, and if dwarf is present then one might be killed.
1138 * (Only way to do so!) Axe also special for dragon, bear, and
1139 * troll. Treasures special for troll. */
1141 if (!TOTING(command->obj)) {
1142 rspeak(actions[command->verb].message);
1145 if (objects[command->obj].is_treasure && AT(TROLL)) {
1146 /* Snarf a treasure for the troll. */
1147 drop(command->obj, LOC_NOWHERE);
1148 move(TROLL, LOC_NOWHERE);
1149 move(TROLL + NOBJECTS, LOC_NOWHERE);
1150 drop(TROLL2, objects[TROLL].plac);
1151 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1153 rspeak(TROLL_SATISFIED);
1156 if (command->obj == FOOD && HERE(BEAR)) {
1157 /* But throwing food is another story. */
1158 command->obj = BEAR;
1159 return (feed(command->verb, command->obj));
1161 if (command->obj != AXE)
1162 return (discard(command->verb, command->obj, false));
1164 if (atdwrf(game.loc) <= 0) {
1165 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1166 return throw_support(DRAGON_SCALES);
1168 return throw_support(TROLL_RETURNS);
1170 return throw_support(OGRE_DODGE);
1171 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1172 /* This'll teach him to throw the axe at the bear! */
1173 drop(AXE, game.loc);
1174 game.fixed[AXE] = IS_FIXED;
1176 state_change(AXE, AXE_LOST);
1179 command->obj = NO_OBJECT;
1180 return (attack(command));
1183 if (randrange(NDWARVES + 1) < game.dflag) {
1184 return throw_support(DWARF_DODGES);
1186 long i = atdwrf(game.loc);
1187 game.dseen[i] = false;
1188 game.dloc[i] = LOC_NOWHERE;
1189 return throw_support((++game.dkill == 1) ?
1196 static int wake(token_t verb, token_t obj)
1197 /* Wake. Only use is to disturb the dwarves. */
1201 rspeak(actions[verb].message);
1205 return GO_DWARFWAKE;
1209 static int wave(token_t verb, token_t obj)
1210 /* Wave. No effect unless waving rod at fissure or at bird. */
1217 rspeak(((!TOTING(obj)) && (obj != ROD ||
1220 actions[verb].message);
1224 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1225 drop(JADE, game.loc);
1226 game.prop[JADE] = STATE_FOUND;
1228 rspeak(NECKLACE_FLY);
1232 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1235 return GO_DWARFWAKE;
1239 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1245 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1249 state_change(FISSURE,
1250 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1255 int action(struct command_t *command)
1256 /* Analyse a verb. Remember what it was, go back for object if second word
1257 * unless verb is "say", which snarfs arbitrary second word.
1260 if (command->part == unknown) {
1261 /* Analyse an object word. See if the thing is here, whether
1262 * we've got a verb yet, and so on. Object must be here
1263 * unless verb is "find" or "invent(ory)" (and no new verb
1264 * yet to be analysed). Water and oil are also funny, since
1265 * they are never actually dropped at any location, but might
1266 * be here inside the bottle or urn or as a feature of the
1268 if (HERE(command->obj))
1270 else if (command->obj == GRATE) {
1271 if (game.loc == LOC_START ||
1272 game.loc == LOC_VALLEY ||
1273 game.loc == LOC_SLIT) {
1274 command->obj = DPRSSN;
1276 if (game.loc == LOC_COBBLE ||
1277 game.loc == LOC_DEBRIS ||
1278 game.loc == LOC_AWKWARD ||
1279 game.loc == LOC_BIRD ||
1280 game.loc == LOC_PITTOP) {
1281 command->obj = ENTRNC;
1283 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1285 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1286 command->obj == LIQLOC(game.loc))
1288 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1291 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1292 command->obj = PLANT2;
1294 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1296 rspeak(KNIVES_VANISH);
1298 } else if (command->obj == ROD && HERE(ROD2)) {
1299 command->obj = ROD2;
1301 } else if ((command->verb == FIND ||
1302 command->verb == INVENTORY) && command->wd2 <= 0)
1305 sspeak(NO_SEE, command->raw1);
1309 if (command->wd2 > 0)
1311 if (command->verb != 0)
1312 command->part = transitive;
1315 switch (command->part) {
1317 if (command->wd2 > 0 && command->verb != SAY)
1319 if (command->verb == SAY)
1320 command->obj = command->wd2;
1321 if (command->obj == NO_OBJECT ||
1322 command->obj == INTRANSITIVE) {
1323 /* Analyse an intransitive verb (ie, no object given yet). */
1324 switch (command->verb) {
1326 return vcarry(command->verb, INTRANSITIVE);
1332 return lock(command->verb, INTRANSITIVE);
1335 return (GO_CLEAROBJ);
1338 return lock(command->verb, INTRANSITIVE);
1340 return light(command->verb, INTRANSITIVE);
1342 return extinguish(command->verb, INTRANSITIVE);
1348 rspeak(actions[command->verb].message);
1352 return attack(command);
1354 return pour(command->verb, command->obj);
1356 return eat(command->verb, INTRANSITIVE);
1358 return drink(command->verb, command->obj);
1372 return fill(command->verb, command->obj);
1380 return bigwords(command->wd1);
1384 command->obj = INTRANSITIVE;
1385 return read(*command);
1395 return fly(command->verb, INTRANSITIVE);
1401 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1406 /* Analyse a transitive verb. */
1407 switch (command->verb) {
1409 return vcarry(command->verb, command->obj);
1411 return discard(command->verb, command->obj, false);
1413 return say(command);
1415 return lock(command->verb, command->obj);
1418 return (GO_CLEAROBJ);
1421 return lock(command->verb, command->obj);
1423 return light(command->verb, command->obj);
1425 return extinguish(command->verb, command->obj);
1427 return wave(command->verb, command->obj);
1429 rspeak(actions[command->verb].message);
1433 rspeak(actions[command->verb].message);
1437 return attack(command);
1439 return pour(command->verb, command->obj);
1441 return eat(command->verb, command->obj);
1443 return drink(command->verb, command->obj);
1445 return rub(command->verb, command->obj);
1447 return throw (command);
1449 rspeak(actions[command->verb].message);
1453 return find(command->verb, command->obj);
1455 return find(command->verb, command->obj);
1457 return feed(command->verb, command->obj);
1459 return fill(command->verb, command->obj);
1464 rspeak(actions[command->verb].message);
1468 rspeak(actions[command->verb].message);
1472 rspeak(actions[command->verb].message);
1476 return read(*command);
1478 return vbreak(command->verb, command->obj);
1480 return wake(command->verb, command->obj);
1482 rspeak(actions[command->verb].message);
1486 rspeak(actions[command->verb].message);
1490 return fly(command->verb, command->obj);
1492 rspeak(actions[command->verb].message);
1498 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1501 /* Unknown verb, couldn't deduce object - might need hint */
1502 sspeak(WHAT_DO, command->raw1);
1503 return GO_CHECKHINT;
1505 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE