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 rspeak(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 rspeak(NOTHING_HAPPENS);
224 game.foobar = WORD_EMPTY;
229 static void blast(void)
230 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
232 if (game.prop[ROD2] < 0 ||
234 rspeak(REQUIRES_DYNAMITE);
236 game.bonus = VICTORY_MESSAGE;
237 if (game.loc == LOC_NE)
238 game.bonus = DEFEAT_MESSAGE;
240 game.bonus = SPLATTER_MESSAGE;
246 static int vbreak(token_t verb, token_t obj)
247 /* Break. Only works for mirror in repository and, of course, the vase. */
251 rspeak(BREAK_MIRROR);
258 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
260 drop(VASE, game.loc);
261 state_change(VASE, VASE_BROKEN);
262 game.fixed[VASE] = IS_FIXED;
265 rspeak(actions[verb].message);
266 return (GO_CLEAROBJ);
269 static int brief(void)
270 /* Brief. Intransitive only. Suppress long descriptions after first time. */
274 rspeak(BRIEF_CONFIRM);
278 static int vcarry(token_t verb, token_t obj)
279 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
280 * take one without the other). Liquids also special, since they depend on
281 * status of bottle. Also various side effects, etc. */
283 if (obj == INTRANSITIVE) {
284 /* Carry, no object given yet. OK if only one object present. */
285 if (game.atloc[game.loc] == 0 ||
286 game.link[game.atloc[game.loc]] != 0 ||
287 atdwrf(game.loc) > 0)
289 obj = game.atloc[game.loc];
293 rspeak(ALREADY_CARRYING);
298 rspeak(REMOVE_MESSAGE);
303 if (game.fixed[obj] != IS_FREE) {
304 /* Next guard tests whether plant is tiny or stashed */
305 if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
309 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
310 rspeak(BEAR_CHAINED);
313 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
314 rspeak(STILL_LOCKED);
322 rspeak(DOUGHNUT_HOLES);
329 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
334 rspeak(HAND_PASSTHROUGH);
345 if (TOTING(BOTTLE)) {
346 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
347 return (fill(verb, BOTTLE));
348 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
352 rspeak(NO_CONTAINER);
358 if (game.holdng >= INVLIMIT) {
364 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
365 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
371 rspeak(CANNOT_CARRY);
378 game.prop[BIRD] = BIRD_CAGED;
382 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
383 /* expression maps BIRD to CAGE and CAGE to BIRD */
384 carry(BIRD + CAGE - obj, game.loc);
385 carry(obj, game.loc);
386 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
387 game.place[LIQUID()] = CARRIED;
388 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
389 game.prop[obj] = STATE_FOUND;
390 game.prop[CAVITY] = CAVITY_EMPTY;
396 static int chain(token_t verb)
397 /* Do something to the bear's chain */
400 if (game.prop[BEAR] == UNTAMED_BEAR) {
404 if (game.prop[CHAIN] == CHAIN_HEAP) {
405 rspeak(ALREADY_UNLOCKED);
408 game.prop[CHAIN] = CHAIN_HEAP;
409 game.fixed[CHAIN] = IS_FREE;
410 if (game.prop[BEAR] != BEAR_DEAD)
411 game.prop[BEAR] = CONTENTED_BEAR;
413 switch (game.prop[BEAR]) {
415 game.fixed[BEAR] = IS_FIXED;
418 game.fixed[BEAR] = IS_FREE;
420 rspeak(CHAIN_UNLOCKED);
424 if (game.prop[CHAIN] != CHAIN_HEAP) {
425 rspeak(ALREADY_LOCKED);
428 if (game.loc != objects[CHAIN].plac) {
433 game.prop[CHAIN] = CHAIN_FIXED;
436 drop(CHAIN, game.loc);
437 game.fixed[CHAIN] = IS_FIXED;
439 rspeak(CHAIN_LOCKED);
443 static int discard(token_t verb, token_t obj, bool just_do_it)
444 /* Discard object. "Throw" also comes here for most objects. Special cases for
445 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
446 * Drop coins at vending machine for extra batteries. */
449 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
452 rspeak(actions[verb].message);
455 if (obj == BIRD && HERE(SNAKE)) {
456 rspeak(BIRD_ATTACKS);
460 /* Set game.prop for use by travel options */
461 game.prop[SNAKE] = SNAKE_CHASED;
463 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
465 game.prop[obj] = STATE_IN_CAVITY;
466 game.prop[CAVITY] = CAVITY_FULL;
467 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
468 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
475 if (spk != RUG_WIGGLES) {
476 /* FIXME: Arithmetic on state numbers */
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;
514 if (obj == BOTTLE && k != NO_OBJECT)
515 game.place[k] = LOC_NOWHERE;
516 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
517 drop(BIRD, game.loc);
521 game.prop[BIRD] = BIRD_UNCAGED;
522 if (FOREST(game.loc))
523 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
527 static int drink(token_t verb, token_t obj)
528 /* Drink. If no object, assume water and look for it here. If water is in
529 * the bottle, drink that, else must be at a water loc, so drink stream. */
531 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
532 (LIQUID() != WATER || !HERE(BOTTLE))) {
538 state_change(DRAGON, DRAGON_BLOODLESS);
543 if (obj != NO_OBJECT && obj != WATER) {
544 rspeak(RIDICULOUS_ATTEMPT);
547 if (LIQUID() == WATER && HERE(BOTTLE)) {
548 game.place[WATER] = LOC_NOWHERE;
549 state_change(BOTTLE, EMPTY_BOTTLE);
553 rspeak(actions[verb].message);
557 static int eat(token_t verb, token_t obj)
558 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
559 * ok, some things lose appetite, rest are ridiculous. */
561 if (obj == INTRANSITIVE) {
565 rspeak(THANKS_DELICIOUS);
570 rspeak(THANKS_DELICIOUS);
582 rspeak(LOST_APPETITE);
585 rspeak(actions[verb].message);
589 static int extinguish(token_t verb, int obj)
590 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
592 if (obj == INTRANSITIVE) {
593 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
595 if (HERE(URN) && game.prop[URN] == URN_LIT)
597 if (obj == INTRANSITIVE)
602 if (game.prop[URN] != URN_EMPTY) {
603 state_change(URN, URN_DARK);
605 pspeak(URN, change, URN_DARK, true);
611 state_change(LAMP, LAMP_DARK);
612 rspeak(DARK(game.loc) ?
620 rspeak(BEYOND_POWER);
624 rspeak(actions[verb].message);
628 static int feed(token_t verb, token_t obj)
629 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
630 * mad. Bear, special. */
637 if (game.prop[DRAGON] != DRAGON_BARS)
638 rspeak(RIDICULOUS_ATTEMPT);
640 rspeak(NOTHING_EDIBLE);
643 if (!game.closed && HERE(BIRD)) {
645 rspeak(BIRD_DEVOURED);
647 rspeak(NOTHING_EDIBLE);
657 rspeak(actions[verb].message);
660 if (game.prop[BEAR] == BEAR_DEAD) {
661 rspeak(RIDICULOUS_ATTEMPT);
664 if (game.prop[BEAR] == UNTAMED_BEAR) {
667 game.fixed[AXE] = IS_FREE;
668 game.prop[AXE] = AXE_HERE;
669 state_change(BEAR, SITTING_BEAR);
671 rspeak(NOTHING_EDIBLE);
674 rspeak(actions[verb].message);
680 rspeak(actions[verb].message);
688 int fill(token_t verb, token_t obj)
689 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
693 if (LIQLOC(game.loc) == NO_OBJECT) {
694 rspeak(FILL_INVALID);
698 rspeak(ARENT_CARRYING);
701 rspeak(SHATTER_VASE);
702 game.prop[VASE] = VASE_BROKEN;
703 game.fixed[VASE] = IS_FIXED;
704 return (discard(verb, VASE, true));
708 if (game.prop[URN] != URN_EMPTY) {
713 rspeak(FILL_INVALID);
719 game.prop[BOTTLE] = EMPTY_BOTTLE;
723 game.prop[URN] = URN_DARK;
724 game.prop[BOTTLE] = EMPTY_BOTTLE;
729 rspeak(FILL_INVALID);
732 game.place[k] = LOC_NOWHERE;
735 if (obj != NO_OBJECT && obj != BOTTLE) {
736 rspeak(actions[verb].message);
739 if (obj == NO_OBJECT && !HERE(BOTTLE))
742 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
746 if (LIQUID() != NO_OBJECT) {
750 if (LIQLOC(game.loc) == NO_OBJECT) {
755 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
759 game.place[LIQUID()] = CARRIED;
763 static int find(token_t verb, token_t obj)
764 /* Find. Might be carrying it, or it might be here. Else give caveat. */
767 rspeak(ALREADY_CARRYING);
772 rspeak(NEEDED_NEARBY);
777 (LIQUID() == obj && AT(BOTTLE)) ||
778 obj == LIQLOC(game.loc) ||
779 (obj == DWARF && atdwrf(game.loc) > 0)) {
785 rspeak(actions[verb].message);
789 static int fly(token_t verb, token_t obj)
790 /* Fly. Snide remarks unless hovering rug is here. */
792 if (obj == INTRANSITIVE) {
797 if (game.prop[RUG] != RUG_HOVER) {
798 rspeak(RUG_NOTHING2);
805 rspeak(actions[verb].message);
808 if (game.prop[RUG] != RUG_HOVER) {
809 rspeak(RUG_NOTHING1);
812 game.oldlc2 = game.oldloc;
813 game.oldloc = game.loc;
814 /* FIXME: Arithmetic on location values */
815 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
817 if (game.prop[SAPPH] == STATE_NOTFOUND) {
825 static int inven(void)
826 /* Inventory. If object, treat same as find. Else report on current burden. */
829 for (int i = 1; i <= NOBJECTS; i++) {
837 pspeak(i, touch, -1, false);
846 static int light(token_t verb, token_t obj)
847 /* Light. Applicable only to lamp and urn. */
849 if (obj == INTRANSITIVE) {
850 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
852 if (HERE(URN) && game.prop[URN] == URN_DARK)
854 if (obj == INTRANSITIVE ||
855 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
856 HERE(URN) && game.prop[URN] == URN_DARK))
861 state_change(URN, game.prop[URN] == URN_EMPTY ?
867 rspeak(actions[verb].message);
870 if (game.limit < 0) {
874 state_change(LAMP, LAMP_BRIGHT);
882 static int listen(void)
883 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
885 long sound = locations[game.loc].sound;
886 if (sound != SILENT) {
888 if (!locations[game.loc].loud)
892 for (int i = 1; i <= NOBJECTS; i++) {
894 objects[i].sounds[0] == NULL ||
897 int mi = game.prop[i];
899 mi += 3 * game.blooded;
900 long packed_zzword = token_to_packed(game.zzword);
901 pspeak(i, hear, mi, true, packed_zzword);
903 if (i == BIRD && mi == BIRD_ENDSTATE)
911 static int lock(token_t verb, token_t obj)
912 /* Lock, unlock, no object given. Assume various things if present. */
914 if (obj == INTRANSITIVE) {
925 if (obj == INTRANSITIVE) {
926 rspeak(NOTHING_LOCKED);
931 /* Lock, unlock object. Special stuff for opening clam/oyster
941 game.clock2 = PANICTIME;
945 state_change(GRATE, (verb == LOCK) ?
959 else if (!TOTING(TRIDENT))
960 rspeak(OYSTER_OPENER);
963 drop(OYSTER, game.loc);
964 drop(PEARL, LOC_CULDESAC);
972 rspeak(OYSTER_OPENER);
976 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
982 rspeak(CANNOT_UNLOCK);
985 rspeak(actions[verb].message);
991 static int pour(token_t verb, token_t obj)
992 /* Pour. If no object, or object is bottle, assume contents of bottle.
993 * special tests for pouring water or oil on plant or rusty door. */
998 if (obj == NO_OBJECT)
1001 rspeak(actions[verb].message);
1005 if (obj != OIL && obj != WATER) {
1009 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1010 return fill(verb, URN);
1011 game.prop[BOTTLE] = EMPTY_BOTTLE;
1012 game.place[obj] = LOC_NOWHERE;
1020 /* cycle through the three plant states */
1021 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1022 game.prop[PLANT2] = game.prop[PLANT];
1025 rspeak(SHAKING_LEAVES);
1029 state_change(DOOR, (obj == OIL) ?
1036 static int quit(void)
1037 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1039 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1040 terminate(quitgame);
1044 static int read(struct command_t command)
1045 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1047 if (command.obj == INTRANSITIVE) {
1049 for (int i = 1; i <= NOBJECTS; i++) {
1050 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1051 command.obj = command.obj * NOBJECTS + i;
1053 if (command.obj > NOBJECTS ||
1059 if (DARK(game.loc)) {
1060 sspeak(NO_SEE, command.raw1);
1061 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1062 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1063 } else if (objects[command.obj].texts[0] == NULL ||
1064 game.prop[command.obj] < 0) {
1065 rspeak(actions[command.verb].message);
1067 pspeak(command.obj, study, game.prop[command.obj], true);
1071 static int reservoir(void)
1072 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1074 /* FIXME: Arithmetic on state numbers */
1075 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
1076 rspeak(NOTHING_HAPPENS);
1080 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1084 game.oldlc2 = game.loc;
1085 game.newloc = LOC_NOWHERE;
1087 return GO_TERMINATE;
1092 static int rub(token_t verb, token_t obj)
1093 /* Rub. Yields various snide remarks except for lit urn. */
1095 if (obj == URN && game.prop[URN] == URN_LIT) {
1097 drop(AMBER, game.loc);
1098 game.prop[AMBER] = AMBER_IN_ROCK;
1100 drop(CAVITY, game.loc);
1102 } else if (obj != LAMP) {
1103 rspeak(PECULIAR_NOTHING);
1105 rspeak(actions[verb].message);
1110 static int say(struct command_t *command)
1111 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1113 if (command->wd2 > 0) {
1114 command->wd1 = command->wd2;
1115 strcpy(command->raw1, command->raw2);
1117 char word1[TOKLEN + 1];
1118 packed_to_token(command->wd1, word1);
1119 int wd = (int) get_vocab_id(word1);
1120 if (wd == MOTION_WORD(XYZZY) ||
1121 wd == MOTION_WORD(PLUGH) ||
1122 wd == MOTION_WORD(PLOVER) ||
1123 wd == ACTION_WORD(FEE) ||
1124 wd == ACTION_WORD(FIE) ||
1125 wd == ACTION_WORD(FOE) ||
1126 wd == ACTION_WORD(FOO) ||
1127 wd == ACTION_WORD(FUM) ||
1128 wd == ACTION_WORD(PART)) {
1129 /* FIXME: scribbles on the interpreter's command block */
1130 wordclear(&command->wd2);
1133 sspeak(OKEY_DOKEY, command->raw1);
1137 static int throw_support(long spk)
1140 drop(AXE, game.loc);
1144 static int throw (struct command_t *command)
1145 /* Throw. Same as discard unless axe. Then same as attack except
1146 * ignore bird, and if dwarf is present then one might be killed.
1147 * (Only way to do so!) Axe also special for dragon, bear, and
1148 * troll. Treasures special for troll. */
1150 if (!TOTING(command->obj)) {
1151 rspeak(actions[command->verb].message);
1154 if (objects[command->obj].is_treasure && AT(TROLL)) {
1155 /* Snarf a treasure for the troll. */
1156 drop(command->obj, LOC_NOWHERE);
1157 move(TROLL, LOC_NOWHERE);
1158 move(TROLL + NOBJECTS, LOC_NOWHERE);
1159 drop(TROLL2, objects[TROLL].plac);
1160 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1162 rspeak(TROLL_SATISFIED);
1165 if (command->obj == FOOD && HERE(BEAR)) {
1166 /* But throwing food is another story. */
1167 command->obj = BEAR;
1168 return (feed(command->verb, command->obj));
1170 if (command->obj != AXE)
1171 return (discard(command->verb, command->obj, false));
1173 if (atdwrf(game.loc) <= 0) {
1174 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1175 return throw_support(DRAGON_SCALES);
1177 return throw_support(TROLL_RETURNS);
1179 return throw_support(OGRE_DODGE);
1180 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1181 /* This'll teach him to throw the axe at the bear! */
1182 drop(AXE, game.loc);
1183 game.fixed[AXE] = IS_FIXED;
1185 state_change(AXE, AXE_LOST);
1188 command->obj = NO_OBJECT;
1189 return (attack(command));
1192 if (randrange(NDWARVES + 1) < game.dflag) {
1193 return throw_support(DWARF_DODGES);
1195 long i = atdwrf(game.loc);
1196 game.dseen[i] = false;
1197 game.dloc[i] = LOC_NOWHERE;
1198 return throw_support((++game.dkill == 1) ?
1205 static int wake(token_t verb, token_t obj)
1206 /* Wake. Only use is to disturb the dwarves. */
1210 rspeak(actions[verb].message);
1214 return GO_DWARFWAKE;
1218 static int wave(token_t verb, token_t obj)
1219 /* Wave. No effect unless waving rod at fissure or at bird. */
1226 rspeak(((!TOTING(obj)) && (obj != ROD ||
1229 actions[verb].message);
1233 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1234 drop(JADE, game.loc);
1235 game.prop[JADE] = STATE_FOUND;
1237 rspeak(NECKLACE_FLY);
1241 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1244 return GO_DWARFWAKE;
1248 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1254 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1258 state_change(FISSURE,
1259 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1264 int action(struct command_t *command)
1265 /* Analyse a verb. Remember what it was, go back for object if second word
1266 * unless verb is "say", which snarfs arbitrary second word.
1269 if (command->part == unknown) {
1270 /* Analyse an object word. See if the thing is here, whether
1271 * we've got a verb yet, and so on. Object must be here
1272 * unless verb is "find" or "invent(ory)" (and no new verb
1273 * yet to be analysed). Water and oil are also funny, since
1274 * they are never actually dropped at any location, but might
1275 * be here inside the bottle or urn or as a feature of the
1277 if (HERE(command->obj))
1279 else if (command->obj == GRATE) {
1280 if (game.loc == LOC_START ||
1281 game.loc == LOC_VALLEY ||
1282 game.loc == LOC_SLIT) {
1283 command->obj = DPRSSN;
1285 if (game.loc == LOC_COBBLE ||
1286 game.loc == LOC_DEBRIS ||
1287 game.loc == LOC_AWKWARD ||
1288 game.loc == LOC_BIRD ||
1289 game.loc == LOC_PITTOP) {
1290 command->obj = ENTRNC;
1292 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1294 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1295 command->obj == LIQLOC(game.loc))
1297 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1300 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1301 command->obj = PLANT2;
1303 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1305 rspeak(KNIVES_VANISH);
1307 } else if (command->obj == ROD && HERE(ROD2)) {
1308 command->obj = ROD2;
1310 } else if ((command->verb == FIND ||
1311 command->verb == INVENTORY) && command->wd2 <= 0)
1314 sspeak(NO_SEE, command->raw1);
1318 if (command->wd2 > 0)
1320 if (command->verb != 0)
1321 command->part = transitive;
1324 switch (command->part) {
1326 if (command->wd2 > 0 && command->verb != SAY)
1328 if (command->verb == SAY)
1329 command->obj = command->wd2;
1330 if (command->obj == NO_OBJECT ||
1331 command->obj == INTRANSITIVE) {
1332 /* Analyse an intransitive verb (ie, no object given yet). */
1333 switch (command->verb) {
1335 return vcarry(command->verb, INTRANSITIVE);
1341 return lock(command->verb, INTRANSITIVE);
1344 return (GO_CLEAROBJ);
1347 return lock(command->verb, INTRANSITIVE);
1349 return light(command->verb, INTRANSITIVE);
1351 return extinguish(command->verb, INTRANSITIVE);
1357 rspeak(actions[command->verb].message);
1361 return attack(command);
1363 return pour(command->verb, command->obj);
1365 return eat(command->verb, INTRANSITIVE);
1367 return drink(command->verb, command->obj);
1381 return fill(command->verb, command->obj);
1393 return bigwords(command->id1);
1397 command->obj = INTRANSITIVE;
1398 return read(*command);
1408 return fly(command->verb, INTRANSITIVE);
1414 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1419 /* Analyse a transitive verb. */
1420 switch (command->verb) {
1422 return vcarry(command->verb, command->obj);
1424 return discard(command->verb, command->obj, false);
1426 return say(command);
1428 return lock(command->verb, command->obj);
1431 return (GO_CLEAROBJ);
1434 return lock(command->verb, command->obj);
1436 return light(command->verb, command->obj);
1438 return extinguish(command->verb, command->obj);
1440 return wave(command->verb, command->obj);
1442 rspeak(actions[command->verb].message);
1446 rspeak(actions[command->verb].message);
1450 return attack(command);
1452 return pour(command->verb, command->obj);
1454 return eat(command->verb, command->obj);
1456 return drink(command->verb, command->obj);
1458 return rub(command->verb, command->obj);
1460 return throw (command);
1462 rspeak(actions[command->verb].message);
1466 return find(command->verb, command->obj);
1468 return find(command->verb, command->obj);
1470 return feed(command->verb, command->obj);
1472 return fill(command->verb, command->obj);
1477 rspeak(actions[command->verb].message);
1485 rspeak(actions[command->verb].message);
1489 rspeak(actions[command->verb].message);
1493 return read(*command);
1495 return vbreak(command->verb, command->obj);
1497 return wake(command->verb, command->obj);
1499 rspeak(actions[command->verb].message);
1503 rspeak(actions[command->verb].message);
1507 return fly(command->verb, command->obj);
1509 rspeak(actions[command->verb].message);
1515 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1518 /* Unknown verb, couldn't deduce object - might need hint */
1519 sspeak(WHAT_DO, command->raw1);
1520 return GO_CHECKHINT;
1522 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE