2 * Actions for the duneon-running code.
4 * Copyright (c) 1977, 2005 by Will Crowther and Don Woods
5 * Copyright (c) 2017 by Eric S. Raymond
6 * SPDX-License-Identifier: BSD-2-clause
16 static phase_codes_t fill(verb_t, obj_t);
18 static phase_codes_t attack(command_t command)
19 /* Attack. Assume target if unambiguous. "Throw" also links here.
20 * Attackable objects fall into two categories: enemies (snake,
21 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
22 * enemies, or no enemies but 2 others. */
24 verb_t verb = command.verb;
25 obj_t obj = command.obj;
27 if (obj == INTRANSITIVE) {
29 if (atdwrf(game.loc) > 0) {
37 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
49 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
53 /* check for low-priority targets */
54 if (obj == INTRANSITIVE) {
55 /* Can't attack bird or machine by throwing axe. */
56 if (HERE(BIRD) && verb != THROW) {
60 if (HERE(VEND) && verb != THROW) {
64 /* Clam and oyster both treated as clam for intransitive case;
66 if (HERE(CLAM) || HERE(OYSTER)) {
86 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
92 switch (game.prop[BEAR]) {
97 rspeak(BEAR_CONFUSED);
100 rspeak(BEAR_CONFUSED);
103 rspeak(ALREADY_DEAD);
108 if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
109 /* Fun stuff for dragon. If he insists on attacking it, win!
110 * Set game.prop to dead, move dragon to central loc (still
111 * fixed), move rug there (not fixed), and move him there,
112 * too. Then do a null motion to get new description. */
113 rspeak(BARE_HANDS_QUERY);
115 speak(arbitrary_messages[NASTY_DRAGON]);
118 state_change(DRAGON, DRAGON_DEAD);
119 game.prop[RUG] = RUG_FLOOR;
120 /* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.
121 * The way it was computed before was worse; it depended on the
122 * two dragon locations being LOC_SECRET4 and LOC_SECRET6 and
123 * LOC_SECRET5 being right between them.
125 move(DRAGON + NOBJECTS, IS_FIXED);
126 move(RUG + NOBJECTS, IS_FREE);
127 move(DRAGON, LOC_SECRET5);
128 move(RUG, LOC_SECRET5);
129 drop(BLOOD, LOC_SECRET5);
130 for (obj_t i = 1; i <= NOBJECTS; i++) {
131 if (game.place[i] == objects[DRAGON].plac ||
132 game.place[i] == objects[DRAGON].fixd)
133 move(i, LOC_SECRET5);
135 game.loc = LOC_SECRET5;
141 if (atdwrf(game.loc) == 0)
144 rspeak(KNIFE_THROWN);
147 for (int i = 1; i < PIRATE; i++) {
148 if (game.dloc[i] == game.loc) {
150 game.dloc[i] = LOC_LONGWEST;
151 game.dseen[i] = false;
154 rspeak((dwarves > 1) ?
166 rspeak(SHELL_IMPERVIOUS);
169 rspeak(SNAKE_WARNING);
175 rspeak(BARE_HANDS_QUERY);
178 rspeak(ALREADY_DEAD);
184 speak(actions[verb].message);
189 static phase_codes_t bigwords(vocab_t id)
190 /* Only called on FEE FIE FOE FOO (AND FUM). Advance to next state if given
191 * in proper order. Look up foo in special section of vocab to determine which
192 * word we've got. Last word zips the eggs back to the giant room (unless
195 if ((game.foobar == WORD_EMPTY && id == FEE) ||
196 (game.foobar == FEE && id == FIE) ||
197 (game.foobar == FIE && id == FOE) ||
198 (game.foobar == FOE && id == FOO) ||
199 (game.foobar == FOE && id == FUM)) {
201 if ((id != FOO) && (id != FUM)) {
205 game.foobar = WORD_EMPTY;
206 if (game.place[EGGS] == objects[EGGS].plac ||
207 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
208 rspeak(NOTHING_HAPPENS);
210 } else if (id == FUM) {
213 /* Bring back troll if we steal the eggs back from him before
215 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
216 game.prop[TROLL] = TROLL_PAIDONCE;
218 pspeak(EGGS, look, true, EGGS_VANISHED);
219 else if (game.loc == objects[EGGS].plac)
220 pspeak(EGGS, look, true, EGGS_HERE);
222 pspeak(EGGS, look, true, EGGS_DONE);
223 move(EGGS, objects[EGGS].plac);
229 if (game.loc == LOC_GIANTROOM) {
232 /* This is new behavior in Open Adventure - sounds better when
233 * player isn't in the Giant Room. */
234 rspeak(NOTHING_HAPPENS);
236 game.foobar = WORD_EMPTY;
241 static void blast(void)
242 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
244 if (game.prop[ROD2] == STATE_NOTFOUND ||
246 rspeak(REQUIRES_DYNAMITE);
249 game.bonus = splatter;
250 rspeak(SPLATTER_MESSAGE);
251 } else if (game.loc == LOC_NE) {
253 rspeak(DEFEAT_MESSAGE);
255 game.bonus = victory;
256 rspeak(VICTORY_MESSAGE);
262 static phase_codes_t vbreak(verb_t verb, obj_t obj)
263 /* Break. Only works for mirror in repository and, of course, the vase. */
268 state_change(MIRROR, MIRROR_BROKEN);
275 if (game.prop[VASE] == VASE_WHOLE) {
277 drop(VASE, game.loc);
278 state_change(VASE, VASE_BROKEN);
279 game.fixed[VASE] = IS_FIXED;
284 speak(actions[verb].message);
286 return (GO_CLEAROBJ);
289 static phase_codes_t brief(void)
290 /* Brief. Intransitive only. Suppress full descriptions after first time. */
294 rspeak(BRIEF_CONFIRM);
298 static phase_codes_t vcarry(verb_t verb, obj_t obj)
299 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
300 * take one without the other). Liquids also special, since they depend on
301 * status of bottle. Also various side effects, etc. */
303 if (obj == INTRANSITIVE) {
304 /* Carry, no object given yet. OK if only one object present. */
305 if (game.atloc[game.loc] == NO_OBJECT ||
306 game.link[game.atloc[game.loc]] != 0 ||
307 atdwrf(game.loc) > 0)
309 obj = game.atloc[game.loc];
313 speak(actions[verb].message);
318 rspeak(REMOVE_MESSAGE);
323 if (game.fixed[obj] != IS_FREE) {
326 /* Next guard tests whether plant is tiny or stashed */
327 rspeak(game.prop[PLANT] <= PLANT_THIRSTY ? DEEP_ROOTS : YOU_JOKING);
330 rspeak( game.prop[BEAR] == SITTING_BEAR ? BEAR_CHAINED : YOU_JOKING);
333 rspeak( game.prop[BEAR] != UNTAMED_BEAR ? STILL_LOCKED : YOU_JOKING);
336 rspeak(game.prop[RUG] == RUG_HOVER ? RUG_HOVERS : YOU_JOKING);
342 rspeak(DOUGHNUT_HOLES);
348 rspeak(HAND_PASSTHROUGH);
360 if (!TOTING(BOTTLE)) {
361 rspeak(NO_CONTAINER);
364 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
365 return (fill(verb, BOTTLE));
373 if (game.holdng >= INVLIMIT) {
379 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
380 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
386 rspeak(CANNOT_CARRY);
393 game.prop[BIRD] = BIRD_CAGED;
397 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) {
398 /* expression maps BIRD to CAGE and CAGE to BIRD */
399 carry(BIRD + CAGE - obj, game.loc);
402 carry(obj, game.loc);
404 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
405 game.place[LIQUID()] = CARRIED;
407 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
408 game.prop[obj] = STATE_FOUND;
409 game.prop[CAVITY] = CAVITY_EMPTY;
415 static int chain(verb_t verb)
416 /* Do something to the bear's chain */
419 if (game.prop[BEAR] == UNTAMED_BEAR) {
423 if (game.prop[CHAIN] == CHAIN_HEAP) {
424 rspeak(ALREADY_UNLOCKED);
427 game.prop[CHAIN] = CHAIN_HEAP;
428 game.fixed[CHAIN] = IS_FREE;
429 if (game.prop[BEAR] != BEAR_DEAD)
430 game.prop[BEAR] = CONTENTED_BEAR;
432 switch (game.prop[BEAR]) {
435 /* Can't be reached until the bear can die in some way other
436 * than a bridge collapse. Leave in in case this changes, but
437 * exclude from coverage testing. */
438 game.fixed[BEAR] = IS_FIXED;
442 game.fixed[BEAR] = IS_FREE;
444 rspeak(CHAIN_UNLOCKED);
448 if (game.prop[CHAIN] != CHAIN_HEAP) {
449 rspeak(ALREADY_LOCKED);
452 if (game.loc != objects[CHAIN].plac) {
457 game.prop[CHAIN] = CHAIN_FIXED;
460 drop(CHAIN, game.loc);
461 game.fixed[CHAIN] = IS_FIXED;
463 rspeak(CHAIN_LOCKED);
467 static phase_codes_t discard(verb_t verb, obj_t obj)
468 /* Discard object. "Throw" also comes here for most objects. Special cases for
469 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
470 * Drop coins at vending machine for extra batteries. */
472 if (obj == ROD && !TOTING(ROD) && TOTING(ROD2)) {
477 speak(actions[verb].message);
481 if (GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL) {
483 game.prop[obj] = STATE_IN_CAVITY;
484 game.prop[CAVITY] = CAVITY_FULL;
485 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
486 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
489 else if (TOTING(RUG))
493 if (!TOTING(RUG) || obj == RUBY) {
494 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
497 k = objects[SAPPH].plac;
498 move(RUG + NOBJECTS, k);
505 if (obj == COINS && HERE(VEND)) {
507 drop(BATTERY, game.loc);
508 pspeak(BATTERY, look, true, FRESH_BATTERIES);
514 if (obj == BOTTLE && LIQUID() != NO_OBJECT) {
515 game.place[LIQUID()] = LOC_NOWHERE;
518 if (obj == BEAR && AT(TROLL)) {
519 state_change(TROLL, TROLL_GONE);
520 move(TROLL, LOC_NOWHERE);
521 move(TROLL + NOBJECTS, IS_FREE);
522 move(TROLL2, objects[TROLL].plac);
523 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
530 if (game.loc != objects[PILLOW].plac) {
531 state_change(VASE, AT(PILLOW)
534 if (game.prop[VASE] != VASE_WHOLE)
535 game.fixed[VASE] = IS_FIXED;
541 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) {
542 drop(BIRD, game.loc);
546 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
552 rspeak(BIRD_ATTACKS);
556 /* Set game.prop for use by travel options */
557 game.prop[SNAKE] = SNAKE_CHASED;
561 game.prop[BIRD] = FOREST(game.loc) ? BIRD_FOREST_UNCAGED : BIRD_UNCAGED;
571 static phase_codes_t drink(verb_t verb, obj_t obj)
572 /* Drink. If no object, assume water and look for it here. If water is in
573 * the bottle, drink that, else must be at a water loc, so drink stream. */
575 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
576 (LIQUID() != WATER || !HERE(BOTTLE))) {
582 state_change(DRAGON, DRAGON_BLOODLESS);
587 if (obj != INTRANSITIVE && obj != WATER) {
588 rspeak(RIDICULOUS_ATTEMPT);
591 if (LIQUID() == WATER && HERE(BOTTLE)) {
592 game.place[WATER] = LOC_NOWHERE;
593 state_change(BOTTLE, EMPTY_BOTTLE);
597 speak(actions[verb].message);
601 static phase_codes_t eat(verb_t verb, obj_t obj)
602 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
603 * ok, some things lose appetite, rest are ridiculous. */
612 rspeak(THANKS_DELICIOUS);
623 rspeak(LOST_APPETITE);
626 speak(actions[verb].message);
631 static phase_codes_t extinguish(verb_t verb, obj_t obj)
632 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
634 if (obj == INTRANSITIVE) {
635 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
637 if (HERE(URN) && game.prop[URN] == URN_LIT)
639 if (obj == INTRANSITIVE)
645 if (game.prop[URN] != URN_EMPTY) {
646 state_change(URN, URN_DARK);
648 pspeak(URN, change, true, URN_DARK);
652 state_change(LAMP, LAMP_DARK);
653 rspeak(DARK(game.loc) ?
659 rspeak(BEYOND_POWER);
662 speak(actions[verb].message);
667 static phase_codes_t feed(verb_t verb, obj_t obj)
668 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
669 * mad. Bear, special. */
676 if (game.prop[DRAGON] != DRAGON_BARS)
677 rspeak(RIDICULOUS_ATTEMPT);
679 rspeak(NOTHING_EDIBLE);
682 if (!game.closed && HERE(BIRD)) {
684 rspeak(BIRD_DEVOURED);
686 rspeak(NOTHING_EDIBLE);
696 speak(actions[verb].message);
699 if (game.prop[BEAR] == BEAR_DEAD) {
700 rspeak(RIDICULOUS_ATTEMPT);
703 if (game.prop[BEAR] == UNTAMED_BEAR) {
706 game.fixed[AXE] = IS_FREE;
707 game.prop[AXE] = AXE_HERE;
708 state_change(BEAR, SITTING_BEAR);
710 rspeak(NOTHING_EDIBLE);
713 speak(actions[verb].message);
719 speak(actions[verb].message);
727 phase_codes_t fill(verb_t verb, obj_t obj)
728 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
732 if (LIQLOC(game.loc) == NO_OBJECT) {
733 rspeak(FILL_INVALID);
737 rspeak(ARENT_CARRYING);
740 rspeak(SHATTER_VASE);
741 game.prop[VASE] = VASE_BROKEN;
742 game.fixed[VASE] = IS_FIXED;
743 drop(VASE, game.loc);
748 if (game.prop[URN] != URN_EMPTY) {
753 rspeak(FILL_INVALID);
759 game.prop[BOTTLE] = EMPTY_BOTTLE;
763 game.prop[URN] = URN_DARK;
764 game.prop[BOTTLE] = EMPTY_BOTTLE;
769 rspeak(FILL_INVALID);
772 game.place[k] = LOC_NOWHERE;
775 if (obj != INTRANSITIVE && obj != BOTTLE) {
776 speak(actions[verb].message);
779 if (obj == INTRANSITIVE && !HERE(BOTTLE))
782 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
786 if (LIQUID() != NO_OBJECT) {
790 if (LIQLOC(game.loc) == NO_OBJECT) {
795 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
799 game.place[LIQUID()] = CARRIED;
803 static phase_codes_t find(verb_t verb, obj_t obj)
804 /* Find. Might be carrying it, or it might be here. Else give caveat. */
807 rspeak(ALREADY_CARRYING);
812 rspeak(NEEDED_NEARBY);
817 (LIQUID() == obj && AT(BOTTLE)) ||
818 obj == LIQLOC(game.loc) ||
819 (obj == DWARF && atdwrf(game.loc) > 0)) {
825 speak(actions[verb].message);
829 static phase_codes_t fly(verb_t verb, obj_t obj)
830 /* Fly. Snide remarks unless hovering rug is here. */
832 if (obj == INTRANSITIVE) {
837 if (game.prop[RUG] != RUG_HOVER) {
838 rspeak(RUG_NOTHING2);
845 speak(actions[verb].message);
848 if (game.prop[RUG] != RUG_HOVER) {
849 rspeak(RUG_NOTHING1);
853 if (game.loc == LOC_CLIFF) {
854 game.oldlc2 = game.oldloc;
855 game.oldloc = game.loc;
856 game.newloc = LOC_LEDGE;
858 } else if (game.loc == LOC_LEDGE) {
859 game.oldlc2 = game.oldloc;
860 game.oldloc = game.loc;
861 game.newloc = LOC_CLIFF;
864 /* should never happen */
865 rspeak(NOTHING_HAPPENS);
870 static phase_codes_t inven(void)
871 /* Inventory. If object, treat same as find. Else report on current burden. */
874 for (obj_t i = 1; i <= NOBJECTS; i++) {
882 pspeak(i, touch, false, -1);
891 static phase_codes_t light(verb_t verb, obj_t obj)
892 /* Light. Applicable only to lamp and urn. */
894 if (obj == INTRANSITIVE) {
896 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
900 if (HERE(URN) && game.prop[URN] == URN_DARK) {
910 state_change(URN, game.prop[URN] == URN_EMPTY ?
915 if (game.limit < 0) {
919 state_change(LAMP, LAMP_BRIGHT);
924 speak(actions[verb].message);
929 static phase_codes_t listen(void)
930 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
932 bool soundlatch = false;
933 vocab_t sound = locations[game.loc].sound;
934 if (sound != SILENT) {
936 if (!locations[game.loc].loud)
940 for (obj_t i = 1; i <= NOBJECTS; i++) {
942 objects[i].sounds[0] == NULL ||
945 int mi = game.prop[i];
946 /* (ESR) Some unpleasant magic on object states here. Ideally
947 * we'd have liked the bird to be a normal object that we can
948 * use state_change() on; can't do it, because there are
949 * actually two different series of per-state birdsounds
950 * depending on whether player has drunk dragon's blood. */
952 mi += 3 * game.blooded;
953 pspeak(i, hear, true, mi, game.zzword);
955 if (i == BIRD && mi == BIRD_ENDSTATE)
964 static phase_codes_t lock(verb_t verb, obj_t obj)
965 /* Lock, unlock, no object given. Assume various things if present. */
967 if (obj == INTRANSITIVE) {
978 if (obj == INTRANSITIVE) {
979 rspeak(NOTHING_LOCKED);
984 /* Lock, unlock object. Special stuff for opening clam/oyster
999 game.clock2 = PANICTIME;
1002 state_change(GRATE, (verb == LOCK) ?
1012 else if (TOTING(CLAM))
1014 else if (!TOTING(TRIDENT))
1015 rspeak(CLAM_OPENER);
1018 drop(OYSTER, game.loc);
1019 drop(PEARL, LOC_CULDESAC);
1020 rspeak(PEARL_FALLS);
1026 else if (TOTING(OYSTER))
1027 rspeak(DROP_OYSTER);
1028 else if (!TOTING(TRIDENT))
1029 rspeak(OYSTER_OPENER);
1031 rspeak(OYSTER_OPENS);
1034 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
1040 rspeak(CANNOT_UNLOCK);
1043 speak(actions[verb].message);
1049 static phase_codes_t pour(verb_t verb, obj_t obj)
1050 /* Pour. If no object, or object is bottle, assume contents of bottle.
1051 * special tests for pouring water or oil on plant or rusty door. */
1053 if (obj == BOTTLE ||
1054 obj == INTRANSITIVE)
1056 if (obj == NO_OBJECT)
1059 speak(actions[verb].message);
1063 if (obj != OIL && obj != WATER) {
1067 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1068 return fill(verb, URN);
1069 game.prop[BOTTLE] = EMPTY_BOTTLE;
1070 game.place[obj] = LOC_NOWHERE;
1078 /* cycle through the three plant states */
1079 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1080 game.prop[PLANT2] = game.prop[PLANT];
1083 rspeak(SHAKING_LEAVES);
1087 state_change(DOOR, (obj == OIL) ?
1094 static phase_codes_t quit(void)
1095 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1097 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1098 terminate(quitgame);
1102 static phase_codes_t read(command_t command)
1103 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1105 if (command.obj == INTRANSITIVE) {
1106 command.obj = NO_OBJECT;
1107 for (int i = 1; i <= NOBJECTS; i++) {
1108 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1109 command.obj = command.obj * NOBJECTS + i;
1111 if (command.obj > NOBJECTS ||
1112 command.obj == NO_OBJECT ||
1117 if (DARK(game.loc)) {
1118 sspeak(NO_SEE, command.word[0].raw);
1119 } else if (command.obj == OYSTER) {
1120 if (!TOTING(OYSTER) || !game.closed) {
1121 rspeak(DONT_UNDERSTAND);
1122 } else if (!game.clshnt) {
1123 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1124 } else if (game.clshnt) {
1125 pspeak(OYSTER, hear, true, 1); // Not really a sound, but oh well.
1127 } else if (objects[command.obj].texts[0] == NULL ||
1128 game.prop[command.obj] == STATE_NOTFOUND) {
1129 speak(actions[command.verb].message);
1131 pspeak(command.obj, study, true, game.prop[command.obj]);
1135 static phase_codes_t reservoir(void)
1136 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1138 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1139 rspeak(NOTHING_HAPPENS);
1143 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1147 game.oldlc2 = game.loc;
1148 game.newloc = LOC_NOWHERE;
1150 return GO_TERMINATE;
1155 static phase_codes_t rub(verb_t verb, obj_t obj)
1156 /* Rub. Yields various snide remarks except for lit urn. */
1158 if (obj == URN && game.prop[URN] == URN_LIT) {
1160 drop(AMBER, game.loc);
1161 game.prop[AMBER] = AMBER_IN_ROCK;
1163 drop(CAVITY, game.loc);
1165 } else if (obj != LAMP) {
1166 rspeak(PECULIAR_NOTHING);
1168 speak(actions[verb].message);
1173 static phase_codes_t say(command_t command)
1174 /* Say. Echo WD2. Magic words override. */
1176 if (command.word[1].type == MOTION &&
1177 (command.word[1].id == XYZZY ||
1178 command.word[1].id == PLUGH ||
1179 command.word[1].id == PLOVER)) {
1182 if (command.word[1].type == ACTION && command.word[1].id == PART)
1185 if (command.word[1].type == ACTION &&
1186 (command.word[1].id == FEE ||
1187 command.word[1].id == FIE ||
1188 command.word[1].id == FOE ||
1189 command.word[1].id == FOO ||
1190 command.word[1].id == FUM ||
1191 command.word[1].id == PART)) {
1192 return bigwords(command.word[1].id);
1194 sspeak(OKEY_DOKEY, command.word[1].raw);
1198 static phase_codes_t throw_support(vocab_t spk)
1201 drop(AXE, game.loc);
1205 static phase_codes_t throw (command_t command)
1206 /* Throw. Same as discard unless axe. Then same as attack except
1207 * ignore bird, and if dwarf is present then one might be killed.
1208 * (Only way to do so!) Axe also special for dragon, bear, and
1209 * troll. Treasures special for troll. */
1211 if (!TOTING(command.obj)) {
1212 speak(actions[command.verb].message);
1215 if (objects[command.obj].is_treasure && AT(TROLL)) {
1216 /* Snarf a treasure for the troll. */
1217 drop(command.obj, LOC_NOWHERE);
1218 move(TROLL, LOC_NOWHERE);
1219 move(TROLL + NOBJECTS, IS_FREE);
1220 drop(TROLL2, objects[TROLL].plac);
1221 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1223 rspeak(TROLL_SATISFIED);
1226 if (command.obj == FOOD && HERE(BEAR)) {
1227 /* But throwing food is another story. */
1229 return (feed(command.verb, command.obj));
1231 if (command.obj != AXE)
1232 return (discard(command.verb, command.obj));
1234 if (atdwrf(game.loc) <= 0) {
1235 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1236 return throw_support(DRAGON_SCALES);
1238 return throw_support(TROLL_RETURNS);
1240 return throw_support(OGRE_DODGE);
1241 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1242 /* This'll teach him to throw the axe at the bear! */
1243 drop(AXE, game.loc);
1244 game.fixed[AXE] = IS_FIXED;
1246 state_change(AXE, AXE_LOST);
1249 command.obj = INTRANSITIVE;
1250 return (attack(command));
1253 if (randrange(NDWARVES + 1) < game.dflag) {
1254 return throw_support(DWARF_DODGES);
1256 int i = atdwrf(game.loc);
1257 game.dseen[i] = false;
1258 game.dloc[i] = LOC_NOWHERE;
1259 return throw_support((++game.dkill == 1) ?
1266 static phase_codes_t wake(verb_t verb, obj_t obj)
1267 /* Wake. Only use is to disturb the dwarves. */
1271 speak(actions[verb].message);
1275 return GO_DWARFWAKE;
1279 static phase_codes_t seed(verb_t verb, const char *arg)
1282 int32_t seed = strtol(arg, NULL, 10);
1283 speak(actions[verb].message, seed);
1289 static phase_codes_t waste(verb_t verb, turn_t turns)
1292 game.limit -= turns;
1293 speak(actions[verb].message, (int)game.limit);
1297 static phase_codes_t wave(verb_t verb, obj_t obj)
1298 /* Wave. No effect unless waving rod at fissure or at bird. */
1305 speak(((!TOTING(obj)) && (obj != ROD ||
1307 arbitrary_messages[ARENT_CARRYING] :
1308 actions[verb].message);
1312 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1313 drop(JADE, game.loc);
1314 game.prop[JADE] = STATE_FOUND;
1316 rspeak(NECKLACE_FLY);
1320 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1323 return GO_DWARFWAKE;
1327 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1333 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1337 state_change(FISSURE,
1338 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1343 phase_codes_t action(command_t command)
1344 /* Analyse a verb. Remember what it was, go back for object if second word
1345 * unless verb is "say", which snarfs arbitrary second word.
1348 /* Previously, actions that result in a message, but don't do anything
1349 * further were called "specials". Now they're handled here as normal
1350 * actions. If noaction is true, then we spit out the message and return */
1351 if (actions[command.verb].noaction) {
1352 speak(actions[command.verb].message);
1356 if (command.part == unknown) {
1357 /* Analyse an object word. See if the thing is here, whether
1358 * we've got a verb yet, and so on. Object must be here
1359 * unless verb is "find" or "invent(ory)" (and no new verb
1360 * yet to be analysed). Water and oil are also funny, since
1361 * they are never actually dropped at any location, but might
1362 * be here inside the bottle or urn or as a feature of the
1364 if (HERE(command.obj))
1366 else if (command.obj == DWARF && atdwrf(game.loc) > 0)
1368 else if (!game.closed && ((LIQUID() == command.obj && HERE(BOTTLE)) ||
1369 command.obj == LIQLOC(game.loc)))
1371 else if (command.obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1374 } else if (command.obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1375 command.obj = PLANT2;
1377 } else if (command.obj == KNIFE && game.knfloc == game.loc) {
1379 rspeak(KNIVES_VANISH);
1381 } else if (command.obj == ROD && HERE(ROD2)) {
1384 } else if ((command.verb == FIND ||
1385 command.verb == INVENTORY) && (command.word[1].id == WORD_EMPTY || command.word[1].id == WORD_NOT_FOUND))
1388 sspeak(NO_SEE, command.word[0].raw);
1392 if (command.verb != 0)
1393 command.part = transitive;
1396 switch (command.part) {
1398 if (command.word[1].raw[0] != '\0' && command.verb != SAY)
1400 if (command.verb == SAY)
1401 /* KEYS is not special, anything not NO_OBJECT or INTRANSITIVE
1402 * will do here. We're preventing interpretation as an intransitive
1403 * verb when the word is unknown. */
1404 command.obj = command.word[1].raw[0] != '\0' ? KEYS : NO_OBJECT;
1405 if (command.obj == NO_OBJECT ||
1406 command.obj == INTRANSITIVE) {
1407 /* Analyse an intransitive verb (ie, no object given yet). */
1408 switch (command.verb) {
1410 return vcarry(command.verb, INTRANSITIVE);
1416 return lock(command.verb, INTRANSITIVE);
1419 return (GO_CLEAROBJ);
1422 return lock(command.verb, INTRANSITIVE);
1424 return light(command.verb, INTRANSITIVE);
1426 return extinguish(command.verb, INTRANSITIVE);
1432 speak(actions[command.verb].message);
1436 command.obj = INTRANSITIVE;
1437 return attack(command);
1439 return pour(command.verb, INTRANSITIVE);
1441 return eat(command.verb, INTRANSITIVE);
1443 return drink(command.verb, INTRANSITIVE);
1457 return fill(command.verb, INTRANSITIVE);
1469 return bigwords(command.word[0].id);
1473 command.obj = INTRANSITIVE;
1474 return read(command);
1484 return fly(command.verb, INTRANSITIVE);
1491 rspeak(NUMERIC_REQUIRED);
1493 default: // LCOV_EXCL_LINE
1494 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1499 /* Analyse a transitive verb. */
1500 switch (command.verb) {
1502 return vcarry(command.verb, command.obj);
1504 return discard(command.verb, command.obj);
1506 return say(command);
1508 return lock(command.verb, command.obj);
1511 return (GO_CLEAROBJ);
1514 return lock(command.verb, command.obj);
1516 return light(command.verb, command.obj);
1518 return extinguish(command.verb, command.obj);
1520 return wave(command.verb, command.obj);
1522 speak(actions[command.verb].message);
1526 speak(actions[command.verb].message);
1530 return attack(command);
1532 return pour(command.verb, command.obj);
1534 return eat(command.verb, command.obj);
1536 return drink(command.verb, command.obj);
1538 return rub(command.verb, command.obj);
1540 return throw (command);
1542 speak(actions[command.verb].message);
1546 return find(command.verb, command.obj);
1548 return find(command.verb, command.obj);
1550 return feed(command.verb, command.obj);
1552 return fill(command.verb, command.obj);
1557 speak(actions[command.verb].message);
1565 speak(actions[command.verb].message);
1569 speak(actions[command.verb].message);
1573 return read(command);
1575 return vbreak(command.verb, command.obj);
1577 return wake(command.verb, command.obj);
1579 speak(actions[command.verb].message);
1583 speak(actions[command.verb].message);
1587 return fly(command.verb, command.obj);
1589 speak(actions[command.verb].message);
1593 // This case should never happen - here only as placeholder
1598 return seed(command.verb, command.word[1].raw);
1600 return waste(command.verb, (turn_t)atol(command.word[1].raw));
1601 default: // LCOV_EXCL_LINE
1602 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1605 /* Unknown verb, couldn't deduce object - might need hint */
1606 sspeak(WHAT_DO, command.word[0].raw);
1607 return GO_CHECKHINT;
1608 default: // LCOV_EXCL_LINE
1609 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE