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 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] == STATE_NOTFOUND ||
235 rspeak(REQUIRES_DYNAMITE);
238 game.bonus = SPLATTER_MESSAGE;
239 else if (game.loc == LOC_NE)
240 game.bonus = DEFEAT_MESSAGE;
242 game.bonus = VICTORY_MESSAGE;
248 static int vbreak(verb_t verb, obj_t obj)
249 /* Break. Only works for mirror in repository and, of course, the vase. */
254 rspeak(BREAK_MIRROR);
261 if (game.prop[VASE] == VASE_WHOLE) {
263 drop(VASE, game.loc);
264 state_change(VASE, VASE_BROKEN);
265 game.fixed[VASE] = IS_FIXED;
269 speak(actions[verb].message);
271 return (GO_CLEAROBJ);
274 static int brief(void)
275 /* Brief. Intransitive only. Suppress long descriptions after first time. */
279 rspeak(BRIEF_CONFIRM);
283 static int vcarry(verb_t verb, obj_t obj)
284 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
285 * take one without the other). Liquids also special, since they depend on
286 * status of bottle. Also various side effects, etc. */
288 if (obj == INTRANSITIVE) {
289 /* Carry, no object given yet. OK if only one object present. */
290 if (game.atloc[game.loc] == NO_OBJECT ||
291 game.link[game.atloc[game.loc]] != 0 ||
292 atdwrf(game.loc) > 0)
294 obj = game.atloc[game.loc];
298 speak(actions[verb].message);
303 rspeak(REMOVE_MESSAGE);
308 if (game.fixed[obj] != IS_FREE) {
309 /* Next guard tests whether plant is tiny or stashed */
310 if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
314 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
315 rspeak(BEAR_CHAINED);
318 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
319 rspeak(STILL_LOCKED);
327 rspeak(DOUGHNUT_HOLES);
334 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
339 rspeak(HAND_PASSTHROUGH);
350 if (TOTING(BOTTLE)) {
351 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
352 return (fill(verb, BOTTLE));
353 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
357 rspeak(NO_CONTAINER);
363 if (game.holdng >= INVLIMIT) {
369 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
370 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
376 rspeak(CANNOT_CARRY);
383 game.prop[BIRD] = BIRD_CAGED;
387 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
388 /* expression maps BIRD to CAGE and CAGE to BIRD */
389 carry(BIRD + CAGE - obj, game.loc);
390 carry(obj, game.loc);
391 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
392 game.place[LIQUID()] = CARRIED;
393 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
394 game.prop[obj] = STATE_FOUND;
395 game.prop[CAVITY] = CAVITY_EMPTY;
401 static int chain(verb_t verb)
402 /* Do something to the bear's chain */
405 if (game.prop[BEAR] == UNTAMED_BEAR) {
409 if (game.prop[CHAIN] == CHAIN_HEAP) {
410 rspeak(ALREADY_UNLOCKED);
413 game.prop[CHAIN] = CHAIN_HEAP;
414 game.fixed[CHAIN] = IS_FREE;
415 if (game.prop[BEAR] != BEAR_DEAD)
416 game.prop[BEAR] = CONTENTED_BEAR;
418 switch (game.prop[BEAR]) {
420 game.fixed[BEAR] = IS_FIXED;
423 game.fixed[BEAR] = IS_FREE;
425 rspeak(CHAIN_UNLOCKED);
429 if (game.prop[CHAIN] != CHAIN_HEAP) {
430 rspeak(ALREADY_LOCKED);
433 if (game.loc != objects[CHAIN].plac) {
438 game.prop[CHAIN] = CHAIN_FIXED;
441 drop(CHAIN, game.loc);
442 game.fixed[CHAIN] = IS_FIXED;
444 rspeak(CHAIN_LOCKED);
448 static int discard(verb_t verb, obj_t obj)
449 /* Discard object. "Throw" also comes here for most objects. Special cases for
450 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
451 * Drop coins at vending machine for extra batteries. */
453 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
456 speak(actions[verb].message);
459 if (obj == BIRD && HERE(SNAKE)) {
460 rspeak(BIRD_ATTACKS);
464 /* Set game.prop for use by travel options */
465 game.prop[SNAKE] = SNAKE_CHASED;
467 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
469 game.prop[obj] = STATE_IN_CAVITY;
470 game.prop[CAVITY] = CAVITY_FULL;
471 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
472 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
479 if (spk != RUG_WIGGLES) {
480 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
483 k = objects[SAPPH].plac;
484 move(RUG + NOBJECTS, k);
487 } else if (obj == COINS && HERE(VEND)) {
489 drop(BATTERY, game.loc);
490 pspeak(BATTERY, look, FRESH_BATTERIES, true);
492 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
496 } else if (obj == BEAR && AT(TROLL)) {
497 state_change(TROLL, TROLL_GONE);
498 move(TROLL, LOC_NOWHERE);
499 move(TROLL + NOBJECTS, IS_FREE);
500 move(TROLL2, objects[TROLL].plac);
501 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
503 } else if (obj != VASE ||
504 game.loc == objects[PILLOW].plac) {
507 state_change(VASE, AT(PILLOW)
510 if (game.prop[VASE] != VASE_WHOLE)
511 game.fixed[VASE] = IS_FIXED;
516 if (obj == BOTTLE && k != NO_OBJECT)
517 game.place[k] = LOC_NOWHERE;
518 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
519 drop(BIRD, game.loc);
523 game.prop[BIRD] = BIRD_UNCAGED;
524 if (FOREST(game.loc))
525 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
529 static int drink(verb_t verb, obj_t obj)
530 /* Drink. If no object, assume water and look for it here. If water is in
531 * the bottle, drink that, else must be at a water loc, so drink stream. */
533 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
534 (LIQUID() != WATER || !HERE(BOTTLE))) {
540 state_change(DRAGON, DRAGON_BLOODLESS);
545 if (obj != INTRANSITIVE && obj != WATER) {
546 rspeak(RIDICULOUS_ATTEMPT);
549 if (LIQUID() == WATER && HERE(BOTTLE)) {
550 game.place[WATER] = LOC_NOWHERE;
551 state_change(BOTTLE, EMPTY_BOTTLE);
555 speak(actions[verb].message);
559 static int eat(verb_t verb, obj_t obj)
560 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
561 * ok, some things lose appetite, rest are ridiculous. */
569 rspeak(THANKS_DELICIOUS);
580 rspeak(LOST_APPETITE);
583 speak(actions[verb].message);
588 static int extinguish(verb_t verb, obj_t obj)
589 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
591 if (obj == INTRANSITIVE) {
592 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
594 if (HERE(URN) && game.prop[URN] == URN_LIT)
596 if (obj == INTRANSITIVE)
602 if (game.prop[URN] != URN_EMPTY) {
603 state_change(URN, URN_DARK);
605 pspeak(URN, change, URN_DARK, true);
609 state_change(LAMP, LAMP_DARK);
610 rspeak(DARK(game.loc) ?
616 rspeak(BEYOND_POWER);
619 speak(actions[verb].message);
624 static int feed(verb_t verb, obj_t obj)
625 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
626 * mad. Bear, special. */
633 if (game.prop[DRAGON] != DRAGON_BARS)
634 rspeak(RIDICULOUS_ATTEMPT);
636 rspeak(NOTHING_EDIBLE);
639 if (!game.closed && HERE(BIRD)) {
641 rspeak(BIRD_DEVOURED);
643 rspeak(NOTHING_EDIBLE);
653 speak(actions[verb].message);
656 if (game.prop[BEAR] == BEAR_DEAD) {
657 rspeak(RIDICULOUS_ATTEMPT);
660 if (game.prop[BEAR] == UNTAMED_BEAR) {
663 game.fixed[AXE] = IS_FREE;
664 game.prop[AXE] = AXE_HERE;
665 state_change(BEAR, SITTING_BEAR);
667 rspeak(NOTHING_EDIBLE);
670 speak(actions[verb].message);
676 speak(actions[verb].message);
684 int fill(verb_t verb, obj_t obj)
685 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
689 if (LIQLOC(game.loc) == NO_OBJECT) {
690 rspeak(FILL_INVALID);
694 rspeak(ARENT_CARRYING);
697 rspeak(SHATTER_VASE);
698 game.prop[VASE] = VASE_BROKEN;
699 game.fixed[VASE] = IS_FIXED;
700 drop(VASE, game.loc);
705 if (game.prop[URN] != URN_EMPTY) {
710 rspeak(FILL_INVALID);
716 game.prop[BOTTLE] = EMPTY_BOTTLE;
720 game.prop[URN] = URN_DARK;
721 game.prop[BOTTLE] = EMPTY_BOTTLE;
726 rspeak(FILL_INVALID);
729 game.place[k] = LOC_NOWHERE;
732 if (obj != INTRANSITIVE && obj != BOTTLE) {
733 speak(actions[verb].message);
736 if (obj == INTRANSITIVE && !HERE(BOTTLE))
739 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
743 if (LIQUID() != NO_OBJECT) {
747 if (LIQLOC(game.loc) == NO_OBJECT) {
752 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
756 game.place[LIQUID()] = CARRIED;
760 static int find(verb_t verb, obj_t obj)
761 /* Find. Might be carrying it, or it might be here. Else give caveat. */
764 rspeak(ALREADY_CARRYING);
769 rspeak(NEEDED_NEARBY);
774 (LIQUID() == obj && AT(BOTTLE)) ||
775 obj == LIQLOC(game.loc) ||
776 (obj == DWARF && atdwrf(game.loc) > 0)) {
782 speak(actions[verb].message);
786 static int fly(verb_t verb, obj_t obj)
787 /* Fly. Snide remarks unless hovering rug is here. */
789 if (obj == INTRANSITIVE) {
794 if (game.prop[RUG] != RUG_HOVER) {
795 rspeak(RUG_NOTHING2);
802 speak(actions[verb].message);
805 if (game.prop[RUG] != RUG_HOVER) {
806 rspeak(RUG_NOTHING1);
809 game.oldlc2 = game.oldloc;
810 game.oldloc = game.loc;
812 if (game.prop[SAPPH] == STATE_NOTFOUND) {
813 game.newloc = game.place[SAPPH];
816 game.newloc = LOC_CLIFF;
822 static int inven(void)
823 /* Inventory. If object, treat same as find. Else report on current burden. */
826 for (obj_t i = 1; i <= NOBJECTS; i++) {
834 pspeak(i, touch, -1, false);
843 static int light(verb_t verb, obj_t obj)
844 /* Light. Applicable only to lamp and urn. */
846 if (obj == INTRANSITIVE) {
848 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
852 if (HERE(URN) && game.prop[URN] == URN_DARK) {
862 state_change(URN, game.prop[URN] == URN_EMPTY ?
867 if (game.limit < 0) {
871 state_change(LAMP, LAMP_BRIGHT);
876 speak(actions[verb].message);
881 static int listen(void)
882 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
884 long sound = locations[game.loc].sound;
885 if (sound != SILENT) {
887 if (!locations[game.loc].loud)
891 for (obj_t i = 1; i <= NOBJECTS; i++) {
893 objects[i].sounds[0] == NULL ||
896 int mi = game.prop[i];
897 /* FIXME: Weird magic on object states */
899 mi += 3 * game.blooded;
900 long packed_zzword = token_to_packed(game.zzword);
901 pspeak(i, hear, mi, true, packed_zzword);
903 if (i == BIRD && mi == BIRD_ENDSTATE)
911 static int lock(verb_t verb, obj_t obj)
912 /* Lock, unlock, no object given. Assume various things if present. */
914 if (obj == INTRANSITIVE) {
925 if (obj == INTRANSITIVE) {
926 rspeak(NOTHING_LOCKED);
931 /* Lock, unlock object. Special stuff for opening clam/oyster
946 game.clock2 = PANICTIME;
949 state_change(GRATE, (verb == LOCK) ?
959 else if (!TOTING(TRIDENT))
960 rspeak(OYSTER_OPENER);
963 drop(OYSTER, game.loc);
964 drop(PEARL, LOC_CULDESAC);
972 rspeak(OYSTER_OPENER);
975 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
981 rspeak(CANNOT_UNLOCK);
984 speak(actions[verb].message);
990 static int pour(verb_t verb, obj_t obj)
991 /* Pour. If no object, or object is bottle, assume contents of bottle.
992 * special tests for pouring water or oil on plant or rusty door. */
997 if (obj == NO_OBJECT)
1000 speak(actions[verb].message);
1004 if (obj != OIL && obj != WATER) {
1008 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1009 return fill(verb, URN);
1010 game.prop[BOTTLE] = EMPTY_BOTTLE;
1011 game.place[obj] = LOC_NOWHERE;
1019 /* cycle through the three plant states */
1020 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1021 game.prop[PLANT2] = game.prop[PLANT];
1024 rspeak(SHAKING_LEAVES);
1028 state_change(DOOR, (obj == OIL) ?
1035 static int quit(void)
1036 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1038 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1039 terminate(quitgame);
1043 static int read(struct command_t command)
1044 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1046 if (command.obj == INTRANSITIVE) {
1047 command.obj = NO_OBJECT;
1048 for (int i = 1; i <= NOBJECTS; i++) {
1049 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1050 command.obj = command.obj * NOBJECTS + i;
1052 if (command.obj > NOBJECTS ||
1053 command.obj == NO_OBJECT ||
1058 if (DARK(game.loc)) {
1059 sspeak(NO_SEE, command.raw1);
1060 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1061 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1062 } else if (objects[command.obj].texts[0] == NULL ||
1063 game.prop[command.obj] == STATE_NOTFOUND) {
1064 speak(actions[command.verb].message);
1066 pspeak(command.obj, study, game.prop[command.obj], true);
1070 static int reservoir(void)
1071 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1073 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1074 rspeak(NOTHING_HAPPENS);
1078 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1082 game.oldlc2 = game.loc;
1083 game.newloc = LOC_NOWHERE;
1085 return GO_TERMINATE;
1090 static int rub(verb_t verb, obj_t obj)
1091 /* Rub. Yields various snide remarks except for lit urn. */
1093 if (obj == URN && game.prop[URN] == URN_LIT) {
1095 drop(AMBER, game.loc);
1096 game.prop[AMBER] = AMBER_IN_ROCK;
1098 drop(CAVITY, game.loc);
1100 } else if (obj != LAMP) {
1101 rspeak(PECULIAR_NOTHING);
1103 speak(actions[verb].message);
1108 static int say(struct command_t *command)
1109 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1111 if (command->wd2 > 0) {
1112 command->wd1 = command->wd2;
1113 strcpy(command->raw1, command->raw2);
1115 char word1[TOKLEN + 1];
1116 packed_to_token(command->wd1, word1);
1117 int wd = (int) get_vocab_id(word1);
1118 if (wd == MOTION_WORD(XYZZY) ||
1119 wd == MOTION_WORD(PLUGH) ||
1120 wd == MOTION_WORD(PLOVER) ||
1121 wd == ACTION_WORD(FEE) ||
1122 wd == ACTION_WORD(FIE) ||
1123 wd == ACTION_WORD(FOE) ||
1124 wd == ACTION_WORD(FOO) ||
1125 wd == ACTION_WORD(FUM) ||
1126 wd == ACTION_WORD(PART)) {
1127 /* FIXME: scribbles on the interpreter's command block */
1128 wordclear(&command->wd2);
1131 sspeak(OKEY_DOKEY, command->raw1);
1135 static int throw_support(long spk)
1138 drop(AXE, game.loc);
1142 static int throw (struct command_t *command)
1143 /* Throw. Same as discard unless axe. Then same as attack except
1144 * ignore bird, and if dwarf is present then one might be killed.
1145 * (Only way to do so!) Axe also special for dragon, bear, and
1146 * troll. Treasures special for troll. */
1148 if (!TOTING(command->obj)) {
1149 speak(actions[command->verb].message);
1152 if (objects[command->obj].is_treasure && AT(TROLL)) {
1153 /* Snarf a treasure for the troll. */
1154 drop(command->obj, LOC_NOWHERE);
1155 move(TROLL, LOC_NOWHERE);
1156 move(TROLL + NOBJECTS, IS_FREE);
1157 drop(TROLL2, objects[TROLL].plac);
1158 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1160 rspeak(TROLL_SATISFIED);
1163 if (command->obj == FOOD && HERE(BEAR)) {
1164 /* But throwing food is another story. */
1165 command->obj = BEAR;
1166 return (feed(command->verb, command->obj));
1168 if (command->obj != AXE)
1169 return (discard(command->verb, command->obj));
1171 if (atdwrf(game.loc) <= 0) {
1172 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1173 return throw_support(DRAGON_SCALES);
1175 return throw_support(TROLL_RETURNS);
1177 return throw_support(OGRE_DODGE);
1178 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1179 /* This'll teach him to throw the axe at the bear! */
1180 drop(AXE, game.loc);
1181 game.fixed[AXE] = IS_FIXED;
1183 state_change(AXE, AXE_LOST);
1186 command->obj = INTRANSITIVE;
1187 return (attack(command));
1190 if (randrange(NDWARVES + 1) < game.dflag) {
1191 return throw_support(DWARF_DODGES);
1193 long i = atdwrf(game.loc);
1194 game.dseen[i] = false;
1195 game.dloc[i] = LOC_NOWHERE;
1196 return throw_support((++game.dkill == 1) ?
1203 static int wake(verb_t verb, obj_t obj)
1204 /* Wake. Only use is to disturb the dwarves. */
1208 speak(actions[verb].message);
1212 return GO_DWARFWAKE;
1216 static int wave(verb_t verb, obj_t obj)
1217 /* Wave. No effect unless waving rod at fissure or at bird. */
1224 speak(((!TOTING(obj)) && (obj != ROD ||
1226 arbitrary_messages[ARENT_CARRYING] :
1227 actions[verb].message);
1231 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1232 drop(JADE, game.loc);
1233 game.prop[JADE] = STATE_FOUND;
1235 rspeak(NECKLACE_FLY);
1239 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1242 return GO_DWARFWAKE;
1246 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1252 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1256 state_change(FISSURE,
1257 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1262 int action(struct command_t *command)
1263 /* Analyse a verb. Remember what it was, go back for object if second word
1264 * unless verb is "say", which snarfs arbitrary second word.
1267 if (command->part == unknown) {
1268 /* Analyse an object word. See if the thing is here, whether
1269 * we've got a verb yet, and so on. Object must be here
1270 * unless verb is "find" or "invent(ory)" (and no new verb
1271 * yet to be analysed). Water and oil are also funny, since
1272 * they are never actually dropped at any location, but might
1273 * be here inside the bottle or urn or as a feature of the
1275 if (HERE(command->obj))
1277 else if (command->obj == GRATE) {
1278 if (game.loc == LOC_START ||
1279 game.loc == LOC_VALLEY ||
1280 game.loc == LOC_SLIT) {
1281 command->obj = DPRSSN;
1283 if (game.loc == LOC_COBBLE ||
1284 game.loc == LOC_DEBRIS ||
1285 game.loc == LOC_AWKWARD ||
1286 game.loc == LOC_BIRD ||
1287 game.loc == LOC_PITTOP) {
1288 command->obj = ENTRNC;
1290 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1292 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1293 command->obj == LIQLOC(game.loc))
1295 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1298 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1299 command->obj = PLANT2;
1301 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1303 rspeak(KNIVES_VANISH);
1305 } else if (command->obj == ROD && HERE(ROD2)) {
1306 command->obj = ROD2;
1308 } else if ((command->verb == FIND ||
1309 command->verb == INVENTORY) && command->wd2 <= 0)
1312 sspeak(NO_SEE, command->raw1);
1316 if (command->wd2 > 0)
1318 if (command->verb != 0)
1319 command->part = transitive;
1322 switch (command->part) {
1324 if (command->wd2 > 0 && command->verb != SAY)
1326 if (command->verb == SAY)
1327 command->obj = command->wd2;
1328 if (command->obj == NO_OBJECT ||
1329 command->obj == INTRANSITIVE) {
1330 /* Analyse an intransitive verb (ie, no object given yet). */
1331 switch (command->verb) {
1333 return vcarry(command->verb, INTRANSITIVE);
1339 return lock(command->verb, INTRANSITIVE);
1342 return (GO_CLEAROBJ);
1345 return lock(command->verb, INTRANSITIVE);
1347 return light(command->verb, INTRANSITIVE);
1349 return extinguish(command->verb, INTRANSITIVE);
1355 speak(actions[command->verb].message);
1359 command->obj = INTRANSITIVE;
1360 return attack(command);
1362 return pour(command->verb, INTRANSITIVE);
1364 return eat(command->verb, INTRANSITIVE);
1366 return drink(command->verb, INTRANSITIVE);
1380 return fill(command->verb, INTRANSITIVE);
1392 return bigwords(command->id1);
1396 command->obj = INTRANSITIVE;
1397 return read(*command);
1407 return fly(command->verb, INTRANSITIVE);
1413 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1418 /* Analyse a transitive verb. */
1419 switch (command->verb) {
1421 return vcarry(command->verb, command->obj);
1423 return discard(command->verb, command->obj);
1425 return say(command);
1427 return lock(command->verb, command->obj);
1430 return (GO_CLEAROBJ);
1433 return lock(command->verb, command->obj);
1435 return light(command->verb, command->obj);
1437 return extinguish(command->verb, command->obj);
1439 return wave(command->verb, command->obj);
1441 speak(actions[command->verb].message);
1445 speak(actions[command->verb].message);
1449 return attack(command);
1451 return pour(command->verb, command->obj);
1453 return eat(command->verb, command->obj);
1455 return drink(command->verb, command->obj);
1457 return rub(command->verb, command->obj);
1459 return throw (command);
1461 speak(actions[command->verb].message);
1465 return find(command->verb, command->obj);
1467 return find(command->verb, command->obj);
1469 return feed(command->verb, command->obj);
1471 return fill(command->verb, command->obj);
1476 speak(actions[command->verb].message);
1484 speak(actions[command->verb].message);
1488 speak(actions[command->verb].message);
1492 return read(*command);
1494 return vbreak(command->verb, command->obj);
1496 return wake(command->verb, command->obj);
1498 speak(actions[command->verb].message);
1502 speak(actions[command->verb].message);
1506 return fly(command->verb, command->obj);
1508 speak(actions[command->verb].message);
1514 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1517 /* Unknown verb, couldn't deduce object - might need hint */
1518 sspeak(WHAT_DO, command->raw1);
1519 return GO_CHECKHINT;
1521 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE