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. */
451 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
454 rspeak(actions[verb].message);
457 if (obj == BIRD && HERE(SNAKE)) {
458 rspeak(BIRD_ATTACKS);
462 /* Set game.prop for use by travel options */
463 game.prop[SNAKE] = SNAKE_CHASED;
465 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
468 game.prop[CAVITY] = CAVITY_FULL;
469 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
470 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
477 if (spk != RUG_WIGGLES) {
478 /* FIXME: Arithmetic on state numbers */
479 int k = 2 - game.prop[RUG];
482 k = objects[SAPPH].plac;
483 move(RUG + NOBJECTS, k);
486 } else if (obj == COINS && HERE(VEND)) {
488 drop(BATTERY, game.loc);
489 pspeak(BATTERY, look, FRESH_BATTERIES, true);
491 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
495 } else if (obj == BEAR && AT(TROLL)) {
496 state_change(TROLL, TROLL_GONE);
497 move(TROLL, LOC_NOWHERE);
498 move(TROLL + NOBJECTS, LOC_NOWHERE);
499 move(TROLL2, objects[TROLL].plac);
500 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
502 } else if (obj != VASE ||
503 game.loc == objects[PILLOW].plac) {
506 game.prop[VASE] = VASE_BROKEN;
508 game.prop[VASE] = VASE_WHOLE;
509 pspeak(VASE, look, game.prop[VASE] + 1, true);
510 if (game.prop[VASE] != VASE_WHOLE)
511 game.fixed[VASE] = -1;
517 if (obj == BOTTLE && k != NO_OBJECT)
518 game.place[k] = LOC_NOWHERE;
519 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
520 drop(BIRD, game.loc);
524 game.prop[BIRD] = BIRD_UNCAGED;
525 if (FOREST(game.loc))
526 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
530 static int drink(token_t verb, token_t obj)
531 /* Drink. If no object, assume water and look for it here. If water is in
532 * the bottle, drink that, else must be at a water loc, so drink stream. */
534 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
535 (LIQUID() != WATER || !HERE(BOTTLE))) {
541 state_change(DRAGON, DRAGON_BLOODLESS);
546 if (obj != NO_OBJECT && obj != WATER) {
547 rspeak(RIDICULOUS_ATTEMPT);
550 if (LIQUID() == WATER && HERE(BOTTLE)) {
551 game.prop[BOTTLE] = EMPTY_BOTTLE;
552 game.place[WATER] = LOC_NOWHERE;
553 rspeak(BOTTLE_EMPTY);
557 rspeak(actions[verb].message);
561 static int eat(token_t verb, token_t obj)
562 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
563 * ok, some things lose appetite, rest are ridiculous. */
565 if (obj == INTRANSITIVE) {
569 rspeak(THANKS_DELICIOUS);
574 rspeak(THANKS_DELICIOUS);
586 rspeak(LOST_APPETITE);
589 rspeak(actions[verb].message);
593 static int extinguish(token_t verb, int obj)
594 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
596 if (obj == INTRANSITIVE) {
597 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
599 if (HERE(URN) && game.prop[URN] == URN_LIT)
601 if (obj == INTRANSITIVE)
606 if (game.prop[URN] != URN_EMPTY) {
607 state_change(URN, URN_DARK);
609 pspeak(URN, change, URN_DARK, true);
615 state_change(LAMP, LAMP_DARK);
616 rspeak(DARK(game.loc) ?
624 rspeak(BEYOND_POWER);
628 rspeak(actions[verb].message);
632 static int feed(token_t verb, token_t obj)
633 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
634 * mad. Bear, special. */
636 int spk = actions[verb].message;
640 } else if (obj == SNAKE ||
643 spk = NOTHING_EDIBLE;
644 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
645 spk = RIDICULOUS_ATTEMPT;
648 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
652 } else if (obj == DWARF) {
657 } else if (obj == BEAR) {
658 if (game.prop[BEAR] == UNTAMED_BEAR)
659 spk = NOTHING_EDIBLE;
660 if (game.prop[BEAR] == BEAR_DEAD)
661 spk = RIDICULOUS_ATTEMPT;
664 game.prop[BEAR] = SITTING_BEAR;
669 } else if (obj == OGRE) {
679 int fill(token_t verb, token_t obj)
680 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
684 if (LIQLOC(game.loc) == NO_OBJECT) {
685 rspeak(FILL_INVALID);
689 rspeak(ARENT_CARRYING);
692 rspeak(SHATTER_VASE);
693 game.prop[VASE] = VASE_BROKEN;
694 game.fixed[VASE] = -1;
695 return (discard(verb, VASE, true));
699 if (game.prop[URN] != URN_EMPTY) {
704 rspeak(FILL_INVALID);
710 game.prop[BOTTLE] = EMPTY_BOTTLE;
714 game.prop[URN] = URN_DARK;
715 game.prop[BOTTLE] = EMPTY_BOTTLE;
720 rspeak(FILL_INVALID);
723 game.place[k] = LOC_NOWHERE;
726 if (obj != NO_OBJECT && obj != BOTTLE) {
727 rspeak(actions[verb].message);
730 if (obj == NO_OBJECT && !HERE(BOTTLE))
733 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
737 if (LIQUID() != NO_OBJECT) {
741 if (LIQLOC(game.loc) == NO_OBJECT) {
746 game.prop[BOTTLE] = (LIQLOC(game.loc) == OIL) ? OIL_BOTTLE : WATER_BOTTLE;
748 game.place[LIQUID()] = CARRIED;
752 rspeak(BOTTLED_WATER);
756 static int find(token_t verb, token_t obj)
757 /* Find. Might be carrying it, or it might be here. Else give caveat. */
760 rspeak(ALREADY_CARRYING);
765 rspeak(NEEDED_NEARBY);
770 (LIQUID() == obj && AT(BOTTLE)) ||
771 obj == LIQLOC(game.loc) ||
772 (obj == DWARF && atdwrf(game.loc) > 0)) {
778 rspeak(actions[verb].message);
782 static int fly(token_t verb, token_t obj)
783 /* Fly. Snide remarks unless hovering rug is here. */
785 if (obj == INTRANSITIVE) {
790 if (game.prop[RUG] != RUG_HOVER) {
791 rspeak(RUG_NOTHING2);
798 rspeak(actions[verb].message);
801 if (game.prop[RUG] != RUG_HOVER) {
802 rspeak(RUG_NOTHING1);
805 game.oldlc2 = game.oldloc;
806 game.oldloc = game.loc;
807 /* FIXME: Arithmetic on location values */
808 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
810 if (game.prop[SAPPH] >= 0) {
818 static int inven(void)
819 /* Inventory. If object, treat same as find. Else report on current burden. */
822 for (int i = 1; i <= NOBJECTS; i++) {
830 pspeak(i, touch, -1, false);
839 static int light(token_t verb, token_t obj)
840 /* Light. Applicable only to lamp and urn. */
842 if (obj == INTRANSITIVE) {
843 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
845 if (HERE(URN) && game.prop[URN] == URN_DARK)
847 if (obj == INTRANSITIVE ||
848 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
849 HERE(URN) && game.prop[URN] == URN_DARK))
854 state_change(URN, game.prop[URN] == URN_EMPTY ?
860 rspeak(actions[verb].message);
863 if (game.limit < 0) {
867 state_change(LAMP, LAMP_BRIGHT);
875 static int listen(void)
876 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
878 long sound = locations[game.loc].sound;
879 if (sound != SILENT) {
881 if (!locations[game.loc].loud)
885 for (int i = 1; i <= NOBJECTS; i++) {
887 objects[i].sounds[0] == NULL ||
890 int mi = game.prop[i];
892 mi += 3 * game.blooded;
893 long packed_zzword = token_to_packed(game.zzword);
894 pspeak(i, hear, mi, true, packed_zzword);
896 /* FIXME: Magic number, sensitive to bird state logic */
897 if (i == BIRD && game.prop[i] == 5)
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 /* FIXME: magic numbers */
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(ROD2) && command->obj == ROD && !TOTING(ROD))
1142 command->obj = ROD2;
1143 if (!TOTING(command->obj)) {
1144 rspeak(actions[command->verb].message);
1147 if (objects[command->obj].is_treasure && AT(TROLL)) {
1148 /* Snarf a treasure for the troll. */
1149 drop(command->obj, LOC_NOWHERE);
1150 move(TROLL, LOC_NOWHERE);
1151 move(TROLL + NOBJECTS, LOC_NOWHERE);
1152 drop(TROLL2, objects[TROLL].plac);
1153 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1155 rspeak(TROLL_SATISFIED);
1158 if (command->obj == FOOD && HERE(BEAR)) {
1159 /* But throwing food is another story. */
1160 command->obj = BEAR;
1161 return (feed(command->verb, command->obj));
1163 if (command->obj != AXE)
1164 return (discard(command->verb, command->obj, false));
1166 if (atdwrf(game.loc) <= 0) {
1167 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1168 return throw_support(DRAGON_SCALES);
1170 return throw_support(TROLL_RETURNS);
1172 return throw_support(OGRE_DODGE);
1173 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1174 /* This'll teach him to throw the axe at the bear! */
1175 drop(AXE, game.loc);
1176 game.fixed[AXE] = -1;
1178 state_change(AXE, AXE_LOST);
1181 command->obj = NO_OBJECT;
1182 return (attack(command));
1185 if (randrange(NDWARVES + 1) < game.dflag) {
1186 return throw_support(DWARF_DODGES);
1188 long i = atdwrf(game.loc);
1189 game.dseen[i] = false;
1190 game.dloc[i] = LOC_NOWHERE;
1191 return throw_support((++game.dkill == 1) ?
1198 static int wake(token_t verb, token_t obj)
1199 /* Wake. Only use is to disturb the dwarves. */
1203 rspeak(actions[verb].message);
1207 return GO_DWARFWAKE;
1211 static int wave(token_t verb, token_t obj)
1212 /* Wave. No effect unless waving rod at fissure or at bird. */
1219 rspeak(((!TOTING(obj)) && (obj != ROD ||
1222 actions[verb].message);
1226 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1227 drop(JADE, game.loc);
1228 game.prop[JADE] = 0;
1230 rspeak(NECKLACE_FLY);
1234 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1237 return GO_DWARFWAKE;
1241 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1247 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1251 state_change(FISSURE,
1252 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1257 int action(struct command_t *command)
1258 /* Analyse a verb. Remember what it was, go back for object if second word
1259 * unless verb is "say", which snarfs arbitrary second word.
1262 if (command->part == unknown) {
1263 /* Analyse an object word. See if the thing is here, whether
1264 * we've got a verb yet, and so on. Object must be here
1265 * unless verb is "find" or "invent(ory)" (and no new verb
1266 * yet to be analysed). Water and oil are also funny, since
1267 * they are never actually dropped at any location, but might
1268 * be here inside the bottle or urn or as a feature of the
1270 if (HERE(command->obj))
1272 else if (command->obj == GRATE) {
1273 if (game.loc == LOC_START ||
1274 game.loc == LOC_VALLEY ||
1275 game.loc == LOC_SLIT) {
1276 command->obj = DPRSSN;
1278 if (game.loc == LOC_COBBLE ||
1279 game.loc == LOC_DEBRIS ||
1280 game.loc == LOC_AWKWARD ||
1281 game.loc == LOC_BIRD ||
1282 game.loc == LOC_PITTOP) {
1283 command->obj = ENTRNC;
1285 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1287 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1288 command->obj == LIQLOC(game.loc))
1290 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1293 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1294 command->obj = PLANT2;
1296 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1298 rspeak(KNIVES_VANISH);
1300 } else if (command->obj == ROD && HERE(ROD2)) {
1301 command->obj = ROD2;
1303 } else if ((command->verb == FIND ||
1304 command->verb == INVENTORY) && command->wd2 <= 0)
1307 sspeak(NO_SEE, command->raw1);
1311 if (command->wd2 > 0)
1313 if (command->verb != 0)
1314 command->part = transitive;
1317 switch (command->part) {
1319 if (command->wd2 > 0 && command->verb != SAY)
1321 if (command->verb == SAY)
1322 command->obj = command->wd2;
1323 if (command->obj == NO_OBJECT ||
1324 command->obj == INTRANSITIVE) {
1325 /* Analyse an intransitive verb (ie, no object given yet). */
1326 switch (command->verb) {
1328 return vcarry(command->verb, INTRANSITIVE);
1334 return lock(command->verb, INTRANSITIVE);
1337 return (GO_CLEAROBJ);
1340 return lock(command->verb, INTRANSITIVE);
1342 return light(command->verb, INTRANSITIVE);
1344 return extinguish(command->verb, INTRANSITIVE);
1350 rspeak(actions[command->verb].message);
1354 return attack(command);
1356 return pour(command->verb, command->obj);
1358 return eat(command->verb, INTRANSITIVE);
1360 return drink(command->verb, command->obj);
1374 return fill(command->verb, command->obj);
1382 return bigwords(command->wd1);
1386 command->obj = INTRANSITIVE;
1387 return read(*command);
1397 return fly(command->verb, INTRANSITIVE);
1403 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1408 /* Analyse a transitive verb. */
1409 switch (command->verb) {
1411 return vcarry(command->verb, command->obj);
1413 return discard(command->verb, command->obj, false);
1415 return say(command);
1417 return lock(command->verb, command->obj);
1420 return (GO_CLEAROBJ);
1423 return lock(command->verb, command->obj);
1425 return light(command->verb, command->obj);
1427 return extinguish(command->verb, command->obj);
1429 return wave(command->verb, command->obj);
1431 rspeak(actions[command->verb].message);
1435 rspeak(actions[command->verb].message);
1439 return attack(command);
1441 return pour(command->verb, command->obj);
1443 return eat(command->verb, command->obj);
1445 return drink(command->verb, command->obj);
1447 return rub(command->verb, command->obj);
1449 return throw (command);
1451 rspeak(actions[command->verb].message);
1455 return find(command->verb, command->obj);
1457 return find(command->verb, command->obj);
1459 return feed(command->verb, command->obj);
1461 return fill(command->verb, command->obj);
1466 rspeak(actions[command->verb].message);
1470 rspeak(actions[command->verb].message);
1474 rspeak(actions[command->verb].message);
1478 return read(*command);
1480 return vbreak(command->verb, command->obj);
1482 return wake(command->verb, command->obj);
1484 rspeak(actions[command->verb].message);
1488 rspeak(actions[command->verb].message);
1492 return fly(command->verb, command->obj);
1494 rspeak(actions[command->verb].message);
1500 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1503 /* Unknown verb, couldn't deduce object - might need hint */
1504 sspeak(WHAT_DO, command->raw1);
1505 return GO_CHECKHINT;
1507 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE