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 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
191 * Look up foo in special section of vocab to determine which word we've got.
192 * Last word zips the eggs back to the giant room (unless already there). */
194 if ((game.foobar == WORD_EMPTY && id == FEE) ||
195 (game.foobar == FEE && id == FIE) ||
196 (game.foobar == FIE && id == FOE) ||
197 (game.foobar == FOE && id == FOO) ||
198 (game.foobar == FOE && id == FUM)) {
200 if ((id != FOO) && (id != FUM)) {
204 game.foobar = WORD_EMPTY;
205 if (game.place[EGGS] == objects[EGGS].plac ||
206 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
207 rspeak(NOTHING_HAPPENS);
210 /* Bring back troll if we steal the eggs back from him before
212 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
213 game.prop[TROLL] = TROLL_PAIDONCE;
215 pspeak(EGGS, look, true, EGGS_VANISHED);
216 else if (game.loc == objects[EGGS].plac)
217 pspeak(EGGS, look, true, EGGS_HERE);
219 pspeak(EGGS, look, true, EGGS_DONE);
220 move(EGGS, objects[EGGS].plac);
225 if (game.loc == LOC_GIANTROOM) {
228 /* This is new begavior in Open Adventure - sounds better when
229 * player isn't in the Giant Room. */
230 rspeak(WELL_POINTLESS);
232 game.foobar = WORD_EMPTY;
237 static void blast(void)
238 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
240 if (game.prop[ROD2] == STATE_NOTFOUND ||
242 rspeak(REQUIRES_DYNAMITE);
245 game.bonus = splatter;
246 rspeak(SPLATTER_MESSAGE);
247 } else if (game.loc == LOC_NE) {
249 rspeak(DEFEAT_MESSAGE);
251 game.bonus = victory;
252 rspeak(VICTORY_MESSAGE);
258 static phase_codes_t vbreak(verb_t verb, obj_t obj)
259 /* Break. Only works for mirror in repository and, of course, the vase. */
264 state_change(MIRROR, MIRROR_BROKEN);
271 if (game.prop[VASE] == VASE_WHOLE) {
273 drop(VASE, game.loc);
274 state_change(VASE, VASE_BROKEN);
275 game.fixed[VASE] = IS_FIXED;
280 speak(actions[verb].message);
282 return (GO_CLEAROBJ);
285 static phase_codes_t brief(void)
286 /* Brief. Intransitive only. Suppress full descriptions after first time. */
290 rspeak(BRIEF_CONFIRM);
294 static phase_codes_t vcarry(verb_t verb, obj_t obj)
295 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
296 * take one without the other). Liquids also special, since they depend on
297 * status of bottle. Also various side effects, etc. */
299 if (obj == INTRANSITIVE) {
300 /* Carry, no object given yet. OK if only one object present. */
301 if (game.atloc[game.loc] == NO_OBJECT ||
302 game.link[game.atloc[game.loc]] != 0 ||
303 atdwrf(game.loc) > 0)
305 obj = game.atloc[game.loc];
309 speak(actions[verb].message);
314 rspeak(REMOVE_MESSAGE);
319 if (game.fixed[obj] != IS_FREE) {
322 /* Next guard tests whether plant is tiny or stashed */
323 rspeak(game.prop[PLANT] <= PLANT_THIRSTY ? DEEP_ROOTS : YOU_JOKING);
326 rspeak( game.prop[BEAR] == SITTING_BEAR ? BEAR_CHAINED : YOU_JOKING);
329 rspeak( game.prop[BEAR] != UNTAMED_BEAR ? STILL_LOCKED : YOU_JOKING);
332 rspeak(game.prop[RUG] == RUG_HOVER ? RUG_HOVERS : YOU_JOKING);
338 rspeak(DOUGHNUT_HOLES);
344 rspeak(HAND_PASSTHROUGH);
356 if (!TOTING(BOTTLE)) {
357 rspeak(NO_CONTAINER);
360 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
361 return (fill(verb, BOTTLE));
369 if (game.holdng >= INVLIMIT) {
375 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
376 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
382 rspeak(CANNOT_CARRY);
389 game.prop[BIRD] = BIRD_CAGED;
393 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) {
394 /* expression maps BIRD to CAGE and CAGE to BIRD */
395 carry(BIRD + CAGE - obj, game.loc);
398 carry(obj, game.loc);
400 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
401 game.place[LIQUID()] = CARRIED;
403 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
404 game.prop[obj] = STATE_FOUND;
405 game.prop[CAVITY] = CAVITY_EMPTY;
411 static int chain(verb_t verb)
412 /* Do something to the bear's chain */
415 if (game.prop[BEAR] == UNTAMED_BEAR) {
419 if (game.prop[CHAIN] == CHAIN_HEAP) {
420 rspeak(ALREADY_UNLOCKED);
423 game.prop[CHAIN] = CHAIN_HEAP;
424 game.fixed[CHAIN] = IS_FREE;
425 if (game.prop[BEAR] != BEAR_DEAD)
426 game.prop[BEAR] = CONTENTED_BEAR;
428 switch (game.prop[BEAR]) {
431 /* Can't be reached until the bear can die in some way other
432 * than a bridge collapse. Leave in in case this changes, but
433 * exclude from coverage testing. */
434 game.fixed[BEAR] = IS_FIXED;
438 game.fixed[BEAR] = IS_FREE;
440 rspeak(CHAIN_UNLOCKED);
444 if (game.prop[CHAIN] != CHAIN_HEAP) {
445 rspeak(ALREADY_LOCKED);
448 if (game.loc != objects[CHAIN].plac) {
453 game.prop[CHAIN] = CHAIN_FIXED;
456 drop(CHAIN, game.loc);
457 game.fixed[CHAIN] = IS_FIXED;
459 rspeak(CHAIN_LOCKED);
463 static phase_codes_t discard(verb_t verb, obj_t obj)
464 /* Discard object. "Throw" also comes here for most objects. Special cases for
465 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
466 * Drop coins at vending machine for extra batteries. */
468 if (obj == ROD && !TOTING(ROD) && TOTING(ROD2)) {
473 speak(actions[verb].message);
477 if (GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL) {
479 game.prop[obj] = STATE_IN_CAVITY;
480 game.prop[CAVITY] = CAVITY_FULL;
481 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
482 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
485 else if (TOTING(RUG))
489 if (!TOTING(RUG) || obj == RUBY) {
490 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
493 k = objects[SAPPH].plac;
494 move(RUG + NOBJECTS, k);
501 if (obj == COINS && HERE(VEND)) {
503 drop(BATTERY, game.loc);
504 pspeak(BATTERY, look, true, FRESH_BATTERIES);
510 if (obj == BOTTLE && LIQUID() != NO_OBJECT) {
511 game.place[LIQUID()] = LOC_NOWHERE;
514 if (obj == BEAR && AT(TROLL)) {
515 state_change(TROLL, TROLL_GONE);
516 move(TROLL, LOC_NOWHERE);
517 move(TROLL + NOBJECTS, IS_FREE);
518 move(TROLL2, objects[TROLL].plac);
519 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
526 if (game.loc != objects[PILLOW].plac) {
527 state_change(VASE, AT(PILLOW)
530 if (game.prop[VASE] != VASE_WHOLE)
531 game.fixed[VASE] = IS_FIXED;
537 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) {
538 drop(BIRD, game.loc);
542 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
548 rspeak(BIRD_ATTACKS);
552 /* Set game.prop for use by travel options */
553 game.prop[SNAKE] = SNAKE_CHASED;
557 game.prop[BIRD] = FOREST(game.loc) ? BIRD_FOREST_UNCAGED : BIRD_UNCAGED;
567 static phase_codes_t drink(verb_t verb, obj_t obj)
568 /* Drink. If no object, assume water and look for it here. If water is in
569 * the bottle, drink that, else must be at a water loc, so drink stream. */
571 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
572 (LIQUID() != WATER || !HERE(BOTTLE))) {
578 state_change(DRAGON, DRAGON_BLOODLESS);
583 if (obj != INTRANSITIVE && obj != WATER) {
584 rspeak(RIDICULOUS_ATTEMPT);
587 if (LIQUID() == WATER && HERE(BOTTLE)) {
588 game.place[WATER] = LOC_NOWHERE;
589 state_change(BOTTLE, EMPTY_BOTTLE);
593 speak(actions[verb].message);
597 static phase_codes_t eat(verb_t verb, obj_t obj)
598 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
599 * ok, some things lose appetite, rest are ridiculous. */
608 rspeak(THANKS_DELICIOUS);
619 rspeak(LOST_APPETITE);
622 speak(actions[verb].message);
627 static phase_codes_t extinguish(verb_t verb, obj_t obj)
628 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
630 if (obj == INTRANSITIVE) {
631 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
633 if (HERE(URN) && game.prop[URN] == URN_LIT)
635 if (obj == INTRANSITIVE)
641 if (game.prop[URN] != URN_EMPTY) {
642 state_change(URN, URN_DARK);
644 pspeak(URN, change, true, URN_DARK);
648 state_change(LAMP, LAMP_DARK);
649 rspeak(DARK(game.loc) ?
655 rspeak(BEYOND_POWER);
658 speak(actions[verb].message);
663 static phase_codes_t feed(verb_t verb, obj_t obj)
664 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
665 * mad. Bear, special. */
672 if (game.prop[DRAGON] != DRAGON_BARS)
673 rspeak(RIDICULOUS_ATTEMPT);
675 rspeak(NOTHING_EDIBLE);
678 if (!game.closed && HERE(BIRD)) {
680 rspeak(BIRD_DEVOURED);
682 rspeak(NOTHING_EDIBLE);
692 speak(actions[verb].message);
695 if (game.prop[BEAR] == BEAR_DEAD) {
696 rspeak(RIDICULOUS_ATTEMPT);
699 if (game.prop[BEAR] == UNTAMED_BEAR) {
702 game.fixed[AXE] = IS_FREE;
703 game.prop[AXE] = AXE_HERE;
704 state_change(BEAR, SITTING_BEAR);
706 rspeak(NOTHING_EDIBLE);
709 speak(actions[verb].message);
715 speak(actions[verb].message);
723 phase_codes_t fill(verb_t verb, obj_t obj)
724 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
728 if (LIQLOC(game.loc) == NO_OBJECT) {
729 rspeak(FILL_INVALID);
733 rspeak(ARENT_CARRYING);
736 rspeak(SHATTER_VASE);
737 game.prop[VASE] = VASE_BROKEN;
738 game.fixed[VASE] = IS_FIXED;
739 drop(VASE, game.loc);
744 if (game.prop[URN] != URN_EMPTY) {
749 rspeak(FILL_INVALID);
755 game.prop[BOTTLE] = EMPTY_BOTTLE;
759 game.prop[URN] = URN_DARK;
760 game.prop[BOTTLE] = EMPTY_BOTTLE;
765 rspeak(FILL_INVALID);
768 game.place[k] = LOC_NOWHERE;
771 if (obj != INTRANSITIVE && obj != BOTTLE) {
772 speak(actions[verb].message);
775 if (obj == INTRANSITIVE && !HERE(BOTTLE))
778 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
782 if (LIQUID() != NO_OBJECT) {
786 if (LIQLOC(game.loc) == NO_OBJECT) {
791 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
795 game.place[LIQUID()] = CARRIED;
799 static phase_codes_t find(verb_t verb, obj_t obj)
800 /* Find. Might be carrying it, or it might be here. Else give caveat. */
803 rspeak(ALREADY_CARRYING);
808 rspeak(NEEDED_NEARBY);
813 (LIQUID() == obj && AT(BOTTLE)) ||
814 obj == LIQLOC(game.loc) ||
815 (obj == DWARF && atdwrf(game.loc) > 0)) {
821 speak(actions[verb].message);
825 static phase_codes_t fly(verb_t verb, obj_t obj)
826 /* Fly. Snide remarks unless hovering rug is here. */
828 if (obj == INTRANSITIVE) {
833 if (game.prop[RUG] != RUG_HOVER) {
834 rspeak(RUG_NOTHING2);
841 speak(actions[verb].message);
844 if (game.prop[RUG] != RUG_HOVER) {
845 rspeak(RUG_NOTHING1);
849 if (game.loc == LOC_CLIFF) {
850 game.oldlc2 = game.oldloc;
851 game.oldloc = game.loc;
852 game.newloc = LOC_LEDGE;
854 } else if (game.loc == LOC_LEDGE) {
855 game.oldlc2 = game.oldloc;
856 game.oldloc = game.loc;
857 game.newloc = LOC_CLIFF;
860 /* should never happen */
861 rspeak(NOTHING_HAPPENS);
866 static phase_codes_t inven(void)
867 /* Inventory. If object, treat same as find. Else report on current burden. */
870 for (obj_t i = 1; i <= NOBJECTS; i++) {
878 pspeak(i, touch, false, -1);
887 static phase_codes_t light(verb_t verb, obj_t obj)
888 /* Light. Applicable only to lamp and urn. */
890 if (obj == INTRANSITIVE) {
892 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
896 if (HERE(URN) && game.prop[URN] == URN_DARK) {
906 state_change(URN, game.prop[URN] == URN_EMPTY ?
911 if (game.limit < 0) {
915 state_change(LAMP, LAMP_BRIGHT);
920 speak(actions[verb].message);
925 static phase_codes_t listen(void)
926 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
928 vocab_t sound = locations[game.loc].sound;
929 if (sound != SILENT) {
931 if (!locations[game.loc].loud)
935 for (obj_t i = 1; i <= NOBJECTS; i++) {
937 objects[i].sounds[0] == NULL ||
940 int mi = game.prop[i];
941 /* (ESR) Some unpleasant magic on object states here. Ideally
942 * we'd have liked the bird to be a normal object that we can
943 * use state_change() on; can't do it, because there are
944 * actually two different series of per-state birdsounds
945 * depending on whether player has drunk dragon's blood. */
947 mi += 3 * game.blooded;
948 pspeak(i, hear, true, mi, game.zzword);
950 if (i == BIRD && mi == BIRD_ENDSTATE)
958 static phase_codes_t lock(verb_t verb, obj_t obj)
959 /* Lock, unlock, no object given. Assume various things if present. */
961 if (obj == INTRANSITIVE) {
972 if (obj == INTRANSITIVE) {
973 rspeak(NOTHING_LOCKED);
978 /* Lock, unlock object. Special stuff for opening clam/oyster
993 game.clock2 = PANICTIME;
996 state_change(GRATE, (verb == LOCK) ?
1006 else if (TOTING(CLAM))
1008 else if (!TOTING(TRIDENT))
1009 rspeak(CLAM_OPENER);
1012 drop(OYSTER, game.loc);
1013 drop(PEARL, LOC_CULDESAC);
1014 rspeak(PEARL_FALLS);
1020 else if (TOTING(OYSTER))
1021 rspeak(DROP_OYSTER);
1022 else if (!TOTING(TRIDENT))
1023 rspeak(OYSTER_OPENER);
1025 rspeak(OYSTER_OPENS);
1028 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
1034 rspeak(CANNOT_UNLOCK);
1037 speak(actions[verb].message);
1043 static phase_codes_t pour(verb_t verb, obj_t obj)
1044 /* Pour. If no object, or object is bottle, assume contents of bottle.
1045 * special tests for pouring water or oil on plant or rusty door. */
1047 if (obj == BOTTLE ||
1048 obj == INTRANSITIVE)
1050 if (obj == NO_OBJECT)
1053 speak(actions[verb].message);
1057 if (obj != OIL && obj != WATER) {
1061 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1062 return fill(verb, URN);
1063 game.prop[BOTTLE] = EMPTY_BOTTLE;
1064 game.place[obj] = LOC_NOWHERE;
1072 /* cycle through the three plant states */
1073 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1074 game.prop[PLANT2] = game.prop[PLANT];
1077 rspeak(SHAKING_LEAVES);
1081 state_change(DOOR, (obj == OIL) ?
1088 static phase_codes_t quit(void)
1089 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1091 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1092 terminate(quitgame);
1096 static phase_codes_t read(command_t command)
1097 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1099 if (command.obj == INTRANSITIVE) {
1100 command.obj = NO_OBJECT;
1101 for (int i = 1; i <= NOBJECTS; i++) {
1102 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1103 command.obj = command.obj * NOBJECTS + i;
1105 if (command.obj > NOBJECTS ||
1106 command.obj == NO_OBJECT ||
1111 if (DARK(game.loc)) {
1112 sspeak(NO_SEE, command.word[0].raw);
1113 } else if (command.obj == OYSTER) {
1114 if (!TOTING(OYSTER) || !game.closed) {
1115 rspeak(DONT_UNDERSTAND);
1116 } else if (!game.clshnt) {
1117 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1118 } else if (game.clshnt) {
1119 pspeak(OYSTER, hear, true, 1); // Not really a sound, but oh well.
1121 } else if (objects[command.obj].texts[0] == NULL ||
1122 game.prop[command.obj] == STATE_NOTFOUND) {
1123 speak(actions[command.verb].message);
1125 pspeak(command.obj, study, true, game.prop[command.obj]);
1129 static phase_codes_t reservoir(void)
1130 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1132 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1133 rspeak(NOTHING_HAPPENS);
1137 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1141 game.oldlc2 = game.loc;
1142 game.newloc = LOC_NOWHERE;
1144 return GO_TERMINATE;
1149 static phase_codes_t rub(verb_t verb, obj_t obj)
1150 /* Rub. Yields various snide remarks except for lit urn. */
1152 if (obj == URN && game.prop[URN] == URN_LIT) {
1154 drop(AMBER, game.loc);
1155 game.prop[AMBER] = AMBER_IN_ROCK;
1157 drop(CAVITY, game.loc);
1159 } else if (obj != LAMP) {
1160 rspeak(PECULIAR_NOTHING);
1162 speak(actions[verb].message);
1167 static phase_codes_t say(command_t command)
1168 /* Say. Echo WD2. Magic words override. */
1170 if (command.word[1].type == MOTION &&
1171 (command.word[1].id == XYZZY ||
1172 command.word[1].id == PLUGH ||
1173 command.word[1].id == PLOVER)) {
1176 if (command.word[1].type == ACTION && command.word[1].id == PART)
1179 if (command.word[1].type == ACTION &&
1180 (command.word[1].id == FEE ||
1181 command.word[1].id == FIE ||
1182 command.word[1].id == FOE ||
1183 command.word[1].id == FOO ||
1184 command.word[1].id == FUM ||
1185 command.word[1].id == PART)) {
1186 return bigwords(command.word[1].id);
1188 sspeak(OKEY_DOKEY, command.word[1].raw);
1192 static phase_codes_t throw_support(vocab_t spk)
1195 drop(AXE, game.loc);
1199 static phase_codes_t throw (command_t command)
1200 /* Throw. Same as discard unless axe. Then same as attack except
1201 * ignore bird, and if dwarf is present then one might be killed.
1202 * (Only way to do so!) Axe also special for dragon, bear, and
1203 * troll. Treasures special for troll. */
1205 if (!TOTING(command.obj)) {
1206 speak(actions[command.verb].message);
1209 if (objects[command.obj].is_treasure && AT(TROLL)) {
1210 /* Snarf a treasure for the troll. */
1211 drop(command.obj, LOC_NOWHERE);
1212 move(TROLL, LOC_NOWHERE);
1213 move(TROLL + NOBJECTS, IS_FREE);
1214 drop(TROLL2, objects[TROLL].plac);
1215 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1217 rspeak(TROLL_SATISFIED);
1220 if (command.obj == FOOD && HERE(BEAR)) {
1221 /* But throwing food is another story. */
1223 return (feed(command.verb, command.obj));
1225 if (command.obj != AXE)
1226 return (discard(command.verb, command.obj));
1228 if (atdwrf(game.loc) <= 0) {
1229 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1230 return throw_support(DRAGON_SCALES);
1232 return throw_support(TROLL_RETURNS);
1234 return throw_support(OGRE_DODGE);
1235 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1236 /* This'll teach him to throw the axe at the bear! */
1237 drop(AXE, game.loc);
1238 game.fixed[AXE] = IS_FIXED;
1240 state_change(AXE, AXE_LOST);
1243 command.obj = INTRANSITIVE;
1244 return (attack(command));
1247 if (randrange(NDWARVES + 1) < game.dflag) {
1248 return throw_support(DWARF_DODGES);
1250 int i = atdwrf(game.loc);
1251 game.dseen[i] = false;
1252 game.dloc[i] = LOC_NOWHERE;
1253 return throw_support((++game.dkill == 1) ?
1260 static phase_codes_t wake(verb_t verb, obj_t obj)
1261 /* Wake. Only use is to disturb the dwarves. */
1265 speak(actions[verb].message);
1269 return GO_DWARFWAKE;
1273 static phase_codes_t seed(verb_t verb, const char *arg)
1276 int32_t seed = strtol(arg, NULL, 10);
1277 speak(actions[verb].message, seed);
1283 static phase_codes_t waste(verb_t verb, turn_t turns)
1286 game.limit -= turns;
1287 speak(actions[verb].message, (int)game.limit);
1291 static phase_codes_t wave(verb_t verb, obj_t obj)
1292 /* Wave. No effect unless waving rod at fissure or at bird. */
1299 speak(((!TOTING(obj)) && (obj != ROD ||
1301 arbitrary_messages[ARENT_CARRYING] :
1302 actions[verb].message);
1306 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1307 drop(JADE, game.loc);
1308 game.prop[JADE] = STATE_FOUND;
1310 rspeak(NECKLACE_FLY);
1314 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1317 return GO_DWARFWAKE;
1321 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1327 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1331 state_change(FISSURE,
1332 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1337 phase_codes_t action(command_t command)
1338 /* Analyse a verb. Remember what it was, go back for object if second word
1339 * unless verb is "say", which snarfs arbitrary second word.
1342 /* Previously, actions that result in a message, but don't do anything
1343 * further were called "specials". Now they're handled here as normal
1344 * actions. If noaction is true, then we spit out the message and return */
1345 if (actions[command.verb].noaction) {
1346 speak(actions[command.verb].message);
1350 if (command.part == unknown) {
1351 /* Analyse an object word. See if the thing is here, whether
1352 * we've got a verb yet, and so on. Object must be here
1353 * unless verb is "find" or "invent(ory)" (and no new verb
1354 * yet to be analysed). Water and oil are also funny, since
1355 * they are never actually dropped at any location, but might
1356 * be here inside the bottle or urn or as a feature of the
1358 if (HERE(command.obj))
1360 else if (command.obj == DWARF && atdwrf(game.loc) > 0)
1362 else if (!game.closed && ((LIQUID() == command.obj && HERE(BOTTLE)) ||
1363 command.obj == LIQLOC(game.loc)))
1365 else if (command.obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1368 } else if (command.obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1369 command.obj = PLANT2;
1371 } else if (command.obj == KNIFE && game.knfloc == game.loc) {
1373 rspeak(KNIVES_VANISH);
1375 } else if (command.obj == ROD && HERE(ROD2)) {
1378 } else if ((command.verb == FIND ||
1379 command.verb == INVENTORY) && (command.word[1].id == WORD_EMPTY || command.word[1].id == WORD_NOT_FOUND))
1382 sspeak(NO_SEE, command.word[0].raw);
1386 if (command.verb != 0)
1387 command.part = transitive;
1390 switch (command.part) {
1392 if (command.word[1].raw[0] != '\0' && command.verb != SAY)
1394 if (command.verb == SAY)
1395 /* KEYS is not special, anything not NO_OBJECT or INTRANSITIVE
1396 * will do here. We're preventing interpretation as an intransitive
1397 * verb when the word is unknown. */
1398 command.obj = command.word[1].raw[0] != '\0' ? KEYS : NO_OBJECT;
1399 if (command.obj == NO_OBJECT ||
1400 command.obj == INTRANSITIVE) {
1401 /* Analyse an intransitive verb (ie, no object given yet). */
1402 switch (command.verb) {
1404 return vcarry(command.verb, INTRANSITIVE);
1410 return lock(command.verb, INTRANSITIVE);
1413 return (GO_CLEAROBJ);
1416 return lock(command.verb, INTRANSITIVE);
1418 return light(command.verb, INTRANSITIVE);
1420 return extinguish(command.verb, INTRANSITIVE);
1426 speak(actions[command.verb].message);
1430 command.obj = INTRANSITIVE;
1431 return attack(command);
1433 return pour(command.verb, INTRANSITIVE);
1435 return eat(command.verb, INTRANSITIVE);
1437 return drink(command.verb, INTRANSITIVE);
1451 return fill(command.verb, INTRANSITIVE);
1463 return bigwords(command.word[0].id);
1467 command.obj = INTRANSITIVE;
1468 return read(command);
1478 return fly(command.verb, INTRANSITIVE);
1485 rspeak(NUMERIC_REQUIRED);
1487 default: // LCOV_EXCL_LINE
1488 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1493 /* Analyse a transitive verb. */
1494 switch (command.verb) {
1496 return vcarry(command.verb, command.obj);
1498 return discard(command.verb, command.obj);
1500 return say(command);
1502 return lock(command.verb, command.obj);
1505 return (GO_CLEAROBJ);
1508 return lock(command.verb, command.obj);
1510 return light(command.verb, command.obj);
1512 return extinguish(command.verb, command.obj);
1514 return wave(command.verb, command.obj);
1516 speak(actions[command.verb].message);
1520 speak(actions[command.verb].message);
1524 return attack(command);
1526 return pour(command.verb, command.obj);
1528 return eat(command.verb, command.obj);
1530 return drink(command.verb, command.obj);
1532 return rub(command.verb, command.obj);
1534 return throw (command);
1536 speak(actions[command.verb].message);
1540 return find(command.verb, command.obj);
1542 return find(command.verb, command.obj);
1544 return feed(command.verb, command.obj);
1546 return fill(command.verb, command.obj);
1551 speak(actions[command.verb].message);
1559 speak(actions[command.verb].message);
1563 speak(actions[command.verb].message);
1567 return read(command);
1569 return vbreak(command.verb, command.obj);
1571 return wake(command.verb, command.obj);
1573 speak(actions[command.verb].message);
1577 speak(actions[command.verb].message);
1581 return fly(command.verb, command.obj);
1583 speak(actions[command.verb].message);
1587 // This case should never happen - here only as placeholder
1592 return seed(command.verb, command.word[1].raw);
1594 return waste(command.verb, (turn_t)atol(command.word[1].raw));
1595 default: // LCOV_EXCL_LINE
1596 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1599 /* Unknown verb, couldn't deduce object - might need hint */
1600 sspeak(WHAT_DO, command.word[0].raw);
1601 return GO_CHECKHINT;
1602 default: // LCOV_EXCL_LINE
1603 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE