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 == 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 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]) {
422 game.fixed[BEAR] = IS_FIXED;
425 game.fixed[BEAR] = IS_FREE;
427 rspeak(CHAIN_UNLOCKED);
431 if (game.prop[CHAIN] != CHAIN_HEAP) {
432 rspeak(ALREADY_LOCKED);
435 if (game.loc != objects[CHAIN].plac) {
440 game.prop[CHAIN] = CHAIN_FIXED;
443 drop(CHAIN, game.loc);
444 game.fixed[CHAIN] = IS_FIXED;
446 rspeak(CHAIN_LOCKED);
450 static int discard(verb_t verb, obj_t obj)
451 /* Discard object. "Throw" also comes here for most objects. Special cases for
452 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
453 * Drop coins at vending machine for extra batteries. */
455 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
458 speak(actions[verb].message);
461 if (obj == BIRD && HERE(SNAKE)) {
462 rspeak(BIRD_ATTACKS);
466 /* Set game.prop for use by travel options */
467 game.prop[SNAKE] = SNAKE_CHASED;
469 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
471 game.prop[obj] = STATE_IN_CAVITY;
472 game.prop[CAVITY] = CAVITY_FULL;
473 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
474 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
478 else if (TOTING(RUG))
483 if (spk != RUG_WIGGLES) {
484 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
487 k = objects[SAPPH].plac;
488 move(RUG + NOBJECTS, k);
491 } else if (obj == COINS && HERE(VEND)) {
493 drop(BATTERY, game.loc);
494 pspeak(BATTERY, look, FRESH_BATTERIES, true);
496 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
500 } else if (obj == BEAR && AT(TROLL)) {
501 state_change(TROLL, TROLL_GONE);
502 move(TROLL, LOC_NOWHERE);
503 move(TROLL + NOBJECTS, IS_FREE);
504 move(TROLL2, objects[TROLL].plac);
505 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
507 } else if (obj != VASE ||
508 game.loc == objects[PILLOW].plac) {
511 state_change(VASE, AT(PILLOW)
514 if (game.prop[VASE] != VASE_WHOLE)
515 game.fixed[VASE] = IS_FIXED;
520 if (obj == BOTTLE && k != NO_OBJECT)
521 game.place[k] = LOC_NOWHERE;
522 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
523 drop(BIRD, game.loc);
527 game.prop[BIRD] = BIRD_UNCAGED;
528 if (FOREST(game.loc))
529 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
533 static int drink(verb_t verb, obj_t obj)
534 /* Drink. If no object, assume water and look for it here. If water is in
535 * the bottle, drink that, else must be at a water loc, so drink stream. */
537 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
538 (LIQUID() != WATER || !HERE(BOTTLE))) {
544 state_change(DRAGON, DRAGON_BLOODLESS);
549 if (obj != INTRANSITIVE && obj != WATER) {
550 rspeak(RIDICULOUS_ATTEMPT);
553 if (LIQUID() == WATER && HERE(BOTTLE)) {
554 game.place[WATER] = LOC_NOWHERE;
555 state_change(BOTTLE, EMPTY_BOTTLE);
559 speak(actions[verb].message);
563 static int eat(verb_t verb, obj_t obj)
564 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
565 * ok, some things lose appetite, rest are ridiculous. */
573 rspeak(THANKS_DELICIOUS);
584 rspeak(LOST_APPETITE);
587 speak(actions[verb].message);
592 static int extinguish(verb_t verb, obj_t obj)
593 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
595 if (obj == INTRANSITIVE) {
596 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
598 if (HERE(URN) && game.prop[URN] == URN_LIT)
600 if (obj == INTRANSITIVE)
606 if (game.prop[URN] != URN_EMPTY) {
607 state_change(URN, URN_DARK);
609 pspeak(URN, change, URN_DARK, true);
613 state_change(LAMP, LAMP_DARK);
614 rspeak(DARK(game.loc) ?
620 rspeak(BEYOND_POWER);
623 speak(actions[verb].message);
628 static int feed(verb_t verb, obj_t obj)
629 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
630 * mad. Bear, special. */
637 if (game.prop[DRAGON] != DRAGON_BARS)
638 rspeak(RIDICULOUS_ATTEMPT);
640 rspeak(NOTHING_EDIBLE);
643 if (!game.closed && HERE(BIRD)) {
645 rspeak(BIRD_DEVOURED);
647 rspeak(NOTHING_EDIBLE);
657 speak(actions[verb].message);
660 if (game.prop[BEAR] == BEAR_DEAD) {
661 rspeak(RIDICULOUS_ATTEMPT);
664 if (game.prop[BEAR] == UNTAMED_BEAR) {
667 game.fixed[AXE] = IS_FREE;
668 game.prop[AXE] = AXE_HERE;
669 state_change(BEAR, SITTING_BEAR);
671 rspeak(NOTHING_EDIBLE);
674 speak(actions[verb].message);
680 speak(actions[verb].message);
688 int fill(verb_t verb, obj_t obj)
689 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
693 if (LIQLOC(game.loc) == NO_OBJECT) {
694 rspeak(FILL_INVALID);
698 rspeak(ARENT_CARRYING);
701 rspeak(SHATTER_VASE);
702 game.prop[VASE] = VASE_BROKEN;
703 game.fixed[VASE] = IS_FIXED;
704 drop(VASE, game.loc);
709 if (game.prop[URN] != URN_EMPTY) {
714 rspeak(FILL_INVALID);
720 game.prop[BOTTLE] = EMPTY_BOTTLE;
724 game.prop[URN] = URN_DARK;
725 game.prop[BOTTLE] = EMPTY_BOTTLE;
730 rspeak(FILL_INVALID);
733 game.place[k] = LOC_NOWHERE;
736 if (obj != INTRANSITIVE && obj != BOTTLE) {
737 speak(actions[verb].message);
740 if (obj == INTRANSITIVE && !HERE(BOTTLE))
743 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
747 if (LIQUID() != NO_OBJECT) {
751 if (LIQLOC(game.loc) == NO_OBJECT) {
756 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
760 game.place[LIQUID()] = CARRIED;
764 static int find(verb_t verb, obj_t obj)
765 /* Find. Might be carrying it, or it might be here. Else give caveat. */
768 rspeak(ALREADY_CARRYING);
773 rspeak(NEEDED_NEARBY);
778 (LIQUID() == obj && AT(BOTTLE)) ||
779 obj == LIQLOC(game.loc) ||
780 (obj == DWARF && atdwrf(game.loc) > 0)) {
786 speak(actions[verb].message);
790 static int fly(verb_t verb, obj_t obj)
791 /* Fly. Snide remarks unless hovering rug is here. */
793 if (obj == INTRANSITIVE) {
798 if (game.prop[RUG] != RUG_HOVER) {
799 rspeak(RUG_NOTHING2);
806 speak(actions[verb].message);
809 if (game.prop[RUG] != RUG_HOVER) {
810 rspeak(RUG_NOTHING1);
813 game.oldlc2 = game.oldloc;
814 game.oldloc = game.loc;
816 if (game.prop[SAPPH] == STATE_NOTFOUND) {
817 game.newloc = game.place[SAPPH];
820 game.newloc = LOC_CLIFF;
826 static int inven(void)
827 /* Inventory. If object, treat same as find. Else report on current burden. */
830 for (obj_t i = 1; i <= NOBJECTS; i++) {
838 pspeak(i, touch, -1, false);
847 static int light(verb_t verb, obj_t obj)
848 /* Light. Applicable only to lamp and urn. */
850 if (obj == INTRANSITIVE) {
852 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
856 if (HERE(URN) && game.prop[URN] == URN_DARK) {
866 state_change(URN, game.prop[URN] == URN_EMPTY ?
871 if (game.limit < 0) {
875 state_change(LAMP, LAMP_BRIGHT);
880 speak(actions[verb].message);
885 static int listen(void)
886 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
888 long sound = locations[game.loc].sound;
889 if (sound != SILENT) {
891 if (!locations[game.loc].loud)
895 for (obj_t i = 1; i <= NOBJECTS; i++) {
897 objects[i].sounds[0] == NULL ||
900 int mi = game.prop[i];
901 /* FIXME: Weird magic on object states */
903 mi += 3 * game.blooded;
904 long packed_zzword = token_to_packed(game.zzword);
905 pspeak(i, hear, mi, true, packed_zzword);
907 if (i == BIRD && mi == BIRD_ENDSTATE)
915 static int lock(verb_t verb, obj_t obj)
916 /* Lock, unlock, no object given. Assume various things if present. */
918 if (obj == INTRANSITIVE) {
929 if (obj == INTRANSITIVE) {
930 rspeak(NOTHING_LOCKED);
935 /* Lock, unlock object. Special stuff for opening clam/oyster
950 game.clock2 = PANICTIME;
953 state_change(GRATE, (verb == LOCK) ?
963 else if (!TOTING(TRIDENT))
964 rspeak(OYSTER_OPENER);
967 drop(OYSTER, game.loc);
968 drop(PEARL, LOC_CULDESAC);
976 rspeak(OYSTER_OPENER);
979 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
985 rspeak(CANNOT_UNLOCK);
988 speak(actions[verb].message);
994 static int pour(verb_t verb, obj_t obj)
995 /* Pour. If no object, or object is bottle, assume contents of bottle.
996 * special tests for pouring water or oil on plant or rusty door. */
1001 if (obj == NO_OBJECT)
1004 speak(actions[verb].message);
1008 if (obj != OIL && obj != WATER) {
1012 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1013 return fill(verb, URN);
1014 game.prop[BOTTLE] = EMPTY_BOTTLE;
1015 game.place[obj] = LOC_NOWHERE;
1023 /* cycle through the three plant states */
1024 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1025 game.prop[PLANT2] = game.prop[PLANT];
1028 rspeak(SHAKING_LEAVES);
1032 state_change(DOOR, (obj == OIL) ?
1039 static int quit(void)
1040 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1042 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1043 terminate(quitgame);
1047 static int read(struct command_t command)
1048 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1050 if (command.obj == INTRANSITIVE) {
1051 command.obj = NO_OBJECT;
1052 for (int i = 1; i <= NOBJECTS; i++) {
1053 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1054 command.obj = command.obj * NOBJECTS + i;
1056 if (command.obj > NOBJECTS ||
1057 command.obj == NO_OBJECT ||
1062 if (DARK(game.loc)) {
1063 sspeak(NO_SEE, command.raw1);
1064 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1065 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1066 } else if (objects[command.obj].texts[0] == NULL ||
1067 game.prop[command.obj] == STATE_NOTFOUND) {
1068 speak(actions[command.verb].message);
1070 pspeak(command.obj, study, game.prop[command.obj], true);
1074 static int reservoir(void)
1075 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1077 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1078 rspeak(NOTHING_HAPPENS);
1082 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1086 game.oldlc2 = game.loc;
1087 game.newloc = LOC_NOWHERE;
1089 return GO_TERMINATE;
1094 static int rub(verb_t verb, obj_t obj)
1095 /* Rub. Yields various snide remarks except for lit urn. */
1097 if (obj == URN && game.prop[URN] == URN_LIT) {
1099 drop(AMBER, game.loc);
1100 game.prop[AMBER] = AMBER_IN_ROCK;
1102 drop(CAVITY, game.loc);
1104 } else if (obj != LAMP) {
1105 rspeak(PECULIAR_NOTHING);
1107 speak(actions[verb].message);
1112 static int say(struct command_t *command)
1113 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1115 if (command->wd2 > 0) {
1116 command->wd1 = command->wd2;
1117 strcpy(command->raw1, command->raw2);
1119 char word1[TOKLEN + 1];
1120 packed_to_token(command->wd1, word1);
1121 int wd = (int) get_vocab_id(word1);
1122 if (wd == MOTION_WORD(XYZZY) ||
1123 wd == MOTION_WORD(PLUGH) ||
1124 wd == MOTION_WORD(PLOVER) ||
1125 wd == ACTION_WORD(FEE) ||
1126 wd == ACTION_WORD(FIE) ||
1127 wd == ACTION_WORD(FOE) ||
1128 wd == ACTION_WORD(FOO) ||
1129 wd == ACTION_WORD(FUM) ||
1130 wd == ACTION_WORD(PART)) {
1131 /* FIXME: scribbles on the interpreter's command block */
1132 wordclear(&command->wd2);
1135 sspeak(OKEY_DOKEY, command->raw1);
1139 static int throw_support(long spk)
1142 drop(AXE, game.loc);
1146 static int throw (struct command_t *command)
1147 /* Throw. Same as discard unless axe. Then same as attack except
1148 * ignore bird, and if dwarf is present then one might be killed.
1149 * (Only way to do so!) Axe also special for dragon, bear, and
1150 * troll. Treasures special for troll. */
1152 if (!TOTING(command->obj)) {
1153 speak(actions[command->verb].message);
1156 if (objects[command->obj].is_treasure && AT(TROLL)) {
1157 /* Snarf a treasure for the troll. */
1158 drop(command->obj, LOC_NOWHERE);
1159 move(TROLL, LOC_NOWHERE);
1160 move(TROLL + NOBJECTS, IS_FREE);
1161 drop(TROLL2, objects[TROLL].plac);
1162 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1164 rspeak(TROLL_SATISFIED);
1167 if (command->obj == FOOD && HERE(BEAR)) {
1168 /* But throwing food is another story. */
1169 command->obj = BEAR;
1170 return (feed(command->verb, command->obj));
1172 if (command->obj != AXE)
1173 return (discard(command->verb, command->obj));
1175 if (atdwrf(game.loc) <= 0) {
1176 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1177 return throw_support(DRAGON_SCALES);
1179 return throw_support(TROLL_RETURNS);
1181 return throw_support(OGRE_DODGE);
1182 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1183 /* This'll teach him to throw the axe at the bear! */
1184 drop(AXE, game.loc);
1185 game.fixed[AXE] = IS_FIXED;
1187 state_change(AXE, AXE_LOST);
1190 command->obj = INTRANSITIVE;
1191 return (attack(command));
1194 if (randrange(NDWARVES + 1) < game.dflag) {
1195 return throw_support(DWARF_DODGES);
1197 long i = atdwrf(game.loc);
1198 game.dseen[i] = false;
1199 game.dloc[i] = LOC_NOWHERE;
1200 return throw_support((++game.dkill == 1) ?
1207 static int wake(verb_t verb, obj_t obj)
1208 /* Wake. Only use is to disturb the dwarves. */
1212 speak(actions[verb].message);
1216 return GO_DWARFWAKE;
1220 static int wave(verb_t verb, obj_t obj)
1221 /* Wave. No effect unless waving rod at fissure or at bird. */
1228 speak(((!TOTING(obj)) && (obj != ROD ||
1230 arbitrary_messages[ARENT_CARRYING] :
1231 actions[verb].message);
1235 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1236 drop(JADE, game.loc);
1237 game.prop[JADE] = STATE_FOUND;
1239 rspeak(NECKLACE_FLY);
1243 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1246 return GO_DWARFWAKE;
1250 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1256 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1260 state_change(FISSURE,
1261 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1266 int action(struct command_t *command)
1267 /* Analyse a verb. Remember what it was, go back for object if second word
1268 * unless verb is "say", which snarfs arbitrary second word.
1271 if (command->part == unknown) {
1272 /* Analyse an object word. See if the thing is here, whether
1273 * we've got a verb yet, and so on. Object must be here
1274 * unless verb is "find" or "invent(ory)" (and no new verb
1275 * yet to be analysed). Water and oil are also funny, since
1276 * they are never actually dropped at any location, but might
1277 * be here inside the bottle or urn or as a feature of the
1279 if (HERE(command->obj))
1281 else if (command->obj == GRATE) {
1282 if (game.loc == LOC_START ||
1283 game.loc == LOC_VALLEY ||
1284 game.loc == LOC_SLIT) {
1285 command->obj = DPRSSN;
1287 if (game.loc == LOC_COBBLE ||
1288 game.loc == LOC_DEBRIS ||
1289 game.loc == LOC_AWKWARD ||
1290 game.loc == LOC_BIRD ||
1291 game.loc == LOC_PITTOP) {
1292 command->obj = ENTRNC;
1294 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1296 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1297 command->obj == LIQLOC(game.loc))
1299 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1302 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1303 command->obj = PLANT2;
1305 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1307 rspeak(KNIVES_VANISH);
1309 } else if (command->obj == ROD && HERE(ROD2)) {
1310 command->obj = ROD2;
1312 } else if ((command->verb == FIND ||
1313 command->verb == INVENTORY) && command->wd2 <= 0)
1316 sspeak(NO_SEE, command->raw1);
1320 if (command->wd2 > 0)
1322 if (command->verb != 0)
1323 command->part = transitive;
1326 switch (command->part) {
1328 if (command->wd2 > 0 && command->verb != SAY)
1330 if (command->verb == SAY)
1331 command->obj = command->wd2;
1332 if (command->obj == NO_OBJECT ||
1333 command->obj == INTRANSITIVE) {
1334 /* Analyse an intransitive verb (ie, no object given yet). */
1335 switch (command->verb) {
1337 return vcarry(command->verb, INTRANSITIVE);
1343 return lock(command->verb, INTRANSITIVE);
1346 return (GO_CLEAROBJ);
1349 return lock(command->verb, INTRANSITIVE);
1351 return light(command->verb, INTRANSITIVE);
1353 return extinguish(command->verb, INTRANSITIVE);
1359 speak(actions[command->verb].message);
1363 command->obj = INTRANSITIVE;
1364 return attack(command);
1366 return pour(command->verb, INTRANSITIVE);
1368 return eat(command->verb, INTRANSITIVE);
1370 return drink(command->verb, INTRANSITIVE);
1384 return fill(command->verb, INTRANSITIVE);
1396 return bigwords(command->id1);
1400 command->obj = INTRANSITIVE;
1401 return read(*command);
1411 return fly(command->verb, INTRANSITIVE);
1417 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1422 /* Analyse a transitive verb. */
1423 switch (command->verb) {
1425 return vcarry(command->verb, command->obj);
1427 return discard(command->verb, command->obj);
1429 return say(command);
1431 return lock(command->verb, command->obj);
1434 return (GO_CLEAROBJ);
1437 return lock(command->verb, command->obj);
1439 return light(command->verb, command->obj);
1441 return extinguish(command->verb, command->obj);
1443 return wave(command->verb, command->obj);
1445 speak(actions[command->verb].message);
1449 speak(actions[command->verb].message);
1453 return attack(command);
1455 return pour(command->verb, command->obj);
1457 return eat(command->verb, command->obj);
1459 return drink(command->verb, command->obj);
1461 return rub(command->verb, command->obj);
1463 return throw (command);
1465 speak(actions[command->verb].message);
1469 return find(command->verb, command->obj);
1471 return find(command->verb, command->obj);
1473 return feed(command->verb, command->obj);
1475 return fill(command->verb, command->obj);
1480 speak(actions[command->verb].message);
1488 speak(actions[command->verb].message);
1492 speak(actions[command->verb].message);
1496 return read(*command);
1498 return vbreak(command->verb, command->obj);
1500 return wake(command->verb, command->obj);
1502 speak(actions[command->verb].message);
1506 speak(actions[command->verb].message);
1510 return fly(command->verb, command->obj);
1512 speak(actions[command->verb].message);
1518 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1521 /* Unknown verb, couldn't deduce object - might need hint */
1522 sspeak(WHAT_DO, command->raw1);
1523 return GO_CHECKHINT;
1525 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE