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 obj_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 /* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.
116 * The way it was computed before was wirse; it depended on the
117 * two dragon locations being LOC_SECRET4 and LOC_SECRET6 and
118 * LOC_SECRET5 being right between them.
120 move(DRAGON + NOBJECTS, -1);
121 move(RUG + NOBJECTS, LOC_NOWHERE);
122 move(DRAGON, LOC_SECRET5);
123 move(RUG, LOC_SECRET5);
124 drop(BLOOD, LOC_SECRET5);
125 for (obj = 1; obj <= NOBJECTS; obj++) {
126 if (game.place[obj] == objects[DRAGON].plac ||
127 game.place[obj] == objects[DRAGON].fixd)
128 move(obj, LOC_SECRET5);
130 game.loc = LOC_SECRET5;
136 if (atdwrf(game.loc) == 0)
139 rspeak(KNIFE_THROWN);
142 for (int i = 1; i < PIRATE; i++) {
143 if (game.dloc[i] == game.loc) {
145 game.dloc[i] = LOC_LONGWEST;
146 game.dseen[i] = false;
149 rspeak((dwarves > 1) ?
161 rspeak(SHELL_IMPERVIOUS);
164 rspeak(SNAKE_WARNING);
170 rspeak(BARE_HANDS_QUERY);
173 rspeak(ALREADY_DEAD);
179 speak(actions[verb].message);
184 static int bigwords(long id)
185 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
186 * Look up foo in special section of vocab to determine which word we've got.
187 * Last word zips the eggs back to the giant room (unless already there). */
189 if ((game.foobar == WORD_EMPTY && id == ACTION_WORD(FEE)) ||
190 (game.foobar == ACTION_WORD(FEE) && id == ACTION_WORD(FIE)) ||
191 (game.foobar == ACTION_WORD(FIE) && id == ACTION_WORD(FOE)) ||
192 (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FOO)) ||
193 (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FUM))) {
195 if ((id != ACTION_WORD(FOO)) && (id != ACTION_WORD(FUM))) {
199 game.foobar = WORD_EMPTY;
200 if (game.place[EGGS] == objects[EGGS].plac ||
201 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
202 rspeak(NOTHING_HAPPENS);
205 /* Bring back troll if we steal the eggs back from him before
207 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
208 game.prop[TROLL] = TROLL_PAIDONCE;
212 if (game.loc == objects[EGGS].plac)
214 move(EGGS, objects[EGGS].plac);
215 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(vocab_t verb, obj_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, obj_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, obj_t obj)
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 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
453 speak(actions[verb].message);
456 if (obj == BIRD && HERE(SNAKE)) {
457 rspeak(BIRD_ATTACKS);
461 /* Set game.prop for use by travel options */
462 game.prop[SNAKE] = SNAKE_CHASED;
464 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
466 game.prop[obj] = STATE_IN_CAVITY;
467 game.prop[CAVITY] = CAVITY_FULL;
468 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
469 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
476 if (spk != RUG_WIGGLES) {
477 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
480 k = objects[SAPPH].plac;
481 move(RUG + NOBJECTS, k);
484 } else if (obj == COINS && HERE(VEND)) {
486 drop(BATTERY, game.loc);
487 pspeak(BATTERY, look, FRESH_BATTERIES, true);
489 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
493 } else if (obj == BEAR && AT(TROLL)) {
494 state_change(TROLL, TROLL_GONE);
495 move(TROLL, LOC_NOWHERE);
496 move(TROLL + NOBJECTS, LOC_NOWHERE);
497 move(TROLL2, objects[TROLL].plac);
498 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
500 } else if (obj != VASE ||
501 game.loc == objects[PILLOW].plac) {
504 state_change(VASE, AT(PILLOW)
507 if (game.prop[VASE] != VASE_WHOLE)
508 game.fixed[VASE] = IS_FIXED;
513 if (obj == BOTTLE && k != NO_OBJECT)
514 game.place[k] = LOC_NOWHERE;
515 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
516 drop(BIRD, game.loc);
520 game.prop[BIRD] = BIRD_UNCAGED;
521 if (FOREST(game.loc))
522 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
526 static int drink(token_t verb, obj_t obj)
527 /* Drink. If no object, assume water and look for it here. If water is in
528 * the bottle, drink that, else must be at a water loc, so drink stream. */
530 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
531 (LIQUID() != WATER || !HERE(BOTTLE))) {
537 state_change(DRAGON, DRAGON_BLOODLESS);
542 if (obj != NO_OBJECT && obj != WATER) {
543 rspeak(RIDICULOUS_ATTEMPT);
546 if (LIQUID() == WATER && HERE(BOTTLE)) {
547 game.place[WATER] = LOC_NOWHERE;
548 state_change(BOTTLE, EMPTY_BOTTLE);
552 speak(actions[verb].message);
556 static int eat(token_t verb, obj_t obj)
557 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
558 * ok, some things lose appetite, rest are ridiculous. */
566 rspeak(THANKS_DELICIOUS);
577 rspeak(LOST_APPETITE);
580 speak(actions[verb].message);
585 static int extinguish(token_t verb, obj_t obj)
586 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
588 if (obj == INTRANSITIVE) {
589 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
591 if (HERE(URN) && game.prop[URN] == URN_LIT)
593 if (obj == INTRANSITIVE)
598 if (game.prop[URN] != URN_EMPTY) {
599 state_change(URN, URN_DARK);
601 pspeak(URN, change, URN_DARK, true);
607 state_change(LAMP, LAMP_DARK);
608 rspeak(DARK(game.loc) ?
616 rspeak(BEYOND_POWER);
620 speak(actions[verb].message);
624 static int feed(token_t verb, obj_t obj)
625 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
626 * mad. Bear, special. */
633 if (game.prop[DRAGON] != DRAGON_BARS)
634 rspeak(RIDICULOUS_ATTEMPT);
636 rspeak(NOTHING_EDIBLE);
639 if (!game.closed && HERE(BIRD)) {
641 rspeak(BIRD_DEVOURED);
643 rspeak(NOTHING_EDIBLE);
653 speak(actions[verb].message);
656 if (game.prop[BEAR] == BEAR_DEAD) {
657 rspeak(RIDICULOUS_ATTEMPT);
660 if (game.prop[BEAR] == UNTAMED_BEAR) {
663 game.fixed[AXE] = IS_FREE;
664 game.prop[AXE] = AXE_HERE;
665 state_change(BEAR, SITTING_BEAR);
667 rspeak(NOTHING_EDIBLE);
670 speak(actions[verb].message);
676 speak(actions[verb].message);
684 int fill(token_t verb, obj_t obj)
685 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
689 if (LIQLOC(game.loc) == NO_OBJECT) {
690 rspeak(FILL_INVALID);
694 rspeak(ARENT_CARRYING);
697 rspeak(SHATTER_VASE);
698 game.prop[VASE] = VASE_BROKEN;
699 game.fixed[VASE] = IS_FIXED;
700 drop(VASE, game.loc);
705 if (game.prop[URN] != URN_EMPTY) {
710 rspeak(FILL_INVALID);
716 game.prop[BOTTLE] = EMPTY_BOTTLE;
720 game.prop[URN] = URN_DARK;
721 game.prop[BOTTLE] = EMPTY_BOTTLE;
726 rspeak(FILL_INVALID);
729 game.place[k] = LOC_NOWHERE;
732 if (obj != NO_OBJECT && obj != BOTTLE) {
733 speak(actions[verb].message);
736 if (obj == NO_OBJECT && !HERE(BOTTLE))
739 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
743 if (LIQUID() != NO_OBJECT) {
747 if (LIQLOC(game.loc) == NO_OBJECT) {
752 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
756 game.place[LIQUID()] = CARRIED;
760 static int find(token_t verb, obj_t obj)
761 /* Find. Might be carrying it, or it might be here. Else give caveat. */
764 rspeak(ALREADY_CARRYING);
769 rspeak(NEEDED_NEARBY);
774 (LIQUID() == obj && AT(BOTTLE)) ||
775 obj == LIQLOC(game.loc) ||
776 (obj == DWARF && atdwrf(game.loc) > 0)) {
782 speak(actions[verb].message);
786 static int fly(token_t verb, obj_t obj)
787 /* Fly. Snide remarks unless hovering rug is here. */
789 if (obj == INTRANSITIVE) {
794 if (game.prop[RUG] != RUG_HOVER) {
795 rspeak(RUG_NOTHING2);
802 speak(actions[verb].message);
805 if (game.prop[RUG] != RUG_HOVER) {
806 rspeak(RUG_NOTHING1);
809 game.oldlc2 = game.oldloc;
810 game.oldloc = game.loc;
812 if (game.prop[SAPPH] == STATE_NOTFOUND) {
813 game.newloc = game.place[SAPPH];
816 game.newloc = LOC_CLIFF;
822 static int inven(void)
823 /* Inventory. If object, treat same as find. Else report on current burden. */
826 for (obj_t i = 1; i <= NOBJECTS; i++) {
834 pspeak(i, touch, -1, false);
843 static int light(token_t verb, obj_t obj)
844 /* Light. Applicable only to lamp and urn. */
846 if (obj == INTRANSITIVE) {
847 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
849 if (HERE(URN) && game.prop[URN] == URN_DARK)
851 if (obj == INTRANSITIVE ||
852 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
853 HERE(URN) && game.prop[URN] == URN_DARK))
858 state_change(URN, game.prop[URN] == URN_EMPTY ?
864 speak(actions[verb].message);
867 if (game.limit < 0) {
871 state_change(LAMP, LAMP_BRIGHT);
879 static int listen(void)
880 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
882 long sound = locations[game.loc].sound;
883 if (sound != SILENT) {
885 if (!locations[game.loc].loud)
889 for (obj_t i = 1; i <= NOBJECTS; i++) {
891 objects[i].sounds[0] == NULL ||
894 int mi = game.prop[i];
895 /* FIXME: Weird magic on object states */
897 mi += 3 * game.blooded;
898 long packed_zzword = token_to_packed(game.zzword);
899 pspeak(i, hear, mi, true, packed_zzword);
901 if (i == BIRD && mi == BIRD_ENDSTATE)
909 static int lock(token_t verb, obj_t obj)
910 /* Lock, unlock, no object given. Assume various things if present. */
912 if (obj == INTRANSITIVE) {
923 if (obj == INTRANSITIVE) {
924 rspeak(NOTHING_LOCKED);
929 /* Lock, unlock object. Special stuff for opening clam/oyster
944 game.clock2 = PANICTIME;
947 state_change(GRATE, (verb == LOCK) ?
957 else if (!TOTING(TRIDENT))
958 rspeak(OYSTER_OPENER);
961 drop(OYSTER, game.loc);
962 drop(PEARL, LOC_CULDESAC);
970 rspeak(OYSTER_OPENER);
973 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
979 rspeak(CANNOT_UNLOCK);
982 speak(actions[verb].message);
988 static int pour(token_t verb, obj_t obj)
989 /* Pour. If no object, or object is bottle, assume contents of bottle.
990 * special tests for pouring water or oil on plant or rusty door. */
995 if (obj == NO_OBJECT)
998 speak(actions[verb].message);
1002 if (obj != OIL && obj != WATER) {
1006 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1007 return fill(verb, URN);
1008 game.prop[BOTTLE] = EMPTY_BOTTLE;
1009 game.place[obj] = LOC_NOWHERE;
1017 /* cycle through the three plant states */
1018 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1019 game.prop[PLANT2] = game.prop[PLANT];
1022 rspeak(SHAKING_LEAVES);
1026 state_change(DOOR, (obj == OIL) ?
1033 static int quit(void)
1034 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1036 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1037 terminate(quitgame);
1041 static int read(struct command_t command)
1042 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1044 if (command.obj == INTRANSITIVE) {
1045 command.obj = NO_OBJECT;
1046 for (int i = 1; i <= NOBJECTS; i++) {
1047 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1048 command.obj = command.obj * NOBJECTS + i;
1050 if (command.obj > NOBJECTS ||
1051 command.obj == NO_OBJECT ||
1056 if (DARK(game.loc)) {
1057 sspeak(NO_SEE, command.raw1);
1058 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1059 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1060 } else if (objects[command.obj].texts[0] == NULL ||
1061 game.prop[command.obj] == STATE_NOTFOUND) {
1062 speak(actions[command.verb].message);
1064 pspeak(command.obj, study, game.prop[command.obj], true);
1068 static int reservoir(void)
1069 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1071 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1072 rspeak(NOTHING_HAPPENS);
1076 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1080 game.oldlc2 = game.loc;
1081 game.newloc = LOC_NOWHERE;
1083 return GO_TERMINATE;
1088 static int rub(token_t verb, obj_t obj)
1089 /* Rub. Yields various snide remarks except for lit urn. */
1091 if (obj == URN && game.prop[URN] == URN_LIT) {
1093 drop(AMBER, game.loc);
1094 game.prop[AMBER] = AMBER_IN_ROCK;
1096 drop(CAVITY, game.loc);
1098 } else if (obj != LAMP) {
1099 rspeak(PECULIAR_NOTHING);
1101 speak(actions[verb].message);
1106 static int say(struct command_t *command)
1107 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1109 if (command->wd2 > 0) {
1110 command->wd1 = command->wd2;
1111 strcpy(command->raw1, command->raw2);
1113 char word1[TOKLEN + 1];
1114 packed_to_token(command->wd1, word1);
1115 int wd = (int) get_vocab_id(word1);
1116 if (wd == MOTION_WORD(XYZZY) ||
1117 wd == MOTION_WORD(PLUGH) ||
1118 wd == MOTION_WORD(PLOVER) ||
1119 wd == ACTION_WORD(FEE) ||
1120 wd == ACTION_WORD(FIE) ||
1121 wd == ACTION_WORD(FOE) ||
1122 wd == ACTION_WORD(FOO) ||
1123 wd == ACTION_WORD(FUM) ||
1124 wd == ACTION_WORD(PART)) {
1125 /* FIXME: scribbles on the interpreter's command block */
1126 wordclear(&command->wd2);
1129 sspeak(OKEY_DOKEY, command->raw1);
1133 static int throw_support(long spk)
1136 drop(AXE, game.loc);
1140 static int throw (struct command_t *command)
1141 /* Throw. Same as discard unless axe. Then same as attack except
1142 * ignore bird, and if dwarf is present then one might be killed.
1143 * (Only way to do so!) Axe also special for dragon, bear, and
1144 * troll. Treasures special for troll. */
1146 if (!TOTING(command->obj)) {
1147 speak(actions[command->verb].message);
1150 if (objects[command->obj].is_treasure && AT(TROLL)) {
1151 /* Snarf a treasure for the troll. */
1152 drop(command->obj, LOC_NOWHERE);
1153 move(TROLL, LOC_NOWHERE);
1154 move(TROLL + NOBJECTS, LOC_NOWHERE);
1155 drop(TROLL2, objects[TROLL].plac);
1156 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1158 rspeak(TROLL_SATISFIED);
1161 if (command->obj == FOOD && HERE(BEAR)) {
1162 /* But throwing food is another story. */
1163 command->obj = BEAR;
1164 return (feed(command->verb, command->obj));
1166 if (command->obj != AXE)
1167 return (discard(command->verb, command->obj));
1169 if (atdwrf(game.loc) <= 0) {
1170 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1171 return throw_support(DRAGON_SCALES);
1173 return throw_support(TROLL_RETURNS);
1175 return throw_support(OGRE_DODGE);
1176 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1177 /* This'll teach him to throw the axe at the bear! */
1178 drop(AXE, game.loc);
1179 game.fixed[AXE] = IS_FIXED;
1181 state_change(AXE, AXE_LOST);
1184 command->obj = NO_OBJECT;
1185 return (attack(command));
1188 if (randrange(NDWARVES + 1) < game.dflag) {
1189 return throw_support(DWARF_DODGES);
1191 long i = atdwrf(game.loc);
1192 game.dseen[i] = false;
1193 game.dloc[i] = LOC_NOWHERE;
1194 return throw_support((++game.dkill == 1) ?
1201 static int wake(token_t verb, obj_t obj)
1202 /* Wake. Only use is to disturb the dwarves. */
1206 speak(actions[verb].message);
1210 return GO_DWARFWAKE;
1214 static int wave(token_t verb, obj_t obj)
1215 /* Wave. No effect unless waving rod at fissure or at bird. */
1222 speak(((!TOTING(obj)) && (obj != ROD ||
1224 arbitrary_messages[ARENT_CARRYING] :
1225 actions[verb].message);
1229 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1230 drop(JADE, game.loc);
1231 game.prop[JADE] = STATE_FOUND;
1233 rspeak(NECKLACE_FLY);
1237 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1240 return GO_DWARFWAKE;
1244 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1250 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1254 state_change(FISSURE,
1255 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1260 int action(struct command_t *command)
1261 /* Analyse a verb. Remember what it was, go back for object if second word
1262 * unless verb is "say", which snarfs arbitrary second word.
1265 if (command->part == unknown) {
1266 /* Analyse an object word. See if the thing is here, whether
1267 * we've got a verb yet, and so on. Object must be here
1268 * unless verb is "find" or "invent(ory)" (and no new verb
1269 * yet to be analysed). Water and oil are also funny, since
1270 * they are never actually dropped at any location, but might
1271 * be here inside the bottle or urn or as a feature of the
1273 if (HERE(command->obj))
1275 else if (command->obj == GRATE) {
1276 if (game.loc == LOC_START ||
1277 game.loc == LOC_VALLEY ||
1278 game.loc == LOC_SLIT) {
1279 command->obj = DPRSSN;
1281 if (game.loc == LOC_COBBLE ||
1282 game.loc == LOC_DEBRIS ||
1283 game.loc == LOC_AWKWARD ||
1284 game.loc == LOC_BIRD ||
1285 game.loc == LOC_PITTOP) {
1286 command->obj = ENTRNC;
1288 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1290 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1291 command->obj == LIQLOC(game.loc))
1293 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1296 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1297 command->obj = PLANT2;
1299 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1301 rspeak(KNIVES_VANISH);
1303 } else if (command->obj == ROD && HERE(ROD2)) {
1304 command->obj = ROD2;
1306 } else if ((command->verb == FIND ||
1307 command->verb == INVENTORY) && command->wd2 <= 0)
1310 sspeak(NO_SEE, command->raw1);
1314 if (command->wd2 > 0)
1316 if (command->verb != 0)
1317 command->part = transitive;
1320 switch (command->part) {
1322 if (command->wd2 > 0 && command->verb != SAY)
1324 if (command->verb == SAY)
1325 command->obj = command->wd2;
1326 if (command->obj == NO_OBJECT ||
1327 command->obj == INTRANSITIVE) {
1328 /* Analyse an intransitive verb (ie, no object given yet). */
1329 switch (command->verb) {
1331 return vcarry(command->verb, INTRANSITIVE);
1337 return lock(command->verb, INTRANSITIVE);
1340 return (GO_CLEAROBJ);
1343 return lock(command->verb, INTRANSITIVE);
1345 return light(command->verb, INTRANSITIVE);
1347 return extinguish(command->verb, INTRANSITIVE);
1353 speak(actions[command->verb].message);
1357 return attack(command);
1359 return pour(command->verb, command->obj);
1361 return eat(command->verb, INTRANSITIVE);
1363 return drink(command->verb, command->obj);
1377 return fill(command->verb, command->obj);
1389 return bigwords(command->id1);
1393 command->obj = INTRANSITIVE;
1394 return read(*command);
1404 return fly(command->verb, INTRANSITIVE);
1410 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1415 /* Analyse a transitive verb. */
1416 switch (command->verb) {
1418 return vcarry(command->verb, command->obj);
1420 return discard(command->verb, command->obj);
1422 return say(command);
1424 return lock(command->verb, command->obj);
1427 return (GO_CLEAROBJ);
1430 return lock(command->verb, command->obj);
1432 return light(command->verb, command->obj);
1434 return extinguish(command->verb, command->obj);
1436 return wave(command->verb, command->obj);
1438 speak(actions[command->verb].message);
1442 speak(actions[command->verb].message);
1446 return attack(command);
1448 return pour(command->verb, command->obj);
1450 return eat(command->verb, command->obj);
1452 return drink(command->verb, command->obj);
1454 return rub(command->verb, command->obj);
1456 return throw (command);
1458 speak(actions[command->verb].message);
1462 return find(command->verb, command->obj);
1464 return find(command->verb, command->obj);
1466 return feed(command->verb, command->obj);
1468 return fill(command->verb, command->obj);
1473 speak(actions[command->verb].message);
1481 speak(actions[command->verb].message);
1485 speak(actions[command->verb].message);
1489 return read(*command);
1491 return vbreak(command->verb, command->obj);
1493 return wake(command->verb, command->obj);
1495 speak(actions[command->verb].message);
1499 speak(actions[command->verb].message);
1503 return fly(command->verb, command->obj);
1505 speak(actions[command->verb].message);
1511 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1514 /* Unknown verb, couldn't deduce object - might need hint */
1515 sspeak(WHAT_DO, command->raw1);
1516 return GO_CHECKHINT;
1518 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE