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);
105 // FIXME: setting wd1 is a workaround for broken logic
106 command->wd1 = token_to_packed("Y");
108 // FIXME: setting wd1 is a workaround for broken logic
109 command->wd1 = token_to_packed("N");
112 state_change(DRAGON, DRAGON_DEAD);
113 game.prop[RUG] = RUG_FLOOR;
114 /* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.
115 * The way it was computed before was worse; it depended on the
116 * two dragon locations being LOC_SECRET4 and LOC_SECRET6 and
117 * LOC_SECRET5 being right between them.
119 move(DRAGON + NOBJECTS, IS_FIXED);
120 move(RUG + NOBJECTS, IS_FREE);
121 move(DRAGON, LOC_SECRET5);
122 move(RUG, LOC_SECRET5);
123 drop(BLOOD, LOC_SECRET5);
124 for (obj_t i = 1; i <= NOBJECTS; i++) {
125 if (game.place[i] == objects[DRAGON].plac ||
126 game.place[i] == objects[DRAGON].fixd)
127 move(i, LOC_SECRET5);
129 game.loc = LOC_SECRET5;
135 if (atdwrf(game.loc) == 0)
138 rspeak(KNIFE_THROWN);
141 for (int i = 1; i < PIRATE; i++) {
142 if (game.dloc[i] == game.loc) {
144 game.dloc[i] = LOC_LONGWEST;
145 game.dseen[i] = false;
148 rspeak((dwarves > 1) ?
160 rspeak(SHELL_IMPERVIOUS);
163 rspeak(SNAKE_WARNING);
169 rspeak(BARE_HANDS_QUERY);
172 rspeak(ALREADY_DEAD);
178 speak(actions[verb].message);
183 static int bigwords(long id)
184 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
185 * Look up foo in special section of vocab to determine which word we've got.
186 * Last word zips the eggs back to the giant room (unless already there). */
188 if ((game.foobar == WORD_EMPTY && id == FEE) ||
189 (game.foobar == FEE && id == FIE) ||
190 (game.foobar == FIE && id == FOE) ||
191 (game.foobar == FOE && id == FOO) ||
192 (game.foobar == FOE && id == FUM)) {
194 if ((id != FOO) && (id != FUM)) {
198 game.foobar = WORD_EMPTY;
199 if (game.place[EGGS] == objects[EGGS].plac ||
200 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
201 rspeak(NOTHING_HAPPENS);
204 /* Bring back troll if we steal the eggs back from him before
206 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
207 game.prop[TROLL] = TROLL_PAIDONCE;
211 else if (game.loc == objects[EGGS].plac)
215 move(EGGS, objects[EGGS].plac);
216 pspeak(EGGS, look, k, true);
220 if (game.loc == LOC_GIANTROOM) {
223 /* This is new begavior in Open Adventure - sounds better when
224 * player isn't in the Giant Room. */
225 rspeak(WELL_POINTLESS);
227 game.foobar = WORD_EMPTY;
232 static void blast(void)
233 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
235 if (game.prop[ROD2] == STATE_NOTFOUND ||
237 rspeak(REQUIRES_DYNAMITE);
240 game.bonus = SPLATTER_MESSAGE;
241 else if (game.loc == LOC_NE)
242 game.bonus = DEFEAT_MESSAGE;
244 game.bonus = 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) {
311 /* Next guard tests whether plant is tiny or stashed */
312 if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
316 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
317 rspeak(BEAR_CHAINED);
320 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
321 rspeak(STILL_LOCKED);
329 rspeak(DOUGHNUT_HOLES);
336 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
341 rspeak(HAND_PASSTHROUGH);
352 if (TOTING(BOTTLE)) {
353 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
354 return (fill(verb, BOTTLE));
355 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
359 rspeak(NO_CONTAINER);
365 if (game.holdng >= INVLIMIT) {
371 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
372 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
378 rspeak(CANNOT_CARRY);
385 game.prop[BIRD] = BIRD_CAGED;
389 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
390 /* expression maps BIRD to CAGE and CAGE to BIRD */
391 carry(BIRD + CAGE - obj, game.loc);
392 carry(obj, game.loc);
393 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
394 game.place[LIQUID()] = CARRIED;
395 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
396 game.prop[obj] = STATE_FOUND;
397 game.prop[CAVITY] = CAVITY_EMPTY;
403 static int chain(verb_t verb)
404 /* Do something to the bear's chain */
407 if (game.prop[BEAR] == UNTAMED_BEAR) {
411 if (game.prop[CHAIN] == CHAIN_HEAP) {
412 rspeak(ALREADY_UNLOCKED);
415 game.prop[CHAIN] = CHAIN_HEAP;
416 game.fixed[CHAIN] = IS_FREE;
417 if (game.prop[BEAR] != BEAR_DEAD)
418 game.prop[BEAR] = CONTENTED_BEAR;
420 switch (game.prop[BEAR]) {
423 /* Can't be reached as long as the only way for the bear to die
424 * is from a bridge collapse. Leave in in case this changes, but
425 * exclude from coverage testing. */
426 game.fixed[BEAR] = IS_FIXED;
430 game.fixed[BEAR] = IS_FREE;
432 rspeak(CHAIN_UNLOCKED);
436 if (game.prop[CHAIN] != CHAIN_HEAP) {
437 rspeak(ALREADY_LOCKED);
440 if (game.loc != objects[CHAIN].plac) {
445 game.prop[CHAIN] = CHAIN_FIXED;
448 drop(CHAIN, game.loc);
449 game.fixed[CHAIN] = IS_FIXED;
451 rspeak(CHAIN_LOCKED);
455 static int discard(verb_t verb, obj_t obj)
456 /* Discard object. "Throw" also comes here for most objects. Special cases for
457 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
458 * Drop coins at vending machine for extra batteries. */
460 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
463 speak(actions[verb].message);
466 if (obj == BIRD && HERE(SNAKE)) {
467 rspeak(BIRD_ATTACKS);
471 /* Set game.prop for use by travel options */
472 game.prop[SNAKE] = SNAKE_CHASED;
474 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
476 game.prop[obj] = STATE_IN_CAVITY;
477 game.prop[CAVITY] = CAVITY_FULL;
478 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
479 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
483 else if (TOTING(RUG))
488 if (spk != RUG_WIGGLES) {
489 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
492 k = objects[SAPPH].plac;
493 move(RUG + NOBJECTS, k);
496 } else if (obj == COINS && HERE(VEND)) {
498 drop(BATTERY, game.loc);
499 pspeak(BATTERY, look, FRESH_BATTERIES, true);
501 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
505 } else 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);
512 } else if (obj != VASE ||
513 game.loc == objects[PILLOW].plac) {
516 state_change(VASE, AT(PILLOW)
519 if (game.prop[VASE] != VASE_WHOLE)
520 game.fixed[VASE] = IS_FIXED;
525 if (obj == BOTTLE && k != NO_OBJECT)
526 game.place[k] = LOC_NOWHERE;
527 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
528 drop(BIRD, game.loc);
532 game.prop[BIRD] = BIRD_UNCAGED;
533 if (FOREST(game.loc))
534 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
538 static int drink(verb_t verb, obj_t obj)
539 /* Drink. If no object, assume water and look for it here. If water is in
540 * the bottle, drink that, else must be at a water loc, so drink stream. */
542 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
543 (LIQUID() != WATER || !HERE(BOTTLE))) {
549 state_change(DRAGON, DRAGON_BLOODLESS);
554 if (obj != INTRANSITIVE && obj != WATER) {
555 rspeak(RIDICULOUS_ATTEMPT);
558 if (LIQUID() == WATER && HERE(BOTTLE)) {
559 game.place[WATER] = LOC_NOWHERE;
560 state_change(BOTTLE, EMPTY_BOTTLE);
564 speak(actions[verb].message);
568 static int eat(verb_t verb, obj_t obj)
569 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
570 * ok, some things lose appetite, rest are ridiculous. */
578 rspeak(THANKS_DELICIOUS);
589 rspeak(LOST_APPETITE);
592 speak(actions[verb].message);
597 static int extinguish(verb_t verb, obj_t obj)
598 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
600 if (obj == INTRANSITIVE) {
601 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
603 if (HERE(URN) && game.prop[URN] == URN_LIT)
605 if (obj == INTRANSITIVE)
611 if (game.prop[URN] != URN_EMPTY) {
612 state_change(URN, URN_DARK);
614 pspeak(URN, change, URN_DARK, true);
618 state_change(LAMP, LAMP_DARK);
619 rspeak(DARK(game.loc) ?
625 rspeak(BEYOND_POWER);
628 speak(actions[verb].message);
633 static int feed(verb_t verb, obj_t obj)
634 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
635 * mad. Bear, special. */
642 if (game.prop[DRAGON] != DRAGON_BARS)
643 rspeak(RIDICULOUS_ATTEMPT);
645 rspeak(NOTHING_EDIBLE);
648 if (!game.closed && HERE(BIRD)) {
650 rspeak(BIRD_DEVOURED);
652 rspeak(NOTHING_EDIBLE);
662 speak(actions[verb].message);
665 if (game.prop[BEAR] == BEAR_DEAD) {
666 rspeak(RIDICULOUS_ATTEMPT);
669 if (game.prop[BEAR] == UNTAMED_BEAR) {
672 game.fixed[AXE] = IS_FREE;
673 game.prop[AXE] = AXE_HERE;
674 state_change(BEAR, SITTING_BEAR);
676 rspeak(NOTHING_EDIBLE);
679 speak(actions[verb].message);
685 speak(actions[verb].message);
693 int fill(verb_t verb, obj_t obj)
694 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
698 if (LIQLOC(game.loc) == NO_OBJECT) {
699 rspeak(FILL_INVALID);
703 rspeak(ARENT_CARRYING);
706 rspeak(SHATTER_VASE);
707 game.prop[VASE] = VASE_BROKEN;
708 game.fixed[VASE] = IS_FIXED;
709 drop(VASE, game.loc);
714 if (game.prop[URN] != URN_EMPTY) {
719 rspeak(FILL_INVALID);
725 game.prop[BOTTLE] = EMPTY_BOTTLE;
729 game.prop[URN] = URN_DARK;
730 game.prop[BOTTLE] = EMPTY_BOTTLE;
735 rspeak(FILL_INVALID);
738 game.place[k] = LOC_NOWHERE;
741 if (obj != INTRANSITIVE && obj != BOTTLE) {
742 speak(actions[verb].message);
745 if (obj == INTRANSITIVE && !HERE(BOTTLE))
748 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
752 if (LIQUID() != NO_OBJECT) {
756 if (LIQLOC(game.loc) == NO_OBJECT) {
761 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
765 game.place[LIQUID()] = CARRIED;
769 static int find(verb_t verb, obj_t obj)
770 /* Find. Might be carrying it, or it might be here. Else give caveat. */
773 rspeak(ALREADY_CARRYING);
778 rspeak(NEEDED_NEARBY);
783 (LIQUID() == obj && AT(BOTTLE)) ||
784 obj == LIQLOC(game.loc) ||
785 (obj == DWARF && atdwrf(game.loc) > 0)) {
791 speak(actions[verb].message);
795 static int fly(verb_t verb, obj_t obj)
796 /* Fly. Snide remarks unless hovering rug is here. */
798 if (obj == INTRANSITIVE) {
803 if (game.prop[RUG] != RUG_HOVER) {
804 rspeak(RUG_NOTHING2);
811 speak(actions[verb].message);
814 if (game.prop[RUG] != RUG_HOVER) {
815 rspeak(RUG_NOTHING1);
818 game.oldlc2 = game.oldloc;
819 game.oldloc = game.loc;
821 if (game.prop[SAPPH] == STATE_NOTFOUND) {
822 game.newloc = game.place[SAPPH];
825 game.newloc = LOC_CLIFF;
831 static int inven(void)
832 /* Inventory. If object, treat same as find. Else report on current burden. */
835 for (obj_t i = 1; i <= NOBJECTS; i++) {
843 pspeak(i, touch, -1, false);
852 static int light(verb_t verb, obj_t obj)
853 /* Light. Applicable only to lamp and urn. */
855 if (obj == INTRANSITIVE) {
857 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
861 if (HERE(URN) && game.prop[URN] == URN_DARK) {
871 state_change(URN, game.prop[URN] == URN_EMPTY ?
876 if (game.limit < 0) {
880 state_change(LAMP, LAMP_BRIGHT);
885 speak(actions[verb].message);
890 static int listen(void)
891 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
893 long sound = locations[game.loc].sound;
894 if (sound != SILENT) {
896 if (!locations[game.loc].loud)
900 for (obj_t i = 1; i <= NOBJECTS; i++) {
902 objects[i].sounds[0] == NULL ||
905 int mi = game.prop[i];
906 /* (ESR) Some unpleasant magic on object states here. Ideally
907 * we'd have liked the bird to be a normal object that we can
908 * use state_change() on; can't do it, because there are
909 * actually two different series of per-state birdsounds
910 * depending on whether player has drunk dragon's blood. */
912 mi += 3 * game.blooded;
913 long packed_zzword = token_to_packed(game.zzword);
914 pspeak(i, hear, mi, true, packed_zzword);
916 if (i == BIRD && mi == BIRD_ENDSTATE)
924 static int lock(verb_t verb, obj_t obj)
925 /* Lock, unlock, no object given. Assume various things if present. */
927 if (obj == INTRANSITIVE) {
938 if (obj == INTRANSITIVE) {
939 rspeak(NOTHING_LOCKED);
944 /* Lock, unlock object. Special stuff for opening clam/oyster
959 game.clock2 = PANICTIME;
962 state_change(GRATE, (verb == LOCK) ?
972 else if (!TOTING(TRIDENT))
973 rspeak(OYSTER_OPENER);
976 drop(OYSTER, game.loc);
977 drop(PEARL, LOC_CULDESAC);
985 rspeak(OYSTER_OPENER);
988 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
994 rspeak(CANNOT_UNLOCK);
997 speak(actions[verb].message);
1003 static int pour(verb_t verb, obj_t obj)
1004 /* Pour. If no object, or object is bottle, assume contents of bottle.
1005 * special tests for pouring water or oil on plant or rusty door. */
1007 if (obj == BOTTLE ||
1008 obj == INTRANSITIVE)
1010 if (obj == NO_OBJECT)
1013 speak(actions[verb].message);
1017 if (obj != OIL && obj != WATER) {
1021 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1022 return fill(verb, URN);
1023 game.prop[BOTTLE] = EMPTY_BOTTLE;
1024 game.place[obj] = LOC_NOWHERE;
1032 /* cycle through the three plant states */
1033 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1034 game.prop[PLANT2] = game.prop[PLANT];
1037 rspeak(SHAKING_LEAVES);
1041 state_change(DOOR, (obj == OIL) ?
1048 static int quit(void)
1049 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1051 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1052 terminate(quitgame);
1056 static int read(struct command_t command)
1057 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1059 if (command.obj == INTRANSITIVE) {
1060 command.obj = NO_OBJECT;
1061 for (int i = 1; i <= NOBJECTS; i++) {
1062 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1063 command.obj = command.obj * NOBJECTS + i;
1065 if (command.obj > NOBJECTS ||
1066 command.obj == NO_OBJECT ||
1071 if (DARK(game.loc)) {
1072 sspeak(NO_SEE, command.raw1);
1073 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1074 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1075 } else if (objects[command.obj].texts[0] == NULL ||
1076 game.prop[command.obj] == STATE_NOTFOUND) {
1077 speak(actions[command.verb].message);
1079 pspeak(command.obj, study, game.prop[command.obj], true);
1083 static int reservoir(void)
1084 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1086 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1087 rspeak(NOTHING_HAPPENS);
1091 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1095 game.oldlc2 = game.loc;
1096 game.newloc = LOC_NOWHERE;
1098 return GO_TERMINATE;
1103 static int rub(verb_t verb, obj_t obj)
1104 /* Rub. Yields various snide remarks except for lit urn. */
1106 if (obj == URN && game.prop[URN] == URN_LIT) {
1108 drop(AMBER, game.loc);
1109 game.prop[AMBER] = AMBER_IN_ROCK;
1111 drop(CAVITY, game.loc);
1113 } else if (obj != LAMP) {
1114 rspeak(PECULIAR_NOTHING);
1116 speak(actions[verb].message);
1121 static int say(struct command_t *command)
1122 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1124 if (command->wd2 > 0) {
1125 command->wd1 = command->wd2;
1126 strncpy(command->raw1, command->raw2, LINESIZE - 1);
1128 char word1[TOKLEN + 1];
1129 packed_to_token(command->wd1, word1);
1132 get_vocab_metadata(word1, &wd, &type);
1142 /* FIXME: scribbles on the interpreter's command block */
1143 wordclear(&command->wd2);
1146 sspeak(OKEY_DOKEY, command->raw1);
1150 static int throw_support(long spk)
1153 drop(AXE, game.loc);
1157 static int throw (struct command_t *command)
1158 /* Throw. Same as discard unless axe. Then same as attack except
1159 * ignore bird, and if dwarf is present then one might be killed.
1160 * (Only way to do so!) Axe also special for dragon, bear, and
1161 * troll. Treasures special for troll. */
1163 if (!TOTING(command->obj)) {
1164 speak(actions[command->verb].message);
1167 if (objects[command->obj].is_treasure && AT(TROLL)) {
1168 /* Snarf a treasure for the troll. */
1169 drop(command->obj, LOC_NOWHERE);
1170 move(TROLL, LOC_NOWHERE);
1171 move(TROLL + NOBJECTS, IS_FREE);
1172 drop(TROLL2, objects[TROLL].plac);
1173 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1175 rspeak(TROLL_SATISFIED);
1178 if (command->obj == FOOD && HERE(BEAR)) {
1179 /* But throwing food is another story. */
1180 command->obj = BEAR;
1181 return (feed(command->verb, command->obj));
1183 if (command->obj != AXE)
1184 return (discard(command->verb, command->obj));
1186 if (atdwrf(game.loc) <= 0) {
1187 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1188 return throw_support(DRAGON_SCALES);
1190 return throw_support(TROLL_RETURNS);
1192 return throw_support(OGRE_DODGE);
1193 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1194 /* This'll teach him to throw the axe at the bear! */
1195 drop(AXE, game.loc);
1196 game.fixed[AXE] = IS_FIXED;
1198 state_change(AXE, AXE_LOST);
1201 command->obj = INTRANSITIVE;
1202 return (attack(command));
1205 if (randrange(NDWARVES + 1) < game.dflag) {
1206 return throw_support(DWARF_DODGES);
1208 long i = atdwrf(game.loc);
1209 game.dseen[i] = false;
1210 game.dloc[i] = LOC_NOWHERE;
1211 return throw_support((++game.dkill == 1) ?
1218 static int wake(verb_t verb, obj_t obj)
1219 /* Wake. Only use is to disturb the dwarves. */
1223 speak(actions[verb].message);
1227 return GO_DWARFWAKE;
1231 static int wave(verb_t verb, obj_t obj)
1232 /* Wave. No effect unless waving rod at fissure or at bird. */
1239 speak(((!TOTING(obj)) && (obj != ROD ||
1241 arbitrary_messages[ARENT_CARRYING] :
1242 actions[verb].message);
1246 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1247 drop(JADE, game.loc);
1248 game.prop[JADE] = STATE_FOUND;
1250 rspeak(NECKLACE_FLY);
1254 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1257 return GO_DWARFWAKE;
1261 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1267 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1271 state_change(FISSURE,
1272 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1277 int action(struct command_t *command)
1278 /* Analyse a verb. Remember what it was, go back for object if second word
1279 * unless verb is "say", which snarfs arbitrary second word.
1282 if (command->part == unknown) {
1283 /* Analyse an object word. See if the thing is here, whether
1284 * we've got a verb yet, and so on. Object must be here
1285 * unless verb is "find" or "invent(ory)" (and no new verb
1286 * yet to be analysed). Water and oil are also funny, since
1287 * they are never actually dropped at any location, but might
1288 * be here inside the bottle or urn or as a feature of the
1290 if (HERE(command->obj))
1292 else if (command->obj == GRATE) {
1293 if (game.loc == LOC_START ||
1294 game.loc == LOC_VALLEY ||
1295 game.loc == LOC_SLIT) {
1296 command->obj = DPRSSN;
1298 if (game.loc == LOC_COBBLE ||
1299 game.loc == LOC_DEBRIS ||
1300 game.loc == LOC_AWKWARD ||
1301 game.loc == LOC_BIRD ||
1302 game.loc == LOC_PITTOP) {
1303 command->obj = ENTRNC;
1305 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1307 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1308 command->obj == LIQLOC(game.loc))
1310 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1313 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1314 command->obj = PLANT2;
1316 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1318 rspeak(KNIVES_VANISH);
1320 } else if (command->obj == ROD && HERE(ROD2)) {
1321 command->obj = ROD2;
1323 } else if ((command->verb == FIND ||
1324 command->verb == INVENTORY) && command->wd2 <= 0)
1327 sspeak(NO_SEE, command->raw1);
1331 if (command->wd2 > 0)
1333 if (command->verb != 0)
1334 command->part = transitive;
1337 switch (command->part) {
1339 if (command->wd2 > 0 && command->verb != SAY)
1341 if (command->verb == SAY)
1342 command->obj = command->wd2;
1343 if (command->obj == NO_OBJECT ||
1344 command->obj == INTRANSITIVE) {
1345 /* Analyse an intransitive verb (ie, no object given yet). */
1346 switch (command->verb) {
1348 return vcarry(command->verb, INTRANSITIVE);
1354 return lock(command->verb, INTRANSITIVE);
1357 return (GO_CLEAROBJ);
1360 return lock(command->verb, INTRANSITIVE);
1362 return light(command->verb, INTRANSITIVE);
1364 return extinguish(command->verb, INTRANSITIVE);
1370 speak(actions[command->verb].message);
1374 command->obj = INTRANSITIVE;
1375 return attack(command);
1377 return pour(command->verb, INTRANSITIVE);
1379 return eat(command->verb, INTRANSITIVE);
1381 return drink(command->verb, INTRANSITIVE);
1395 return fill(command->verb, INTRANSITIVE);
1407 return bigwords(command->id1);
1411 command->obj = INTRANSITIVE;
1412 return read(*command);
1422 return fly(command->verb, INTRANSITIVE);
1428 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1433 /* Analyse a transitive verb. */
1434 switch (command->verb) {
1436 return vcarry(command->verb, command->obj);
1438 return discard(command->verb, command->obj);
1440 return say(command);
1442 return lock(command->verb, command->obj);
1445 return (GO_CLEAROBJ);
1448 return lock(command->verb, command->obj);
1450 return light(command->verb, command->obj);
1452 return extinguish(command->verb, command->obj);
1454 return wave(command->verb, command->obj);
1456 speak(actions[command->verb].message);
1460 speak(actions[command->verb].message);
1464 return attack(command);
1466 return pour(command->verb, command->obj);
1468 return eat(command->verb, command->obj);
1470 return drink(command->verb, command->obj);
1472 return rub(command->verb, command->obj);
1474 return throw (command);
1476 speak(actions[command->verb].message);
1480 return find(command->verb, command->obj);
1482 return find(command->verb, command->obj);
1484 return feed(command->verb, command->obj);
1486 return fill(command->verb, command->obj);
1491 speak(actions[command->verb].message);
1499 speak(actions[command->verb].message);
1503 speak(actions[command->verb].message);
1507 return read(*command);
1509 return vbreak(command->verb, command->obj);
1511 return wake(command->verb, command->obj);
1513 speak(actions[command->verb].message);
1517 speak(actions[command->verb].message);
1521 return fly(command->verb, command->obj);
1523 speak(actions[command->verb].message);
1529 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1532 /* Unknown verb, couldn't deduce object - might need hint */
1533 sspeak(WHAT_DO, command->raw1);
1534 return GO_CHECKHINT;
1536 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE