7 static int fill(token_t, token_t);
9 static void state_change(long obj, long state)
11 game.prop[obj] = state;
12 pspeak(obj, change, state, true);
15 static int attack(struct command_t *command)
16 /* Attack. Assume target if unambiguous. "Throw" also links here.
17 * Attackable objects fall into two categories: enemies (snake,
18 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
19 * enemies, or no enemies but 2 others. */
21 vocab_t verb = command->verb;
22 vocab_t obj = command->obj;
24 if (obj == NO_OBJECT ||
25 obj == INTRANSITIVE) {
27 if (atdwrf(game.loc) > 0) {
35 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
47 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
51 /* check for low-priority targets */
52 if (obj == NO_OBJECT) {
53 /* Can't attack bird or machine by throwing axe. */
54 if (HERE(BIRD) && verb != THROW) {
58 if (HERE(VEND) && verb != THROW) {
62 /* Clam and oyster both treated as clam for intransitive case;
64 if (HERE(CLAM) || HERE(OYSTER)) {
84 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
89 switch (game.prop[BEAR]) {
94 rspeak(BEAR_CONFUSED);
97 rspeak(BEAR_CONFUSED);
100 rspeak(ALREADY_DEAD);
105 if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
106 /* Fun stuff for dragon. If he insists on attacking it, win!
107 * Set game.prop to dead, move dragon to central loc (still
108 * fixed), move rug there (not fixed), and move him there,
109 * too. Then do a null motion to get new description. */
110 rspeak(BARE_HANDS_QUERY);
112 // FIXME: setting wd1 is a workaround for broken logic
113 command->wd1 = token_to_packed("Y");
115 // FIXME: setting wd1 is a workaround for broken logic
116 command->wd1 = token_to_packed("N");
119 state_change(DRAGON, DRAGON_DEAD);
120 game.prop[RUG] = RUG_FLOOR;
121 /* FIXME: Arithmetic on location values */
122 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
123 move(DRAGON + NOBJECTS, -1);
124 move(RUG + NOBJECTS, 0);
128 for (obj = 1; obj <= NOBJECTS; obj++) {
129 if (game.place[obj] == objects[DRAGON].plac ||
130 game.place[obj] == objects[DRAGON].fixd)
139 if (atdwrf(game.loc) == 0)
142 rspeak(KNIFE_THROWN);
145 for (int i = 1; i < PIRATE; i++) {
146 if (game.dloc[i] == game.loc) {
148 game.dloc[i] = LOC_LONGWEST;
149 game.dseen[i] = false;
152 rspeak((dwarves > 1) ?
164 rspeak(SHELL_IMPERVIOUS);
167 rspeak(SNAKE_WARNING);
173 rspeak(BARE_HANDS_QUERY);
176 rspeak(ALREADY_DEAD);
182 rspeak(actions[verb].message);
187 static int bigwords(token_t foo)
188 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
189 * Look up foo in special section of vocab to determine which word we've got.
190 * Last word zips the eggs back to the giant room (unless already there). */
192 char word[TOKLEN + 1];
193 packed_to_token(foo, word);
194 int k = (int) get_special_vocab_id(word);
195 if (game.foobar != 1 - k) {
196 if (game.foobar != 0 && game.loc == LOC_GIANTROOM) {
199 rspeak(NOTHING_HAPPENS);
209 if (game.place[EGGS] == objects[EGGS].plac ||
210 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
211 rspeak(NOTHING_HAPPENS);
214 /* Bring back troll if we steal the eggs back from him before
216 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
217 game.prop[TROLL] = TROLL_PAIDONCE;
221 if (game.loc == objects[EGGS].plac)
223 move(EGGS, objects[EGGS].plac);
224 pspeak(EGGS, look, k, true);
230 static void blast(void)
231 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
233 if (game.prop[ROD2] < 0 ||
235 rspeak(REQUIRES_DYNAMITE);
237 game.bonus = VICTORY_MESSAGE;
238 if (game.loc == LOC_NE)
239 game.bonus = DEFEAT_MESSAGE;
241 game.bonus = SPLATTER_MESSAGE;
247 static int vbreak(token_t verb, token_t obj)
248 /* Break. Only works for mirror in repository and, of course, the vase. */
252 rspeak(BREAK_MIRROR);
259 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
261 drop(VASE, game.loc);
262 state_change(VASE, VASE_BROKEN);
263 game.fixed[VASE] = -1;
266 rspeak(actions[verb].message);
267 return (GO_CLEAROBJ);
270 static int brief(void)
271 /* Brief. Intransitive only. Suppress long descriptions after first time. */
275 rspeak(BRIEF_CONFIRM);
279 static int vcarry(token_t verb, token_t obj)
280 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
281 * take one without the other). Liquids also special, since they depend on
282 * 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);
299 if (obj == PLANT && game.prop[PLANT] <= 0)
301 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
303 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
308 spk = DOUGHNUT_HOLES;
311 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
314 spk = HAND_PASSTHROUGH;
316 rspeak(REMOVE_MESSAGE);
320 if (game.fixed[obj] != 0) {
328 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
329 return (fill(verb, BOTTLE));
331 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
343 if (game.holdng >= INVLIMIT) {
346 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
347 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
356 if (spk == CANNOT_CARRY ||
357 spk == BIRD_EVADES) {
361 game.prop[BIRD] = BIRD_CAGED;
363 /* FIXME: Arithmetic on state numbers */
366 (game.prop[BIRD] == BIRD_CAGED ||
367 -1 - game.prop[BIRD] == 1))
368 carry(BIRD + CAGE - obj, game.loc);
369 carry(obj, game.loc);
370 if (obj == BOTTLE && LIQUID() != 0)
371 game.place[LIQUID()] = CARRIED;
372 if (GSTONE(obj) && game.prop[obj] != 0) {
373 game.prop[obj] = STATE_GROUND;
374 game.prop[CAVITY] = CAVITY_EMPTY;
380 static int chain(token_t verb)
381 /* Do something to the bear's chain */
384 if (game.prop[BEAR] == UNTAMED_BEAR) {
388 if (game.prop[CHAIN] == CHAIN_HEAP) {
389 rspeak(ALREADY_UNLOCKED);
392 game.prop[CHAIN] = CHAIN_HEAP;
393 game.fixed[CHAIN] = CHAIN_HEAP;
394 if (game.prop[BEAR] != BEAR_DEAD)
395 game.prop[BEAR] = CONTENTED_BEAR;
397 switch (game.prop[BEAR]) {
399 game.fixed[BEAR] = -1;
402 game.fixed[BEAR] = 0;
404 rspeak(CHAIN_UNLOCKED);
408 if (game.prop[CHAIN] != CHAIN_HEAP) {
409 rspeak(ALREADY_LOCKED);
412 if (game.loc != objects[CHAIN].plac) {
417 game.prop[CHAIN] = CHAIN_FIXED;
420 drop(CHAIN, game.loc);
421 game.fixed[CHAIN] = -1;
423 rspeak(CHAIN_LOCKED);
427 static int discard(token_t verb, token_t obj, bool just_do_it)
428 /* Discard object. "Throw" also comes here for most objects. Special cases for
429 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
430 * Drop coins at vending machine for extra batteries. */
432 int spk = actions[verb].message;
434 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
440 if (obj == BIRD && HERE(SNAKE)) {
441 rspeak(BIRD_ATTACKS);
445 /* Set game.prop for use by travel options */
446 game.prop[SNAKE] = SNAKE_CHASED;
448 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
451 game.prop[CAVITY] = CAVITY_FULL;
452 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
453 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
460 if (spk != RUG_WIGGLES) {
461 /* FIXME: Arithmetic on state numbers */
462 int k = 2 - game.prop[RUG];
465 k = objects[SAPPH].plac;
466 move(RUG + NOBJECTS, k);
469 } else if (obj == COINS && HERE(VEND)) {
471 drop(BATTERY, game.loc);
472 pspeak(BATTERY, look, FRESH_BATTERIES, true);
474 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
478 } else if (obj == BEAR && AT(TROLL)) {
479 state_change(TROLL, TROLL_GONE);
480 move(TROLL, LOC_NOWHERE);
481 move(TROLL + NOBJECTS, LOC_NOWHERE);
482 move(TROLL2, objects[TROLL].plac);
483 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
485 } else if (obj != VASE ||
486 game.loc == objects[PILLOW].plac) {
489 game.prop[VASE] = VASE_BROKEN;
491 game.prop[VASE] = VASE_WHOLE;
492 pspeak(VASE, look, game.prop[VASE] + 1, true);
493 if (game.prop[VASE] != VASE_WHOLE)
494 game.fixed[VASE] = -1;
500 if (obj == BOTTLE && k != 0)
501 game.place[k] = LOC_NOWHERE;
502 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
503 drop(BIRD, game.loc);
507 game.prop[BIRD] = BIRD_UNCAGED;
508 if (FOREST(game.loc))
509 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
513 static int drink(token_t verb, token_t obj)
514 /* Drink. If no object, assume water and look for it here. If water is in
515 * the bottle, drink that, else must be at a water loc, so drink stream. */
517 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
518 (LIQUID() != WATER || !HERE(BOTTLE))) {
524 state_change(DRAGON, DRAGON_BLOODLESS);
529 if (obj != NO_OBJECT && obj != WATER) {
530 rspeak(RIDICULOUS_ATTEMPT);
533 if (LIQUID() == WATER && HERE(BOTTLE)) {
534 game.prop[BOTTLE] = EMPTY_BOTTLE;
535 game.place[WATER] = LOC_NOWHERE;
536 rspeak(BOTTLE_EMPTY);
540 rspeak(actions[verb].message);
544 static int eat(token_t verb, token_t obj)
545 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
546 * ok, some things lose appetite, rest are ridiculous. */
548 if (obj == INTRANSITIVE) {
552 rspeak(THANKS_DELICIOUS);
557 rspeak(THANKS_DELICIOUS);
569 rspeak(LOST_APPETITE);
572 rspeak(actions[verb].message);
576 static int extinguish(token_t verb, int obj)
577 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
579 if (obj == INTRANSITIVE) {
580 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
582 if (HERE(URN) && game.prop[URN] == URN_LIT)
584 if (obj == INTRANSITIVE)
589 if (game.prop[URN] != URN_EMPTY) {
590 state_change(URN, URN_DARK);
592 pspeak(URN, change, URN_DARK, true);
598 state_change(LAMP, LAMP_DARK);
599 rspeak(DARK(game.loc) ?
607 rspeak(BEYOND_POWER);
611 rspeak(actions[verb].message);
615 static int feed(token_t verb, token_t obj)
616 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
617 * mad. Bear, special. */
619 int spk = actions[verb].message;
623 } else if (obj == SNAKE ||
626 spk = NOTHING_EDIBLE;
627 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
628 spk = RIDICULOUS_ATTEMPT;
631 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
635 } else if (obj == DWARF) {
640 } else if (obj == BEAR) {
641 if (game.prop[BEAR] == UNTAMED_BEAR)
642 spk = NOTHING_EDIBLE;
643 if (game.prop[BEAR] == BEAR_DEAD)
644 spk = RIDICULOUS_ATTEMPT;
647 game.prop[BEAR] = SITTING_BEAR;
652 } else if (obj == OGRE) {
662 int fill(token_t verb, token_t obj)
663 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
667 if (LIQLOC(game.loc) == NO_OBJECT) {
668 rspeak(FILL_INVALID);
672 rspeak(ARENT_CARRYING);
675 rspeak(SHATTER_VASE);
676 game.prop[VASE] = VASE_BROKEN;
677 game.fixed[VASE] = -1;
678 return (discard(verb, obj, true));
682 if (game.prop[URN] != URN_EMPTY) {
687 rspeak(FILL_INVALID);
693 game.prop[BOTTLE] = EMPTY_BOTTLE;
697 game.prop[URN] = URN_DARK;
698 game.prop[BOTTLE] = EMPTY_BOTTLE;
703 rspeak(FILL_INVALID);
706 game.place[k] = LOC_NOWHERE;
709 if (obj != NO_OBJECT && obj != BOTTLE) {
710 rspeak(actions[verb].message);
713 if (obj == NO_OBJECT && !HERE(BOTTLE))
716 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
720 if (LIQUID() != NO_OBJECT) {
724 if (LIQLOC(game.loc) == NO_OBJECT) {
729 game.prop[BOTTLE] = (LIQLOC(game.loc) == OIL) ? OIL_BOTTLE : WATER_BOTTLE;
731 game.place[LIQUID()] = CARRIED;
735 rspeak(BOTTLED_WATER);
739 static int find(token_t verb, token_t obj)
740 /* Find. Might be carrying it, or it might be here. Else give caveat. */
743 rspeak(ALREADY_CARRYING);
748 rspeak(NEEDED_NEARBY);
753 (LIQUID() == obj && AT(BOTTLE)) ||
754 obj == LIQLOC(game.loc) ||
755 (obj == DWARF && atdwrf(game.loc) > 0)) {
761 rspeak(actions[verb].message);
765 static int fly(token_t verb, token_t obj)
766 /* Fly. Snide remarks unless hovering rug is here. */
768 if (obj == INTRANSITIVE) {
773 if (game.prop[RUG] != RUG_HOVER) {
774 rspeak(RUG_NOTHING2);
781 rspeak(actions[verb].message);
784 if (game.prop[RUG] != RUG_HOVER) {
785 rspeak(RUG_NOTHING1);
788 game.oldlc2 = game.oldloc;
789 game.oldloc = game.loc;
790 /* FIXME: Arithmetic on location values */
791 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
793 if (game.prop[SAPPH] >= 0) {
801 static int inven(void)
802 /* Inventory. If object, treat same as find. Else report on current burden. */
805 for (int i = 1; i <= NOBJECTS; i++) {
813 pspeak(i, touch, -1, false);
822 static int light(token_t verb, token_t obj)
823 /* Light. Applicable only to lamp and urn. */
825 if (obj == INTRANSITIVE) {
826 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
828 if (HERE(URN) && game.prop[URN] == URN_DARK)
830 if (obj == INTRANSITIVE ||
831 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
832 HERE(URN) && game.prop[URN] == URN_DARK))
837 state_change(URN, game.prop[URN] == URN_EMPTY ?
843 rspeak(actions[verb].message);
846 if (game.limit < 0) {
850 state_change(LAMP, LAMP_BRIGHT);
858 static int listen(void)
859 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
861 long sound = locations[game.loc].sound;
862 if (sound != SILENT) {
864 if (!locations[game.loc].loud)
868 for (int i = 1; i <= NOBJECTS; i++) {
870 objects[i].sounds[0] == NULL ||
873 int mi = game.prop[i];
875 mi += 3 * game.blooded;
876 long packed_zzword = token_to_packed(game.zzword);
877 pspeak(i, hear, mi, true, packed_zzword);
879 /* FIXME: Magic number, sensitive to bird state logic */
880 if (i == BIRD && game.prop[i] == 5)
888 static int lock(token_t verb, token_t obj)
889 /* Lock, unlock, no object given. Assume various things if present. */
891 if (obj == INTRANSITIVE) {
902 if (obj == INTRANSITIVE) {
903 rspeak(NOTHING_LOCKED);
908 /* Lock, unlock object. Special stuff for opening clam/oyster
918 game.clock2 = PANICTIME;
922 state_change(GRATE, (verb == LOCK) ?
936 else if (!TOTING(TRIDENT))
937 rspeak(OYSTER_OPENER);
940 drop(OYSTER, game.loc);
941 drop(PEARL, LOC_CULDESAC);
949 rspeak(OYSTER_OPENER);
953 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
959 rspeak(CANNOT_UNLOCK);
962 rspeak(actions[verb].message);
968 static int pour(token_t verb, token_t obj)
969 /* Pour. If no object, or object is bottle, assume contents of bottle.
970 * special tests for pouring water or oil on plant or rusty door. */
975 if (obj == NO_OBJECT)
978 rspeak(actions[verb].message);
982 if (obj != OIL && obj != WATER) {
986 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
987 return fill(verb, URN);
988 game.prop[BOTTLE] = EMPTY_BOTTLE;
989 game.place[obj] = LOC_NOWHERE;
997 /* cycle through the three plant states */
998 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
999 game.prop[PLANT2] = game.prop[PLANT];
1002 rspeak(SHAKING_LEAVES);
1006 state_change(DOOR, (obj == OIL) ?
1013 static int quit(void)
1014 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1016 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1017 terminate(quitgame);
1021 static int read(struct command_t command)
1022 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1024 if (command.obj == INTRANSITIVE) {
1026 for (int i = 1; i <= NOBJECTS; i++) {
1027 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1028 command.obj = command.obj * NOBJECTS + i;
1030 if (command.obj > NOBJECTS ||
1036 if (DARK(game.loc)) {
1037 sspeak(NO_SEE, command.raw1);
1038 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1039 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1040 } else if (objects[command.obj].texts[0] == NULL ||
1041 game.prop[command.obj] < 0) {
1042 rspeak(actions[command.verb].message);
1044 pspeak(command.obj, study, game.prop[command.obj], true);
1048 static int reservoir(void)
1049 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1051 /* FIXME: Arithmetic on state numbers */
1052 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
1053 rspeak(NOTHING_HAPPENS);
1057 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1061 game.oldlc2 = game.loc;
1062 game.newloc = LOC_NOWHERE;
1064 return GO_TERMINATE;
1069 static int rub(token_t verb, token_t obj)
1070 /* Rub. Yields various snide remarks except for lit urn. */
1072 if (obj == URN && game.prop[URN] == URN_LIT) {
1074 drop(AMBER, game.loc);
1075 game.prop[AMBER] = AMBER_IN_ROCK;
1077 drop(CAVITY, game.loc);
1079 } else if (obj != LAMP) {
1080 rspeak(PECULIAR_NOTHING);
1082 rspeak(actions[verb].message);
1087 static int say(struct command_t *command)
1088 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1090 if (command->wd2 > 0) {
1091 command->wd1 = command->wd2;
1092 strcpy(command->raw1, command->raw2);
1094 char word1[TOKLEN + 1];
1095 packed_to_token(command->wd1, word1);
1096 int wd = (int) get_vocab_id(word1);
1097 /* FIXME: magic numbers */
1098 if (wd == MOTION_WORD(XYZZY) ||
1099 wd == MOTION_WORD(PLUGH) ||
1100 wd == MOTION_WORD(PLOVER) ||
1101 wd == ACTION_WORD(GIANTWORDS) ||
1102 wd == ACTION_WORD(PART)) {
1103 /* FIXME: scribbles on the interpreter's command block */
1104 wordclear(&command->wd2);
1107 sspeak(OKEY_DOKEY, command->raw1);
1111 static int throw_support(long spk)
1114 drop(AXE, game.loc);
1118 static int throw (struct command_t *command)
1119 /* Throw. Same as discard unless axe. Then same as attack except
1120 * ignore bird, and if dwarf is present then one might be killed.
1121 * (Only way to do so!) Axe also special for dragon, bear, and
1122 * troll. Treasures special for troll. */
1124 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1125 command->obj = ROD2;
1126 if (!TOTING(command->obj)) {
1127 rspeak(actions[command->verb].message);
1130 if (objects[command->obj].is_treasure && AT(TROLL)) {
1131 /* Snarf a treasure for the troll. */
1132 drop(command->obj, LOC_NOWHERE);
1133 move(TROLL, LOC_NOWHERE);
1134 move(TROLL + NOBJECTS, LOC_NOWHERE);
1135 drop(TROLL2, objects[TROLL].plac);
1136 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1138 rspeak(TROLL_SATISFIED);
1141 if (command->obj == FOOD && HERE(BEAR)) {
1142 /* But throwing food is another story. */
1143 command->obj = BEAR;
1144 return (feed(command->verb, command->obj));
1146 if (command->obj != AXE)
1147 return (discard(command->verb, command->obj, false));
1149 if (atdwrf(game.loc) <= 0) {
1150 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1151 return throw_support(DRAGON_SCALES);
1153 return throw_support(TROLL_RETURNS);
1155 return throw_support(OGRE_DODGE);
1156 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1157 /* This'll teach him to throw the axe at the bear! */
1158 drop(AXE, game.loc);
1159 game.fixed[AXE] = -1;
1161 state_change(AXE, AXE_LOST);
1164 command->obj = NO_OBJECT;
1165 return (attack(command));
1168 if (randrange(NDWARVES + 1) < game.dflag) {
1169 return throw_support(DWARF_DODGES);
1171 long i = atdwrf(game.loc);
1172 game.dseen[i] = false;
1173 game.dloc[i] = LOC_NOWHERE;
1174 return throw_support((++game.dkill == 1) ?
1181 static int wake(token_t verb, token_t obj)
1182 /* Wake. Only use is to disturb the dwarves. */
1186 rspeak(actions[verb].message);
1190 return GO_DWARFWAKE;
1194 static int wave(token_t verb, token_t obj)
1195 /* Wave. No effect unless waving rod at fissure or at bird. */
1202 rspeak(((!TOTING(obj)) && (obj != ROD ||
1205 actions[verb].message);
1209 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1210 drop(JADE, game.loc);
1211 game.prop[JADE] = 0;
1213 rspeak(NECKLACE_FLY);
1217 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1220 return GO_DWARFWAKE;
1224 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1230 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1234 state_change(FISSURE,
1235 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1240 int action(struct command_t *command)
1241 /* Analyse a verb. Remember what it was, go back for object if second word
1242 * unless verb is "say", which snarfs arbitrary second word.
1245 if (command->part == unknown) {
1246 /* Analyse an object word. See if the thing is here, whether
1247 * we've got a verb yet, and so on. Object must be here
1248 * unless verb is "find" or "invent(ory)" (and no new verb
1249 * yet to be analysed). Water and oil are also funny, since
1250 * they are never actually dropped at any location, but might
1251 * be here inside the bottle or urn or as a feature of the
1253 if (HERE(command->obj))
1255 else if (command->obj == GRATE) {
1256 if (game.loc == LOC_START ||
1257 game.loc == LOC_VALLEY ||
1258 game.loc == LOC_SLIT) {
1259 command->obj = DPRSSN;
1261 if (game.loc == LOC_COBBLE ||
1262 game.loc == LOC_DEBRIS ||
1263 game.loc == LOC_AWKWARD ||
1264 game.loc == LOC_BIRD ||
1265 game.loc == LOC_PITTOP) {
1266 command->obj = ENTRNC;
1268 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1270 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1271 command->obj == LIQLOC(game.loc))
1273 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1276 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1277 command->obj = PLANT2;
1279 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1281 rspeak(KNIVES_VANISH);
1283 } else if (command->obj == ROD && HERE(ROD2)) {
1284 command->obj = ROD2;
1286 } else if ((command->verb == FIND ||
1287 command->verb == INVENTORY) && command->wd2 <= 0)
1290 sspeak(NO_SEE, command->raw1);
1294 if (command->wd2 > 0)
1296 if (command->verb != 0)
1297 command->part = transitive;
1300 switch (command->part) {
1302 if (command->wd2 > 0 && command->verb != SAY)
1304 if (command->verb == SAY)
1305 command->obj = command->wd2;
1306 if (command->obj == NO_OBJECT ||
1307 command->obj == INTRANSITIVE) {
1308 /* Analyse an intransitive verb (ie, no object given yet). */
1309 switch (command->verb) {
1311 return vcarry(command->verb, INTRANSITIVE);
1317 return lock(command->verb, INTRANSITIVE);
1320 return (GO_CLEAROBJ);
1323 return lock(command->verb, INTRANSITIVE);
1325 return light(command->verb, INTRANSITIVE);
1327 return extinguish(command->verb, INTRANSITIVE);
1333 rspeak(actions[command->verb].message);
1337 return attack(command);
1339 return pour(command->verb, command->obj);
1341 return eat(command->verb, INTRANSITIVE);
1343 return drink(command->verb, command->obj);
1357 return fill(command->verb, command->obj);
1365 return bigwords(command->wd1);
1369 command->obj = INTRANSITIVE;
1370 return read(*command);
1380 return fly(command->verb, INTRANSITIVE);
1386 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1391 /* Analyse a transitive verb. */
1392 switch (command->verb) {
1394 return vcarry(command->verb, command->obj);
1396 return discard(command->verb, command->obj, false);
1398 return say(command);
1400 return lock(command->verb, command->obj);
1403 return (GO_CLEAROBJ);
1406 return lock(command->verb, command->obj);
1408 return light(command->verb, command->obj);
1410 return extinguish(command->verb, command->obj);
1412 return wave(command->verb, command->obj);
1414 rspeak(actions[command->verb].message);
1418 rspeak(actions[command->verb].message);
1422 return attack(command);
1424 return pour(command->verb, command->obj);
1426 return eat(command->verb, command->obj);
1428 return drink(command->verb, command->obj);
1430 return rub(command->verb, command->obj);
1432 return throw (command);
1434 rspeak(actions[command->verb].message);
1438 return find(command->verb, command->obj);
1440 return find(command->verb, command->obj);
1442 return feed(command->verb, command->obj);
1444 return fill(command->verb, command->obj);
1449 rspeak(actions[command->verb].message);
1453 rspeak(actions[command->verb].message);
1457 rspeak(actions[command->verb].message);
1461 return read(*command);
1463 return vbreak(command->verb, command->obj);
1465 return wake(command->verb, command->obj);
1467 rspeak(actions[command->verb].message);
1471 rspeak(actions[command->verb].message);
1475 return fly(command->verb, command->obj);
1477 rspeak(actions[command->verb].message);
1483 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1486 /* Unknown verb, couldn't deduce object - might need hint */
1487 sspeak(WHAT_DO, command->raw1);
1488 return GO_CHECKHINT;
1490 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE