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 rspeak(BREAK_MIRROR);
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] = BIRD_UNCAGED;
549 if (FOREST(game.loc))
550 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
560 static int drink(verb_t verb, obj_t obj)
561 /* Drink. If no object, assume water and look for it here. If water is in
562 * the bottle, drink that, else must be at a water loc, so drink stream. */
564 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
565 (LIQUID() != WATER || !HERE(BOTTLE))) {
571 state_change(DRAGON, DRAGON_BLOODLESS);
576 if (obj != INTRANSITIVE && obj != WATER) {
577 rspeak(RIDICULOUS_ATTEMPT);
580 if (LIQUID() == WATER && HERE(BOTTLE)) {
581 game.place[WATER] = LOC_NOWHERE;
582 state_change(BOTTLE, EMPTY_BOTTLE);
586 speak(actions[verb].message);
590 static int eat(verb_t verb, obj_t obj)
591 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
592 * ok, some things lose appetite, rest are ridiculous. */
600 rspeak(THANKS_DELICIOUS);
611 rspeak(LOST_APPETITE);
614 speak(actions[verb].message);
619 static int extinguish(verb_t verb, obj_t obj)
620 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
622 if (obj == INTRANSITIVE) {
623 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
625 if (HERE(URN) && game.prop[URN] == URN_LIT)
627 if (obj == INTRANSITIVE)
633 if (game.prop[URN] != URN_EMPTY) {
634 state_change(URN, URN_DARK);
636 pspeak(URN, change, URN_DARK, true);
640 state_change(LAMP, LAMP_DARK);
641 rspeak(DARK(game.loc) ?
647 rspeak(BEYOND_POWER);
650 speak(actions[verb].message);
655 static int feed(verb_t verb, obj_t obj)
656 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
657 * mad. Bear, special. */
664 if (game.prop[DRAGON] != DRAGON_BARS)
665 rspeak(RIDICULOUS_ATTEMPT);
667 rspeak(NOTHING_EDIBLE);
670 if (!game.closed && HERE(BIRD)) {
672 rspeak(BIRD_DEVOURED);
674 rspeak(NOTHING_EDIBLE);
684 speak(actions[verb].message);
687 if (game.prop[BEAR] == BEAR_DEAD) {
688 rspeak(RIDICULOUS_ATTEMPT);
691 if (game.prop[BEAR] == UNTAMED_BEAR) {
694 game.fixed[AXE] = IS_FREE;
695 game.prop[AXE] = AXE_HERE;
696 state_change(BEAR, SITTING_BEAR);
698 rspeak(NOTHING_EDIBLE);
701 speak(actions[verb].message);
707 speak(actions[verb].message);
715 int fill(verb_t verb, obj_t obj)
716 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
720 if (LIQLOC(game.loc) == NO_OBJECT) {
721 rspeak(FILL_INVALID);
725 rspeak(ARENT_CARRYING);
728 rspeak(SHATTER_VASE);
729 game.prop[VASE] = VASE_BROKEN;
730 game.fixed[VASE] = IS_FIXED;
731 drop(VASE, game.loc);
736 if (game.prop[URN] != URN_EMPTY) {
741 rspeak(FILL_INVALID);
747 game.prop[BOTTLE] = EMPTY_BOTTLE;
751 game.prop[URN] = URN_DARK;
752 game.prop[BOTTLE] = EMPTY_BOTTLE;
757 rspeak(FILL_INVALID);
760 game.place[k] = LOC_NOWHERE;
763 if (obj != INTRANSITIVE && obj != BOTTLE) {
764 speak(actions[verb].message);
767 if (obj == INTRANSITIVE && !HERE(BOTTLE))
770 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
774 if (LIQUID() != NO_OBJECT) {
778 if (LIQLOC(game.loc) == NO_OBJECT) {
783 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
787 game.place[LIQUID()] = CARRIED;
791 static int find(verb_t verb, obj_t obj)
792 /* Find. Might be carrying it, or it might be here. Else give caveat. */
795 rspeak(ALREADY_CARRYING);
800 rspeak(NEEDED_NEARBY);
805 (LIQUID() == obj && AT(BOTTLE)) ||
806 obj == LIQLOC(game.loc) ||
807 (obj == DWARF && atdwrf(game.loc) > 0)) {
813 speak(actions[verb].message);
817 static int fly(verb_t verb, obj_t obj)
818 /* Fly. Snide remarks unless hovering rug is here. */
820 if (obj == INTRANSITIVE) {
825 if (game.prop[RUG] != RUG_HOVER) {
826 rspeak(RUG_NOTHING2);
833 speak(actions[verb].message);
836 if (game.prop[RUG] != RUG_HOVER) {
837 rspeak(RUG_NOTHING1);
840 game.oldlc2 = game.oldloc;
841 game.oldloc = game.loc;
843 if (game.prop[SAPPH] == STATE_NOTFOUND) {
844 game.newloc = game.place[SAPPH];
847 game.newloc = LOC_CLIFF;
853 static int inven(void)
854 /* Inventory. If object, treat same as find. Else report on current burden. */
857 for (obj_t i = 1; i <= NOBJECTS; i++) {
865 pspeak(i, touch, -1, false);
874 static int light(verb_t verb, obj_t obj)
875 /* Light. Applicable only to lamp and urn. */
877 if (obj == INTRANSITIVE) {
879 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
883 if (HERE(URN) && game.prop[URN] == URN_DARK) {
893 state_change(URN, game.prop[URN] == URN_EMPTY ?
898 if (game.limit < 0) {
902 state_change(LAMP, LAMP_BRIGHT);
907 speak(actions[verb].message);
912 static int listen(void)
913 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
915 long sound = locations[game.loc].sound;
916 if (sound != SILENT) {
918 if (!locations[game.loc].loud)
922 for (obj_t i = 1; i <= NOBJECTS; i++) {
924 objects[i].sounds[0] == NULL ||
927 int mi = game.prop[i];
928 /* (ESR) Some unpleasant magic on object states here. Ideally
929 * we'd have liked the bird to be a normal object that we can
930 * use state_change() on; can't do it, because there are
931 * actually two different series of per-state birdsounds
932 * depending on whether player has drunk dragon's blood. */
934 mi += 3 * game.blooded;
935 long packed_zzword = token_to_packed(game.zzword);
936 pspeak(i, hear, mi, true, packed_zzword);
938 if (i == BIRD && mi == BIRD_ENDSTATE)
946 static int lock(verb_t verb, obj_t obj)
947 /* Lock, unlock, no object given. Assume various things if present. */
949 if (obj == INTRANSITIVE) {
960 if (obj == INTRANSITIVE) {
961 rspeak(NOTHING_LOCKED);
966 /* Lock, unlock object. Special stuff for opening clam/oyster
981 game.clock2 = PANICTIME;
984 state_change(GRATE, (verb == LOCK) ?
994 else if (!TOTING(TRIDENT))
998 drop(OYSTER, game.loc);
999 drop(PEARL, LOC_CULDESAC);
1000 rspeak(PEARL_FALLS);
1006 else if (TOTING(OYSTER))
1007 rspeak(DROP_OYSTER);
1008 else if (!TOTING(TRIDENT))
1009 rspeak(OYSTER_OPENER);
1011 rspeak(OYSTER_OPENS);
1014 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
1020 rspeak(CANNOT_UNLOCK);
1023 speak(actions[verb].message);
1029 static int pour(verb_t verb, obj_t obj)
1030 /* Pour. If no object, or object is bottle, assume contents of bottle.
1031 * special tests for pouring water or oil on plant or rusty door. */
1033 if (obj == BOTTLE ||
1034 obj == INTRANSITIVE)
1036 if (obj == NO_OBJECT)
1039 speak(actions[verb].message);
1043 if (obj != OIL && obj != WATER) {
1047 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1048 return fill(verb, URN);
1049 game.prop[BOTTLE] = EMPTY_BOTTLE;
1050 game.place[obj] = LOC_NOWHERE;
1058 /* cycle through the three plant states */
1059 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1060 game.prop[PLANT2] = game.prop[PLANT];
1063 rspeak(SHAKING_LEAVES);
1067 state_change(DOOR, (obj == OIL) ?
1074 static int quit(void)
1075 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1077 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1078 terminate(quitgame);
1082 static int read(struct command_t command)
1083 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1085 if (command.obj == INTRANSITIVE) {
1086 command.obj = NO_OBJECT;
1087 for (int i = 1; i <= NOBJECTS; i++) {
1088 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1089 command.obj = command.obj * NOBJECTS + i;
1091 if (command.obj > NOBJECTS ||
1092 command.obj == NO_OBJECT ||
1097 if (DARK(game.loc)) {
1098 sspeak(NO_SEE, command.raw1);
1099 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1100 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1101 } else if (objects[command.obj].texts[0] == NULL ||
1102 game.prop[command.obj] == STATE_NOTFOUND) {
1103 speak(actions[command.verb].message);
1105 pspeak(command.obj, study, game.prop[command.obj], true);
1109 static int reservoir(void)
1110 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1112 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1113 rspeak(NOTHING_HAPPENS);
1117 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1121 game.oldlc2 = game.loc;
1122 game.newloc = LOC_NOWHERE;
1124 return GO_TERMINATE;
1129 static int rub(verb_t verb, obj_t obj)
1130 /* Rub. Yields various snide remarks except for lit urn. */
1132 if (obj == URN && game.prop[URN] == URN_LIT) {
1134 drop(AMBER, game.loc);
1135 game.prop[AMBER] = AMBER_IN_ROCK;
1137 drop(CAVITY, game.loc);
1139 } else if (obj != LAMP) {
1140 rspeak(PECULIAR_NOTHING);
1142 speak(actions[verb].message);
1147 static int say(struct command_t *command)
1148 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1150 if (command->wd2 > 0) {
1151 command->wd1 = command->wd2;
1152 strncpy(command->raw1, command->raw2, LINESIZE - 1);
1154 char word1[TOKLEN + 1];
1155 packed_to_token(command->wd1, word1);
1158 get_vocab_metadata(word1, &wd, &type);
1168 /* FIXME: scribbles on the interpreter's command block */
1169 wordclear(&command->wd2);
1172 sspeak(OKEY_DOKEY, command->raw1);
1176 static int throw_support(long spk)
1179 drop(AXE, game.loc);
1183 static int throw (struct command_t *command)
1184 /* Throw. Same as discard unless axe. Then same as attack except
1185 * ignore bird, and if dwarf is present then one might be killed.
1186 * (Only way to do so!) Axe also special for dragon, bear, and
1187 * troll. Treasures special for troll. */
1189 if (!TOTING(command->obj)) {
1190 speak(actions[command->verb].message);
1193 if (objects[command->obj].is_treasure && AT(TROLL)) {
1194 /* Snarf a treasure for the troll. */
1195 drop(command->obj, LOC_NOWHERE);
1196 move(TROLL, LOC_NOWHERE);
1197 move(TROLL + NOBJECTS, IS_FREE);
1198 drop(TROLL2, objects[TROLL].plac);
1199 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1201 rspeak(TROLL_SATISFIED);
1204 if (command->obj == FOOD && HERE(BEAR)) {
1205 /* But throwing food is another story. */
1206 command->obj = BEAR;
1207 return (feed(command->verb, command->obj));
1209 if (command->obj != AXE)
1210 return (discard(command->verb, command->obj));
1212 if (atdwrf(game.loc) <= 0) {
1213 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1214 return throw_support(DRAGON_SCALES);
1216 return throw_support(TROLL_RETURNS);
1218 return throw_support(OGRE_DODGE);
1219 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1220 /* This'll teach him to throw the axe at the bear! */
1221 drop(AXE, game.loc);
1222 game.fixed[AXE] = IS_FIXED;
1224 state_change(AXE, AXE_LOST);
1227 command->obj = INTRANSITIVE;
1228 return (attack(command));
1231 if (randrange(NDWARVES + 1) < game.dflag) {
1232 return throw_support(DWARF_DODGES);
1234 long i = atdwrf(game.loc);
1235 game.dseen[i] = false;
1236 game.dloc[i] = LOC_NOWHERE;
1237 return throw_support((++game.dkill == 1) ?
1244 static int wake(verb_t verb, obj_t obj)
1245 /* Wake. Only use is to disturb the dwarves. */
1249 speak(actions[verb].message);
1253 return GO_DWARFWAKE;
1257 static int wave(verb_t verb, obj_t obj)
1258 /* Wave. No effect unless waving rod at fissure or at bird. */
1265 speak(((!TOTING(obj)) && (obj != ROD ||
1267 arbitrary_messages[ARENT_CARRYING] :
1268 actions[verb].message);
1272 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1273 drop(JADE, game.loc);
1274 game.prop[JADE] = STATE_FOUND;
1276 rspeak(NECKLACE_FLY);
1280 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1283 return GO_DWARFWAKE;
1287 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1293 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1297 state_change(FISSURE,
1298 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1303 int action(struct command_t *command)
1304 /* Analyse a verb. Remember what it was, go back for object if second word
1305 * unless verb is "say", which snarfs arbitrary second word.
1308 if (command->part == unknown) {
1309 /* Analyse an object word. See if the thing is here, whether
1310 * we've got a verb yet, and so on. Object must be here
1311 * unless verb is "find" or "invent(ory)" (and no new verb
1312 * yet to be analysed). Water and oil are also funny, since
1313 * they are never actually dropped at any location, but might
1314 * be here inside the bottle or urn or as a feature of the
1316 if (HERE(command->obj))
1318 else if (command->obj == GRATE) {
1319 if (game.loc == LOC_START ||
1320 game.loc == LOC_VALLEY ||
1321 game.loc == LOC_SLIT) {
1322 command->obj = DPRSSN;
1324 if (game.loc == LOC_COBBLE ||
1325 game.loc == LOC_DEBRIS ||
1326 game.loc == LOC_AWKWARD ||
1327 game.loc == LOC_BIRD ||
1328 game.loc == LOC_PITTOP) {
1329 command->obj = ENTRNC;
1331 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1333 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1334 command->obj == LIQLOC(game.loc))
1336 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1339 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1340 command->obj = PLANT2;
1342 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1344 rspeak(KNIVES_VANISH);
1346 } else if (command->obj == ROD && HERE(ROD2)) {
1347 command->obj = ROD2;
1349 } else if ((command->verb == FIND ||
1350 command->verb == INVENTORY) && command->wd2 <= 0)
1353 sspeak(NO_SEE, command->raw1);
1357 if (command->wd2 > 0)
1359 if (command->verb != 0)
1360 command->part = transitive;
1363 switch (command->part) {
1365 if (command->wd2 > 0 && command->verb != SAY)
1367 if (command->verb == SAY)
1368 command->obj = command->wd2;
1369 if (command->obj == NO_OBJECT ||
1370 command->obj == INTRANSITIVE) {
1371 /* Analyse an intransitive verb (ie, no object given yet). */
1372 switch (command->verb) {
1374 return vcarry(command->verb, INTRANSITIVE);
1380 return lock(command->verb, INTRANSITIVE);
1383 return (GO_CLEAROBJ);
1386 return lock(command->verb, INTRANSITIVE);
1388 return light(command->verb, INTRANSITIVE);
1390 return extinguish(command->verb, INTRANSITIVE);
1396 speak(actions[command->verb].message);
1400 command->obj = INTRANSITIVE;
1401 return attack(command);
1403 return pour(command->verb, INTRANSITIVE);
1405 return eat(command->verb, INTRANSITIVE);
1407 return drink(command->verb, INTRANSITIVE);
1421 return fill(command->verb, INTRANSITIVE);
1433 return bigwords(command->id1);
1437 command->obj = INTRANSITIVE;
1438 return read(*command);
1448 return fly(command->verb, INTRANSITIVE);
1454 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1459 /* Analyse a transitive verb. */
1460 switch (command->verb) {
1462 return vcarry(command->verb, command->obj);
1464 return discard(command->verb, command->obj);
1466 return say(command);
1468 return lock(command->verb, command->obj);
1471 return (GO_CLEAROBJ);
1474 return lock(command->verb, command->obj);
1476 return light(command->verb, command->obj);
1478 return extinguish(command->verb, command->obj);
1480 return wave(command->verb, command->obj);
1482 speak(actions[command->verb].message);
1486 speak(actions[command->verb].message);
1490 return attack(command);
1492 return pour(command->verb, command->obj);
1494 return eat(command->verb, command->obj);
1496 return drink(command->verb, command->obj);
1498 return rub(command->verb, command->obj);
1500 return throw (command);
1502 speak(actions[command->verb].message);
1506 return find(command->verb, command->obj);
1508 return find(command->verb, command->obj);
1510 return feed(command->verb, command->obj);
1512 return fill(command->verb, command->obj);
1517 speak(actions[command->verb].message);
1525 speak(actions[command->verb].message);
1529 speak(actions[command->verb].message);
1533 return read(*command);
1535 return vbreak(command->verb, command->obj);
1537 return wake(command->verb, command->obj);
1539 speak(actions[command->verb].message);
1543 speak(actions[command->verb].message);
1547 return fly(command->verb, command->obj);
1549 speak(actions[command->verb].message);
1555 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1558 /* Unknown verb, couldn't deduce object - might need hint */
1559 sspeak(WHAT_DO, command->raw1);
1560 return GO_CHECKHINT;
1562 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE