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);
114 if (!silent_yes_or_no()) {
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;
865 /* should never happen */
866 rspeak(NOTHING_HAPPENS);
872 static phase_codes_t inven(void)
873 /* Inventory. If object, treat same as find. Else report on current burden. */
876 for (obj_t i = 1; i <= NOBJECTS; i++) {
884 pspeak(i, touch, false, -1);
893 static phase_codes_t light(verb_t verb, obj_t obj)
894 /* Light. Applicable only to lamp and urn. */
896 if (obj == INTRANSITIVE) {
898 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
902 if (HERE(URN) && game.prop[URN] == URN_DARK) {
912 state_change(URN, game.prop[URN] == URN_EMPTY ?
917 if (game.limit < 0) {
921 state_change(LAMP, LAMP_BRIGHT);
926 speak(actions[verb].message);
931 static phase_codes_t listen(void)
932 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
934 bool soundlatch = false;
935 vocab_t sound = locations[game.loc].sound;
936 if (sound != SILENT) {
938 if (!locations[game.loc].loud)
942 for (obj_t i = 1; i <= NOBJECTS; i++) {
944 objects[i].sounds[0] == NULL ||
947 int mi = game.prop[i];
948 /* (ESR) Some unpleasant magic on object states here. Ideally
949 * we'd have liked the bird to be a normal object that we can
950 * use state_change() on; can't do it, because there are
951 * actually two different series of per-state birdsounds
952 * depending on whether player has drunk dragon's blood. */
954 mi += 3 * game.blooded;
955 pspeak(i, hear, true, mi, game.zzword);
957 if (i == BIRD && mi == BIRD_ENDSTATE)
966 static phase_codes_t lock(verb_t verb, obj_t obj)
967 /* Lock, unlock, no object given. Assume various things if present. */
969 if (obj == INTRANSITIVE) {
980 if (obj == INTRANSITIVE) {
981 rspeak(NOTHING_LOCKED);
986 /* Lock, unlock object. Special stuff for opening clam/oyster
1001 game.clock2 = PANICTIME;
1004 state_change(GRATE, (verb == LOCK) ?
1014 else if (TOTING(CLAM))
1016 else if (!TOTING(TRIDENT))
1017 rspeak(CLAM_OPENER);
1020 drop(OYSTER, game.loc);
1021 drop(PEARL, LOC_CULDESAC);
1022 rspeak(PEARL_FALLS);
1028 else if (TOTING(OYSTER))
1029 rspeak(DROP_OYSTER);
1030 else if (!TOTING(TRIDENT))
1031 rspeak(OYSTER_OPENER);
1033 rspeak(OYSTER_OPENS);
1036 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
1042 rspeak(CANNOT_UNLOCK);
1045 speak(actions[verb].message);
1051 static phase_codes_t pour(verb_t verb, obj_t obj)
1052 /* Pour. If no object, or object is bottle, assume contents of bottle.
1053 * special tests for pouring water or oil on plant or rusty door. */
1055 if (obj == BOTTLE ||
1056 obj == INTRANSITIVE)
1058 if (obj == NO_OBJECT)
1061 speak(actions[verb].message);
1065 if (obj != OIL && obj != WATER) {
1069 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1070 return fill(verb, URN);
1071 game.prop[BOTTLE] = EMPTY_BOTTLE;
1072 game.place[obj] = LOC_NOWHERE;
1080 /* cycle through the three plant states */
1081 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1082 game.prop[PLANT2] = game.prop[PLANT];
1085 rspeak(SHAKING_LEAVES);
1089 state_change(DOOR, (obj == OIL) ?
1096 static phase_codes_t quit(void)
1097 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1099 if (yes_or_no(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1100 terminate(quitgame);
1104 static phase_codes_t read(command_t command)
1105 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1107 if (command.obj == INTRANSITIVE) {
1108 command.obj = NO_OBJECT;
1109 for (int i = 1; i <= NOBJECTS; i++) {
1110 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1111 command.obj = command.obj * NOBJECTS + i;
1113 if (command.obj > NOBJECTS ||
1114 command.obj == NO_OBJECT ||
1119 if (DARK(game.loc)) {
1120 sspeak(NO_SEE, command.word[0].raw);
1121 } else if (command.obj == OYSTER) {
1122 if (!TOTING(OYSTER) || !game.closed) {
1123 rspeak(DONT_UNDERSTAND);
1124 } else if (!game.clshnt) {
1125 game.clshnt = yes_or_no(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1127 pspeak(OYSTER, hear, true, 1); // Not really a sound, but oh well.
1129 } else if (objects[command.obj].texts[0] == NULL ||
1130 game.prop[command.obj] == STATE_NOTFOUND) {
1131 speak(actions[command.verb].message);
1133 pspeak(command.obj, study, true, game.prop[command.obj]);
1137 static phase_codes_t reservoir(void)
1138 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1140 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1141 rspeak(NOTHING_HAPPENS);
1145 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1149 game.oldlc2 = game.loc;
1150 game.newloc = LOC_NOWHERE;
1152 return GO_TERMINATE;
1157 static phase_codes_t rub(verb_t verb, obj_t obj)
1158 /* Rub. Yields various snide remarks except for lit urn. */
1160 if (obj == URN && game.prop[URN] == URN_LIT) {
1162 drop(AMBER, game.loc);
1163 game.prop[AMBER] = AMBER_IN_ROCK;
1165 drop(CAVITY, game.loc);
1167 } else if (obj != LAMP) {
1168 rspeak(PECULIAR_NOTHING);
1170 speak(actions[verb].message);
1175 static phase_codes_t say(command_t command)
1176 /* Say. Echo WD2. Magic words override. */
1178 if (command.word[1].type == MOTION &&
1179 (command.word[1].id == XYZZY ||
1180 command.word[1].id == PLUGH ||
1181 command.word[1].id == PLOVER)) {
1184 if (command.word[1].type == ACTION && command.word[1].id == PART)
1187 if (command.word[1].type == ACTION &&
1188 (command.word[1].id == FEE ||
1189 command.word[1].id == FIE ||
1190 command.word[1].id == FOE ||
1191 command.word[1].id == FOO ||
1192 command.word[1].id == FUM ||
1193 command.word[1].id == PART)) {
1194 return bigwords(command.word[1].id);
1196 sspeak(OKEY_DOKEY, command.word[1].raw);
1200 static phase_codes_t throw_support(vocab_t spk)
1203 drop(AXE, game.loc);
1207 static phase_codes_t throwit(command_t command)
1208 /* Throw. Same as discard unless axe. Then same as attack except
1209 * ignore bird, and if dwarf is present then one might be killed.
1210 * (Only way to do so!) Axe also special for dragon, bear, and
1211 * troll. Treasures special for troll. */
1213 if (!TOTING(command.obj)) {
1214 speak(actions[command.verb].message);
1217 if (objects[command.obj].is_treasure && AT(TROLL)) {
1218 /* Snarf a treasure for the troll. */
1219 drop(command.obj, LOC_NOWHERE);
1220 move(TROLL, LOC_NOWHERE);
1221 move(TROLL + NOBJECTS, IS_FREE);
1222 drop(TROLL2, objects[TROLL].plac);
1223 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1225 rspeak(TROLL_SATISFIED);
1228 if (command.obj == FOOD && HERE(BEAR)) {
1229 /* But throwing food is another story. */
1231 return (feed(command.verb, command.obj));
1233 if (command.obj != AXE)
1234 return (discard(command.verb, command.obj));
1236 if (atdwrf(game.loc) <= 0) {
1237 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1238 return throw_support(DRAGON_SCALES);
1240 return throw_support(TROLL_RETURNS);
1242 return throw_support(OGRE_DODGE);
1243 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1244 /* This'll teach him to throw the axe at the bear! */
1245 drop(AXE, game.loc);
1246 game.fixed[AXE] = IS_FIXED;
1248 state_change(AXE, AXE_LOST);
1251 command.obj = INTRANSITIVE;
1252 return (attack(command));
1255 if (randrange(NDWARVES + 1) < game.dflag) {
1256 return throw_support(DWARF_DODGES);
1258 int i = atdwrf(game.loc);
1259 game.dseen[i] = false;
1260 game.dloc[i] = LOC_NOWHERE;
1261 return throw_support((++game.dkill == 1) ?
1268 static phase_codes_t wake(verb_t verb, obj_t obj)
1269 /* Wake. Only use is to disturb the dwarves. */
1273 speak(actions[verb].message);
1277 return GO_DWARFWAKE;
1281 static phase_codes_t seed(verb_t verb, const char *arg)
1284 int32_t seed = strtol(arg, NULL, 10);
1285 speak(actions[verb].message, seed);
1291 static phase_codes_t waste(verb_t verb, turn_t turns)
1294 game.limit -= turns;
1295 speak(actions[verb].message, (int)game.limit);
1299 static phase_codes_t wave(verb_t verb, obj_t obj)
1300 /* Wave. No effect unless waving rod at fissure or at bird. */
1307 speak(((!TOTING(obj)) && (obj != ROD ||
1309 arbitrary_messages[ARENT_CARRYING] :
1310 actions[verb].message);
1314 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1315 drop(JADE, game.loc);
1316 game.prop[JADE] = STATE_FOUND;
1318 rspeak(NECKLACE_FLY);
1322 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1325 return GO_DWARFWAKE;
1329 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1335 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1339 state_change(FISSURE,
1340 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1345 phase_codes_t action(command_t command)
1346 /* Analyse a verb. Remember what it was, go back for object if second word
1347 * unless verb is "say", which snarfs arbitrary second word.
1350 /* Previously, actions that result in a message, but don't do anything
1351 * further were called "specials". Now they're handled here as normal
1352 * actions. If noaction is true, then we spit out the message and return */
1353 if (actions[command.verb].noaction) {
1354 speak(actions[command.verb].message);
1358 if (command.part == unknown) {
1359 /* Analyse an object word. See if the thing is here, whether
1360 * we've got a verb yet, and so on. Object must be here
1361 * unless verb is "find" or "invent(ory)" (and no new verb
1362 * yet to be analysed). Water and oil are also funny, since
1363 * they are never actually dropped at any location, but might
1364 * be here inside the bottle or urn or as a feature of the
1366 if (HERE(command.obj))
1368 else if (command.obj == DWARF && atdwrf(game.loc) > 0)
1370 else if (!game.closed && ((LIQUID() == command.obj && HERE(BOTTLE)) ||
1371 command.obj == LIQLOC(game.loc)))
1373 else if (command.obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1376 } else if (command.obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1377 command.obj = PLANT2;
1379 } else if (command.obj == KNIFE && game.knfloc == game.loc) {
1381 rspeak(KNIVES_VANISH);
1383 } else if (command.obj == ROD && HERE(ROD2)) {
1386 } else if ((command.verb == FIND ||
1387 command.verb == INVENTORY) && (command.word[1].id == WORD_EMPTY || command.word[1].id == WORD_NOT_FOUND))
1390 sspeak(NO_SEE, command.word[0].raw);
1394 if (command.verb != 0)
1395 command.part = transitive;
1398 switch (command.part) {
1400 if (command.word[1].raw[0] != '\0' && command.verb != SAY)
1402 if (command.verb == SAY)
1403 /* KEYS is not special, anything not NO_OBJECT or INTRANSITIVE
1404 * will do here. We're preventing interpretation as an intransitive
1405 * verb when the word is unknown. */
1406 command.obj = command.word[1].raw[0] != '\0' ? KEYS : NO_OBJECT;
1407 if (command.obj == NO_OBJECT ||
1408 command.obj == INTRANSITIVE) {
1409 /* Analyse an intransitive verb (ie, no object given yet). */
1410 switch (command.verb) {
1412 return vcarry(command.verb, INTRANSITIVE);
1418 return lock(command.verb, INTRANSITIVE);
1421 return (GO_CLEAROBJ);
1424 return lock(command.verb, INTRANSITIVE);
1426 return light(command.verb, INTRANSITIVE);
1428 return extinguish(command.verb, INTRANSITIVE);
1434 speak(actions[command.verb].message);
1438 command.obj = INTRANSITIVE;
1439 return attack(command);
1441 return pour(command.verb, INTRANSITIVE);
1443 return eat(command.verb, INTRANSITIVE);
1445 return drink(command.verb, INTRANSITIVE);
1459 return fill(command.verb, INTRANSITIVE);
1471 return bigwords(command.word[0].id);
1475 command.obj = INTRANSITIVE;
1476 return read(command);
1486 return fly(command.verb, INTRANSITIVE);
1493 rspeak(NUMERIC_REQUIRED);
1495 default: // LCOV_EXCL_LINE
1496 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1501 /* Analyse a transitive verb. */
1502 switch (command.verb) {
1504 return vcarry(command.verb, command.obj);
1506 return discard(command.verb, command.obj);
1508 return say(command);
1510 return lock(command.verb, command.obj);
1513 return (GO_CLEAROBJ);
1516 return lock(command.verb, command.obj);
1518 return light(command.verb, command.obj);
1520 return extinguish(command.verb, command.obj);
1522 return wave(command.verb, command.obj);
1524 speak(actions[command.verb].message);
1528 speak(actions[command.verb].message);
1532 return attack(command);
1534 return pour(command.verb, command.obj);
1536 return eat(command.verb, command.obj);
1538 return drink(command.verb, command.obj);
1540 return rub(command.verb, command.obj);
1542 return throwit(command);
1544 speak(actions[command.verb].message);
1548 return find(command.verb, command.obj);
1550 return find(command.verb, command.obj);
1552 return feed(command.verb, command.obj);
1554 return fill(command.verb, command.obj);
1559 speak(actions[command.verb].message);
1567 speak(actions[command.verb].message);
1571 speak(actions[command.verb].message);
1575 return read(command);
1577 return vbreak(command.verb, command.obj);
1579 return wake(command.verb, command.obj);
1581 speak(actions[command.verb].message);
1585 speak(actions[command.verb].message);
1589 return fly(command.verb, command.obj);
1591 speak(actions[command.verb].message);
1595 // This case should never happen - here only as placeholder
1600 return seed(command.verb, command.word[1].raw);
1602 return waste(command.verb, (turn_t)atol(command.word[1].raw));
1603 default: // LCOV_EXCL_LINE
1604 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1607 /* Unknown verb, couldn't deduce object - might need hint */
1608 sspeak(WHAT_DO, command.word[0].raw);
1609 return GO_CHECKHINT;
1610 default: // LCOV_EXCL_LINE
1611 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE