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 speak(actions[verb].message);
181 static int bigwords(long id)
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 if ((game.foobar == WORD_EMPTY && id == ACTION_WORD(FEE)) ||
187 (game.foobar == ACTION_WORD(FEE) && id == ACTION_WORD(FIE)) ||
188 (game.foobar == ACTION_WORD(FIE) && id == ACTION_WORD(FOE)) ||
189 (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FOO)) ||
190 (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FUM)))
193 if ((id != ACTION_WORD(FOO)) && (id != ACTION_WORD(FUM))) {
197 game.foobar = WORD_EMPTY;
198 if (game.place[EGGS] == objects[EGGS].plac ||
199 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
200 rspeak(NOTHING_HAPPENS);
203 /* Bring back troll if we steal the eggs back from him before
205 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
206 game.prop[TROLL] = TROLL_PAIDONCE;
210 if (game.loc == objects[EGGS].plac)
212 move(EGGS, objects[EGGS].plac);
213 pspeak(EGGS, look, k, true);
219 if (game.loc == LOC_GIANTROOM) {
222 /* This is new begavior in Open Adventure - sounds better when
223 * player isn't in the Giant Room. */
224 rspeak(WELL_POINTLESS);
226 game.foobar = WORD_EMPTY;
231 static void blast(void)
232 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
234 if (game.prop[ROD2] < 0 ||
236 rspeak(REQUIRES_DYNAMITE);
238 game.bonus = VICTORY_MESSAGE;
239 if (game.loc == LOC_NE)
240 game.bonus = DEFEAT_MESSAGE;
242 game.bonus = SPLATTER_MESSAGE;
248 static int vbreak(token_t verb, token_t obj)
249 /* Break. Only works for mirror in repository and, of course, the vase. */
253 rspeak(BREAK_MIRROR);
260 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
262 drop(VASE, game.loc);
263 state_change(VASE, VASE_BROKEN);
264 game.fixed[VASE] = IS_FIXED;
267 speak(actions[verb].message);
268 return (GO_CLEAROBJ);
271 static int brief(void)
272 /* Brief. Intransitive only. Suppress long descriptions after first time. */
276 rspeak(BRIEF_CONFIRM);
280 static int vcarry(token_t verb, token_t obj)
281 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
282 * take one without the other). Liquids also special, since they depend on
283 * status of bottle. Also various side effects, etc. */
285 if (obj == INTRANSITIVE) {
286 /* Carry, no object given yet. OK if only one object present. */
287 if (game.atloc[game.loc] == 0 ||
288 game.link[game.atloc[game.loc]] != 0 ||
289 atdwrf(game.loc) > 0)
291 obj = game.atloc[game.loc];
295 rspeak(ALREADY_CARRYING);
300 rspeak(REMOVE_MESSAGE);
305 if (game.fixed[obj] != IS_FREE) {
306 /* Next guard tests whether plant is tiny or stashed */
307 if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
311 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
312 rspeak(BEAR_CHAINED);
315 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
316 rspeak(STILL_LOCKED);
324 rspeak(DOUGHNUT_HOLES);
331 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
336 rspeak(HAND_PASSTHROUGH);
347 if (TOTING(BOTTLE)) {
348 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
349 return (fill(verb, BOTTLE));
350 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
354 rspeak(NO_CONTAINER);
360 if (game.holdng >= INVLIMIT) {
366 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
367 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
373 rspeak(CANNOT_CARRY);
380 game.prop[BIRD] = BIRD_CAGED;
384 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
385 /* expression maps BIRD to CAGE and CAGE to BIRD */
386 carry(BIRD + CAGE - obj, game.loc);
387 carry(obj, game.loc);
388 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
389 game.place[LIQUID()] = CARRIED;
390 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
391 game.prop[obj] = STATE_FOUND;
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] = IS_FREE;
412 if (game.prop[BEAR] != BEAR_DEAD)
413 game.prop[BEAR] = CONTENTED_BEAR;
415 switch (game.prop[BEAR]) {
417 game.fixed[BEAR] = IS_FIXED;
420 game.fixed[BEAR] = IS_FREE;
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] = IS_FIXED;
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 speak(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)) {
467 game.prop[obj] = STATE_IN_CAVITY;
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 = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
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 state_change(VASE, AT(PILLOW)
509 if (game.prop[VASE] != VASE_WHOLE)
510 game.fixed[VASE] = IS_FIXED;
516 if (obj == BOTTLE && k != NO_OBJECT)
517 game.place[k] = LOC_NOWHERE;
518 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
519 drop(BIRD, game.loc);
523 game.prop[BIRD] = BIRD_UNCAGED;
524 if (FOREST(game.loc))
525 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
529 static int drink(token_t verb, token_t obj)
530 /* Drink. If no object, assume water and look for it here. If water is in
531 * the bottle, drink that, else must be at a water loc, so drink stream. */
533 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
534 (LIQUID() != WATER || !HERE(BOTTLE))) {
540 state_change(DRAGON, DRAGON_BLOODLESS);
545 if (obj != NO_OBJECT && obj != WATER) {
546 rspeak(RIDICULOUS_ATTEMPT);
549 if (LIQUID() == WATER && HERE(BOTTLE)) {
550 game.place[WATER] = LOC_NOWHERE;
551 state_change(BOTTLE, EMPTY_BOTTLE);
555 speak(actions[verb].message);
559 static int eat(token_t verb, token_t obj)
560 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
561 * ok, some things lose appetite, rest are ridiculous. */
563 if (obj == INTRANSITIVE) {
567 rspeak(THANKS_DELICIOUS);
572 rspeak(THANKS_DELICIOUS);
584 rspeak(LOST_APPETITE);
587 speak(actions[verb].message);
591 static int extinguish(token_t verb, int obj)
592 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
594 if (obj == INTRANSITIVE) {
595 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
597 if (HERE(URN) && game.prop[URN] == URN_LIT)
599 if (obj == INTRANSITIVE)
604 if (game.prop[URN] != URN_EMPTY) {
605 state_change(URN, URN_DARK);
607 pspeak(URN, change, URN_DARK, true);
613 state_change(LAMP, LAMP_DARK);
614 rspeak(DARK(game.loc) ?
622 rspeak(BEYOND_POWER);
626 speak(actions[verb].message);
630 static int feed(token_t verb, token_t obj)
631 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
632 * mad. Bear, special. */
639 if (game.prop[DRAGON] != DRAGON_BARS)
640 rspeak(RIDICULOUS_ATTEMPT);
642 rspeak(NOTHING_EDIBLE);
645 if (!game.closed && HERE(BIRD)) {
647 rspeak(BIRD_DEVOURED);
649 rspeak(NOTHING_EDIBLE);
659 speak(actions[verb].message);
662 if (game.prop[BEAR] == BEAR_DEAD) {
663 rspeak(RIDICULOUS_ATTEMPT);
666 if (game.prop[BEAR] == UNTAMED_BEAR) {
669 game.fixed[AXE] = IS_FREE;
670 game.prop[AXE] = AXE_HERE;
671 state_change(BEAR, SITTING_BEAR);
673 rspeak(NOTHING_EDIBLE);
676 speak(actions[verb].message);
682 speak(actions[verb].message);
690 int fill(token_t verb, token_t obj)
691 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
695 if (LIQLOC(game.loc) == NO_OBJECT) {
696 rspeak(FILL_INVALID);
700 rspeak(ARENT_CARRYING);
703 rspeak(SHATTER_VASE);
704 game.prop[VASE] = VASE_BROKEN;
705 game.fixed[VASE] = IS_FIXED;
706 return (discard(verb, VASE, true));
710 if (game.prop[URN] != URN_EMPTY) {
715 rspeak(FILL_INVALID);
721 game.prop[BOTTLE] = EMPTY_BOTTLE;
725 game.prop[URN] = URN_DARK;
726 game.prop[BOTTLE] = EMPTY_BOTTLE;
731 rspeak(FILL_INVALID);
734 game.place[k] = LOC_NOWHERE;
737 if (obj != NO_OBJECT && obj != BOTTLE) {
738 speak(actions[verb].message);
741 if (obj == NO_OBJECT && !HERE(BOTTLE))
744 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
748 if (LIQUID() != NO_OBJECT) {
752 if (LIQLOC(game.loc) == NO_OBJECT) {
757 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
761 game.place[LIQUID()] = CARRIED;
765 static int find(token_t verb, token_t obj)
766 /* Find. Might be carrying it, or it might be here. Else give caveat. */
769 rspeak(ALREADY_CARRYING);
774 rspeak(NEEDED_NEARBY);
779 (LIQUID() == obj && AT(BOTTLE)) ||
780 obj == LIQLOC(game.loc) ||
781 (obj == DWARF && atdwrf(game.loc) > 0)) {
787 speak(actions[verb].message);
791 static int fly(token_t verb, token_t obj)
792 /* Fly. Snide remarks unless hovering rug is here. */
794 if (obj == INTRANSITIVE) {
799 if (game.prop[RUG] != RUG_HOVER) {
800 rspeak(RUG_NOTHING2);
807 speak(actions[verb].message);
810 if (game.prop[RUG] != RUG_HOVER) {
811 rspeak(RUG_NOTHING1);
814 game.oldlc2 = game.oldloc;
815 game.oldloc = game.loc;
817 if (game.prop[SAPPH] == STATE_NOTFOUND) {
818 game.newloc = game.place[SAPPH];
821 game.newloc = LOC_CLIFF;
827 static int inven(void)
828 /* Inventory. If object, treat same as find. Else report on current burden. */
831 for (int i = 1; i <= NOBJECTS; i++) {
839 pspeak(i, touch, -1, false);
848 static int light(token_t verb, token_t obj)
849 /* Light. Applicable only to lamp and urn. */
851 if (obj == INTRANSITIVE) {
852 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
854 if (HERE(URN) && game.prop[URN] == URN_DARK)
856 if (obj == INTRANSITIVE ||
857 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
858 HERE(URN) && game.prop[URN] == URN_DARK))
863 state_change(URN, game.prop[URN] == URN_EMPTY ?
869 speak(actions[verb].message);
872 if (game.limit < 0) {
876 state_change(LAMP, LAMP_BRIGHT);
884 static int listen(void)
885 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
887 long sound = locations[game.loc].sound;
888 if (sound != SILENT) {
890 if (!locations[game.loc].loud)
894 for (int i = 1; i <= NOBJECTS; i++) {
896 objects[i].sounds[0] == NULL ||
899 int mi = game.prop[i];
901 mi += 3 * game.blooded;
902 long packed_zzword = token_to_packed(game.zzword);
903 pspeak(i, hear, mi, true, packed_zzword);
905 if (i == BIRD && mi == BIRD_ENDSTATE)
913 static int lock(token_t verb, token_t obj)
914 /* Lock, unlock, no object given. Assume various things if present. */
916 if (obj == INTRANSITIVE) {
927 if (obj == INTRANSITIVE) {
928 rspeak(NOTHING_LOCKED);
933 /* Lock, unlock object. Special stuff for opening clam/oyster
943 game.clock2 = PANICTIME;
947 state_change(GRATE, (verb == LOCK) ?
961 else if (!TOTING(TRIDENT))
962 rspeak(OYSTER_OPENER);
965 drop(OYSTER, game.loc);
966 drop(PEARL, LOC_CULDESAC);
974 rspeak(OYSTER_OPENER);
978 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
984 rspeak(CANNOT_UNLOCK);
987 speak(actions[verb].message);
993 static int pour(token_t verb, token_t obj)
994 /* Pour. If no object, or object is bottle, assume contents of bottle.
995 * special tests for pouring water or oil on plant or rusty door. */
1000 if (obj == NO_OBJECT)
1003 speak(actions[verb].message);
1007 if (obj != OIL && obj != WATER) {
1011 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1012 return fill(verb, URN);
1013 game.prop[BOTTLE] = EMPTY_BOTTLE;
1014 game.place[obj] = LOC_NOWHERE;
1022 /* cycle through the three plant states */
1023 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1024 game.prop[PLANT2] = game.prop[PLANT];
1027 rspeak(SHAKING_LEAVES);
1031 state_change(DOOR, (obj == OIL) ?
1038 static int quit(void)
1039 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1041 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1042 terminate(quitgame);
1046 static int read(struct command_t command)
1047 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1049 if (command.obj == INTRANSITIVE) {
1051 for (int i = 1; i <= NOBJECTS; i++) {
1052 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1053 command.obj = command.obj * NOBJECTS + i;
1055 if (command.obj > NOBJECTS ||
1061 if (DARK(game.loc)) {
1062 sspeak(NO_SEE, command.raw1);
1063 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1064 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1065 } else if (objects[command.obj].texts[0] == NULL ||
1066 game.prop[command.obj] < 0) {
1067 speak(actions[command.verb].message);
1069 pspeak(command.obj, study, game.prop[command.obj], true);
1073 static int reservoir(void)
1074 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1076 /* FIXME: Arithmetic on state numbers */
1077 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
1078 rspeak(NOTHING_HAPPENS);
1082 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1086 game.oldlc2 = game.loc;
1087 game.newloc = LOC_NOWHERE;
1089 return GO_TERMINATE;
1094 static int rub(token_t verb, token_t obj)
1095 /* Rub. Yields various snide remarks except for lit urn. */
1097 if (obj == URN && game.prop[URN] == URN_LIT) {
1099 drop(AMBER, game.loc);
1100 game.prop[AMBER] = AMBER_IN_ROCK;
1102 drop(CAVITY, game.loc);
1104 } else if (obj != LAMP) {
1105 rspeak(PECULIAR_NOTHING);
1107 speak(actions[verb].message);
1112 static int say(struct command_t *command)
1113 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1115 if (command->wd2 > 0) {
1116 command->wd1 = command->wd2;
1117 strcpy(command->raw1, command->raw2);
1119 char word1[TOKLEN + 1];
1120 packed_to_token(command->wd1, word1);
1121 int wd = (int) get_vocab_id(word1);
1122 if (wd == MOTION_WORD(XYZZY) ||
1123 wd == MOTION_WORD(PLUGH) ||
1124 wd == MOTION_WORD(PLOVER) ||
1125 wd == ACTION_WORD(FEE) ||
1126 wd == ACTION_WORD(FIE) ||
1127 wd == ACTION_WORD(FOE) ||
1128 wd == ACTION_WORD(FOO) ||
1129 wd == ACTION_WORD(FUM) ||
1130 wd == ACTION_WORD(PART)) {
1131 /* FIXME: scribbles on the interpreter's command block */
1132 wordclear(&command->wd2);
1135 sspeak(OKEY_DOKEY, command->raw1);
1139 static int throw_support(long spk)
1142 drop(AXE, game.loc);
1146 static int throw (struct command_t *command)
1147 /* Throw. Same as discard unless axe. Then same as attack except
1148 * ignore bird, and if dwarf is present then one might be killed.
1149 * (Only way to do so!) Axe also special for dragon, bear, and
1150 * troll. Treasures special for troll. */
1152 if (!TOTING(command->obj)) {
1153 speak(actions[command->verb].message);
1156 if (objects[command->obj].is_treasure && AT(TROLL)) {
1157 /* Snarf a treasure for the troll. */
1158 drop(command->obj, LOC_NOWHERE);
1159 move(TROLL, LOC_NOWHERE);
1160 move(TROLL + NOBJECTS, LOC_NOWHERE);
1161 drop(TROLL2, objects[TROLL].plac);
1162 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1164 rspeak(TROLL_SATISFIED);
1167 if (command->obj == FOOD && HERE(BEAR)) {
1168 /* But throwing food is another story. */
1169 command->obj = BEAR;
1170 return (feed(command->verb, command->obj));
1172 if (command->obj != AXE)
1173 return (discard(command->verb, command->obj, false));
1175 if (atdwrf(game.loc) <= 0) {
1176 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1177 return throw_support(DRAGON_SCALES);
1179 return throw_support(TROLL_RETURNS);
1181 return throw_support(OGRE_DODGE);
1182 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1183 /* This'll teach him to throw the axe at the bear! */
1184 drop(AXE, game.loc);
1185 game.fixed[AXE] = IS_FIXED;
1187 state_change(AXE, AXE_LOST);
1190 command->obj = NO_OBJECT;
1191 return (attack(command));
1194 if (randrange(NDWARVES + 1) < game.dflag) {
1195 return throw_support(DWARF_DODGES);
1197 long i = atdwrf(game.loc);
1198 game.dseen[i] = false;
1199 game.dloc[i] = LOC_NOWHERE;
1200 return throw_support((++game.dkill == 1) ?
1207 static int wake(token_t verb, token_t obj)
1208 /* Wake. Only use is to disturb the dwarves. */
1212 speak(actions[verb].message);
1216 return GO_DWARFWAKE;
1220 static int wave(token_t verb, token_t obj)
1221 /* Wave. No effect unless waving rod at fissure or at bird. */
1228 speak(((!TOTING(obj)) && (obj != ROD ||
1230 arbitrary_messages[ARENT_CARRYING] :
1231 actions[verb].message);
1235 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1236 drop(JADE, game.loc);
1237 game.prop[JADE] = STATE_FOUND;
1239 rspeak(NECKLACE_FLY);
1243 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1246 return GO_DWARFWAKE;
1250 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1256 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1260 state_change(FISSURE,
1261 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1266 int action(struct command_t *command)
1267 /* Analyse a verb. Remember what it was, go back for object if second word
1268 * unless verb is "say", which snarfs arbitrary second word.
1271 if (command->part == unknown) {
1272 /* Analyse an object word. See if the thing is here, whether
1273 * we've got a verb yet, and so on. Object must be here
1274 * unless verb is "find" or "invent(ory)" (and no new verb
1275 * yet to be analysed). Water and oil are also funny, since
1276 * they are never actually dropped at any location, but might
1277 * be here inside the bottle or urn or as a feature of the
1279 if (HERE(command->obj))
1281 else if (command->obj == GRATE) {
1282 if (game.loc == LOC_START ||
1283 game.loc == LOC_VALLEY ||
1284 game.loc == LOC_SLIT) {
1285 command->obj = DPRSSN;
1287 if (game.loc == LOC_COBBLE ||
1288 game.loc == LOC_DEBRIS ||
1289 game.loc == LOC_AWKWARD ||
1290 game.loc == LOC_BIRD ||
1291 game.loc == LOC_PITTOP) {
1292 command->obj = ENTRNC;
1294 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1296 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1297 command->obj == LIQLOC(game.loc))
1299 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1302 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1303 command->obj = PLANT2;
1305 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1307 rspeak(KNIVES_VANISH);
1309 } else if (command->obj == ROD && HERE(ROD2)) {
1310 command->obj = ROD2;
1312 } else if ((command->verb == FIND ||
1313 command->verb == INVENTORY) && command->wd2 <= 0)
1316 sspeak(NO_SEE, command->raw1);
1320 if (command->wd2 > 0)
1322 if (command->verb != 0)
1323 command->part = transitive;
1326 switch (command->part) {
1328 if (command->wd2 > 0 && command->verb != SAY)
1330 if (command->verb == SAY)
1331 command->obj = command->wd2;
1332 if (command->obj == NO_OBJECT ||
1333 command->obj == INTRANSITIVE) {
1334 /* Analyse an intransitive verb (ie, no object given yet). */
1335 switch (command->verb) {
1337 return vcarry(command->verb, INTRANSITIVE);
1343 return lock(command->verb, INTRANSITIVE);
1346 return (GO_CLEAROBJ);
1349 return lock(command->verb, INTRANSITIVE);
1351 return light(command->verb, INTRANSITIVE);
1353 return extinguish(command->verb, INTRANSITIVE);
1359 speak(actions[command->verb].message);
1363 return attack(command);
1365 return pour(command->verb, command->obj);
1367 return eat(command->verb, INTRANSITIVE);
1369 return drink(command->verb, command->obj);
1383 return fill(command->verb, command->obj);
1395 return bigwords(command->id1);
1399 command->obj = INTRANSITIVE;
1400 return read(*command);
1410 return fly(command->verb, INTRANSITIVE);
1416 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1421 /* Analyse a transitive verb. */
1422 switch (command->verb) {
1424 return vcarry(command->verb, command->obj);
1426 return discard(command->verb, command->obj, false);
1428 return say(command);
1430 return lock(command->verb, command->obj);
1433 return (GO_CLEAROBJ);
1436 return lock(command->verb, command->obj);
1438 return light(command->verb, command->obj);
1440 return extinguish(command->verb, command->obj);
1442 return wave(command->verb, command->obj);
1444 speak(actions[command->verb].message);
1448 speak(actions[command->verb].message);
1452 return attack(command);
1454 return pour(command->verb, command->obj);
1456 return eat(command->verb, command->obj);
1458 return drink(command->verb, command->obj);
1460 return rub(command->verb, command->obj);
1462 return throw (command);
1464 speak(actions[command->verb].message);
1468 return find(command->verb, command->obj);
1470 return find(command->verb, command->obj);
1472 return feed(command->verb, command->obj);
1474 return fill(command->verb, command->obj);
1479 speak(actions[command->verb].message);
1487 speak(actions[command->verb].message);
1491 speak(actions[command->verb].message);
1495 return read(*command);
1497 return vbreak(command->verb, command->obj);
1499 return wake(command->verb, command->obj);
1501 speak(actions[command->verb].message);
1505 speak(actions[command->verb].message);
1509 return fly(command->verb, command->obj);
1511 speak(actions[command->verb].message);
1517 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1520 /* Unknown verb, couldn't deduce object - might need hint */
1521 sspeak(WHAT_DO, command->raw1);
1522 return GO_CHECKHINT;
1524 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE