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 /* 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, 0);
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)))
196 if ((id != ACTION_WORD(FOO)) && (id != ACTION_WORD(FUM))) {
200 game.foobar = WORD_EMPTY;
201 if (game.place[EGGS] == objects[EGGS].plac ||
202 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
203 rspeak(NOTHING_HAPPENS);
206 /* Bring back troll if we steal the eggs back from him before
208 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
209 game.prop[TROLL] = TROLL_PAIDONCE;
213 if (game.loc == objects[EGGS].plac)
215 move(EGGS, objects[EGGS].plac);
216 pspeak(EGGS, look, k, true);
222 if (game.loc == LOC_GIANTROOM) {
225 /* This is new begavior in Open Adventure - sounds better when
226 * player isn't in the Giant Room. */
227 rspeak(WELL_POINTLESS);
229 game.foobar = WORD_EMPTY;
234 static void blast(void)
235 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
237 if (game.prop[ROD2] < 0 ||
239 rspeak(REQUIRES_DYNAMITE);
241 game.bonus = VICTORY_MESSAGE;
242 if (game.loc == LOC_NE)
243 game.bonus = DEFEAT_MESSAGE;
245 game.bonus = SPLATTER_MESSAGE;
251 static int vbreak(token_t verb, token_t obj)
252 /* Break. Only works for mirror in repository and, of course, the vase. */
256 rspeak(BREAK_MIRROR);
263 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
265 drop(VASE, game.loc);
266 state_change(VASE, VASE_BROKEN);
267 game.fixed[VASE] = IS_FIXED;
270 speak(actions[verb].message);
271 return (GO_CLEAROBJ);
274 static int brief(void)
275 /* Brief. Intransitive only. Suppress long descriptions after first time. */
279 rspeak(BRIEF_CONFIRM);
283 static int vcarry(token_t verb, token_t obj)
284 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
285 * take one without the other). Liquids also special, since they depend on
286 * status of bottle. Also various side effects, etc. */
288 if (obj == INTRANSITIVE) {
289 /* Carry, no object given yet. OK if only one object present. */
290 if (game.atloc[game.loc] == 0 ||
291 game.link[game.atloc[game.loc]] != 0 ||
292 atdwrf(game.loc) > 0)
294 obj = game.atloc[game.loc];
298 rspeak(ALREADY_CARRYING);
303 rspeak(REMOVE_MESSAGE);
308 if (game.fixed[obj] != IS_FREE) {
309 /* Next guard tests whether plant is tiny or stashed */
310 if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
314 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
315 rspeak(BEAR_CHAINED);
318 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
319 rspeak(STILL_LOCKED);
327 rspeak(DOUGHNUT_HOLES);
334 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
339 rspeak(HAND_PASSTHROUGH);
350 if (TOTING(BOTTLE)) {
351 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
352 return (fill(verb, BOTTLE));
353 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
357 rspeak(NO_CONTAINER);
363 if (game.holdng >= INVLIMIT) {
369 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
370 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
376 rspeak(CANNOT_CARRY);
383 game.prop[BIRD] = BIRD_CAGED;
387 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
388 /* expression maps BIRD to CAGE and CAGE to BIRD */
389 carry(BIRD + CAGE - obj, game.loc);
390 carry(obj, game.loc);
391 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
392 game.place[LIQUID()] = CARRIED;
393 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
394 game.prop[obj] = STATE_FOUND;
395 game.prop[CAVITY] = CAVITY_EMPTY;
401 static int chain(token_t verb)
402 /* Do something to the bear's chain */
405 if (game.prop[BEAR] == UNTAMED_BEAR) {
409 if (game.prop[CHAIN] == CHAIN_HEAP) {
410 rspeak(ALREADY_UNLOCKED);
413 game.prop[CHAIN] = CHAIN_HEAP;
414 game.fixed[CHAIN] = IS_FREE;
415 if (game.prop[BEAR] != BEAR_DEAD)
416 game.prop[BEAR] = CONTENTED_BEAR;
418 switch (game.prop[BEAR]) {
420 game.fixed[BEAR] = IS_FIXED;
423 game.fixed[BEAR] = IS_FREE;
425 rspeak(CHAIN_UNLOCKED);
429 if (game.prop[CHAIN] != CHAIN_HEAP) {
430 rspeak(ALREADY_LOCKED);
433 if (game.loc != objects[CHAIN].plac) {
438 game.prop[CHAIN] = CHAIN_FIXED;
441 drop(CHAIN, game.loc);
442 game.fixed[CHAIN] = IS_FIXED;
444 rspeak(CHAIN_LOCKED);
448 static int discard(token_t verb, token_t obj, bool just_do_it)
449 /* Discard object. "Throw" also comes here for most objects. Special cases for
450 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
451 * Drop coins at vending machine for extra batteries. */
454 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
457 speak(actions[verb].message);
460 if (obj == BIRD && HERE(SNAKE)) {
461 rspeak(BIRD_ATTACKS);
465 /* Set game.prop for use by travel options */
466 game.prop[SNAKE] = SNAKE_CHASED;
468 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
470 game.prop[obj] = STATE_IN_CAVITY;
471 game.prop[CAVITY] = CAVITY_FULL;
472 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
473 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
480 if (spk != RUG_WIGGLES) {
481 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
484 k = objects[SAPPH].plac;
485 move(RUG + NOBJECTS, k);
488 } else if (obj == COINS && HERE(VEND)) {
490 drop(BATTERY, game.loc);
491 pspeak(BATTERY, look, FRESH_BATTERIES, true);
493 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
497 } else if (obj == BEAR && AT(TROLL)) {
498 state_change(TROLL, TROLL_GONE);
499 move(TROLL, LOC_NOWHERE);
500 move(TROLL + NOBJECTS, LOC_NOWHERE);
501 move(TROLL2, objects[TROLL].plac);
502 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
504 } else if (obj != VASE ||
505 game.loc == objects[PILLOW].plac) {
508 state_change(VASE, AT(PILLOW)
511 if (game.prop[VASE] != VASE_WHOLE)
512 game.fixed[VASE] = IS_FIXED;
518 if (obj == BOTTLE && k != NO_OBJECT)
519 game.place[k] = LOC_NOWHERE;
520 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
521 drop(BIRD, game.loc);
525 game.prop[BIRD] = BIRD_UNCAGED;
526 if (FOREST(game.loc))
527 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
531 static int drink(token_t verb, token_t obj)
532 /* Drink. If no object, assume water and look for it here. If water is in
533 * the bottle, drink that, else must be at a water loc, so drink stream. */
535 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
536 (LIQUID() != WATER || !HERE(BOTTLE))) {
542 state_change(DRAGON, DRAGON_BLOODLESS);
547 if (obj != NO_OBJECT && obj != WATER) {
548 rspeak(RIDICULOUS_ATTEMPT);
551 if (LIQUID() == WATER && HERE(BOTTLE)) {
552 game.place[WATER] = LOC_NOWHERE;
553 state_change(BOTTLE, EMPTY_BOTTLE);
557 speak(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 speak(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 speak(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. */
641 if (game.prop[DRAGON] != DRAGON_BARS)
642 rspeak(RIDICULOUS_ATTEMPT);
644 rspeak(NOTHING_EDIBLE);
647 if (!game.closed && HERE(BIRD)) {
649 rspeak(BIRD_DEVOURED);
651 rspeak(NOTHING_EDIBLE);
661 speak(actions[verb].message);
664 if (game.prop[BEAR] == BEAR_DEAD) {
665 rspeak(RIDICULOUS_ATTEMPT);
668 if (game.prop[BEAR] == UNTAMED_BEAR) {
671 game.fixed[AXE] = IS_FREE;
672 game.prop[AXE] = AXE_HERE;
673 state_change(BEAR, SITTING_BEAR);
675 rspeak(NOTHING_EDIBLE);
678 speak(actions[verb].message);
684 speak(actions[verb].message);
692 int fill(token_t verb, token_t obj)
693 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
697 if (LIQLOC(game.loc) == NO_OBJECT) {
698 rspeak(FILL_INVALID);
702 rspeak(ARENT_CARRYING);
705 rspeak(SHATTER_VASE);
706 game.prop[VASE] = VASE_BROKEN;
707 game.fixed[VASE] = IS_FIXED;
708 return (discard(verb, VASE, true));
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 != NO_OBJECT && obj != BOTTLE) {
740 speak(actions[verb].message);
743 if (obj == NO_OBJECT && !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(token_t verb, token_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(token_t verb, token_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 (int i = 1; i <= NOBJECTS; i++) {
841 pspeak(i, touch, -1, false);
850 static int light(token_t verb, token_t obj)
851 /* Light. Applicable only to lamp and urn. */
853 if (obj == INTRANSITIVE) {
854 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
856 if (HERE(URN) && game.prop[URN] == URN_DARK)
858 if (obj == INTRANSITIVE ||
859 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
860 HERE(URN) && game.prop[URN] == URN_DARK))
865 state_change(URN, game.prop[URN] == URN_EMPTY ?
871 speak(actions[verb].message);
874 if (game.limit < 0) {
878 state_change(LAMP, LAMP_BRIGHT);
886 static int listen(void)
887 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
889 long sound = locations[game.loc].sound;
890 if (sound != SILENT) {
892 if (!locations[game.loc].loud)
896 for (int i = 1; i <= NOBJECTS; i++) {
898 objects[i].sounds[0] == NULL ||
901 int mi = game.prop[i];
903 mi += 3 * game.blooded;
904 long packed_zzword = token_to_packed(game.zzword);
905 pspeak(i, hear, mi, true, packed_zzword);
907 if (i == BIRD && mi == BIRD_ENDSTATE)
915 static int lock(token_t verb, token_t obj)
916 /* Lock, unlock, no object given. Assume various things if present. */
918 if (obj == INTRANSITIVE) {
929 if (obj == INTRANSITIVE) {
930 rspeak(NOTHING_LOCKED);
935 /* Lock, unlock object. Special stuff for opening clam/oyster
945 game.clock2 = PANICTIME;
949 state_change(GRATE, (verb == LOCK) ?
963 else if (!TOTING(TRIDENT))
964 rspeak(OYSTER_OPENER);
967 drop(OYSTER, game.loc);
968 drop(PEARL, LOC_CULDESAC);
976 rspeak(OYSTER_OPENER);
980 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
986 rspeak(CANNOT_UNLOCK);
989 speak(actions[verb].message);
995 static int pour(token_t verb, token_t obj)
996 /* Pour. If no object, or object is bottle, assume contents of bottle.
997 * special tests for pouring water or oil on plant or rusty door. */
1002 if (obj == NO_OBJECT)
1005 speak(actions[verb].message);
1009 if (obj != OIL && obj != WATER) {
1013 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1014 return fill(verb, URN);
1015 game.prop[BOTTLE] = EMPTY_BOTTLE;
1016 game.place[obj] = LOC_NOWHERE;
1024 /* cycle through the three plant states */
1025 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1026 game.prop[PLANT2] = game.prop[PLANT];
1029 rspeak(SHAKING_LEAVES);
1033 state_change(DOOR, (obj == OIL) ?
1040 static int quit(void)
1041 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1043 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1044 terminate(quitgame);
1048 static int read(struct command_t command)
1049 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1051 if (command.obj == INTRANSITIVE) {
1053 for (int i = 1; i <= NOBJECTS; i++) {
1054 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1055 command.obj = command.obj * NOBJECTS + i;
1057 if (command.obj > NOBJECTS ||
1063 if (DARK(game.loc)) {
1064 sspeak(NO_SEE, command.raw1);
1065 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1066 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1067 } else if (objects[command.obj].texts[0] == NULL ||
1068 game.prop[command.obj] < 0) {
1069 speak(actions[command.verb].message);
1071 pspeak(command.obj, study, game.prop[command.obj], true);
1075 static int reservoir(void)
1076 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1078 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1079 rspeak(NOTHING_HAPPENS);
1083 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1087 game.oldlc2 = game.loc;
1088 game.newloc = LOC_NOWHERE;
1090 return GO_TERMINATE;
1095 static int rub(token_t verb, token_t obj)
1096 /* Rub. Yields various snide remarks except for lit urn. */
1098 if (obj == URN && game.prop[URN] == URN_LIT) {
1100 drop(AMBER, game.loc);
1101 game.prop[AMBER] = AMBER_IN_ROCK;
1103 drop(CAVITY, game.loc);
1105 } else if (obj != LAMP) {
1106 rspeak(PECULIAR_NOTHING);
1108 speak(actions[verb].message);
1113 static int say(struct command_t *command)
1114 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1116 if (command->wd2 > 0) {
1117 command->wd1 = command->wd2;
1118 strcpy(command->raw1, command->raw2);
1120 char word1[TOKLEN + 1];
1121 packed_to_token(command->wd1, word1);
1122 int wd = (int) get_vocab_id(word1);
1123 if (wd == MOTION_WORD(XYZZY) ||
1124 wd == MOTION_WORD(PLUGH) ||
1125 wd == MOTION_WORD(PLOVER) ||
1126 wd == ACTION_WORD(FEE) ||
1127 wd == ACTION_WORD(FIE) ||
1128 wd == ACTION_WORD(FOE) ||
1129 wd == ACTION_WORD(FOO) ||
1130 wd == ACTION_WORD(FUM) ||
1131 wd == ACTION_WORD(PART)) {
1132 /* FIXME: scribbles on the interpreter's command block */
1133 wordclear(&command->wd2);
1136 sspeak(OKEY_DOKEY, command->raw1);
1140 static int throw_support(long spk)
1143 drop(AXE, game.loc);
1147 static int throw (struct command_t *command)
1148 /* Throw. Same as discard unless axe. Then same as attack except
1149 * ignore bird, and if dwarf is present then one might be killed.
1150 * (Only way to do so!) Axe also special for dragon, bear, and
1151 * troll. Treasures special for troll. */
1153 if (!TOTING(command->obj)) {
1154 speak(actions[command->verb].message);
1157 if (objects[command->obj].is_treasure && AT(TROLL)) {
1158 /* Snarf a treasure for the troll. */
1159 drop(command->obj, LOC_NOWHERE);
1160 move(TROLL, LOC_NOWHERE);
1161 move(TROLL + NOBJECTS, LOC_NOWHERE);
1162 drop(TROLL2, objects[TROLL].plac);
1163 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1165 rspeak(TROLL_SATISFIED);
1168 if (command->obj == FOOD && HERE(BEAR)) {
1169 /* But throwing food is another story. */
1170 command->obj = BEAR;
1171 return (feed(command->verb, command->obj));
1173 if (command->obj != AXE)
1174 return (discard(command->verb, command->obj, false));
1176 if (atdwrf(game.loc) <= 0) {
1177 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1178 return throw_support(DRAGON_SCALES);
1180 return throw_support(TROLL_RETURNS);
1182 return throw_support(OGRE_DODGE);
1183 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1184 /* This'll teach him to throw the axe at the bear! */
1185 drop(AXE, game.loc);
1186 game.fixed[AXE] = IS_FIXED;
1188 state_change(AXE, AXE_LOST);
1191 command->obj = NO_OBJECT;
1192 return (attack(command));
1195 if (randrange(NDWARVES + 1) < game.dflag) {
1196 return throw_support(DWARF_DODGES);
1198 long i = atdwrf(game.loc);
1199 game.dseen[i] = false;
1200 game.dloc[i] = LOC_NOWHERE;
1201 return throw_support((++game.dkill == 1) ?
1208 static int wake(token_t verb, token_t obj)
1209 /* Wake. Only use is to disturb the dwarves. */
1213 speak(actions[verb].message);
1217 return GO_DWARFWAKE;
1221 static int wave(token_t verb, token_t obj)
1222 /* Wave. No effect unless waving rod at fissure or at bird. */
1229 speak(((!TOTING(obj)) && (obj != ROD ||
1231 arbitrary_messages[ARENT_CARRYING] :
1232 actions[verb].message);
1236 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1237 drop(JADE, game.loc);
1238 game.prop[JADE] = STATE_FOUND;
1240 rspeak(NECKLACE_FLY);
1244 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1247 return GO_DWARFWAKE;
1251 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1257 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1261 state_change(FISSURE,
1262 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1267 int action(struct command_t *command)
1268 /* Analyse a verb. Remember what it was, go back for object if second word
1269 * unless verb is "say", which snarfs arbitrary second word.
1272 if (command->part == unknown) {
1273 /* Analyse an object word. See if the thing is here, whether
1274 * we've got a verb yet, and so on. Object must be here
1275 * unless verb is "find" or "invent(ory)" (and no new verb
1276 * yet to be analysed). Water and oil are also funny, since
1277 * they are never actually dropped at any location, but might
1278 * be here inside the bottle or urn or as a feature of the
1280 if (HERE(command->obj))
1282 else if (command->obj == GRATE) {
1283 if (game.loc == LOC_START ||
1284 game.loc == LOC_VALLEY ||
1285 game.loc == LOC_SLIT) {
1286 command->obj = DPRSSN;
1288 if (game.loc == LOC_COBBLE ||
1289 game.loc == LOC_DEBRIS ||
1290 game.loc == LOC_AWKWARD ||
1291 game.loc == LOC_BIRD ||
1292 game.loc == LOC_PITTOP) {
1293 command->obj = ENTRNC;
1295 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1297 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1298 command->obj == LIQLOC(game.loc))
1300 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1303 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1304 command->obj = PLANT2;
1306 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1308 rspeak(KNIVES_VANISH);
1310 } else if (command->obj == ROD && HERE(ROD2)) {
1311 command->obj = ROD2;
1313 } else if ((command->verb == FIND ||
1314 command->verb == INVENTORY) && command->wd2 <= 0)
1317 sspeak(NO_SEE, command->raw1);
1321 if (command->wd2 > 0)
1323 if (command->verb != 0)
1324 command->part = transitive;
1327 switch (command->part) {
1329 if (command->wd2 > 0 && command->verb != SAY)
1331 if (command->verb == SAY)
1332 command->obj = command->wd2;
1333 if (command->obj == NO_OBJECT ||
1334 command->obj == INTRANSITIVE) {
1335 /* Analyse an intransitive verb (ie, no object given yet). */
1336 switch (command->verb) {
1338 return vcarry(command->verb, INTRANSITIVE);
1344 return lock(command->verb, INTRANSITIVE);
1347 return (GO_CLEAROBJ);
1350 return lock(command->verb, INTRANSITIVE);
1352 return light(command->verb, INTRANSITIVE);
1354 return extinguish(command->verb, INTRANSITIVE);
1360 speak(actions[command->verb].message);
1364 return attack(command);
1366 return pour(command->verb, command->obj);
1368 return eat(command->verb, INTRANSITIVE);
1370 return drink(command->verb, command->obj);
1384 return fill(command->verb, command->obj);
1396 return bigwords(command->id1);
1400 command->obj = INTRANSITIVE;
1401 return read(*command);
1411 return fly(command->verb, INTRANSITIVE);
1417 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1422 /* Analyse a transitive verb. */
1423 switch (command->verb) {
1425 return vcarry(command->verb, command->obj);
1427 return discard(command->verb, command->obj, false);
1429 return say(command);
1431 return lock(command->verb, command->obj);
1434 return (GO_CLEAROBJ);
1437 return lock(command->verb, command->obj);
1439 return light(command->verb, command->obj);
1441 return extinguish(command->verb, command->obj);
1443 return wave(command->verb, command->obj);
1445 speak(actions[command->verb].message);
1449 speak(actions[command->verb].message);
1453 return attack(command);
1455 return pour(command->verb, command->obj);
1457 return eat(command->verb, command->obj);
1459 return drink(command->verb, command->obj);
1461 return rub(command->verb, command->obj);
1463 return throw (command);
1465 speak(actions[command->verb].message);
1469 return find(command->verb, command->obj);
1471 return find(command->verb, command->obj);
1473 return feed(command->verb, command->obj);
1475 return fill(command->verb, command->obj);
1480 speak(actions[command->verb].message);
1488 speak(actions[command->verb].message);
1492 speak(actions[command->verb].message);
1496 return read(*command);
1498 return vbreak(command->verb, command->obj);
1500 return wake(command->verb, command->obj);
1502 speak(actions[command->verb].message);
1506 speak(actions[command->verb].message);
1510 return fly(command->verb, command->obj);
1512 speak(actions[command->verb].message);
1518 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1521 /* Unknown verb, couldn't deduce object - might need hint */
1522 sspeak(WHAT_DO, command->raw1);
1523 return GO_CHECKHINT;
1525 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE