7 static int fill(token_t, token_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 vocab_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 = 1; obj <= NOBJECTS; obj++) {
125 if (game.place[obj] == objects[DRAGON].plac ||
126 game.place[obj] == objects[DRAGON].fixd)
127 move(obj, 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 == ACTION_WORD(FEE)) ||
189 (game.foobar == ACTION_WORD(FEE) && id == ACTION_WORD(FIE)) ||
190 (game.foobar == ACTION_WORD(FIE) && id == ACTION_WORD(FOE)) ||
191 (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FOO)) ||
192 (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FUM))) {
194 if ((id != ACTION_WORD(FOO)) && (id != ACTION_WORD(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 if (game.loc == objects[EGGS].plac)
213 move(EGGS, objects[EGGS].plac);
214 pspeak(EGGS, look, k, true);
218 if (game.loc == LOC_GIANTROOM) {
221 /* This is new begavior in Open Adventure - sounds better when
222 * player isn't in the Giant Room. */
223 rspeak(WELL_POINTLESS);
225 game.foobar = WORD_EMPTY;
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(vocab_t verb, obj_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] = IS_FIXED;
266 speak(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, obj_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. */
284 if (obj == INTRANSITIVE) {
285 /* Carry, no object given yet. OK if only one object present. */
286 if (game.atloc[game.loc] == 0 ||
287 game.link[game.atloc[game.loc]] != 0 ||
288 atdwrf(game.loc) > 0)
290 obj = game.atloc[game.loc];
294 rspeak(ALREADY_CARRYING);
299 rspeak(REMOVE_MESSAGE);
304 if (game.fixed[obj] != IS_FREE) {
305 /* Next guard tests whether plant is tiny or stashed */
306 if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
310 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
311 rspeak(BEAR_CHAINED);
314 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
315 rspeak(STILL_LOCKED);
323 rspeak(DOUGHNUT_HOLES);
330 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
335 rspeak(HAND_PASSTHROUGH);
346 if (TOTING(BOTTLE)) {
347 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
348 return (fill(verb, BOTTLE));
349 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
353 rspeak(NO_CONTAINER);
359 if (game.holdng >= INVLIMIT) {
365 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
366 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
372 rspeak(CANNOT_CARRY);
379 game.prop[BIRD] = BIRD_CAGED;
383 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
384 /* expression maps BIRD to CAGE and CAGE to BIRD */
385 carry(BIRD + CAGE - obj, game.loc);
386 carry(obj, game.loc);
387 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
388 game.place[LIQUID()] = CARRIED;
389 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
390 game.prop[obj] = STATE_FOUND;
391 game.prop[CAVITY] = CAVITY_EMPTY;
397 static int chain(token_t verb)
398 /* Do something to the bear's chain */
401 if (game.prop[BEAR] == UNTAMED_BEAR) {
405 if (game.prop[CHAIN] == CHAIN_HEAP) {
406 rspeak(ALREADY_UNLOCKED);
409 game.prop[CHAIN] = CHAIN_HEAP;
410 game.fixed[CHAIN] = IS_FREE;
411 if (game.prop[BEAR] != BEAR_DEAD)
412 game.prop[BEAR] = CONTENTED_BEAR;
414 switch (game.prop[BEAR]) {
416 game.fixed[BEAR] = IS_FIXED;
419 game.fixed[BEAR] = IS_FREE;
421 rspeak(CHAIN_UNLOCKED);
425 if (game.prop[CHAIN] != CHAIN_HEAP) {
426 rspeak(ALREADY_LOCKED);
429 if (game.loc != objects[CHAIN].plac) {
434 game.prop[CHAIN] = CHAIN_FIXED;
437 drop(CHAIN, game.loc);
438 game.fixed[CHAIN] = IS_FIXED;
440 rspeak(CHAIN_LOCKED);
444 static int discard(token_t verb, obj_t obj)
445 /* Discard object. "Throw" also comes here for most objects. Special cases for
446 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
447 * Drop coins at vending machine for extra batteries. */
449 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
452 speak(actions[verb].message);
455 if (obj == BIRD && HERE(SNAKE)) {
456 rspeak(BIRD_ATTACKS);
460 /* Set game.prop for use by travel options */
461 game.prop[SNAKE] = SNAKE_CHASED;
463 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
465 game.prop[obj] = STATE_IN_CAVITY;
466 game.prop[CAVITY] = CAVITY_FULL;
467 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
468 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
475 if (spk != RUG_WIGGLES) {
476 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
479 k = objects[SAPPH].plac;
480 move(RUG + NOBJECTS, k);
483 } else if (obj == COINS && HERE(VEND)) {
485 drop(BATTERY, game.loc);
486 pspeak(BATTERY, look, FRESH_BATTERIES, true);
488 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
492 } else if (obj == BEAR && AT(TROLL)) {
493 state_change(TROLL, TROLL_GONE);
494 move(TROLL, LOC_NOWHERE);
495 move(TROLL + NOBJECTS, IS_FREE);
496 move(TROLL2, objects[TROLL].plac);
497 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
499 } else if (obj != VASE ||
500 game.loc == objects[PILLOW].plac) {
503 state_change(VASE, AT(PILLOW)
506 if (game.prop[VASE] != VASE_WHOLE)
507 game.fixed[VASE] = IS_FIXED;
512 if (obj == BOTTLE && k != NO_OBJECT)
513 game.place[k] = LOC_NOWHERE;
514 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
515 drop(BIRD, game.loc);
519 game.prop[BIRD] = BIRD_UNCAGED;
520 if (FOREST(game.loc))
521 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
525 static int drink(token_t verb, obj_t obj)
526 /* Drink. If no object, assume water and look for it here. If water is in
527 * the bottle, drink that, else must be at a water loc, so drink stream. */
529 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
530 (LIQUID() != WATER || !HERE(BOTTLE))) {
536 state_change(DRAGON, DRAGON_BLOODLESS);
541 if (obj != INTRANSITIVE && obj != WATER) {
542 rspeak(RIDICULOUS_ATTEMPT);
545 if (LIQUID() == WATER && HERE(BOTTLE)) {
546 game.place[WATER] = LOC_NOWHERE;
547 state_change(BOTTLE, EMPTY_BOTTLE);
551 speak(actions[verb].message);
555 static int eat(token_t verb, obj_t obj)
556 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
557 * ok, some things lose appetite, rest are ridiculous. */
565 rspeak(THANKS_DELICIOUS);
576 rspeak(LOST_APPETITE);
579 speak(actions[verb].message);
584 static int extinguish(token_t verb, obj_t obj)
585 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
587 if (obj == INTRANSITIVE) {
588 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
590 if (HERE(URN) && game.prop[URN] == URN_LIT)
592 if (obj == INTRANSITIVE)
598 if (game.prop[URN] != URN_EMPTY) {
599 state_change(URN, URN_DARK);
601 pspeak(URN, change, URN_DARK, true);
605 state_change(LAMP, LAMP_DARK);
606 rspeak(DARK(game.loc) ?
612 rspeak(BEYOND_POWER);
615 speak(actions[verb].message);
620 static int feed(token_t verb, obj_t obj)
621 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
622 * mad. Bear, special. */
629 if (game.prop[DRAGON] != DRAGON_BARS)
630 rspeak(RIDICULOUS_ATTEMPT);
632 rspeak(NOTHING_EDIBLE);
635 if (!game.closed && HERE(BIRD)) {
637 rspeak(BIRD_DEVOURED);
639 rspeak(NOTHING_EDIBLE);
649 speak(actions[verb].message);
652 if (game.prop[BEAR] == BEAR_DEAD) {
653 rspeak(RIDICULOUS_ATTEMPT);
656 if (game.prop[BEAR] == UNTAMED_BEAR) {
659 game.fixed[AXE] = IS_FREE;
660 game.prop[AXE] = AXE_HERE;
661 state_change(BEAR, SITTING_BEAR);
663 rspeak(NOTHING_EDIBLE);
666 speak(actions[verb].message);
672 speak(actions[verb].message);
680 int fill(token_t verb, obj_t obj)
681 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
685 if (LIQLOC(game.loc) == NO_OBJECT) {
686 rspeak(FILL_INVALID);
690 rspeak(ARENT_CARRYING);
693 rspeak(SHATTER_VASE);
694 game.prop[VASE] = VASE_BROKEN;
695 game.fixed[VASE] = IS_FIXED;
696 drop(VASE, game.loc);
701 if (game.prop[URN] != URN_EMPTY) {
706 rspeak(FILL_INVALID);
712 game.prop[BOTTLE] = EMPTY_BOTTLE;
716 game.prop[URN] = URN_DARK;
717 game.prop[BOTTLE] = EMPTY_BOTTLE;
722 rspeak(FILL_INVALID);
725 game.place[k] = LOC_NOWHERE;
728 if (obj != INTRANSITIVE && obj != BOTTLE) {
729 speak(actions[verb].message);
732 if (obj == INTRANSITIVE && !HERE(BOTTLE))
735 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
739 if (LIQUID() != NO_OBJECT) {
743 if (LIQLOC(game.loc) == NO_OBJECT) {
748 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
752 game.place[LIQUID()] = CARRIED;
756 static int find(token_t verb, obj_t obj)
757 /* Find. Might be carrying it, or it might be here. Else give caveat. */
760 rspeak(ALREADY_CARRYING);
765 rspeak(NEEDED_NEARBY);
770 (LIQUID() == obj && AT(BOTTLE)) ||
771 obj == LIQLOC(game.loc) ||
772 (obj == DWARF && atdwrf(game.loc) > 0)) {
778 speak(actions[verb].message);
782 static int fly(token_t verb, obj_t obj)
783 /* Fly. Snide remarks unless hovering rug is here. */
785 if (obj == INTRANSITIVE) {
790 if (game.prop[RUG] != RUG_HOVER) {
791 rspeak(RUG_NOTHING2);
798 speak(actions[verb].message);
801 if (game.prop[RUG] != RUG_HOVER) {
802 rspeak(RUG_NOTHING1);
805 game.oldlc2 = game.oldloc;
806 game.oldloc = game.loc;
808 if (game.prop[SAPPH] == STATE_NOTFOUND) {
809 game.newloc = game.place[SAPPH];
812 game.newloc = LOC_CLIFF;
818 static int inven(void)
819 /* Inventory. If object, treat same as find. Else report on current burden. */
822 for (obj_t i = 1; i <= NOBJECTS; i++) {
830 pspeak(i, touch, -1, false);
839 static int light(token_t verb, obj_t obj)
840 /* Light. Applicable only to lamp and urn. */
842 if (obj == INTRANSITIVE) {
844 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
848 if (HERE(URN) && game.prop[URN] == URN_DARK) {
858 state_change(URN, game.prop[URN] == URN_EMPTY ?
863 if (game.limit < 0) {
867 state_change(LAMP, LAMP_BRIGHT);
872 speak(actions[verb].message);
877 static int listen(void)
878 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
880 long sound = locations[game.loc].sound;
881 if (sound != SILENT) {
883 if (!locations[game.loc].loud)
887 for (obj_t i = 1; i <= NOBJECTS; i++) {
889 objects[i].sounds[0] == NULL ||
892 int mi = game.prop[i];
893 /* FIXME: Weird magic on object states */
895 mi += 3 * game.blooded;
896 long packed_zzword = token_to_packed(game.zzword);
897 pspeak(i, hear, mi, true, packed_zzword);
899 if (i == BIRD && mi == BIRD_ENDSTATE)
907 static int lock(token_t verb, obj_t obj)
908 /* Lock, unlock, no object given. Assume various things if present. */
910 if (obj == INTRANSITIVE) {
921 if (obj == INTRANSITIVE) {
922 rspeak(NOTHING_LOCKED);
927 /* Lock, unlock object. Special stuff for opening clam/oyster
942 game.clock2 = PANICTIME;
945 state_change(GRATE, (verb == LOCK) ?
955 else if (!TOTING(TRIDENT))
956 rspeak(OYSTER_OPENER);
959 drop(OYSTER, game.loc);
960 drop(PEARL, LOC_CULDESAC);
968 rspeak(OYSTER_OPENER);
971 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
977 rspeak(CANNOT_UNLOCK);
980 speak(actions[verb].message);
986 static int pour(token_t verb, obj_t obj)
987 /* Pour. If no object, or object is bottle, assume contents of bottle.
988 * special tests for pouring water or oil on plant or rusty door. */
993 if (obj == NO_OBJECT)
996 speak(actions[verb].message);
1000 if (obj != OIL && obj != WATER) {
1004 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1005 return fill(verb, URN);
1006 game.prop[BOTTLE] = EMPTY_BOTTLE;
1007 game.place[obj] = LOC_NOWHERE;
1015 /* cycle through the three plant states */
1016 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1017 game.prop[PLANT2] = game.prop[PLANT];
1020 rspeak(SHAKING_LEAVES);
1024 state_change(DOOR, (obj == OIL) ?
1031 static int quit(void)
1032 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1034 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1035 terminate(quitgame);
1039 static int read(struct command_t command)
1040 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1042 if (command.obj == INTRANSITIVE) {
1043 command.obj = NO_OBJECT;
1044 for (int i = 1; i <= NOBJECTS; i++) {
1045 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1046 command.obj = command.obj * NOBJECTS + i;
1048 if (command.obj > NOBJECTS ||
1049 command.obj == NO_OBJECT ||
1054 if (DARK(game.loc)) {
1055 sspeak(NO_SEE, command.raw1);
1056 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1057 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1058 } else if (objects[command.obj].texts[0] == NULL ||
1059 game.prop[command.obj] == STATE_NOTFOUND) {
1060 speak(actions[command.verb].message);
1062 pspeak(command.obj, study, game.prop[command.obj], true);
1066 static int reservoir(void)
1067 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1069 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1070 rspeak(NOTHING_HAPPENS);
1074 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1078 game.oldlc2 = game.loc;
1079 game.newloc = LOC_NOWHERE;
1081 return GO_TERMINATE;
1086 static int rub(token_t verb, obj_t obj)
1087 /* Rub. Yields various snide remarks except for lit urn. */
1089 if (obj == URN && game.prop[URN] == URN_LIT) {
1091 drop(AMBER, game.loc);
1092 game.prop[AMBER] = AMBER_IN_ROCK;
1094 drop(CAVITY, game.loc);
1096 } else if (obj != LAMP) {
1097 rspeak(PECULIAR_NOTHING);
1099 speak(actions[verb].message);
1104 static int say(struct command_t *command)
1105 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1107 if (command->wd2 > 0) {
1108 command->wd1 = command->wd2;
1109 strcpy(command->raw1, command->raw2);
1111 char word1[TOKLEN + 1];
1112 packed_to_token(command->wd1, word1);
1113 int wd = (int) get_vocab_id(word1);
1114 if (wd == MOTION_WORD(XYZZY) ||
1115 wd == MOTION_WORD(PLUGH) ||
1116 wd == MOTION_WORD(PLOVER) ||
1117 wd == ACTION_WORD(FEE) ||
1118 wd == ACTION_WORD(FIE) ||
1119 wd == ACTION_WORD(FOE) ||
1120 wd == ACTION_WORD(FOO) ||
1121 wd == ACTION_WORD(FUM) ||
1122 wd == ACTION_WORD(PART)) {
1123 /* FIXME: scribbles on the interpreter's command block */
1124 wordclear(&command->wd2);
1127 sspeak(OKEY_DOKEY, command->raw1);
1131 static int throw_support(long spk)
1134 drop(AXE, game.loc);
1138 static int throw (struct command_t *command)
1139 /* Throw. Same as discard unless axe. Then same as attack except
1140 * ignore bird, and if dwarf is present then one might be killed.
1141 * (Only way to do so!) Axe also special for dragon, bear, and
1142 * troll. Treasures special for troll. */
1144 if (!TOTING(command->obj)) {
1145 speak(actions[command->verb].message);
1148 if (objects[command->obj].is_treasure && AT(TROLL)) {
1149 /* Snarf a treasure for the troll. */
1150 drop(command->obj, LOC_NOWHERE);
1151 move(TROLL, LOC_NOWHERE);
1152 move(TROLL + NOBJECTS, IS_FREE);
1153 drop(TROLL2, objects[TROLL].plac);
1154 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1156 rspeak(TROLL_SATISFIED);
1159 if (command->obj == FOOD && HERE(BEAR)) {
1160 /* But throwing food is another story. */
1161 command->obj = BEAR;
1162 return (feed(command->verb, command->obj));
1164 if (command->obj != AXE)
1165 return (discard(command->verb, command->obj));
1167 if (atdwrf(game.loc) <= 0) {
1168 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1169 return throw_support(DRAGON_SCALES);
1171 return throw_support(TROLL_RETURNS);
1173 return throw_support(OGRE_DODGE);
1174 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1175 /* This'll teach him to throw the axe at the bear! */
1176 drop(AXE, game.loc);
1177 game.fixed[AXE] = IS_FIXED;
1179 state_change(AXE, AXE_LOST);
1182 command->obj = INTRANSITIVE;
1183 return (attack(command));
1186 if (randrange(NDWARVES + 1) < game.dflag) {
1187 return throw_support(DWARF_DODGES);
1189 long i = atdwrf(game.loc);
1190 game.dseen[i] = false;
1191 game.dloc[i] = LOC_NOWHERE;
1192 return throw_support((++game.dkill == 1) ?
1199 static int wake(token_t verb, obj_t obj)
1200 /* Wake. Only use is to disturb the dwarves. */
1204 speak(actions[verb].message);
1208 return GO_DWARFWAKE;
1212 static int wave(token_t verb, obj_t obj)
1213 /* Wave. No effect unless waving rod at fissure or at bird. */
1220 speak(((!TOTING(obj)) && (obj != ROD ||
1222 arbitrary_messages[ARENT_CARRYING] :
1223 actions[verb].message);
1227 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1228 drop(JADE, game.loc);
1229 game.prop[JADE] = STATE_FOUND;
1231 rspeak(NECKLACE_FLY);
1235 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1238 return GO_DWARFWAKE;
1242 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1248 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1252 state_change(FISSURE,
1253 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1258 int action(struct command_t *command)
1259 /* Analyse a verb. Remember what it was, go back for object if second word
1260 * unless verb is "say", which snarfs arbitrary second word.
1263 if (command->part == unknown) {
1264 /* Analyse an object word. See if the thing is here, whether
1265 * we've got a verb yet, and so on. Object must be here
1266 * unless verb is "find" or "invent(ory)" (and no new verb
1267 * yet to be analysed). Water and oil are also funny, since
1268 * they are never actually dropped at any location, but might
1269 * be here inside the bottle or urn or as a feature of the
1271 if (HERE(command->obj))
1273 else if (command->obj == GRATE) {
1274 if (game.loc == LOC_START ||
1275 game.loc == LOC_VALLEY ||
1276 game.loc == LOC_SLIT) {
1277 command->obj = DPRSSN;
1279 if (game.loc == LOC_COBBLE ||
1280 game.loc == LOC_DEBRIS ||
1281 game.loc == LOC_AWKWARD ||
1282 game.loc == LOC_BIRD ||
1283 game.loc == LOC_PITTOP) {
1284 command->obj = ENTRNC;
1286 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1288 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1289 command->obj == LIQLOC(game.loc))
1291 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1294 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1295 command->obj = PLANT2;
1297 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1299 rspeak(KNIVES_VANISH);
1301 } else if (command->obj == ROD && HERE(ROD2)) {
1302 command->obj = ROD2;
1304 } else if ((command->verb == FIND ||
1305 command->verb == INVENTORY) && command->wd2 <= 0)
1308 sspeak(NO_SEE, command->raw1);
1312 if (command->wd2 > 0)
1314 if (command->verb != 0)
1315 command->part = transitive;
1318 switch (command->part) {
1320 if (command->wd2 > 0 && command->verb != SAY)
1322 if (command->verb == SAY)
1323 command->obj = command->wd2;
1324 if (command->obj == NO_OBJECT ||
1325 command->obj == INTRANSITIVE) {
1326 /* Analyse an intransitive verb (ie, no object given yet). */
1327 switch (command->verb) {
1329 return vcarry(command->verb, INTRANSITIVE);
1335 return lock(command->verb, INTRANSITIVE);
1338 return (GO_CLEAROBJ);
1341 return lock(command->verb, INTRANSITIVE);
1343 return light(command->verb, INTRANSITIVE);
1345 return extinguish(command->verb, INTRANSITIVE);
1351 speak(actions[command->verb].message);
1355 command->obj = INTRANSITIVE;
1356 return attack(command);
1358 return pour(command->verb, INTRANSITIVE);
1360 return eat(command->verb, INTRANSITIVE);
1362 return drink(command->verb, INTRANSITIVE);
1376 return fill(command->verb, INTRANSITIVE);
1388 return bigwords(command->id1);
1392 command->obj = INTRANSITIVE;
1393 return read(*command);
1403 return fly(command->verb, INTRANSITIVE);
1409 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1414 /* Analyse a transitive verb. */
1415 switch (command->verb) {
1417 return vcarry(command->verb, command->obj);
1419 return discard(command->verb, command->obj);
1421 return say(command);
1423 return lock(command->verb, command->obj);
1426 return (GO_CLEAROBJ);
1429 return lock(command->verb, command->obj);
1431 return light(command->verb, command->obj);
1433 return extinguish(command->verb, command->obj);
1435 return wave(command->verb, command->obj);
1437 speak(actions[command->verb].message);
1441 speak(actions[command->verb].message);
1445 return attack(command);
1447 return pour(command->verb, command->obj);
1449 return eat(command->verb, command->obj);
1451 return drink(command->verb, command->obj);
1453 return rub(command->verb, command->obj);
1455 return throw (command);
1457 speak(actions[command->verb].message);
1461 return find(command->verb, command->obj);
1463 return find(command->verb, command->obj);
1465 return feed(command->verb, command->obj);
1467 return fill(command->verb, command->obj);
1472 speak(actions[command->verb].message);
1480 speak(actions[command->verb].message);
1484 speak(actions[command->verb].message);
1488 return read(*command);
1490 return vbreak(command->verb, command->obj);
1492 return wake(command->verb, command->obj);
1494 speak(actions[command->verb].message);
1498 speak(actions[command->verb].message);
1502 return fly(command->verb, command->obj);
1504 speak(actions[command->verb].message);
1510 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1513 /* Unknown verb, couldn't deduce object - might need hint */
1514 sspeak(WHAT_DO, command->raw1);
1515 return GO_CHECKHINT;
1517 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE