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 == 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 = 1; obj <= NOBJECTS; obj++) {
125 if (game.place[obj] == objects[DRAGON].plac ||
126 game.place[obj] == objects[DRAGON].fixd)
127 move(obj, 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 if (game.loc == objects[EGGS].plac)
213 move(EGGS, objects[EGGS].plac);
214 pspeak(EGGS, look, k, true);
218 if (game.loc == LOC_GIANTROOM) {
221 /* This is new begavior in Open Adventure - sounds better when
222 * player isn't in the Giant Room. */
223 rspeak(WELL_POINTLESS);
225 game.foobar = WORD_EMPTY;
230 static void blast(void)
231 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
233 if (game.prop[ROD2] == STATE_NOTFOUND ||
235 rspeak(REQUIRES_DYNAMITE);
238 game.bonus = SPLATTER_MESSAGE;
239 else if (game.loc == LOC_NE)
240 game.bonus = DEFEAT_MESSAGE;
242 game.bonus = VICTORY_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, IS_FREE);
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 == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
531 (LIQUID() != WATER || !HERE(BOTTLE))) {
537 state_change(DRAGON, DRAGON_BLOODLESS);
542 if (obj != INTRANSITIVE && 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)
599 if (game.prop[URN] != URN_EMPTY) {
600 state_change(URN, URN_DARK);
602 pspeak(URN, change, URN_DARK, true);
606 state_change(LAMP, LAMP_DARK);
607 rspeak(DARK(game.loc) ?
613 rspeak(BEYOND_POWER);
616 speak(actions[verb].message);
621 static int feed(token_t verb, obj_t obj)
622 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
623 * mad. Bear, special. */
630 if (game.prop[DRAGON] != DRAGON_BARS)
631 rspeak(RIDICULOUS_ATTEMPT);
633 rspeak(NOTHING_EDIBLE);
636 if (!game.closed && HERE(BIRD)) {
638 rspeak(BIRD_DEVOURED);
640 rspeak(NOTHING_EDIBLE);
650 speak(actions[verb].message);
653 if (game.prop[BEAR] == BEAR_DEAD) {
654 rspeak(RIDICULOUS_ATTEMPT);
657 if (game.prop[BEAR] == UNTAMED_BEAR) {
660 game.fixed[AXE] = IS_FREE;
661 game.prop[AXE] = AXE_HERE;
662 state_change(BEAR, SITTING_BEAR);
664 rspeak(NOTHING_EDIBLE);
667 speak(actions[verb].message);
673 speak(actions[verb].message);
681 int fill(token_t verb, obj_t obj)
682 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
686 if (LIQLOC(game.loc) == NO_OBJECT) {
687 rspeak(FILL_INVALID);
691 rspeak(ARENT_CARRYING);
694 rspeak(SHATTER_VASE);
695 game.prop[VASE] = VASE_BROKEN;
696 game.fixed[VASE] = IS_FIXED;
697 drop(VASE, game.loc);
702 if (game.prop[URN] != URN_EMPTY) {
707 rspeak(FILL_INVALID);
713 game.prop[BOTTLE] = EMPTY_BOTTLE;
717 game.prop[URN] = URN_DARK;
718 game.prop[BOTTLE] = EMPTY_BOTTLE;
723 rspeak(FILL_INVALID);
726 game.place[k] = LOC_NOWHERE;
729 if (obj != INTRANSITIVE && obj != BOTTLE) {
730 speak(actions[verb].message);
733 if (obj == INTRANSITIVE && !HERE(BOTTLE))
736 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
740 if (LIQUID() != NO_OBJECT) {
744 if (LIQLOC(game.loc) == NO_OBJECT) {
749 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
753 game.place[LIQUID()] = CARRIED;
757 static int find(token_t verb, obj_t obj)
758 /* Find. Might be carrying it, or it might be here. Else give caveat. */
761 rspeak(ALREADY_CARRYING);
766 rspeak(NEEDED_NEARBY);
771 (LIQUID() == obj && AT(BOTTLE)) ||
772 obj == LIQLOC(game.loc) ||
773 (obj == DWARF && atdwrf(game.loc) > 0)) {
779 speak(actions[verb].message);
783 static int fly(token_t verb, obj_t obj)
784 /* Fly. Snide remarks unless hovering rug is here. */
786 if (obj == INTRANSITIVE) {
791 if (game.prop[RUG] != RUG_HOVER) {
792 rspeak(RUG_NOTHING2);
799 speak(actions[verb].message);
802 if (game.prop[RUG] != RUG_HOVER) {
803 rspeak(RUG_NOTHING1);
806 game.oldlc2 = game.oldloc;
807 game.oldloc = game.loc;
809 if (game.prop[SAPPH] == STATE_NOTFOUND) {
810 game.newloc = game.place[SAPPH];
813 game.newloc = LOC_CLIFF;
819 static int inven(void)
820 /* Inventory. If object, treat same as find. Else report on current burden. */
823 for (obj_t i = 1; i <= NOBJECTS; i++) {
831 pspeak(i, touch, -1, false);
840 static int light(token_t verb, obj_t obj)
841 /* Light. Applicable only to lamp and urn. */
843 if (obj == INTRANSITIVE) {
845 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
849 if (HERE(URN) && game.prop[URN] == URN_DARK) {
859 state_change(URN, game.prop[URN] == URN_EMPTY ?
864 if (game.limit < 0) {
868 state_change(LAMP, LAMP_BRIGHT);
873 speak(actions[verb].message);
878 static int listen(void)
879 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
881 long sound = locations[game.loc].sound;
882 if (sound != SILENT) {
884 if (!locations[game.loc].loud)
888 for (obj_t i = 1; i <= NOBJECTS; i++) {
890 objects[i].sounds[0] == NULL ||
893 int mi = game.prop[i];
894 /* FIXME: Weird magic on object states */
896 mi += 3 * game.blooded;
897 long packed_zzword = token_to_packed(game.zzword);
898 pspeak(i, hear, mi, true, packed_zzword);
900 if (i == BIRD && mi == BIRD_ENDSTATE)
908 static int lock(token_t verb, obj_t obj)
909 /* Lock, unlock, no object given. Assume various things if present. */
911 if (obj == INTRANSITIVE) {
922 if (obj == INTRANSITIVE) {
923 rspeak(NOTHING_LOCKED);
928 /* Lock, unlock object. Special stuff for opening clam/oyster
943 game.clock2 = PANICTIME;
946 state_change(GRATE, (verb == LOCK) ?
956 else if (!TOTING(TRIDENT))
957 rspeak(OYSTER_OPENER);
960 drop(OYSTER, game.loc);
961 drop(PEARL, LOC_CULDESAC);
969 rspeak(OYSTER_OPENER);
972 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
978 rspeak(CANNOT_UNLOCK);
981 speak(actions[verb].message);
987 static int pour(token_t verb, obj_t obj)
988 /* Pour. If no object, or object is bottle, assume contents of bottle.
989 * special tests for pouring water or oil on plant or rusty door. */
994 if (obj == NO_OBJECT)
997 speak(actions[verb].message);
1001 if (obj != OIL && obj != WATER) {
1005 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1006 return fill(verb, URN);
1007 game.prop[BOTTLE] = EMPTY_BOTTLE;
1008 game.place[obj] = LOC_NOWHERE;
1016 /* cycle through the three plant states */
1017 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1018 game.prop[PLANT2] = game.prop[PLANT];
1021 rspeak(SHAKING_LEAVES);
1025 state_change(DOOR, (obj == OIL) ?
1032 static int quit(void)
1033 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1035 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1036 terminate(quitgame);
1040 static int read(struct command_t command)
1041 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1043 if (command.obj == INTRANSITIVE) {
1044 command.obj = NO_OBJECT;
1045 for (int i = 1; i <= NOBJECTS; i++) {
1046 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1047 command.obj = command.obj * NOBJECTS + i;
1049 if (command.obj > NOBJECTS ||
1050 command.obj == NO_OBJECT ||
1055 if (DARK(game.loc)) {
1056 sspeak(NO_SEE, command.raw1);
1057 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1058 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1059 } else if (objects[command.obj].texts[0] == NULL ||
1060 game.prop[command.obj] == STATE_NOTFOUND) {
1061 speak(actions[command.verb].message);
1063 pspeak(command.obj, study, game.prop[command.obj], true);
1067 static int reservoir(void)
1068 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1070 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1071 rspeak(NOTHING_HAPPENS);
1075 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1079 game.oldlc2 = game.loc;
1080 game.newloc = LOC_NOWHERE;
1082 return GO_TERMINATE;
1087 static int rub(token_t verb, obj_t obj)
1088 /* Rub. Yields various snide remarks except for lit urn. */
1090 if (obj == URN && game.prop[URN] == URN_LIT) {
1092 drop(AMBER, game.loc);
1093 game.prop[AMBER] = AMBER_IN_ROCK;
1095 drop(CAVITY, game.loc);
1097 } else if (obj != LAMP) {
1098 rspeak(PECULIAR_NOTHING);
1100 speak(actions[verb].message);
1105 static int say(struct command_t *command)
1106 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1108 if (command->wd2 > 0) {
1109 command->wd1 = command->wd2;
1110 strcpy(command->raw1, command->raw2);
1112 char word1[TOKLEN + 1];
1113 packed_to_token(command->wd1, word1);
1114 int wd = (int) get_vocab_id(word1);
1115 if (wd == MOTION_WORD(XYZZY) ||
1116 wd == MOTION_WORD(PLUGH) ||
1117 wd == MOTION_WORD(PLOVER) ||
1118 wd == ACTION_WORD(FEE) ||
1119 wd == ACTION_WORD(FIE) ||
1120 wd == ACTION_WORD(FOE) ||
1121 wd == ACTION_WORD(FOO) ||
1122 wd == ACTION_WORD(FUM) ||
1123 wd == ACTION_WORD(PART)) {
1124 /* FIXME: scribbles on the interpreter's command block */
1125 wordclear(&command->wd2);
1128 sspeak(OKEY_DOKEY, command->raw1);
1132 static int throw_support(long spk)
1135 drop(AXE, game.loc);
1139 static int throw (struct command_t *command)
1140 /* Throw. Same as discard unless axe. Then same as attack except
1141 * ignore bird, and if dwarf is present then one might be killed.
1142 * (Only way to do so!) Axe also special for dragon, bear, and
1143 * troll. Treasures special for troll. */
1145 if (!TOTING(command->obj)) {
1146 speak(actions[command->verb].message);
1149 if (objects[command->obj].is_treasure && AT(TROLL)) {
1150 /* Snarf a treasure for the troll. */
1151 drop(command->obj, LOC_NOWHERE);
1152 move(TROLL, LOC_NOWHERE);
1153 move(TROLL + NOBJECTS, IS_FREE);
1154 drop(TROLL2, objects[TROLL].plac);
1155 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1157 rspeak(TROLL_SATISFIED);
1160 if (command->obj == FOOD && HERE(BEAR)) {
1161 /* But throwing food is another story. */
1162 command->obj = BEAR;
1163 return (feed(command->verb, command->obj));
1165 if (command->obj != AXE)
1166 return (discard(command->verb, command->obj));
1168 if (atdwrf(game.loc) <= 0) {
1169 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1170 return throw_support(DRAGON_SCALES);
1172 return throw_support(TROLL_RETURNS);
1174 return throw_support(OGRE_DODGE);
1175 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1176 /* This'll teach him to throw the axe at the bear! */
1177 drop(AXE, game.loc);
1178 game.fixed[AXE] = IS_FIXED;
1180 state_change(AXE, AXE_LOST);
1183 command->obj = INTRANSITIVE;
1184 return (attack(command));
1187 if (randrange(NDWARVES + 1) < game.dflag) {
1188 return throw_support(DWARF_DODGES);
1190 long i = atdwrf(game.loc);
1191 game.dseen[i] = false;
1192 game.dloc[i] = LOC_NOWHERE;
1193 return throw_support((++game.dkill == 1) ?
1200 static int wake(token_t verb, obj_t obj)
1201 /* Wake. Only use is to disturb the dwarves. */
1205 speak(actions[verb].message);
1209 return GO_DWARFWAKE;
1213 static int wave(token_t verb, obj_t obj)
1214 /* Wave. No effect unless waving rod at fissure or at bird. */
1221 speak(((!TOTING(obj)) && (obj != ROD ||
1223 arbitrary_messages[ARENT_CARRYING] :
1224 actions[verb].message);
1228 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1229 drop(JADE, game.loc);
1230 game.prop[JADE] = STATE_FOUND;
1232 rspeak(NECKLACE_FLY);
1236 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1239 return GO_DWARFWAKE;
1243 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1249 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1253 state_change(FISSURE,
1254 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1259 int action(struct command_t *command)
1260 /* Analyse a verb. Remember what it was, go back for object if second word
1261 * unless verb is "say", which snarfs arbitrary second word.
1264 if (command->part == unknown) {
1265 /* Analyse an object word. See if the thing is here, whether
1266 * we've got a verb yet, and so on. Object must be here
1267 * unless verb is "find" or "invent(ory)" (and no new verb
1268 * yet to be analysed). Water and oil are also funny, since
1269 * they are never actually dropped at any location, but might
1270 * be here inside the bottle or urn or as a feature of the
1272 if (HERE(command->obj))
1274 else if (command->obj == GRATE) {
1275 if (game.loc == LOC_START ||
1276 game.loc == LOC_VALLEY ||
1277 game.loc == LOC_SLIT) {
1278 command->obj = DPRSSN;
1280 if (game.loc == LOC_COBBLE ||
1281 game.loc == LOC_DEBRIS ||
1282 game.loc == LOC_AWKWARD ||
1283 game.loc == LOC_BIRD ||
1284 game.loc == LOC_PITTOP) {
1285 command->obj = ENTRNC;
1287 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1289 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1290 command->obj == LIQLOC(game.loc))
1292 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1295 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1296 command->obj = PLANT2;
1298 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1300 rspeak(KNIVES_VANISH);
1302 } else if (command->obj == ROD && HERE(ROD2)) {
1303 command->obj = ROD2;
1305 } else if ((command->verb == FIND ||
1306 command->verb == INVENTORY) && command->wd2 <= 0)
1309 sspeak(NO_SEE, command->raw1);
1313 if (command->wd2 > 0)
1315 if (command->verb != 0)
1316 command->part = transitive;
1319 switch (command->part) {
1321 if (command->wd2 > 0 && command->verb != SAY)
1323 if (command->verb == SAY)
1324 command->obj = command->wd2;
1325 if (command->obj == NO_OBJECT ||
1326 command->obj == INTRANSITIVE) {
1327 /* Analyse an intransitive verb (ie, no object given yet). */
1328 switch (command->verb) {
1330 return vcarry(command->verb, INTRANSITIVE);
1336 return lock(command->verb, INTRANSITIVE);
1339 return (GO_CLEAROBJ);
1342 return lock(command->verb, INTRANSITIVE);
1344 return light(command->verb, INTRANSITIVE);
1346 return extinguish(command->verb, INTRANSITIVE);
1352 speak(actions[command->verb].message);
1356 command->obj = INTRANSITIVE;
1357 return attack(command);
1359 return pour(command->verb, INTRANSITIVE);
1361 return eat(command->verb, INTRANSITIVE);
1363 return drink(command->verb, INTRANSITIVE);
1377 return fill(command->verb, INTRANSITIVE);
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