7 static int fill(token_t, token_t);
9 static void state_change(long obj, long state)
11 game.prop[obj] = state;
12 pspeak(obj, change, state, true);
15 static int attack(struct command_t *command)
16 /* Attack. Assume target if unambiguous. "Throw" also links here.
17 * Attackable objects fall into two categories: enemies (snake,
18 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
19 * enemies, or no enemies but 2 others. */
21 vocab_t verb = command->verb;
22 vocab_t obj = command->obj;
24 if (obj == NO_OBJECT ||
25 obj == INTRANSITIVE) {
27 if (atdwrf(game.loc) > 0) {
35 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
47 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
51 /* check for low-priority targets */
52 if (obj == NO_OBJECT) {
53 /* Can't attack bird or machine by throwing axe. */
54 if (HERE(BIRD) && verb != THROW) {
58 if (HERE(VEND) && verb != THROW) {
62 /* Clam and oyster both treated as clam for intransitive case;
64 if (HERE(CLAM) || HERE(OYSTER)) {
84 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
89 switch (game.prop[BEAR]) {
94 rspeak(BEAR_CONFUSED);
97 rspeak(BEAR_CONFUSED);
100 rspeak(ALREADY_DEAD);
105 if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
106 /* Fun stuff for dragon. If he insists on attacking it, win!
107 * Set game.prop to dead, move dragon to central loc (still
108 * fixed), move rug there (not fixed), and move him there,
109 * too. Then do a null motion to get new description. */
110 rspeak(BARE_HANDS_QUERY);
112 // FIXME: setting wd1 is a workaround for broken logic
113 command->wd1 = token_to_packed("Y");
115 // FIXME: setting wd1 is a workaround for broken logic
116 command->wd1 = token_to_packed("N");
119 state_change(DRAGON, DRAGON_DEAD);
120 game.prop[RUG] = RUG_FLOOR;
121 /* FIXME: Arithmetic on location values */
122 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
123 move(DRAGON + NOBJECTS, -1);
124 move(RUG + NOBJECTS, 0);
128 for (obj = 1; obj <= NOBJECTS; obj++) {
129 if (game.place[obj] == objects[DRAGON].plac ||
130 game.place[obj] == objects[DRAGON].fixd)
139 if (atdwrf(game.loc) == 0)
142 rspeak(KNIFE_THROWN);
145 for (int i = 1; i < PIRATE; i++) {
146 if (game.dloc[i] == game.loc) {
148 game.dloc[i] = LOC_LONGWEST;
149 game.dseen[i] = false;
152 rspeak((dwarves > 1) ?
164 rspeak(SHELL_IMPERVIOUS);
167 rspeak(SNAKE_WARNING);
173 rspeak(BARE_HANDS_QUERY);
176 rspeak(ALREADY_DEAD);
182 rspeak(actions[verb].message);
187 static int bigwords(token_t foo)
188 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
189 * Look up foo in special section of vocab to determine which word we've got.
190 * Last word zips the eggs back to the giant room (unless already there). */
192 char word[TOKLEN + 1];
193 packed_to_token(foo, word);
194 int k = (int) get_special_vocab_id(word);
195 if (game.foobar != 1 - k) {
196 if (game.foobar != 0 && game.loc == LOC_GIANTROOM) {
199 rspeak(NOTHING_HAPPENS);
209 if (game.place[EGGS] == objects[EGGS].plac ||
210 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
211 rspeak(NOTHING_HAPPENS);
214 /* Bring back troll if we steal the eggs back from him before
216 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
217 game.prop[TROLL] = TROLL_PAIDONCE;
221 if (game.loc == objects[EGGS].plac)
223 move(EGGS, objects[EGGS].plac);
224 pspeak(EGGS, look, k, true);
230 static void blast(void)
231 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
233 if (game.prop[ROD2] < 0 ||
235 rspeak(REQUIRES_DYNAMITE);
237 game.bonus = VICTORY_MESSAGE;
238 if (game.loc == LOC_NE)
239 game.bonus = DEFEAT_MESSAGE;
241 game.bonus = SPLATTER_MESSAGE;
247 static int vbreak(token_t verb, token_t obj)
248 /* Break. Only works for mirror in repository and, of course, the vase. */
252 rspeak(BREAK_MIRROR);
259 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
261 drop(VASE, game.loc);
262 state_change(VASE, VASE_BROKEN);
263 game.fixed[VASE] = -1;
266 rspeak(actions[verb].message);
267 return (GO_CLEAROBJ);
270 static int brief(void)
271 /* Brief. Intransitive only. Suppress long descriptions after first time. */
275 rspeak(BRIEF_CONFIRM);
279 static int vcarry(token_t verb, token_t obj)
280 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
281 * take one without the other). Liquids also special, since they depend on
282 * status of bottle. Also various side effects, etc. */
284 if (obj == INTRANSITIVE) {
285 /* Carry, no object given yet. OK if only one object present. */
286 if (game.atloc[game.loc] == 0 ||
287 game.link[game.atloc[game.loc]] != 0 ||
288 atdwrf(game.loc) > 0)
290 obj = game.atloc[game.loc];
294 rspeak(ALREADY_CARRYING);
299 rspeak(REMOVE_MESSAGE);
304 if (game.fixed[obj] != 0) {
305 if (obj == PLANT && game.prop[PLANT] <= 0) {
309 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
310 rspeak(BEAR_CHAINED);
313 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
314 rspeak(STILL_LOCKED);
322 rspeak(DOUGHNUT_HOLES);
329 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
334 rspeak(HAND_PASSTHROUGH);
345 if (TOTING(BOTTLE)) {
346 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
347 return (fill(verb, BOTTLE));
348 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
352 rspeak(NO_CONTAINER);
358 if (game.holdng >= INVLIMIT) {
364 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
365 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
371 rspeak(CANNOT_CARRY);
378 game.prop[BIRD] = BIRD_CAGED;
380 /* FIXME: Arithmetic on state numbers */
383 (game.prop[BIRD] == BIRD_CAGED ||
384 -1 - game.prop[BIRD] == 1))
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] != 0) {
392 game.prop[CAVITY] = CAVITY_EMPTY;
398 static int chain(token_t verb)
399 /* Do something to the bear's chain */
402 if (game.prop[BEAR] == UNTAMED_BEAR) {
406 if (game.prop[CHAIN] == CHAIN_HEAP) {
407 rspeak(ALREADY_UNLOCKED);
410 game.prop[CHAIN] = CHAIN_HEAP;
411 game.fixed[CHAIN] = CHAIN_HEAP;
412 if (game.prop[BEAR] != BEAR_DEAD)
413 game.prop[BEAR] = CONTENTED_BEAR;
415 switch (game.prop[BEAR]) {
417 game.fixed[BEAR] = -1;
420 game.fixed[BEAR] = 0;
422 rspeak(CHAIN_UNLOCKED);
426 if (game.prop[CHAIN] != CHAIN_HEAP) {
427 rspeak(ALREADY_LOCKED);
430 if (game.loc != objects[CHAIN].plac) {
435 game.prop[CHAIN] = CHAIN_FIXED;
438 drop(CHAIN, game.loc);
439 game.fixed[CHAIN] = -1;
441 rspeak(CHAIN_LOCKED);
445 static int discard(token_t verb, token_t obj, bool just_do_it)
446 /* Discard object. "Throw" also comes here for most objects. Special cases for
447 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
448 * Drop coins at vending machine for extra batteries. */
450 int spk = actions[verb].message;
452 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
458 if (obj == BIRD && HERE(SNAKE)) {
459 rspeak(BIRD_ATTACKS);
463 /* Set game.prop for use by travel options */
464 game.prop[SNAKE] = SNAKE_CHASED;
466 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
469 game.prop[CAVITY] = CAVITY_FULL;
470 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
471 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
478 if (spk != RUG_WIGGLES) {
479 /* FIXME: Arithmetic on state numbers */
480 int k = 2 - game.prop[RUG];
483 k = objects[SAPPH].plac;
484 move(RUG + NOBJECTS, k);
487 } else if (obj == COINS && HERE(VEND)) {
489 drop(BATTERY, game.loc);
490 pspeak(BATTERY, look, FRESH_BATTERIES, true);
492 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
496 } else if (obj == BEAR && AT(TROLL)) {
497 state_change(TROLL, TROLL_GONE);
498 move(TROLL, LOC_NOWHERE);
499 move(TROLL + NOBJECTS, LOC_NOWHERE);
500 move(TROLL2, objects[TROLL].plac);
501 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
503 } else if (obj != VASE ||
504 game.loc == objects[PILLOW].plac) {
507 game.prop[VASE] = VASE_BROKEN;
509 game.prop[VASE] = VASE_WHOLE;
510 pspeak(VASE, look, game.prop[VASE] + 1, true);
511 if (game.prop[VASE] != VASE_WHOLE)
512 game.fixed[VASE] = -1;
518 if (obj == BOTTLE && k != 0)
519 game.place[k] = LOC_NOWHERE;
520 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
521 drop(BIRD, game.loc);
525 game.prop[BIRD] = BIRD_UNCAGED;
526 if (FOREST(game.loc))
527 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
531 static int drink(token_t verb, token_t obj)
532 /* Drink. If no object, assume water and look for it here. If water is in
533 * the bottle, drink that, else must be at a water loc, so drink stream. */
535 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
536 (LIQUID() != WATER || !HERE(BOTTLE))) {
542 state_change(DRAGON, DRAGON_BLOODLESS);
547 if (obj != NO_OBJECT && obj != WATER) {
548 rspeak(RIDICULOUS_ATTEMPT);
551 if (LIQUID() == WATER && HERE(BOTTLE)) {
552 game.prop[BOTTLE] = EMPTY_BOTTLE;
553 game.place[WATER] = LOC_NOWHERE;
554 rspeak(BOTTLE_EMPTY);
558 rspeak(actions[verb].message);
562 static int eat(token_t verb, token_t obj)
563 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
564 * ok, some things lose appetite, rest are ridiculous. */
566 if (obj == INTRANSITIVE) {
570 rspeak(THANKS_DELICIOUS);
575 rspeak(THANKS_DELICIOUS);
587 rspeak(LOST_APPETITE);
590 rspeak(actions[verb].message);
594 static int extinguish(token_t verb, int obj)
595 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
597 if (obj == INTRANSITIVE) {
598 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
600 if (HERE(URN) && game.prop[URN] == URN_LIT)
602 if (obj == INTRANSITIVE)
607 if (game.prop[URN] != URN_EMPTY) {
608 state_change(URN, URN_DARK);
610 pspeak(URN, change, URN_DARK, true);
616 state_change(LAMP, LAMP_DARK);
617 rspeak(DARK(game.loc) ?
625 rspeak(BEYOND_POWER);
629 rspeak(actions[verb].message);
633 static int feed(token_t verb, token_t obj)
634 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
635 * mad. Bear, special. */
637 int spk = actions[verb].message;
641 } else if (obj == SNAKE ||
644 spk = NOTHING_EDIBLE;
645 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
646 spk = RIDICULOUS_ATTEMPT;
649 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
653 } else if (obj == DWARF) {
658 } else if (obj == BEAR) {
659 if (game.prop[BEAR] == UNTAMED_BEAR)
660 spk = NOTHING_EDIBLE;
661 if (game.prop[BEAR] == BEAR_DEAD)
662 spk = RIDICULOUS_ATTEMPT;
665 game.prop[BEAR] = SITTING_BEAR;
670 } else if (obj == OGRE) {
680 int fill(token_t verb, token_t obj)
681 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
685 if (LIQLOC(game.loc) == NO_OBJECT) {
686 rspeak(FILL_INVALID);
690 rspeak(ARENT_CARRYING);
693 rspeak(SHATTER_VASE);
694 game.prop[VASE] = VASE_BROKEN;
695 game.fixed[VASE] = -1;
696 return (discard(verb, obj, true));
700 if (game.prop[URN] != URN_EMPTY) {
705 rspeak(FILL_INVALID);
711 game.prop[BOTTLE] = EMPTY_BOTTLE;
715 game.prop[URN] = URN_DARK;
716 game.prop[BOTTLE] = EMPTY_BOTTLE;
721 rspeak(FILL_INVALID);
724 game.place[k] = LOC_NOWHERE;
727 if (obj != NO_OBJECT && obj != BOTTLE) {
728 rspeak(actions[verb].message);
731 if (obj == NO_OBJECT && !HERE(BOTTLE))
734 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
738 if (LIQUID() != NO_OBJECT) {
742 if (LIQLOC(game.loc) == NO_OBJECT) {
747 game.prop[BOTTLE] = (LIQLOC(game.loc) == OIL) ? OIL_BOTTLE : WATER_BOTTLE;
749 game.place[LIQUID()] = CARRIED;
753 rspeak(BOTTLED_WATER);
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] >= 0) {
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 objsnd/locsnd. */
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 /* FIXME: Magic number, sensitive to bird state logic */
898 if (i == BIRD && game.prop[i] == 5)
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 /* FIXME: magic numbers */
1116 if (wd == MOTION_WORD(XYZZY) ||
1117 wd == MOTION_WORD(PLUGH) ||
1118 wd == MOTION_WORD(PLOVER) ||
1119 wd == ACTION_WORD(GIANTWORDS) ||
1120 wd == ACTION_WORD(PART)) {
1121 /* FIXME: scribbles on the interpreter's command block */
1122 wordclear(&command->wd2);
1125 sspeak(OKEY_DOKEY, command->raw1);
1129 static int throw_support(long spk)
1132 drop(AXE, game.loc);
1136 static int throw (struct command_t *command)
1137 /* Throw. Same as discard unless axe. Then same as attack except
1138 * ignore bird, and if dwarf is present then one might be killed.
1139 * (Only way to do so!) Axe also special for dragon, bear, and
1140 * troll. Treasures special for troll. */
1142 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1143 command->obj = ROD2;
1144 if (!TOTING(command->obj)) {
1145 rspeak(actions[command->verb].message);
1148 if (objects[command->obj].is_treasure && AT(TROLL)) {
1149 /* Snarf a treasure for the troll. */
1150 drop(command->obj, LOC_NOWHERE);
1151 move(TROLL, LOC_NOWHERE);
1152 move(TROLL + NOBJECTS, LOC_NOWHERE);
1153 drop(TROLL2, objects[TROLL].plac);
1154 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1156 rspeak(TROLL_SATISFIED);
1159 if (command->obj == FOOD && HERE(BEAR)) {
1160 /* But throwing food is another story. */
1161 command->obj = BEAR;
1162 return (feed(command->verb, command->obj));
1164 if (command->obj != AXE)
1165 return (discard(command->verb, command->obj, false));
1167 if (atdwrf(game.loc) <= 0) {
1168 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1169 return throw_support(DRAGON_SCALES);
1171 return throw_support(TROLL_RETURNS);
1173 return throw_support(OGRE_DODGE);
1174 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1175 /* This'll teach him to throw the axe at the bear! */
1176 drop(AXE, game.loc);
1177 game.fixed[AXE] = -1;
1179 state_change(AXE, AXE_LOST);
1182 command->obj = NO_OBJECT;
1183 return (attack(command));
1186 if (randrange(NDWARVES + 1) < game.dflag) {
1187 return throw_support(DWARF_DODGES);
1189 long i = atdwrf(game.loc);
1190 game.dseen[i] = false;
1191 game.dloc[i] = LOC_NOWHERE;
1192 return throw_support((++game.dkill == 1) ?
1199 static int wake(token_t verb, token_t obj)
1200 /* Wake. Only use is to disturb the dwarves. */
1204 rspeak(actions[verb].message);
1208 return GO_DWARFWAKE;
1212 static int wave(token_t verb, token_t obj)
1213 /* Wave. No effect unless waving rod at fissure or at bird. */
1220 rspeak(((!TOTING(obj)) && (obj != ROD ||
1223 actions[verb].message);
1227 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1228 drop(JADE, game.loc);
1229 game.prop[JADE] = 0;
1231 rspeak(NECKLACE_FLY);
1235 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1238 return GO_DWARFWAKE;
1242 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1248 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1252 state_change(FISSURE,
1253 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1258 int action(struct command_t *command)
1259 /* Analyse a verb. Remember what it was, go back for object if second word
1260 * unless verb is "say", which snarfs arbitrary second word.
1263 if (command->part == unknown) {
1264 /* Analyse an object word. See if the thing is here, whether
1265 * we've got a verb yet, and so on. Object must be here
1266 * unless verb is "find" or "invent(ory)" (and no new verb
1267 * yet to be analysed). Water and oil are also funny, since
1268 * they are never actually dropped at any location, but might
1269 * be here inside the bottle or urn or as a feature of the
1271 if (HERE(command->obj))
1273 else if (command->obj == GRATE) {
1274 if (game.loc == LOC_START ||
1275 game.loc == LOC_VALLEY ||
1276 game.loc == LOC_SLIT) {
1277 command->obj = DPRSSN;
1279 if (game.loc == LOC_COBBLE ||
1280 game.loc == LOC_DEBRIS ||
1281 game.loc == LOC_AWKWARD ||
1282 game.loc == LOC_BIRD ||
1283 game.loc == LOC_PITTOP) {
1284 command->obj = ENTRNC;
1286 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1288 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1289 command->obj == LIQLOC(game.loc))
1291 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1294 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1295 command->obj = PLANT2;
1297 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1299 rspeak(KNIVES_VANISH);
1301 } else if (command->obj == ROD && HERE(ROD2)) {
1302 command->obj = ROD2;
1304 } else if ((command->verb == FIND ||
1305 command->verb == INVENTORY) && command->wd2 <= 0)
1308 sspeak(NO_SEE, command->raw1);
1312 if (command->wd2 > 0)
1314 if (command->verb != 0)
1315 command->part = transitive;
1318 switch (command->part) {
1320 if (command->wd2 > 0 && command->verb != SAY)
1322 if (command->verb == SAY)
1323 command->obj = command->wd2;
1324 if (command->obj == NO_OBJECT ||
1325 command->obj == INTRANSITIVE) {
1326 /* Analyse an intransitive verb (ie, no object given yet). */
1327 switch (command->verb) {
1329 return vcarry(command->verb, INTRANSITIVE);
1335 return lock(command->verb, INTRANSITIVE);
1338 return (GO_CLEAROBJ);
1341 return lock(command->verb, INTRANSITIVE);
1343 return light(command->verb, INTRANSITIVE);
1345 return extinguish(command->verb, INTRANSITIVE);
1351 rspeak(actions[command->verb].message);
1355 return attack(command);
1357 return pour(command->verb, command->obj);
1359 return eat(command->verb, INTRANSITIVE);
1361 return drink(command->verb, command->obj);
1375 return fill(command->verb, command->obj);
1383 return bigwords(command->wd1);
1387 command->obj = INTRANSITIVE;
1388 return read(*command);
1398 return fly(command->verb, INTRANSITIVE);
1404 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1409 /* Analyse a transitive verb. */
1410 switch (command->verb) {
1412 return vcarry(command->verb, command->obj);
1414 return discard(command->verb, command->obj, false);
1416 return say(command);
1418 return lock(command->verb, command->obj);
1421 return (GO_CLEAROBJ);
1424 return lock(command->verb, command->obj);
1426 return light(command->verb, command->obj);
1428 return extinguish(command->verb, command->obj);
1430 return wave(command->verb, command->obj);
1432 rspeak(actions[command->verb].message);
1436 rspeak(actions[command->verb].message);
1440 return attack(command);
1442 return pour(command->verb, command->obj);
1444 return eat(command->verb, command->obj);
1446 return drink(command->verb, command->obj);
1448 return rub(command->verb, command->obj);
1450 return throw (command);
1452 rspeak(actions[command->verb].message);
1456 return find(command->verb, command->obj);
1458 return find(command->verb, command->obj);
1460 return feed(command->verb, command->obj);
1462 return fill(command->verb, command->obj);
1467 rspeak(actions[command->verb].message);
1471 rspeak(actions[command->verb].message);
1475 rspeak(actions[command->verb].message);
1479 return read(*command);
1481 return vbreak(command->verb, command->obj);
1483 return wake(command->verb, command->obj);
1485 rspeak(actions[command->verb].message);
1489 rspeak(actions[command->verb].message);
1493 return fly(command->verb, command->obj);
1495 rspeak(actions[command->verb].message);
1501 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1504 /* Unknown verb, couldn't deduce object - might need hint */
1505 sspeak(WHAT_DO, command->raw1);
1506 return GO_CHECKHINT;
1508 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE