7 static int fill(verb_t, obj_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 verb_t verb = command->verb;
16 obj_t obj = command->obj;
18 if (obj == INTRANSITIVE) {
20 if (atdwrf(game.loc) > 0) {
28 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
40 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
44 /* check for low-priority targets */
45 if (obj == INTRANSITIVE) {
46 /* Can't attack bird or machine by throwing axe. */
47 if (HERE(BIRD) && verb != THROW) {
51 if (HERE(VEND) && verb != THROW) {
55 /* Clam and oyster both treated as clam for intransitive case;
57 if (HERE(CLAM) || HERE(OYSTER)) {
77 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
82 switch (game.prop[BEAR]) {
87 rspeak(BEAR_CONFUSED);
90 rspeak(BEAR_CONFUSED);
98 if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
99 /* Fun stuff for dragon. If he insists on attacking it, win!
100 * Set game.prop to dead, move dragon to central loc (still
101 * fixed), move rug there (not fixed), and move him there,
102 * too. Then do a null motion to get new description. */
103 rspeak(BARE_HANDS_QUERY);
105 // FIXME: setting wd1 is a workaround for broken logic
106 command->wd1 = token_to_packed("Y");
108 // FIXME: setting wd1 is a workaround for broken logic
109 command->wd1 = token_to_packed("N");
112 state_change(DRAGON, DRAGON_DEAD);
113 game.prop[RUG] = RUG_FLOOR;
114 /* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.
115 * The way it was computed before was worse; it depended on the
116 * two dragon locations being LOC_SECRET4 and LOC_SECRET6 and
117 * LOC_SECRET5 being right between them.
119 move(DRAGON + NOBJECTS, IS_FIXED);
120 move(RUG + NOBJECTS, IS_FREE);
121 move(DRAGON, LOC_SECRET5);
122 move(RUG, LOC_SECRET5);
123 drop(BLOOD, LOC_SECRET5);
124 for (obj_t i = 1; i <= NOBJECTS; i++) {
125 if (game.place[i] == objects[DRAGON].plac ||
126 game.place[i] == objects[DRAGON].fixd)
127 move(i, LOC_SECRET5);
129 game.loc = LOC_SECRET5;
135 if (atdwrf(game.loc) == 0)
138 rspeak(KNIFE_THROWN);
141 for (int i = 1; i < PIRATE; i++) {
142 if (game.dloc[i] == game.loc) {
144 game.dloc[i] = LOC_LONGWEST;
145 game.dseen[i] = false;
148 rspeak((dwarves > 1) ?
160 rspeak(SHELL_IMPERVIOUS);
163 rspeak(SNAKE_WARNING);
169 rspeak(BARE_HANDS_QUERY);
172 rspeak(ALREADY_DEAD);
178 speak(actions[verb].message);
183 static int bigwords(long id)
184 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
185 * Look up foo in special section of vocab to determine which word we've got.
186 * Last word zips the eggs back to the giant room (unless already there). */
188 if ((game.foobar == WORD_EMPTY && id == ACTION_WORD(FEE)) ||
189 (game.foobar == ACTION_WORD(FEE) && id == ACTION_WORD(FIE)) ||
190 (game.foobar == ACTION_WORD(FIE) && id == ACTION_WORD(FOE)) ||
191 (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FOO)) ||
192 (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FUM))) {
194 if ((id != ACTION_WORD(FOO)) && (id != ACTION_WORD(FUM))) {
198 game.foobar = WORD_EMPTY;
199 if (game.place[EGGS] == objects[EGGS].plac ||
200 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
201 rspeak(NOTHING_HAPPENS);
204 /* Bring back troll if we steal the eggs back from him before
206 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
207 game.prop[TROLL] = TROLL_PAIDONCE;
211 else if (game.loc == objects[EGGS].plac)
215 move(EGGS, objects[EGGS].plac);
216 pspeak(EGGS, look, k, true);
220 if (game.loc == LOC_GIANTROOM) {
223 /* This is new begavior in Open Adventure - sounds better when
224 * player isn't in the Giant Room. */
225 rspeak(WELL_POINTLESS);
227 game.foobar = WORD_EMPTY;
232 static void blast(void)
233 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
235 if (game.prop[ROD2] == STATE_NOTFOUND ||
237 rspeak(REQUIRES_DYNAMITE);
240 game.bonus = SPLATTER_MESSAGE;
241 else if (game.loc == LOC_NE)
242 game.bonus = DEFEAT_MESSAGE;
244 game.bonus = VICTORY_MESSAGE;
250 static int vbreak(verb_t verb, obj_t obj)
251 /* Break. Only works for mirror in repository and, of course, the vase. */
256 rspeak(BREAK_MIRROR);
263 if (game.prop[VASE] == VASE_WHOLE) {
265 drop(VASE, game.loc);
266 state_change(VASE, VASE_BROKEN);
267 game.fixed[VASE] = IS_FIXED;
271 speak(actions[verb].message);
273 return (GO_CLEAROBJ);
276 static int brief(void)
277 /* Brief. Intransitive only. Suppress long descriptions after first time. */
281 rspeak(BRIEF_CONFIRM);
285 static int vcarry(verb_t verb, obj_t obj)
286 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
287 * take one without the other). Liquids also special, since they depend on
288 * status of bottle. Also various side effects, etc. */
290 if (obj == INTRANSITIVE) {
291 /* Carry, no object given yet. OK if only one object present. */
292 if (game.atloc[game.loc] == NO_OBJECT ||
293 game.link[game.atloc[game.loc]] != 0 ||
294 atdwrf(game.loc) > 0)
296 obj = game.atloc[game.loc];
300 speak(actions[verb].message);
305 rspeak(REMOVE_MESSAGE);
310 if (game.fixed[obj] != IS_FREE) {
311 /* Next guard tests whether plant is tiny or stashed */
312 if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
316 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
317 rspeak(BEAR_CHAINED);
320 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
321 rspeak(STILL_LOCKED);
329 rspeak(DOUGHNUT_HOLES);
336 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
341 rspeak(HAND_PASSTHROUGH);
352 if (TOTING(BOTTLE)) {
353 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
354 return (fill(verb, BOTTLE));
355 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
359 rspeak(NO_CONTAINER);
365 if (game.holdng >= INVLIMIT) {
371 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
372 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
378 rspeak(CANNOT_CARRY);
385 game.prop[BIRD] = BIRD_CAGED;
389 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
390 /* expression maps BIRD to CAGE and CAGE to BIRD */
391 carry(BIRD + CAGE - obj, game.loc);
392 carry(obj, game.loc);
393 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
394 game.place[LIQUID()] = CARRIED;
395 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
396 game.prop[obj] = STATE_FOUND;
397 game.prop[CAVITY] = CAVITY_EMPTY;
403 static int chain(verb_t verb)
404 /* Do something to the bear's chain */
407 if (game.prop[BEAR] == UNTAMED_BEAR) {
411 if (game.prop[CHAIN] == CHAIN_HEAP) {
412 rspeak(ALREADY_UNLOCKED);
415 game.prop[CHAIN] = CHAIN_HEAP;
416 game.fixed[CHAIN] = IS_FREE;
417 if (game.prop[BEAR] != BEAR_DEAD)
418 game.prop[BEAR] = CONTENTED_BEAR;
420 switch (game.prop[BEAR]) {
422 /* Can't be reached as long as the only way for the bear to die
423 * is from a bridge collapse. Leave in in case this changes, but
424 * exclude from coverage testing. */
425 game.fixed[BEAR] = IS_FIXED; // LCOV_EXCL_LINE
428 game.fixed[BEAR] = IS_FREE;
430 rspeak(CHAIN_UNLOCKED);
434 if (game.prop[CHAIN] != CHAIN_HEAP) {
435 rspeak(ALREADY_LOCKED);
438 if (game.loc != objects[CHAIN].plac) {
443 game.prop[CHAIN] = CHAIN_FIXED;
446 drop(CHAIN, game.loc);
447 game.fixed[CHAIN] = IS_FIXED;
449 rspeak(CHAIN_LOCKED);
453 static int discard(verb_t verb, obj_t obj)
454 /* Discard object. "Throw" also comes here for most objects. Special cases for
455 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
456 * Drop coins at vending machine for extra batteries. */
458 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
461 speak(actions[verb].message);
464 if (obj == BIRD && HERE(SNAKE)) {
465 rspeak(BIRD_ATTACKS);
469 /* Set game.prop for use by travel options */
470 game.prop[SNAKE] = SNAKE_CHASED;
472 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
474 game.prop[obj] = STATE_IN_CAVITY;
475 game.prop[CAVITY] = CAVITY_FULL;
476 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
477 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
481 else if (TOTING(RUG))
486 if (spk != RUG_WIGGLES) {
487 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
490 k = objects[SAPPH].plac;
491 move(RUG + NOBJECTS, k);
494 } else if (obj == COINS && HERE(VEND)) {
496 drop(BATTERY, game.loc);
497 pspeak(BATTERY, look, FRESH_BATTERIES, true);
499 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
503 } else if (obj == BEAR && AT(TROLL)) {
504 state_change(TROLL, TROLL_GONE);
505 move(TROLL, LOC_NOWHERE);
506 move(TROLL + NOBJECTS, IS_FREE);
507 move(TROLL2, objects[TROLL].plac);
508 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
510 } else if (obj != VASE ||
511 game.loc == objects[PILLOW].plac) {
514 state_change(VASE, AT(PILLOW)
517 if (game.prop[VASE] != VASE_WHOLE)
518 game.fixed[VASE] = IS_FIXED;
523 if (obj == BOTTLE && k != NO_OBJECT)
524 game.place[k] = LOC_NOWHERE;
525 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
526 drop(BIRD, game.loc);
530 game.prop[BIRD] = BIRD_UNCAGED;
531 if (FOREST(game.loc))
532 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
536 static int drink(verb_t verb, obj_t obj)
537 /* Drink. If no object, assume water and look for it here. If water is in
538 * the bottle, drink that, else must be at a water loc, so drink stream. */
540 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
541 (LIQUID() != WATER || !HERE(BOTTLE))) {
547 state_change(DRAGON, DRAGON_BLOODLESS);
552 if (obj != INTRANSITIVE && obj != WATER) {
553 rspeak(RIDICULOUS_ATTEMPT);
556 if (LIQUID() == WATER && HERE(BOTTLE)) {
557 game.place[WATER] = LOC_NOWHERE;
558 state_change(BOTTLE, EMPTY_BOTTLE);
562 speak(actions[verb].message);
566 static int eat(verb_t verb, obj_t obj)
567 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
568 * ok, some things lose appetite, rest are ridiculous. */
576 rspeak(THANKS_DELICIOUS);
587 rspeak(LOST_APPETITE);
590 speak(actions[verb].message);
595 static int extinguish(verb_t verb, obj_t obj)
596 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
598 if (obj == INTRANSITIVE) {
599 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
601 if (HERE(URN) && game.prop[URN] == URN_LIT)
603 if (obj == INTRANSITIVE)
609 if (game.prop[URN] != URN_EMPTY) {
610 state_change(URN, URN_DARK);
612 pspeak(URN, change, URN_DARK, true);
616 state_change(LAMP, LAMP_DARK);
617 rspeak(DARK(game.loc) ?
623 rspeak(BEYOND_POWER);
626 speak(actions[verb].message);
631 static int feed(verb_t verb, obj_t obj)
632 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
633 * mad. Bear, special. */
640 if (game.prop[DRAGON] != DRAGON_BARS)
641 rspeak(RIDICULOUS_ATTEMPT);
643 rspeak(NOTHING_EDIBLE);
646 if (!game.closed && HERE(BIRD)) {
648 rspeak(BIRD_DEVOURED);
650 rspeak(NOTHING_EDIBLE);
660 speak(actions[verb].message);
663 if (game.prop[BEAR] == BEAR_DEAD) {
664 rspeak(RIDICULOUS_ATTEMPT);
667 if (game.prop[BEAR] == UNTAMED_BEAR) {
670 game.fixed[AXE] = IS_FREE;
671 game.prop[AXE] = AXE_HERE;
672 state_change(BEAR, SITTING_BEAR);
674 rspeak(NOTHING_EDIBLE);
677 speak(actions[verb].message);
683 speak(actions[verb].message);
691 int fill(verb_t verb, obj_t obj)
692 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
696 if (LIQLOC(game.loc) == NO_OBJECT) {
697 rspeak(FILL_INVALID);
701 rspeak(ARENT_CARRYING);
704 rspeak(SHATTER_VASE);
705 game.prop[VASE] = VASE_BROKEN;
706 game.fixed[VASE] = IS_FIXED;
707 drop(VASE, game.loc);
712 if (game.prop[URN] != URN_EMPTY) {
717 rspeak(FILL_INVALID);
723 game.prop[BOTTLE] = EMPTY_BOTTLE;
727 game.prop[URN] = URN_DARK;
728 game.prop[BOTTLE] = EMPTY_BOTTLE;
733 rspeak(FILL_INVALID);
736 game.place[k] = LOC_NOWHERE;
739 if (obj != INTRANSITIVE && obj != BOTTLE) {
740 speak(actions[verb].message);
743 if (obj == INTRANSITIVE && !HERE(BOTTLE))
746 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
750 if (LIQUID() != NO_OBJECT) {
754 if (LIQLOC(game.loc) == NO_OBJECT) {
759 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
763 game.place[LIQUID()] = CARRIED;
767 static int find(verb_t verb, obj_t obj)
768 /* Find. Might be carrying it, or it might be here. Else give caveat. */
771 rspeak(ALREADY_CARRYING);
776 rspeak(NEEDED_NEARBY);
781 (LIQUID() == obj && AT(BOTTLE)) ||
782 obj == LIQLOC(game.loc) ||
783 (obj == DWARF && atdwrf(game.loc) > 0)) {
789 speak(actions[verb].message);
793 static int fly(verb_t verb, obj_t obj)
794 /* Fly. Snide remarks unless hovering rug is here. */
796 if (obj == INTRANSITIVE) {
801 if (game.prop[RUG] != RUG_HOVER) {
802 rspeak(RUG_NOTHING2);
809 speak(actions[verb].message);
812 if (game.prop[RUG] != RUG_HOVER) {
813 rspeak(RUG_NOTHING1);
816 game.oldlc2 = game.oldloc;
817 game.oldloc = game.loc;
819 if (game.prop[SAPPH] == STATE_NOTFOUND) {
820 game.newloc = game.place[SAPPH];
823 game.newloc = LOC_CLIFF;
829 static int inven(void)
830 /* Inventory. If object, treat same as find. Else report on current burden. */
833 for (obj_t i = 1; i <= NOBJECTS; i++) {
841 pspeak(i, touch, -1, false);
850 static int light(verb_t verb, obj_t obj)
851 /* Light. Applicable only to lamp and urn. */
853 if (obj == INTRANSITIVE) {
855 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
859 if (HERE(URN) && game.prop[URN] == URN_DARK) {
869 state_change(URN, game.prop[URN] == URN_EMPTY ?
874 if (game.limit < 0) {
878 state_change(LAMP, LAMP_BRIGHT);
883 speak(actions[verb].message);
888 static int listen(void)
889 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
891 long sound = locations[game.loc].sound;
892 if (sound != SILENT) {
894 if (!locations[game.loc].loud)
898 for (obj_t i = 1; i <= NOBJECTS; i++) {
900 objects[i].sounds[0] == NULL ||
903 int mi = game.prop[i];
904 /* FIXME: Weird magic on object states */
906 mi += 3 * game.blooded;
907 long packed_zzword = token_to_packed(game.zzword);
908 pspeak(i, hear, mi, true, packed_zzword);
910 if (i == BIRD && mi == BIRD_ENDSTATE)
918 static int lock(verb_t verb, obj_t obj)
919 /* Lock, unlock, no object given. Assume various things if present. */
921 if (obj == INTRANSITIVE) {
932 if (obj == INTRANSITIVE) {
933 rspeak(NOTHING_LOCKED);
938 /* Lock, unlock object. Special stuff for opening clam/oyster
953 game.clock2 = PANICTIME;
956 state_change(GRATE, (verb == LOCK) ?
966 else if (!TOTING(TRIDENT))
967 rspeak(OYSTER_OPENER);
970 drop(OYSTER, game.loc);
971 drop(PEARL, LOC_CULDESAC);
979 rspeak(OYSTER_OPENER);
982 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
988 rspeak(CANNOT_UNLOCK);
991 speak(actions[verb].message);
997 static int pour(verb_t verb, obj_t obj)
998 /* Pour. If no object, or object is bottle, assume contents of bottle.
999 * special tests for pouring water or oil on plant or rusty door. */
1001 if (obj == BOTTLE ||
1002 obj == INTRANSITIVE)
1004 if (obj == NO_OBJECT)
1007 speak(actions[verb].message);
1011 if (obj != OIL && obj != WATER) {
1015 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1016 return fill(verb, URN);
1017 game.prop[BOTTLE] = EMPTY_BOTTLE;
1018 game.place[obj] = LOC_NOWHERE;
1026 /* cycle through the three plant states */
1027 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1028 game.prop[PLANT2] = game.prop[PLANT];
1031 rspeak(SHAKING_LEAVES);
1035 state_change(DOOR, (obj == OIL) ?
1042 static int quit(void)
1043 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1045 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1046 terminate(quitgame);
1050 static int read(struct command_t command)
1051 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1053 if (command.obj == INTRANSITIVE) {
1054 command.obj = NO_OBJECT;
1055 for (int i = 1; i <= NOBJECTS; i++) {
1056 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1057 command.obj = command.obj * NOBJECTS + i;
1059 if (command.obj > NOBJECTS ||
1060 command.obj == NO_OBJECT ||
1065 if (DARK(game.loc)) {
1066 sspeak(NO_SEE, command.raw1);
1067 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1068 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1069 } else if (objects[command.obj].texts[0] == NULL ||
1070 game.prop[command.obj] == STATE_NOTFOUND) {
1071 speak(actions[command.verb].message);
1073 pspeak(command.obj, study, game.prop[command.obj], true);
1077 static int reservoir(void)
1078 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1080 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1081 rspeak(NOTHING_HAPPENS);
1085 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1089 game.oldlc2 = game.loc;
1090 game.newloc = LOC_NOWHERE;
1092 return GO_TERMINATE;
1097 static int rub(verb_t verb, obj_t obj)
1098 /* Rub. Yields various snide remarks except for lit urn. */
1100 if (obj == URN && game.prop[URN] == URN_LIT) {
1102 drop(AMBER, game.loc);
1103 game.prop[AMBER] = AMBER_IN_ROCK;
1105 drop(CAVITY, game.loc);
1107 } else if (obj != LAMP) {
1108 rspeak(PECULIAR_NOTHING);
1110 speak(actions[verb].message);
1115 static int say(struct command_t *command)
1116 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1118 if (command->wd2 > 0) {
1119 command->wd1 = command->wd2;
1120 strncpy(command->raw1, command->raw2, LINESIZE - 1);
1122 char word1[TOKLEN + 1];
1123 packed_to_token(command->wd1, word1);
1124 int wd = (int) get_vocab_id(word1);
1125 if (wd == MOTION_WORD(XYZZY) ||
1126 wd == MOTION_WORD(PLUGH) ||
1127 wd == MOTION_WORD(PLOVER) ||
1128 wd == ACTION_WORD(FEE) ||
1129 wd == ACTION_WORD(FIE) ||
1130 wd == ACTION_WORD(FOE) ||
1131 wd == ACTION_WORD(FOO) ||
1132 wd == ACTION_WORD(FUM) ||
1133 wd == ACTION_WORD(PART)) {
1134 /* FIXME: scribbles on the interpreter's command block */
1135 wordclear(&command->wd2);
1138 sspeak(OKEY_DOKEY, command->raw1);
1142 static int throw_support(long spk)
1145 drop(AXE, game.loc);
1149 static int throw (struct command_t *command)
1150 /* Throw. Same as discard unless axe. Then same as attack except
1151 * ignore bird, and if dwarf is present then one might be killed.
1152 * (Only way to do so!) Axe also special for dragon, bear, and
1153 * troll. Treasures special for troll. */
1155 if (!TOTING(command->obj)) {
1156 speak(actions[command->verb].message);
1159 if (objects[command->obj].is_treasure && AT(TROLL)) {
1160 /* Snarf a treasure for the troll. */
1161 drop(command->obj, LOC_NOWHERE);
1162 move(TROLL, LOC_NOWHERE);
1163 move(TROLL + NOBJECTS, IS_FREE);
1164 drop(TROLL2, objects[TROLL].plac);
1165 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1167 rspeak(TROLL_SATISFIED);
1170 if (command->obj == FOOD && HERE(BEAR)) {
1171 /* But throwing food is another story. */
1172 command->obj = BEAR;
1173 return (feed(command->verb, command->obj));
1175 if (command->obj != AXE)
1176 return (discard(command->verb, command->obj));
1178 if (atdwrf(game.loc) <= 0) {
1179 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1180 return throw_support(DRAGON_SCALES);
1182 return throw_support(TROLL_RETURNS);
1184 return throw_support(OGRE_DODGE);
1185 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1186 /* This'll teach him to throw the axe at the bear! */
1187 drop(AXE, game.loc);
1188 game.fixed[AXE] = IS_FIXED;
1190 state_change(AXE, AXE_LOST);
1193 command->obj = INTRANSITIVE;
1194 return (attack(command));
1197 if (randrange(NDWARVES + 1) < game.dflag) {
1198 return throw_support(DWARF_DODGES);
1200 long i = atdwrf(game.loc);
1201 game.dseen[i] = false;
1202 game.dloc[i] = LOC_NOWHERE;
1203 return throw_support((++game.dkill == 1) ?
1210 static int wake(verb_t verb, obj_t obj)
1211 /* Wake. Only use is to disturb the dwarves. */
1215 speak(actions[verb].message);
1219 return GO_DWARFWAKE;
1223 static int wave(verb_t verb, obj_t obj)
1224 /* Wave. No effect unless waving rod at fissure or at bird. */
1231 speak(((!TOTING(obj)) && (obj != ROD ||
1233 arbitrary_messages[ARENT_CARRYING] :
1234 actions[verb].message);
1238 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1239 drop(JADE, game.loc);
1240 game.prop[JADE] = STATE_FOUND;
1242 rspeak(NECKLACE_FLY);
1246 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1249 return GO_DWARFWAKE;
1253 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1259 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1263 state_change(FISSURE,
1264 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1269 int action(struct command_t *command)
1270 /* Analyse a verb. Remember what it was, go back for object if second word
1271 * unless verb is "say", which snarfs arbitrary second word.
1274 if (command->part == unknown) {
1275 /* Analyse an object word. See if the thing is here, whether
1276 * we've got a verb yet, and so on. Object must be here
1277 * unless verb is "find" or "invent(ory)" (and no new verb
1278 * yet to be analysed). Water and oil are also funny, since
1279 * they are never actually dropped at any location, but might
1280 * be here inside the bottle or urn or as a feature of the
1282 if (HERE(command->obj))
1284 else if (command->obj == GRATE) {
1285 if (game.loc == LOC_START ||
1286 game.loc == LOC_VALLEY ||
1287 game.loc == LOC_SLIT) {
1288 command->obj = DPRSSN;
1290 if (game.loc == LOC_COBBLE ||
1291 game.loc == LOC_DEBRIS ||
1292 game.loc == LOC_AWKWARD ||
1293 game.loc == LOC_BIRD ||
1294 game.loc == LOC_PITTOP) {
1295 command->obj = ENTRNC;
1297 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1299 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1300 command->obj == LIQLOC(game.loc))
1302 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1305 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1306 command->obj = PLANT2;
1308 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1310 rspeak(KNIVES_VANISH);
1312 } else if (command->obj == ROD && HERE(ROD2)) {
1313 command->obj = ROD2;
1315 } else if ((command->verb == FIND ||
1316 command->verb == INVENTORY) && command->wd2 <= 0)
1319 sspeak(NO_SEE, command->raw1);
1323 if (command->wd2 > 0)
1325 if (command->verb != 0)
1326 command->part = transitive;
1329 switch (command->part) {
1331 if (command->wd2 > 0 && command->verb != SAY)
1333 if (command->verb == SAY)
1334 command->obj = command->wd2;
1335 if (command->obj == NO_OBJECT ||
1336 command->obj == INTRANSITIVE) {
1337 /* Analyse an intransitive verb (ie, no object given yet). */
1338 switch (command->verb) {
1340 return vcarry(command->verb, INTRANSITIVE);
1346 return lock(command->verb, INTRANSITIVE);
1349 return (GO_CLEAROBJ);
1352 return lock(command->verb, INTRANSITIVE);
1354 return light(command->verb, INTRANSITIVE);
1356 return extinguish(command->verb, INTRANSITIVE);
1362 speak(actions[command->verb].message);
1366 command->obj = INTRANSITIVE;
1367 return attack(command);
1369 return pour(command->verb, INTRANSITIVE);
1371 return eat(command->verb, INTRANSITIVE);
1373 return drink(command->verb, INTRANSITIVE);
1387 return fill(command->verb, INTRANSITIVE);
1399 return bigwords(command->id1);
1403 command->obj = INTRANSITIVE;
1404 return read(*command);
1414 return fly(command->verb, INTRANSITIVE);
1420 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1425 /* Analyse a transitive verb. */
1426 switch (command->verb) {
1428 return vcarry(command->verb, command->obj);
1430 return discard(command->verb, command->obj);
1432 return say(command);
1434 return lock(command->verb, command->obj);
1437 return (GO_CLEAROBJ);
1440 return lock(command->verb, command->obj);
1442 return light(command->verb, command->obj);
1444 return extinguish(command->verb, command->obj);
1446 return wave(command->verb, command->obj);
1448 speak(actions[command->verb].message);
1452 speak(actions[command->verb].message);
1456 return attack(command);
1458 return pour(command->verb, command->obj);
1460 return eat(command->verb, command->obj);
1462 return drink(command->verb, command->obj);
1464 return rub(command->verb, command->obj);
1466 return throw (command);
1468 speak(actions[command->verb].message);
1472 return find(command->verb, command->obj);
1474 return find(command->verb, command->obj);
1476 return feed(command->verb, command->obj);
1478 return fill(command->verb, command->obj);
1483 speak(actions[command->verb].message);
1491 speak(actions[command->verb].message);
1495 speak(actions[command->verb].message);
1499 return read(*command);
1501 return vbreak(command->verb, command->obj);
1503 return wake(command->verb, command->obj);
1505 speak(actions[command->verb].message);
1509 speak(actions[command->verb].message);
1513 return fly(command->verb, command->obj);
1515 speak(actions[command->verb].message);
1521 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1524 /* Unknown verb, couldn't deduce object - might need hint */
1525 sspeak(WHAT_DO, command->raw1);
1526 return GO_CHECKHINT;
1528 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE