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, bool just_do_it)
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. */
451 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
454 speak(actions[verb].message);
457 if (obj == BIRD && HERE(SNAKE)) {
458 rspeak(BIRD_ATTACKS);
462 /* Set game.prop for use by travel options */
463 game.prop[SNAKE] = SNAKE_CHASED;
465 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
467 game.prop[obj] = STATE_IN_CAVITY;
468 game.prop[CAVITY] = CAVITY_FULL;
469 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
470 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
477 if (spk != RUG_WIGGLES) {
478 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
481 k = objects[SAPPH].plac;
482 move(RUG + NOBJECTS, k);
485 } else if (obj == COINS && HERE(VEND)) {
487 drop(BATTERY, game.loc);
488 pspeak(BATTERY, look, FRESH_BATTERIES, true);
490 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
494 } else if (obj == BEAR && AT(TROLL)) {
495 state_change(TROLL, TROLL_GONE);
496 move(TROLL, LOC_NOWHERE);
497 move(TROLL + NOBJECTS, LOC_NOWHERE);
498 move(TROLL2, objects[TROLL].plac);
499 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
501 } else if (obj != VASE ||
502 game.loc == objects[PILLOW].plac) {
505 state_change(VASE, AT(PILLOW)
508 if (game.prop[VASE] != VASE_WHOLE)
509 game.fixed[VASE] = IS_FIXED;
515 if (obj == BOTTLE && k != NO_OBJECT)
516 game.place[k] = LOC_NOWHERE;
517 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
518 drop(BIRD, game.loc);
522 game.prop[BIRD] = BIRD_UNCAGED;
523 if (FOREST(game.loc))
524 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
528 static int drink(token_t verb, obj_t obj)
529 /* Drink. If no object, assume water and look for it here. If water is in
530 * the bottle, drink that, else must be at a water loc, so drink stream. */
532 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
533 (LIQUID() != WATER || !HERE(BOTTLE))) {
539 state_change(DRAGON, DRAGON_BLOODLESS);
544 if (obj != NO_OBJECT && obj != WATER) {
545 rspeak(RIDICULOUS_ATTEMPT);
548 if (LIQUID() == WATER && HERE(BOTTLE)) {
549 game.place[WATER] = LOC_NOWHERE;
550 state_change(BOTTLE, EMPTY_BOTTLE);
554 speak(actions[verb].message);
558 static int eat(token_t verb, obj_t obj)
559 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
560 * ok, some things lose appetite, rest are ridiculous. */
562 if (obj == INTRANSITIVE) {
566 rspeak(THANKS_DELICIOUS);
571 rspeak(THANKS_DELICIOUS);
583 rspeak(LOST_APPETITE);
586 speak(actions[verb].message);
590 static int extinguish(token_t verb, obj_t obj)
591 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
593 if (obj == INTRANSITIVE) {
594 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
596 if (HERE(URN) && game.prop[URN] == URN_LIT)
598 if (obj == INTRANSITIVE)
603 if (game.prop[URN] != URN_EMPTY) {
604 state_change(URN, URN_DARK);
606 pspeak(URN, change, URN_DARK, true);
612 state_change(LAMP, LAMP_DARK);
613 rspeak(DARK(game.loc) ?
621 rspeak(BEYOND_POWER);
625 speak(actions[verb].message);
629 static int feed(token_t verb, obj_t obj)
630 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
631 * mad. Bear, special. */
638 if (game.prop[DRAGON] != DRAGON_BARS)
639 rspeak(RIDICULOUS_ATTEMPT);
641 rspeak(NOTHING_EDIBLE);
644 if (!game.closed && HERE(BIRD)) {
646 rspeak(BIRD_DEVOURED);
648 rspeak(NOTHING_EDIBLE);
658 speak(actions[verb].message);
661 if (game.prop[BEAR] == BEAR_DEAD) {
662 rspeak(RIDICULOUS_ATTEMPT);
665 if (game.prop[BEAR] == UNTAMED_BEAR) {
668 game.fixed[AXE] = IS_FREE;
669 game.prop[AXE] = AXE_HERE;
670 state_change(BEAR, SITTING_BEAR);
672 rspeak(NOTHING_EDIBLE);
675 speak(actions[verb].message);
681 speak(actions[verb].message);
689 int fill(token_t verb, obj_t obj)
690 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
694 if (LIQLOC(game.loc) == NO_OBJECT) {
695 rspeak(FILL_INVALID);
699 rspeak(ARENT_CARRYING);
702 rspeak(SHATTER_VASE);
703 game.prop[VASE] = VASE_BROKEN;
704 game.fixed[VASE] = IS_FIXED;
705 return (discard(verb, VASE, true));
709 if (game.prop[URN] != URN_EMPTY) {
714 rspeak(FILL_INVALID);
720 game.prop[BOTTLE] = EMPTY_BOTTLE;
724 game.prop[URN] = URN_DARK;
725 game.prop[BOTTLE] = EMPTY_BOTTLE;
730 rspeak(FILL_INVALID);
733 game.place[k] = LOC_NOWHERE;
736 if (obj != NO_OBJECT && obj != BOTTLE) {
737 speak(actions[verb].message);
740 if (obj == NO_OBJECT && !HERE(BOTTLE))
743 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
747 if (LIQUID() != NO_OBJECT) {
751 if (LIQLOC(game.loc) == NO_OBJECT) {
756 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
760 game.place[LIQUID()] = CARRIED;
764 static int find(token_t verb, obj_t obj)
765 /* Find. Might be carrying it, or it might be here. Else give caveat. */
768 rspeak(ALREADY_CARRYING);
773 rspeak(NEEDED_NEARBY);
778 (LIQUID() == obj && AT(BOTTLE)) ||
779 obj == LIQLOC(game.loc) ||
780 (obj == DWARF && atdwrf(game.loc) > 0)) {
786 speak(actions[verb].message);
790 static int fly(token_t verb, obj_t obj)
791 /* Fly. Snide remarks unless hovering rug is here. */
793 if (obj == INTRANSITIVE) {
798 if (game.prop[RUG] != RUG_HOVER) {
799 rspeak(RUG_NOTHING2);
806 speak(actions[verb].message);
809 if (game.prop[RUG] != RUG_HOVER) {
810 rspeak(RUG_NOTHING1);
813 game.oldlc2 = game.oldloc;
814 game.oldloc = game.loc;
816 if (game.prop[SAPPH] == STATE_NOTFOUND) {
817 game.newloc = game.place[SAPPH];
820 game.newloc = LOC_CLIFF;
826 static int inven(void)
827 /* Inventory. If object, treat same as find. Else report on current burden. */
830 for (obj_t i = 1; i <= NOBJECTS; i++) {
838 pspeak(i, touch, -1, false);
847 static int light(token_t verb, obj_t obj)
848 /* Light. Applicable only to lamp and urn. */
850 if (obj == INTRANSITIVE) {
851 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
853 if (HERE(URN) && game.prop[URN] == URN_DARK)
855 if (obj == INTRANSITIVE ||
856 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
857 HERE(URN) && game.prop[URN] == URN_DARK))
862 state_change(URN, game.prop[URN] == URN_EMPTY ?
868 speak(actions[verb].message);
871 if (game.limit < 0) {
875 state_change(LAMP, LAMP_BRIGHT);
883 static int listen(void)
884 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
886 long sound = locations[game.loc].sound;
887 if (sound != SILENT) {
889 if (!locations[game.loc].loud)
893 for (obj_t i = 1; i <= NOBJECTS; i++) {
895 objects[i].sounds[0] == NULL ||
898 int mi = game.prop[i];
899 /* FIXME: Weird magic on object states */
901 mi += 3 * game.blooded;
902 long packed_zzword = token_to_packed(game.zzword);
903 pspeak(i, hear, mi, true, packed_zzword);
905 if (i == BIRD && mi == BIRD_ENDSTATE)
913 static int lock(token_t verb, obj_t obj)
914 /* Lock, unlock, no object given. Assume various things if present. */
916 if (obj == INTRANSITIVE) {
927 if (obj == INTRANSITIVE) {
928 rspeak(NOTHING_LOCKED);
933 /* Lock, unlock object. Special stuff for opening clam/oyster
943 game.clock2 = PANICTIME;
947 state_change(GRATE, (verb == LOCK) ?
961 else if (!TOTING(TRIDENT))
962 rspeak(OYSTER_OPENER);
965 drop(OYSTER, game.loc);
966 drop(PEARL, LOC_CULDESAC);
974 rspeak(OYSTER_OPENER);
978 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
984 rspeak(CANNOT_UNLOCK);
987 speak(actions[verb].message);
993 static int pour(token_t verb, obj_t obj)
994 /* Pour. If no object, or object is bottle, assume contents of bottle.
995 * special tests for pouring water or oil on plant or rusty door. */
1000 if (obj == NO_OBJECT)
1003 speak(actions[verb].message);
1007 if (obj != OIL && obj != WATER) {
1011 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1012 return fill(verb, URN);
1013 game.prop[BOTTLE] = EMPTY_BOTTLE;
1014 game.place[obj] = LOC_NOWHERE;
1022 /* cycle through the three plant states */
1023 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1024 game.prop[PLANT2] = game.prop[PLANT];
1027 rspeak(SHAKING_LEAVES);
1031 state_change(DOOR, (obj == OIL) ?
1038 static int quit(void)
1039 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1041 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1042 terminate(quitgame);
1046 static int read(struct command_t command)
1047 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1049 if (command.obj == INTRANSITIVE) {
1050 command.obj = NO_OBJECT;
1051 for (int i = 1; i <= NOBJECTS; i++) {
1052 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1053 command.obj = command.obj * NOBJECTS + i;
1055 if (command.obj > NOBJECTS ||
1056 command.obj == NO_OBJECT ||
1061 if (DARK(game.loc)) {
1062 sspeak(NO_SEE, command.raw1);
1063 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1064 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1065 } else if (objects[command.obj].texts[0] == NULL ||
1066 game.prop[command.obj] == STATE_NOTFOUND) {
1067 speak(actions[command.verb].message);
1069 pspeak(command.obj, study, game.prop[command.obj], true);
1073 static int reservoir(void)
1074 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1076 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1077 rspeak(NOTHING_HAPPENS);
1081 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1085 game.oldlc2 = game.loc;
1086 game.newloc = LOC_NOWHERE;
1088 return GO_TERMINATE;
1093 static int rub(token_t verb, obj_t obj)
1094 /* Rub. Yields various snide remarks except for lit urn. */
1096 if (obj == URN && game.prop[URN] == URN_LIT) {
1098 drop(AMBER, game.loc);
1099 game.prop[AMBER] = AMBER_IN_ROCK;
1101 drop(CAVITY, game.loc);
1103 } else if (obj != LAMP) {
1104 rspeak(PECULIAR_NOTHING);
1106 speak(actions[verb].message);
1111 static int say(struct command_t *command)
1112 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1114 if (command->wd2 > 0) {
1115 command->wd1 = command->wd2;
1116 strcpy(command->raw1, command->raw2);
1118 char word1[TOKLEN + 1];
1119 packed_to_token(command->wd1, word1);
1120 int wd = (int) get_vocab_id(word1);
1121 if (wd == MOTION_WORD(XYZZY) ||
1122 wd == MOTION_WORD(PLUGH) ||
1123 wd == MOTION_WORD(PLOVER) ||
1124 wd == ACTION_WORD(FEE) ||
1125 wd == ACTION_WORD(FIE) ||
1126 wd == ACTION_WORD(FOE) ||
1127 wd == ACTION_WORD(FOO) ||
1128 wd == ACTION_WORD(FUM) ||
1129 wd == ACTION_WORD(PART)) {
1130 /* FIXME: scribbles on the interpreter's command block */
1131 wordclear(&command->wd2);
1134 sspeak(OKEY_DOKEY, command->raw1);
1138 static int throw_support(long spk)
1141 drop(AXE, game.loc);
1145 static int throw (struct command_t *command)
1146 /* Throw. Same as discard unless axe. Then same as attack except
1147 * ignore bird, and if dwarf is present then one might be killed.
1148 * (Only way to do so!) Axe also special for dragon, bear, and
1149 * troll. Treasures special for troll. */
1151 if (!TOTING(command->obj)) {
1152 speak(actions[command->verb].message);
1155 if (objects[command->obj].is_treasure && AT(TROLL)) {
1156 /* Snarf a treasure for the troll. */
1157 drop(command->obj, LOC_NOWHERE);
1158 move(TROLL, LOC_NOWHERE);
1159 move(TROLL + NOBJECTS, LOC_NOWHERE);
1160 drop(TROLL2, objects[TROLL].plac);
1161 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1163 rspeak(TROLL_SATISFIED);
1166 if (command->obj == FOOD && HERE(BEAR)) {
1167 /* But throwing food is another story. */
1168 command->obj = BEAR;
1169 return (feed(command->verb, command->obj));
1171 if (command->obj != AXE)
1172 return (discard(command->verb, command->obj, false));
1174 if (atdwrf(game.loc) <= 0) {
1175 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1176 return throw_support(DRAGON_SCALES);
1178 return throw_support(TROLL_RETURNS);
1180 return throw_support(OGRE_DODGE);
1181 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1182 /* This'll teach him to throw the axe at the bear! */
1183 drop(AXE, game.loc);
1184 game.fixed[AXE] = IS_FIXED;
1186 state_change(AXE, AXE_LOST);
1189 command->obj = NO_OBJECT;
1190 return (attack(command));
1193 if (randrange(NDWARVES + 1) < game.dflag) {
1194 return throw_support(DWARF_DODGES);
1196 long i = atdwrf(game.loc);
1197 game.dseen[i] = false;
1198 game.dloc[i] = LOC_NOWHERE;
1199 return throw_support((++game.dkill == 1) ?
1206 static int wake(token_t verb, obj_t obj)
1207 /* Wake. Only use is to disturb the dwarves. */
1211 speak(actions[verb].message);
1215 return GO_DWARFWAKE;
1219 static int wave(token_t verb, obj_t obj)
1220 /* Wave. No effect unless waving rod at fissure or at bird. */
1227 speak(((!TOTING(obj)) && (obj != ROD ||
1229 arbitrary_messages[ARENT_CARRYING] :
1230 actions[verb].message);
1234 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1235 drop(JADE, game.loc);
1236 game.prop[JADE] = STATE_FOUND;
1238 rspeak(NECKLACE_FLY);
1242 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1245 return GO_DWARFWAKE;
1249 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1255 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1259 state_change(FISSURE,
1260 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1265 int action(struct command_t *command)
1266 /* Analyse a verb. Remember what it was, go back for object if second word
1267 * unless verb is "say", which snarfs arbitrary second word.
1270 if (command->part == unknown) {
1271 /* Analyse an object word. See if the thing is here, whether
1272 * we've got a verb yet, and so on. Object must be here
1273 * unless verb is "find" or "invent(ory)" (and no new verb
1274 * yet to be analysed). Water and oil are also funny, since
1275 * they are never actually dropped at any location, but might
1276 * be here inside the bottle or urn or as a feature of the
1278 if (HERE(command->obj))
1280 else if (command->obj == GRATE) {
1281 if (game.loc == LOC_START ||
1282 game.loc == LOC_VALLEY ||
1283 game.loc == LOC_SLIT) {
1284 command->obj = DPRSSN;
1286 if (game.loc == LOC_COBBLE ||
1287 game.loc == LOC_DEBRIS ||
1288 game.loc == LOC_AWKWARD ||
1289 game.loc == LOC_BIRD ||
1290 game.loc == LOC_PITTOP) {
1291 command->obj = ENTRNC;
1293 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1295 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1296 command->obj == LIQLOC(game.loc))
1298 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1301 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1302 command->obj = PLANT2;
1304 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1306 rspeak(KNIVES_VANISH);
1308 } else if (command->obj == ROD && HERE(ROD2)) {
1309 command->obj = ROD2;
1311 } else if ((command->verb == FIND ||
1312 command->verb == INVENTORY) && command->wd2 <= 0)
1315 sspeak(NO_SEE, command->raw1);
1319 if (command->wd2 > 0)
1321 if (command->verb != 0)
1322 command->part = transitive;
1325 switch (command->part) {
1327 if (command->wd2 > 0 && command->verb != SAY)
1329 if (command->verb == SAY)
1330 command->obj = command->wd2;
1331 if (command->obj == NO_OBJECT ||
1332 command->obj == INTRANSITIVE) {
1333 /* Analyse an intransitive verb (ie, no object given yet). */
1334 switch (command->verb) {
1336 return vcarry(command->verb, INTRANSITIVE);
1342 return lock(command->verb, INTRANSITIVE);
1345 return (GO_CLEAROBJ);
1348 return lock(command->verb, INTRANSITIVE);
1350 return light(command->verb, INTRANSITIVE);
1352 return extinguish(command->verb, INTRANSITIVE);
1358 speak(actions[command->verb].message);
1362 return attack(command);
1364 return pour(command->verb, command->obj);
1366 return eat(command->verb, INTRANSITIVE);
1368 return drink(command->verb, command->obj);
1382 return fill(command->verb, command->obj);
1394 return bigwords(command->id1);
1398 command->obj = INTRANSITIVE;
1399 return read(*command);
1409 return fly(command->verb, INTRANSITIVE);
1415 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1420 /* Analyse a transitive verb. */
1421 switch (command->verb) {
1423 return vcarry(command->verb, command->obj);
1425 return discard(command->verb, command->obj, false);
1427 return say(command);
1429 return lock(command->verb, command->obj);
1432 return (GO_CLEAROBJ);
1435 return lock(command->verb, command->obj);
1437 return light(command->verb, command->obj);
1439 return extinguish(command->verb, command->obj);
1441 return wave(command->verb, command->obj);
1443 speak(actions[command->verb].message);
1447 speak(actions[command->verb].message);
1451 return attack(command);
1453 return pour(command->verb, command->obj);
1455 return eat(command->verb, command->obj);
1457 return drink(command->verb, command->obj);
1459 return rub(command->verb, command->obj);
1461 return throw (command);
1463 speak(actions[command->verb].message);
1467 return find(command->verb, command->obj);
1469 return find(command->verb, command->obj);
1471 return feed(command->verb, command->obj);
1473 return fill(command->verb, command->obj);
1478 speak(actions[command->verb].message);
1486 speak(actions[command->verb].message);
1490 speak(actions[command->verb].message);
1494 return read(*command);
1496 return vbreak(command->verb, command->obj);
1498 return wake(command->verb, command->obj);
1500 speak(actions[command->verb].message);
1504 speak(actions[command->verb].message);
1508 return fly(command->verb, command->obj);
1510 speak(actions[command->verb].message);
1516 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1519 /* Unknown verb, couldn't deduce object - might need hint */
1520 sspeak(WHAT_DO, command->raw1);
1521 return GO_CHECKHINT;
1523 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE