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;
241 rspeak(SPLATTER_MESSAGE);
242 } else if (game.loc == LOC_NE) {
244 rspeak(DEFEAT_MESSAGE);
246 game.bonus = victory;
247 rspeak(VICTORY_MESSAGE);
253 static int vbreak(verb_t verb, obj_t obj)
254 /* Break. Only works for mirror in repository and, of course, the vase. */
259 rspeak(BREAK_MIRROR);
266 if (game.prop[VASE] == VASE_WHOLE) {
268 drop(VASE, game.loc);
269 state_change(VASE, VASE_BROKEN);
270 game.fixed[VASE] = IS_FIXED;
274 speak(actions[verb].message);
276 return (GO_CLEAROBJ);
279 static int brief(void)
280 /* Brief. Intransitive only. Suppress long descriptions after first time. */
284 rspeak(BRIEF_CONFIRM);
288 static int vcarry(verb_t verb, obj_t obj)
289 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
290 * take one without the other). Liquids also special, since they depend on
291 * status of bottle. Also various side effects, etc. */
293 if (obj == INTRANSITIVE) {
294 /* Carry, no object given yet. OK if only one object present. */
295 if (game.atloc[game.loc] == NO_OBJECT ||
296 game.link[game.atloc[game.loc]] != 0 ||
297 atdwrf(game.loc) > 0)
299 obj = game.atloc[game.loc];
303 speak(actions[verb].message);
308 rspeak(REMOVE_MESSAGE);
313 if (game.fixed[obj] != IS_FREE) {
314 /* Next guard tests whether plant is tiny or stashed */
315 if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
319 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
320 rspeak(BEAR_CHAINED);
323 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
324 rspeak(STILL_LOCKED);
332 rspeak(DOUGHNUT_HOLES);
339 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
344 rspeak(HAND_PASSTHROUGH);
355 if (TOTING(BOTTLE)) {
356 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
357 return (fill(verb, BOTTLE));
358 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
362 rspeak(NO_CONTAINER);
368 if (game.holdng >= INVLIMIT) {
374 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
375 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
381 rspeak(CANNOT_CARRY);
388 game.prop[BIRD] = BIRD_CAGED;
392 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
393 /* expression maps BIRD to CAGE and CAGE to BIRD */
394 carry(BIRD + CAGE - obj, game.loc);
395 carry(obj, game.loc);
396 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
397 game.place[LIQUID()] = CARRIED;
398 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
399 game.prop[obj] = STATE_FOUND;
400 game.prop[CAVITY] = CAVITY_EMPTY;
406 static int chain(verb_t verb)
407 /* Do something to the bear's chain */
410 if (game.prop[BEAR] == UNTAMED_BEAR) {
414 if (game.prop[CHAIN] == CHAIN_HEAP) {
415 rspeak(ALREADY_UNLOCKED);
418 game.prop[CHAIN] = CHAIN_HEAP;
419 game.fixed[CHAIN] = IS_FREE;
420 if (game.prop[BEAR] != BEAR_DEAD)
421 game.prop[BEAR] = CONTENTED_BEAR;
423 switch (game.prop[BEAR]) {
426 /* Can't be reached as long as the only way for the bear to die
427 * is from a bridge collapse. Leave in in case this changes, but
428 * exclude from coverage testing. */
429 game.fixed[BEAR] = IS_FIXED;
433 game.fixed[BEAR] = IS_FREE;
435 rspeak(CHAIN_UNLOCKED);
439 if (game.prop[CHAIN] != CHAIN_HEAP) {
440 rspeak(ALREADY_LOCKED);
443 if (game.loc != objects[CHAIN].plac) {
448 game.prop[CHAIN] = CHAIN_FIXED;
451 drop(CHAIN, game.loc);
452 game.fixed[CHAIN] = IS_FIXED;
454 rspeak(CHAIN_LOCKED);
458 static int discard(verb_t verb, obj_t obj)
459 /* Discard object. "Throw" also comes here for most objects. Special cases for
460 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
461 * Drop coins at vending machine for extra batteries. */
463 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
466 speak(actions[verb].message);
469 if (obj == BIRD && HERE(SNAKE)) {
470 rspeak(BIRD_ATTACKS);
474 /* Set game.prop for use by travel options */
475 game.prop[SNAKE] = SNAKE_CHASED;
477 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
479 game.prop[obj] = STATE_IN_CAVITY;
480 game.prop[CAVITY] = CAVITY_FULL;
481 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
482 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
485 else if (TOTING(RUG))
489 if (!TOTING(RUG) || obj == RUBY) {
490 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
493 k = objects[SAPPH].plac;
494 move(RUG + NOBJECTS, k);
497 } else if (obj == COINS && HERE(VEND)) {
499 drop(BATTERY, game.loc);
500 pspeak(BATTERY, look, FRESH_BATTERIES, true);
502 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
506 } else if (obj == BEAR && AT(TROLL)) {
507 state_change(TROLL, TROLL_GONE);
508 move(TROLL, LOC_NOWHERE);
509 move(TROLL + NOBJECTS, IS_FREE);
510 move(TROLL2, objects[TROLL].plac);
511 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
513 } else if (obj != VASE ||
514 game.loc == objects[PILLOW].plac) {
517 state_change(VASE, AT(PILLOW)
520 if (game.prop[VASE] != VASE_WHOLE)
521 game.fixed[VASE] = IS_FIXED;
526 if (obj == BOTTLE && k != NO_OBJECT)
527 game.place[k] = LOC_NOWHERE;
528 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
529 drop(BIRD, game.loc);
533 game.prop[BIRD] = BIRD_UNCAGED;
534 if (FOREST(game.loc))
535 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
539 static int drink(verb_t verb, obj_t obj)
540 /* Drink. If no object, assume water and look for it here. If water is in
541 * the bottle, drink that, else must be at a water loc, so drink stream. */
543 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
544 (LIQUID() != WATER || !HERE(BOTTLE))) {
550 state_change(DRAGON, DRAGON_BLOODLESS);
555 if (obj != INTRANSITIVE && obj != WATER) {
556 rspeak(RIDICULOUS_ATTEMPT);
559 if (LIQUID() == WATER && HERE(BOTTLE)) {
560 game.place[WATER] = LOC_NOWHERE;
561 state_change(BOTTLE, EMPTY_BOTTLE);
565 speak(actions[verb].message);
569 static int eat(verb_t verb, obj_t obj)
570 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
571 * ok, some things lose appetite, rest are ridiculous. */
579 rspeak(THANKS_DELICIOUS);
590 rspeak(LOST_APPETITE);
593 speak(actions[verb].message);
598 static int extinguish(verb_t verb, obj_t obj)
599 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
601 if (obj == INTRANSITIVE) {
602 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
604 if (HERE(URN) && game.prop[URN] == URN_LIT)
606 if (obj == INTRANSITIVE)
612 if (game.prop[URN] != URN_EMPTY) {
613 state_change(URN, URN_DARK);
615 pspeak(URN, change, URN_DARK, true);
619 state_change(LAMP, LAMP_DARK);
620 rspeak(DARK(game.loc) ?
626 rspeak(BEYOND_POWER);
629 speak(actions[verb].message);
634 static int feed(verb_t verb, obj_t obj)
635 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
636 * mad. Bear, special. */
643 if (game.prop[DRAGON] != DRAGON_BARS)
644 rspeak(RIDICULOUS_ATTEMPT);
646 rspeak(NOTHING_EDIBLE);
649 if (!game.closed && HERE(BIRD)) {
651 rspeak(BIRD_DEVOURED);
653 rspeak(NOTHING_EDIBLE);
663 speak(actions[verb].message);
666 if (game.prop[BEAR] == BEAR_DEAD) {
667 rspeak(RIDICULOUS_ATTEMPT);
670 if (game.prop[BEAR] == UNTAMED_BEAR) {
673 game.fixed[AXE] = IS_FREE;
674 game.prop[AXE] = AXE_HERE;
675 state_change(BEAR, SITTING_BEAR);
677 rspeak(NOTHING_EDIBLE);
680 speak(actions[verb].message);
686 speak(actions[verb].message);
694 int fill(verb_t verb, obj_t obj)
695 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
699 if (LIQLOC(game.loc) == NO_OBJECT) {
700 rspeak(FILL_INVALID);
704 rspeak(ARENT_CARRYING);
707 rspeak(SHATTER_VASE);
708 game.prop[VASE] = VASE_BROKEN;
709 game.fixed[VASE] = IS_FIXED;
710 drop(VASE, game.loc);
715 if (game.prop[URN] != URN_EMPTY) {
720 rspeak(FILL_INVALID);
726 game.prop[BOTTLE] = EMPTY_BOTTLE;
730 game.prop[URN] = URN_DARK;
731 game.prop[BOTTLE] = EMPTY_BOTTLE;
736 rspeak(FILL_INVALID);
739 game.place[k] = LOC_NOWHERE;
742 if (obj != INTRANSITIVE && obj != BOTTLE) {
743 speak(actions[verb].message);
746 if (obj == INTRANSITIVE && !HERE(BOTTLE))
749 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
753 if (LIQUID() != NO_OBJECT) {
757 if (LIQLOC(game.loc) == NO_OBJECT) {
762 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
766 game.place[LIQUID()] = CARRIED;
770 static int find(verb_t verb, obj_t obj)
771 /* Find. Might be carrying it, or it might be here. Else give caveat. */
774 rspeak(ALREADY_CARRYING);
779 rspeak(NEEDED_NEARBY);
784 (LIQUID() == obj && AT(BOTTLE)) ||
785 obj == LIQLOC(game.loc) ||
786 (obj == DWARF && atdwrf(game.loc) > 0)) {
792 speak(actions[verb].message);
796 static int fly(verb_t verb, obj_t obj)
797 /* Fly. Snide remarks unless hovering rug is here. */
799 if (obj == INTRANSITIVE) {
804 if (game.prop[RUG] != RUG_HOVER) {
805 rspeak(RUG_NOTHING2);
812 speak(actions[verb].message);
815 if (game.prop[RUG] != RUG_HOVER) {
816 rspeak(RUG_NOTHING1);
819 game.oldlc2 = game.oldloc;
820 game.oldloc = game.loc;
822 if (game.prop[SAPPH] == STATE_NOTFOUND) {
823 game.newloc = game.place[SAPPH];
826 game.newloc = LOC_CLIFF;
832 static int inven(void)
833 /* Inventory. If object, treat same as find. Else report on current burden. */
836 for (obj_t i = 1; i <= NOBJECTS; i++) {
844 pspeak(i, touch, -1, false);
853 static int light(verb_t verb, obj_t obj)
854 /* Light. Applicable only to lamp and urn. */
856 if (obj == INTRANSITIVE) {
858 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
862 if (HERE(URN) && game.prop[URN] == URN_DARK) {
872 state_change(URN, game.prop[URN] == URN_EMPTY ?
877 if (game.limit < 0) {
881 state_change(LAMP, LAMP_BRIGHT);
886 speak(actions[verb].message);
891 static int listen(void)
892 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
894 long sound = locations[game.loc].sound;
895 if (sound != SILENT) {
897 if (!locations[game.loc].loud)
901 for (obj_t i = 1; i <= NOBJECTS; i++) {
903 objects[i].sounds[0] == NULL ||
906 int mi = game.prop[i];
907 /* (ESR) Some unpleasant magic on object states here. Ideally
908 * we'd have liked the bird to be a normal object that we can
909 * use state_change() on; can't do it, because there are
910 * actually two different series of per-state birdsounds
911 * depending on whether player has drunk dragon's blood. */
913 mi += 3 * game.blooded;
914 long packed_zzword = token_to_packed(game.zzword);
915 pspeak(i, hear, mi, true, packed_zzword);
917 if (i == BIRD && mi == BIRD_ENDSTATE)
925 static int lock(verb_t verb, obj_t obj)
926 /* Lock, unlock, no object given. Assume various things if present. */
928 if (obj == INTRANSITIVE) {
939 if (obj == INTRANSITIVE) {
940 rspeak(NOTHING_LOCKED);
945 /* Lock, unlock object. Special stuff for opening clam/oyster
960 game.clock2 = PANICTIME;
963 state_change(GRATE, (verb == LOCK) ?
973 else if (!TOTING(TRIDENT))
974 rspeak(OYSTER_OPENER);
977 drop(OYSTER, game.loc);
978 drop(PEARL, LOC_CULDESAC);
986 rspeak(OYSTER_OPENER);
989 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
995 rspeak(CANNOT_UNLOCK);
998 speak(actions[verb].message);
1004 static int pour(verb_t verb, obj_t obj)
1005 /* Pour. If no object, or object is bottle, assume contents of bottle.
1006 * special tests for pouring water or oil on plant or rusty door. */
1008 if (obj == BOTTLE ||
1009 obj == INTRANSITIVE)
1011 if (obj == NO_OBJECT)
1014 speak(actions[verb].message);
1018 if (obj != OIL && obj != WATER) {
1022 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1023 return fill(verb, URN);
1024 game.prop[BOTTLE] = EMPTY_BOTTLE;
1025 game.place[obj] = LOC_NOWHERE;
1033 /* cycle through the three plant states */
1034 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1035 game.prop[PLANT2] = game.prop[PLANT];
1038 rspeak(SHAKING_LEAVES);
1042 state_change(DOOR, (obj == OIL) ?
1049 static int quit(void)
1050 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1052 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1053 terminate(quitgame);
1057 static int read(struct command_t command)
1058 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1060 if (command.obj == INTRANSITIVE) {
1061 command.obj = NO_OBJECT;
1062 for (int i = 1; i <= NOBJECTS; i++) {
1063 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1064 command.obj = command.obj * NOBJECTS + i;
1066 if (command.obj > NOBJECTS ||
1067 command.obj == NO_OBJECT ||
1072 if (DARK(game.loc)) {
1073 sspeak(NO_SEE, command.raw1);
1074 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1075 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1076 } else if (objects[command.obj].texts[0] == NULL ||
1077 game.prop[command.obj] == STATE_NOTFOUND) {
1078 speak(actions[command.verb].message);
1080 pspeak(command.obj, study, game.prop[command.obj], true);
1084 static int reservoir(void)
1085 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1087 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1088 rspeak(NOTHING_HAPPENS);
1092 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1096 game.oldlc2 = game.loc;
1097 game.newloc = LOC_NOWHERE;
1099 return GO_TERMINATE;
1104 static int rub(verb_t verb, obj_t obj)
1105 /* Rub. Yields various snide remarks except for lit urn. */
1107 if (obj == URN && game.prop[URN] == URN_LIT) {
1109 drop(AMBER, game.loc);
1110 game.prop[AMBER] = AMBER_IN_ROCK;
1112 drop(CAVITY, game.loc);
1114 } else if (obj != LAMP) {
1115 rspeak(PECULIAR_NOTHING);
1117 speak(actions[verb].message);
1122 static int say(struct command_t *command)
1123 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1125 if (command->wd2 > 0) {
1126 command->wd1 = command->wd2;
1127 strncpy(command->raw1, command->raw2, LINESIZE - 1);
1129 char word1[TOKLEN + 1];
1130 packed_to_token(command->wd1, word1);
1133 get_vocab_metadata(word1, &wd, &type);
1143 /* FIXME: scribbles on the interpreter's command block */
1144 wordclear(&command->wd2);
1147 sspeak(OKEY_DOKEY, command->raw1);
1151 static int throw_support(long spk)
1154 drop(AXE, game.loc);
1158 static int throw (struct command_t *command)
1159 /* Throw. Same as discard unless axe. Then same as attack except
1160 * ignore bird, and if dwarf is present then one might be killed.
1161 * (Only way to do so!) Axe also special for dragon, bear, and
1162 * troll. Treasures special for troll. */
1164 if (!TOTING(command->obj)) {
1165 speak(actions[command->verb].message);
1168 if (objects[command->obj].is_treasure && AT(TROLL)) {
1169 /* Snarf a treasure for the troll. */
1170 drop(command->obj, LOC_NOWHERE);
1171 move(TROLL, LOC_NOWHERE);
1172 move(TROLL + NOBJECTS, IS_FREE);
1173 drop(TROLL2, objects[TROLL].plac);
1174 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1176 rspeak(TROLL_SATISFIED);
1179 if (command->obj == FOOD && HERE(BEAR)) {
1180 /* But throwing food is another story. */
1181 command->obj = BEAR;
1182 return (feed(command->verb, command->obj));
1184 if (command->obj != AXE)
1185 return (discard(command->verb, command->obj));
1187 if (atdwrf(game.loc) <= 0) {
1188 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1189 return throw_support(DRAGON_SCALES);
1191 return throw_support(TROLL_RETURNS);
1193 return throw_support(OGRE_DODGE);
1194 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1195 /* This'll teach him to throw the axe at the bear! */
1196 drop(AXE, game.loc);
1197 game.fixed[AXE] = IS_FIXED;
1199 state_change(AXE, AXE_LOST);
1202 command->obj = INTRANSITIVE;
1203 return (attack(command));
1206 if (randrange(NDWARVES + 1) < game.dflag) {
1207 return throw_support(DWARF_DODGES);
1209 long i = atdwrf(game.loc);
1210 game.dseen[i] = false;
1211 game.dloc[i] = LOC_NOWHERE;
1212 return throw_support((++game.dkill == 1) ?
1219 static int wake(verb_t verb, obj_t obj)
1220 /* Wake. Only use is to disturb the dwarves. */
1224 speak(actions[verb].message);
1228 return GO_DWARFWAKE;
1232 static int wave(verb_t verb, obj_t obj)
1233 /* Wave. No effect unless waving rod at fissure or at bird. */
1240 speak(((!TOTING(obj)) && (obj != ROD ||
1242 arbitrary_messages[ARENT_CARRYING] :
1243 actions[verb].message);
1247 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1248 drop(JADE, game.loc);
1249 game.prop[JADE] = STATE_FOUND;
1251 rspeak(NECKLACE_FLY);
1255 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1258 return GO_DWARFWAKE;
1262 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1268 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1272 state_change(FISSURE,
1273 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1278 int action(struct command_t *command)
1279 /* Analyse a verb. Remember what it was, go back for object if second word
1280 * unless verb is "say", which snarfs arbitrary second word.
1283 if (command->part == unknown) {
1284 /* Analyse an object word. See if the thing is here, whether
1285 * we've got a verb yet, and so on. Object must be here
1286 * unless verb is "find" or "invent(ory)" (and no new verb
1287 * yet to be analysed). Water and oil are also funny, since
1288 * they are never actually dropped at any location, but might
1289 * be here inside the bottle or urn or as a feature of the
1291 if (HERE(command->obj))
1293 else if (command->obj == GRATE) {
1294 if (game.loc == LOC_START ||
1295 game.loc == LOC_VALLEY ||
1296 game.loc == LOC_SLIT) {
1297 command->obj = DPRSSN;
1299 if (game.loc == LOC_COBBLE ||
1300 game.loc == LOC_DEBRIS ||
1301 game.loc == LOC_AWKWARD ||
1302 game.loc == LOC_BIRD ||
1303 game.loc == LOC_PITTOP) {
1304 command->obj = ENTRNC;
1306 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1308 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1309 command->obj == LIQLOC(game.loc))
1311 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1314 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1315 command->obj = PLANT2;
1317 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1319 rspeak(KNIVES_VANISH);
1321 } else if (command->obj == ROD && HERE(ROD2)) {
1322 command->obj = ROD2;
1324 } else if ((command->verb == FIND ||
1325 command->verb == INVENTORY) && command->wd2 <= 0)
1328 sspeak(NO_SEE, command->raw1);
1332 if (command->wd2 > 0)
1334 if (command->verb != 0)
1335 command->part = transitive;
1338 switch (command->part) {
1340 if (command->wd2 > 0 && command->verb != SAY)
1342 if (command->verb == SAY)
1343 command->obj = command->wd2;
1344 if (command->obj == NO_OBJECT ||
1345 command->obj == INTRANSITIVE) {
1346 /* Analyse an intransitive verb (ie, no object given yet). */
1347 switch (command->verb) {
1349 return vcarry(command->verb, INTRANSITIVE);
1355 return lock(command->verb, INTRANSITIVE);
1358 return (GO_CLEAROBJ);
1361 return lock(command->verb, INTRANSITIVE);
1363 return light(command->verb, INTRANSITIVE);
1365 return extinguish(command->verb, INTRANSITIVE);
1371 speak(actions[command->verb].message);
1375 command->obj = INTRANSITIVE;
1376 return attack(command);
1378 return pour(command->verb, INTRANSITIVE);
1380 return eat(command->verb, INTRANSITIVE);
1382 return drink(command->verb, INTRANSITIVE);
1396 return fill(command->verb, INTRANSITIVE);
1408 return bigwords(command->id1);
1412 command->obj = INTRANSITIVE;
1413 return read(*command);
1423 return fly(command->verb, INTRANSITIVE);
1429 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1434 /* Analyse a transitive verb. */
1435 switch (command->verb) {
1437 return vcarry(command->verb, command->obj);
1439 return discard(command->verb, command->obj);
1441 return say(command);
1443 return lock(command->verb, command->obj);
1446 return (GO_CLEAROBJ);
1449 return lock(command->verb, command->obj);
1451 return light(command->verb, command->obj);
1453 return extinguish(command->verb, command->obj);
1455 return wave(command->verb, command->obj);
1457 speak(actions[command->verb].message);
1461 speak(actions[command->verb].message);
1465 return attack(command);
1467 return pour(command->verb, command->obj);
1469 return eat(command->verb, command->obj);
1471 return drink(command->verb, command->obj);
1473 return rub(command->verb, command->obj);
1475 return throw (command);
1477 speak(actions[command->verb].message);
1481 return find(command->verb, command->obj);
1483 return find(command->verb, command->obj);
1485 return feed(command->verb, command->obj);
1487 return fill(command->verb, command->obj);
1492 speak(actions[command->verb].message);
1500 speak(actions[command->verb].message);
1504 speak(actions[command->verb].message);
1508 return read(*command);
1510 return vbreak(command->verb, command->obj);
1512 return wake(command->verb, command->obj);
1514 speak(actions[command->verb].message);
1518 speak(actions[command->verb].message);
1522 return fly(command->verb, command->obj);
1524 speak(actions[command->verb].message);
1530 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1533 /* Unknown verb, couldn't deduce object - might need hint */
1534 sspeak(WHAT_DO, command->raw1);
1535 return GO_CHECKHINT;
1537 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE