7 static int fill(verb_t, obj_t);
9 static int attack(struct command_t *command)
10 /* Attack. Assume target if unambiguous. "Throw" also links here.
11 * Attackable objects fall into two categories: enemies (snake,
12 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
13 * enemies, or no enemies but 2 others. */
15 verb_t verb = command->verb;
16 obj_t obj = command->obj;
18 if (obj == INTRANSITIVE) {
20 if (atdwrf(game.loc) > 0) {
28 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
40 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
44 /* check for low-priority targets */
45 if (obj == INTRANSITIVE) {
46 /* Can't attack bird or machine by throwing axe. */
47 if (HERE(BIRD) && verb != THROW) {
51 if (HERE(VEND) && verb != THROW) {
55 /* Clam and oyster both treated as clam for intransitive case;
57 if (HERE(CLAM) || HERE(OYSTER)) {
77 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
82 switch (game.prop[BEAR]) {
87 rspeak(BEAR_CONFUSED);
90 rspeak(BEAR_CONFUSED);
98 if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
99 /* Fun stuff for dragon. If he insists on attacking it, win!
100 * Set game.prop to dead, move dragon to central loc (still
101 * fixed), move rug there (not fixed), and move him there,
102 * too. Then do a null motion to get new description. */
103 rspeak(BARE_HANDS_QUERY);
106 speak(arbitrary_messages[NASTY_DRAGON]);
109 state_change(DRAGON, DRAGON_DEAD);
110 game.prop[RUG] = RUG_FLOOR;
111 /* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.
112 * The way it was computed before was worse; it depended on the
113 * two dragon locations being LOC_SECRET4 and LOC_SECRET6 and
114 * LOC_SECRET5 being right between them.
116 move(DRAGON + NOBJECTS, IS_FIXED);
117 move(RUG + NOBJECTS, IS_FREE);
118 move(DRAGON, LOC_SECRET5);
119 move(RUG, LOC_SECRET5);
120 drop(BLOOD, LOC_SECRET5);
121 for (obj_t i = 1; i <= NOBJECTS; i++) {
122 if (game.place[i] == objects[DRAGON].plac ||
123 game.place[i] == objects[DRAGON].fixd)
124 move(i, LOC_SECRET5);
126 game.loc = LOC_SECRET5;
132 if (atdwrf(game.loc) == 0)
135 rspeak(KNIFE_THROWN);
138 for (int i = 1; i < PIRATE; i++) {
139 if (game.dloc[i] == game.loc) {
141 game.dloc[i] = LOC_LONGWEST;
142 game.dseen[i] = false;
145 rspeak((dwarves > 1) ?
157 rspeak(SHELL_IMPERVIOUS);
160 rspeak(SNAKE_WARNING);
166 rspeak(BARE_HANDS_QUERY);
169 rspeak(ALREADY_DEAD);
175 speak(actions[verb].message);
180 static int bigwords(long id)
181 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
182 * Look up foo in special section of vocab to determine which word we've got.
183 * Last word zips the eggs back to the giant room (unless already there). */
185 if ((game.foobar == WORD_EMPTY && id == FEE) ||
186 (game.foobar == FEE && id == FIE) ||
187 (game.foobar == FIE && id == FOE) ||
188 (game.foobar == FOE && id == FOO) ||
189 (game.foobar == FOE && id == FUM)) {
191 if ((id != FOO) && (id != FUM)) {
195 game.foobar = WORD_EMPTY;
196 if (game.place[EGGS] == objects[EGGS].plac ||
197 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
198 rspeak(NOTHING_HAPPENS);
201 /* Bring back troll if we steal the eggs back from him before
203 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
204 game.prop[TROLL] = TROLL_PAIDONCE;
208 else if (game.loc == objects[EGGS].plac)
212 move(EGGS, objects[EGGS].plac);
213 pspeak(EGGS, look, k, true);
217 if (game.loc == LOC_GIANTROOM) {
220 /* This is new begavior in Open Adventure - sounds better when
221 * player isn't in the Giant Room. */
222 rspeak(WELL_POINTLESS);
224 game.foobar = WORD_EMPTY;
229 static void blast(void)
230 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
232 if (game.prop[ROD2] == STATE_NOTFOUND ||
234 rspeak(REQUIRES_DYNAMITE);
237 game.bonus = splatter;
238 rspeak(SPLATTER_MESSAGE);
239 } else if (game.loc == LOC_NE) {
241 rspeak(DEFEAT_MESSAGE);
243 game.bonus = victory;
244 rspeak(VICTORY_MESSAGE);
250 static int vbreak(verb_t verb, obj_t obj)
251 /* Break. Only works for mirror in repository and, of course, the vase. */
256 state_change(MIRROR, MIRROR_BROKEN);
263 if (game.prop[VASE] == VASE_WHOLE) {
265 drop(VASE, game.loc);
266 state_change(VASE, VASE_BROKEN);
267 game.fixed[VASE] = IS_FIXED;
271 speak(actions[verb].message);
273 return (GO_CLEAROBJ);
276 static int brief(void)
277 /* Brief. Intransitive only. Suppress long descriptions after first time. */
281 rspeak(BRIEF_CONFIRM);
285 static int vcarry(verb_t verb, obj_t obj)
286 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
287 * take one without the other). Liquids also special, since they depend on
288 * status of bottle. Also various side effects, etc. */
290 if (obj == INTRANSITIVE) {
291 /* Carry, no object given yet. OK if only one object present. */
292 if (game.atloc[game.loc] == NO_OBJECT ||
293 game.link[game.atloc[game.loc]] != 0 ||
294 atdwrf(game.loc) > 0)
296 obj = game.atloc[game.loc];
300 speak(actions[verb].message);
305 rspeak(REMOVE_MESSAGE);
310 if (game.fixed[obj] != IS_FREE) {
313 /* Next guard tests whether plant is tiny or stashed */
314 rspeak(game.prop[PLANT] <= PLANT_THIRSTY ? DEEP_ROOTS : YOU_JOKING);
317 rspeak( game.prop[BEAR] == SITTING_BEAR ? BEAR_CHAINED : YOU_JOKING);
320 rspeak( game.prop[BEAR] != UNTAMED_BEAR ? STILL_LOCKED : YOU_JOKING);
323 rspeak(game.prop[RUG] == RUG_HOVER ? RUG_HOVERS : YOU_JOKING);
329 rspeak(DOUGHNUT_HOLES);
335 rspeak(HAND_PASSTHROUGH);
347 if (!TOTING(BOTTLE)) {
348 rspeak(NO_CONTAINER);
351 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
352 return (fill(verb, BOTTLE));
360 if (game.holdng >= INVLIMIT) {
366 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
367 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
373 rspeak(CANNOT_CARRY);
380 game.prop[BIRD] = BIRD_CAGED;
384 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) {
385 /* expression maps BIRD to CAGE and CAGE to BIRD */
386 carry(BIRD + CAGE - obj, game.loc);
389 carry(obj, game.loc);
391 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
392 game.place[LIQUID()] = CARRIED;
394 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
395 game.prop[obj] = STATE_FOUND;
396 game.prop[CAVITY] = CAVITY_EMPTY;
402 static int chain(verb_t verb)
403 /* Do something to the bear's chain */
406 if (game.prop[BEAR] == UNTAMED_BEAR) {
410 if (game.prop[CHAIN] == CHAIN_HEAP) {
411 rspeak(ALREADY_UNLOCKED);
414 game.prop[CHAIN] = CHAIN_HEAP;
415 game.fixed[CHAIN] = IS_FREE;
416 if (game.prop[BEAR] != BEAR_DEAD)
417 game.prop[BEAR] = CONTENTED_BEAR;
419 switch (game.prop[BEAR]) {
422 /* Can't be reached as long as the only way for the bear to die
423 * is from a bridge collapse. Leave in in case this changes, but
424 * exclude from coverage testing. */
425 game.fixed[BEAR] = IS_FIXED;
429 game.fixed[BEAR] = IS_FREE;
431 rspeak(CHAIN_UNLOCKED);
435 if (game.prop[CHAIN] != CHAIN_HEAP) {
436 rspeak(ALREADY_LOCKED);
439 if (game.loc != objects[CHAIN].plac) {
444 game.prop[CHAIN] = CHAIN_FIXED;
447 drop(CHAIN, game.loc);
448 game.fixed[CHAIN] = IS_FIXED;
450 rspeak(CHAIN_LOCKED);
454 static int discard(verb_t verb, obj_t obj)
455 /* Discard object. "Throw" also comes here for most objects. Special cases for
456 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
457 * Drop coins at vending machine for extra batteries. */
459 if (obj == ROD && !TOTING(ROD) && TOTING(ROD2)) {
464 speak(actions[verb].message);
468 if (GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL) {
470 game.prop[obj] = STATE_IN_CAVITY;
471 game.prop[CAVITY] = CAVITY_FULL;
472 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
473 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
476 else if (TOTING(RUG))
480 if (!TOTING(RUG) || obj == RUBY) {
481 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
484 k = objects[SAPPH].plac;
485 move(RUG + NOBJECTS, k);
492 if (obj == COINS && HERE(VEND)) {
494 drop(BATTERY, game.loc);
495 pspeak(BATTERY, look, FRESH_BATTERIES, true);
501 if (obj == BOTTLE && LIQUID() != NO_OBJECT) {
502 game.place[LIQUID()] = LOC_NOWHERE;
505 if (obj == BEAR && AT(TROLL)) {
506 state_change(TROLL, TROLL_GONE);
507 move(TROLL, LOC_NOWHERE);
508 move(TROLL + NOBJECTS, IS_FREE);
509 move(TROLL2, objects[TROLL].plac);
510 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
517 if (game.loc != objects[PILLOW].plac) {
518 state_change(VASE, AT(PILLOW)
521 if (game.prop[VASE] != VASE_WHOLE)
522 game.fixed[VASE] = IS_FIXED;
528 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) {
529 drop(BIRD, game.loc);
533 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
539 rspeak(BIRD_ATTACKS);
543 /* Set game.prop for use by travel options */
544 game.prop[SNAKE] = SNAKE_CHASED;
548 game.prop[BIRD] = FOREST(game.loc) ? BIRD_FOREST_UNCAGED : BIRD_UNCAGED;
558 static int drink(verb_t verb, obj_t obj)
559 /* Drink. If no object, assume water and look for it here. If water is in
560 * the bottle, drink that, else must be at a water loc, so drink stream. */
562 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
563 (LIQUID() != WATER || !HERE(BOTTLE))) {
569 state_change(DRAGON, DRAGON_BLOODLESS);
574 if (obj != INTRANSITIVE && obj != WATER) {
575 rspeak(RIDICULOUS_ATTEMPT);
578 if (LIQUID() == WATER && HERE(BOTTLE)) {
579 game.place[WATER] = LOC_NOWHERE;
580 state_change(BOTTLE, EMPTY_BOTTLE);
584 speak(actions[verb].message);
588 static int eat(verb_t verb, obj_t obj)
589 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
590 * ok, some things lose appetite, rest are ridiculous. */
598 rspeak(THANKS_DELICIOUS);
609 rspeak(LOST_APPETITE);
612 speak(actions[verb].message);
617 static int extinguish(verb_t verb, obj_t obj)
618 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
620 if (obj == INTRANSITIVE) {
621 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
623 if (HERE(URN) && game.prop[URN] == URN_LIT)
625 if (obj == INTRANSITIVE)
631 if (game.prop[URN] != URN_EMPTY) {
632 state_change(URN, URN_DARK);
634 pspeak(URN, change, URN_DARK, true);
638 state_change(LAMP, LAMP_DARK);
639 rspeak(DARK(game.loc) ?
645 rspeak(BEYOND_POWER);
648 speak(actions[verb].message);
653 static int feed(verb_t verb, obj_t obj)
654 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
655 * mad. Bear, special. */
662 if (game.prop[DRAGON] != DRAGON_BARS)
663 rspeak(RIDICULOUS_ATTEMPT);
665 rspeak(NOTHING_EDIBLE);
668 if (!game.closed && HERE(BIRD)) {
670 rspeak(BIRD_DEVOURED);
672 rspeak(NOTHING_EDIBLE);
682 speak(actions[verb].message);
685 if (game.prop[BEAR] == BEAR_DEAD) {
686 rspeak(RIDICULOUS_ATTEMPT);
689 if (game.prop[BEAR] == UNTAMED_BEAR) {
692 game.fixed[AXE] = IS_FREE;
693 game.prop[AXE] = AXE_HERE;
694 state_change(BEAR, SITTING_BEAR);
696 rspeak(NOTHING_EDIBLE);
699 speak(actions[verb].message);
705 speak(actions[verb].message);
713 int fill(verb_t verb, obj_t obj)
714 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
718 if (LIQLOC(game.loc) == NO_OBJECT) {
719 rspeak(FILL_INVALID);
723 rspeak(ARENT_CARRYING);
726 rspeak(SHATTER_VASE);
727 game.prop[VASE] = VASE_BROKEN;
728 game.fixed[VASE] = IS_FIXED;
729 drop(VASE, game.loc);
734 if (game.prop[URN] != URN_EMPTY) {
739 rspeak(FILL_INVALID);
745 game.prop[BOTTLE] = EMPTY_BOTTLE;
749 game.prop[URN] = URN_DARK;
750 game.prop[BOTTLE] = EMPTY_BOTTLE;
755 rspeak(FILL_INVALID);
758 game.place[k] = LOC_NOWHERE;
761 if (obj != INTRANSITIVE && obj != BOTTLE) {
762 speak(actions[verb].message);
765 if (obj == INTRANSITIVE && !HERE(BOTTLE))
768 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
772 if (LIQUID() != NO_OBJECT) {
776 if (LIQLOC(game.loc) == NO_OBJECT) {
781 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
785 game.place[LIQUID()] = CARRIED;
789 static int find(verb_t verb, obj_t obj)
790 /* Find. Might be carrying it, or it might be here. Else give caveat. */
793 rspeak(ALREADY_CARRYING);
798 rspeak(NEEDED_NEARBY);
803 (LIQUID() == obj && AT(BOTTLE)) ||
804 obj == LIQLOC(game.loc) ||
805 (obj == DWARF && atdwrf(game.loc) > 0)) {
811 speak(actions[verb].message);
815 static int fly(verb_t verb, obj_t obj)
816 /* Fly. Snide remarks unless hovering rug is here. */
818 if (obj == INTRANSITIVE) {
823 if (game.prop[RUG] != RUG_HOVER) {
824 rspeak(RUG_NOTHING2);
831 speak(actions[verb].message);
834 if (game.prop[RUG] != RUG_HOVER) {
835 rspeak(RUG_NOTHING1);
838 game.oldlc2 = game.oldloc;
839 game.oldloc = game.loc;
841 if (game.prop[SAPPH] == STATE_NOTFOUND) {
842 game.newloc = game.place[SAPPH];
845 game.newloc = LOC_CLIFF;
851 static int inven(void)
852 /* Inventory. If object, treat same as find. Else report on current burden. */
855 for (obj_t i = 1; i <= NOBJECTS; i++) {
863 pspeak(i, touch, -1, false);
872 static int light(verb_t verb, obj_t obj)
873 /* Light. Applicable only to lamp and urn. */
875 if (obj == INTRANSITIVE) {
877 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
881 if (HERE(URN) && game.prop[URN] == URN_DARK) {
891 state_change(URN, game.prop[URN] == URN_EMPTY ?
896 if (game.limit < 0) {
900 state_change(LAMP, LAMP_BRIGHT);
905 speak(actions[verb].message);
910 static int listen(void)
911 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
913 long sound = locations[game.loc].sound;
914 if (sound != SILENT) {
916 if (!locations[game.loc].loud)
920 for (obj_t i = 1; i <= NOBJECTS; i++) {
922 objects[i].sounds[0] == NULL ||
925 int mi = game.prop[i];
926 /* (ESR) Some unpleasant magic on object states here. Ideally
927 * we'd have liked the bird to be a normal object that we can
928 * use state_change() on; can't do it, because there are
929 * actually two different series of per-state birdsounds
930 * depending on whether player has drunk dragon's blood. */
932 mi += 3 * game.blooded;
933 long packed_zzword = token_to_packed(game.zzword);
934 pspeak(i, hear, mi, true, packed_zzword);
936 if (i == BIRD && mi == BIRD_ENDSTATE)
944 static int lock(verb_t verb, obj_t obj)
945 /* Lock, unlock, no object given. Assume various things if present. */
947 if (obj == INTRANSITIVE) {
958 if (obj == INTRANSITIVE) {
959 rspeak(NOTHING_LOCKED);
964 /* Lock, unlock object. Special stuff for opening clam/oyster
979 game.clock2 = PANICTIME;
982 state_change(GRATE, (verb == LOCK) ?
992 else if (!TOTING(TRIDENT))
996 drop(OYSTER, game.loc);
997 drop(PEARL, LOC_CULDESAC);
1004 else if (TOTING(OYSTER))
1005 rspeak(DROP_OYSTER);
1006 else if (!TOTING(TRIDENT))
1007 rspeak(OYSTER_OPENER);
1009 rspeak(OYSTER_OPENS);
1012 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
1018 rspeak(CANNOT_UNLOCK);
1021 speak(actions[verb].message);
1027 static int pour(verb_t verb, obj_t obj)
1028 /* Pour. If no object, or object is bottle, assume contents of bottle.
1029 * special tests for pouring water or oil on plant or rusty door. */
1031 if (obj == BOTTLE ||
1032 obj == INTRANSITIVE)
1034 if (obj == NO_OBJECT)
1037 speak(actions[verb].message);
1041 if (obj != OIL && obj != WATER) {
1045 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1046 return fill(verb, URN);
1047 game.prop[BOTTLE] = EMPTY_BOTTLE;
1048 game.place[obj] = LOC_NOWHERE;
1056 /* cycle through the three plant states */
1057 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1058 game.prop[PLANT2] = game.prop[PLANT];
1061 rspeak(SHAKING_LEAVES);
1065 state_change(DOOR, (obj == OIL) ?
1072 static int quit(void)
1073 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1075 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1076 terminate(quitgame);
1080 static int read(struct command_t command)
1081 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1083 if (command.obj == INTRANSITIVE) {
1084 command.obj = NO_OBJECT;
1085 for (int i = 1; i <= NOBJECTS; i++) {
1086 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1087 command.obj = command.obj * NOBJECTS + i;
1089 if (command.obj > NOBJECTS ||
1090 command.obj == NO_OBJECT ||
1095 if (DARK(game.loc)) {
1096 sspeak(NO_SEE, command.raw1);
1097 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1098 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1099 } else if (objects[command.obj].texts[0] == NULL ||
1100 game.prop[command.obj] == STATE_NOTFOUND) {
1101 speak(actions[command.verb].message);
1103 pspeak(command.obj, study, game.prop[command.obj], true);
1107 static int reservoir(void)
1108 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1110 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1111 rspeak(NOTHING_HAPPENS);
1115 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1119 game.oldlc2 = game.loc;
1120 game.newloc = LOC_NOWHERE;
1122 return GO_TERMINATE;
1127 static int rub(verb_t verb, obj_t obj)
1128 /* Rub. Yields various snide remarks except for lit urn. */
1130 if (obj == URN && game.prop[URN] == URN_LIT) {
1132 drop(AMBER, game.loc);
1133 game.prop[AMBER] = AMBER_IN_ROCK;
1135 drop(CAVITY, game.loc);
1137 } else if (obj != LAMP) {
1138 rspeak(PECULIAR_NOTHING);
1140 speak(actions[verb].message);
1145 static int say(struct command_t *command)
1146 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1148 if (command->wd2 > 0) {
1149 command->wd1 = command->wd2;
1150 strncpy(command->raw1, command->raw2, LINESIZE - 1);
1152 char word1[TOKLEN + 1];
1153 packed_to_token(command->wd1, word1);
1156 get_vocab_metadata(word1, &wd, &type);
1166 /* FIXME: scribbles on the interpreter's command block */
1167 wordclear(&command->wd2);
1170 sspeak(OKEY_DOKEY, command->raw1);
1174 static int throw_support(long spk)
1177 drop(AXE, game.loc);
1181 static int throw (struct command_t *command)
1182 /* Throw. Same as discard unless axe. Then same as attack except
1183 * ignore bird, and if dwarf is present then one might be killed.
1184 * (Only way to do so!) Axe also special for dragon, bear, and
1185 * troll. Treasures special for troll. */
1187 if (!TOTING(command->obj)) {
1188 speak(actions[command->verb].message);
1191 if (objects[command->obj].is_treasure && AT(TROLL)) {
1192 /* Snarf a treasure for the troll. */
1193 drop(command->obj, LOC_NOWHERE);
1194 move(TROLL, LOC_NOWHERE);
1195 move(TROLL + NOBJECTS, IS_FREE);
1196 drop(TROLL2, objects[TROLL].plac);
1197 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1199 rspeak(TROLL_SATISFIED);
1202 if (command->obj == FOOD && HERE(BEAR)) {
1203 /* But throwing food is another story. */
1204 command->obj = BEAR;
1205 return (feed(command->verb, command->obj));
1207 if (command->obj != AXE)
1208 return (discard(command->verb, command->obj));
1210 if (atdwrf(game.loc) <= 0) {
1211 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1212 return throw_support(DRAGON_SCALES);
1214 return throw_support(TROLL_RETURNS);
1216 return throw_support(OGRE_DODGE);
1217 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1218 /* This'll teach him to throw the axe at the bear! */
1219 drop(AXE, game.loc);
1220 game.fixed[AXE] = IS_FIXED;
1222 state_change(AXE, AXE_LOST);
1225 command->obj = INTRANSITIVE;
1226 return (attack(command));
1229 if (randrange(NDWARVES + 1) < game.dflag) {
1230 return throw_support(DWARF_DODGES);
1232 long i = atdwrf(game.loc);
1233 game.dseen[i] = false;
1234 game.dloc[i] = LOC_NOWHERE;
1235 return throw_support((++game.dkill == 1) ?
1242 static int wake(verb_t verb, obj_t obj)
1243 /* Wake. Only use is to disturb the dwarves. */
1247 speak(actions[verb].message);
1251 return GO_DWARFWAKE;
1255 static int wave(verb_t verb, obj_t obj)
1256 /* Wave. No effect unless waving rod at fissure or at bird. */
1263 speak(((!TOTING(obj)) && (obj != ROD ||
1265 arbitrary_messages[ARENT_CARRYING] :
1266 actions[verb].message);
1270 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1271 drop(JADE, game.loc);
1272 game.prop[JADE] = STATE_FOUND;
1274 rspeak(NECKLACE_FLY);
1278 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1281 return GO_DWARFWAKE;
1285 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1291 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1295 state_change(FISSURE,
1296 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1301 int action(struct command_t *command)
1302 /* Analyse a verb. Remember what it was, go back for object if second word
1303 * unless verb is "say", which snarfs arbitrary second word.
1306 if (command->part == unknown) {
1307 /* Analyse an object word. See if the thing is here, whether
1308 * we've got a verb yet, and so on. Object must be here
1309 * unless verb is "find" or "invent(ory)" (and no new verb
1310 * yet to be analysed). Water and oil are also funny, since
1311 * they are never actually dropped at any location, but might
1312 * be here inside the bottle or urn or as a feature of the
1314 if (HERE(command->obj))
1316 else if (command->obj == GRATE) {
1317 if (game.loc == LOC_START ||
1318 game.loc == LOC_VALLEY ||
1319 game.loc == LOC_SLIT) {
1320 command->obj = DPRSSN;
1322 if (game.loc == LOC_COBBLE ||
1323 game.loc == LOC_DEBRIS ||
1324 game.loc == LOC_AWKWARD ||
1325 game.loc == LOC_BIRD ||
1326 game.loc == LOC_PITTOP) {
1327 command->obj = ENTRNC;
1329 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1331 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1332 command->obj == LIQLOC(game.loc))
1334 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1337 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1338 command->obj = PLANT2;
1340 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1342 rspeak(KNIVES_VANISH);
1344 } else if (command->obj == ROD && HERE(ROD2)) {
1345 command->obj = ROD2;
1347 } else if ((command->verb == FIND ||
1348 command->verb == INVENTORY) && (command->id2 == WORD_EMPTY || command->id2 == WORD_NOT_FOUND))
1351 sspeak(NO_SEE, command->raw1);
1355 if (command->id2 != WORD_EMPTY && command->id2 != WORD_NOT_FOUND)
1357 if (command->verb != 0)
1358 command->part = transitive;
1361 switch (command->part) {
1363 if (command->wd2 > 0 && command->verb != SAY)
1365 if (command->verb == SAY)
1366 command->obj = command->wd2;
1367 if (command->obj == NO_OBJECT ||
1368 command->obj == INTRANSITIVE) {
1369 /* Analyse an intransitive verb (ie, no object given yet). */
1370 switch (command->verb) {
1372 return vcarry(command->verb, INTRANSITIVE);
1378 return lock(command->verb, INTRANSITIVE);
1381 return (GO_CLEAROBJ);
1384 return lock(command->verb, INTRANSITIVE);
1386 return light(command->verb, INTRANSITIVE);
1388 return extinguish(command->verb, INTRANSITIVE);
1394 speak(actions[command->verb].message);
1398 command->obj = INTRANSITIVE;
1399 return attack(command);
1401 return pour(command->verb, INTRANSITIVE);
1403 return eat(command->verb, INTRANSITIVE);
1405 return drink(command->verb, INTRANSITIVE);
1419 return fill(command->verb, INTRANSITIVE);
1431 return bigwords(command->id1);
1435 command->obj = INTRANSITIVE;
1436 return read(*command);
1446 return fly(command->verb, INTRANSITIVE);
1452 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1457 /* Analyse a transitive verb. */
1458 switch (command->verb) {
1460 return vcarry(command->verb, command->obj);
1462 return discard(command->verb, command->obj);
1464 return say(command);
1466 return lock(command->verb, command->obj);
1469 return (GO_CLEAROBJ);
1472 return lock(command->verb, command->obj);
1474 return light(command->verb, command->obj);
1476 return extinguish(command->verb, command->obj);
1478 return wave(command->verb, command->obj);
1480 speak(actions[command->verb].message);
1484 speak(actions[command->verb].message);
1488 return attack(command);
1490 return pour(command->verb, command->obj);
1492 return eat(command->verb, command->obj);
1494 return drink(command->verb, command->obj);
1496 return rub(command->verb, command->obj);
1498 return throw (command);
1500 speak(actions[command->verb].message);
1504 return find(command->verb, command->obj);
1506 return find(command->verb, command->obj);
1508 return feed(command->verb, command->obj);
1510 return fill(command->verb, command->obj);
1515 speak(actions[command->verb].message);
1523 speak(actions[command->verb].message);
1527 speak(actions[command->verb].message);
1531 return read(*command);
1533 return vbreak(command->verb, command->obj);
1535 return wake(command->verb, command->obj);
1537 speak(actions[command->verb].message);
1541 speak(actions[command->verb].message);
1545 return fly(command->verb, command->obj);
1547 speak(actions[command->verb].message);
1553 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1556 /* Unknown verb, couldn't deduce object - might need hint */
1557 sspeak(WHAT_DO, command->raw1);
1558 return GO_CHECKHINT;
1560 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE