7 static int fill(verb_t, obj_t);
9 static int attack(struct command_t *command)
10 /* Attack. Assume target if unambiguous. "Throw" also links here.
11 * Attackable objects fall into two categories: enemies (snake,
12 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
13 * enemies, or no enemies but 2 others. */
15 verb_t verb = command->verb;
16 obj_t obj = command->obj;
18 if (obj == INTRANSITIVE) {
20 if (atdwrf(game.loc) > 0) {
28 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
40 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
44 /* check for low-priority targets */
45 if (obj == INTRANSITIVE) {
46 /* Can't attack bird or machine by throwing axe. */
47 if (HERE(BIRD) && verb != THROW) {
51 if (HERE(VEND) && verb != THROW) {
55 /* Clam and oyster both treated as clam for intransitive case;
57 if (HERE(CLAM) || HERE(OYSTER)) {
77 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
82 switch (game.prop[BEAR]) {
87 rspeak(BEAR_CONFUSED);
90 rspeak(BEAR_CONFUSED);
98 if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
99 /* Fun stuff for dragon. If he insists on attacking it, win!
100 * Set game.prop to dead, move dragon to central loc (still
101 * fixed), move rug there (not fixed), and move him there,
102 * too. Then do a null motion to get new description. */
103 rspeak(BARE_HANDS_QUERY);
105 // FIXME: setting wd1 is a workaround for broken logic
106 command->wd1 = token_to_packed("Y");
108 // FIXME: setting wd1 is a workaround for broken logic
109 command->wd1 = token_to_packed("N");
112 state_change(DRAGON, DRAGON_DEAD);
113 game.prop[RUG] = RUG_FLOOR;
114 /* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.
115 * The way it was computed before was worse; it depended on the
116 * two dragon locations being LOC_SECRET4 and LOC_SECRET6 and
117 * LOC_SECRET5 being right between them.
119 move(DRAGON + NOBJECTS, IS_FIXED);
120 move(RUG + NOBJECTS, IS_FREE);
121 move(DRAGON, LOC_SECRET5);
122 move(RUG, LOC_SECRET5);
123 drop(BLOOD, LOC_SECRET5);
124 for (obj_t i = 1; i <= NOBJECTS; i++) {
125 if (game.place[i] == objects[DRAGON].plac ||
126 game.place[i] == objects[DRAGON].fixd)
127 move(i, LOC_SECRET5);
129 game.loc = LOC_SECRET5;
135 if (atdwrf(game.loc) == 0)
138 rspeak(KNIFE_THROWN);
141 for (int i = 1; i < PIRATE; i++) {
142 if (game.dloc[i] == game.loc) {
144 game.dloc[i] = LOC_LONGWEST;
145 game.dseen[i] = false;
148 rspeak((dwarves > 1) ?
160 rspeak(SHELL_IMPERVIOUS);
163 rspeak(SNAKE_WARNING);
169 rspeak(BARE_HANDS_QUERY);
172 rspeak(ALREADY_DEAD);
178 speak(actions[verb].message);
183 static int bigwords(long id)
184 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
185 * Look up foo in special section of vocab to determine which word we've got.
186 * Last word zips the eggs back to the giant room (unless already there). */
188 if ((game.foobar == WORD_EMPTY && id == FEE) ||
189 (game.foobar == FEE && id == FIE) ||
190 (game.foobar == FIE && id == FOE) ||
191 (game.foobar == FOE && id == FOO) ||
192 (game.foobar == FOE && id == FUM)) {
194 if ((id != FOO) && (id != FUM)) {
198 game.foobar = WORD_EMPTY;
199 if (game.place[EGGS] == objects[EGGS].plac ||
200 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
201 rspeak(NOTHING_HAPPENS);
204 /* Bring back troll if we steal the eggs back from him before
206 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
207 game.prop[TROLL] = TROLL_PAIDONCE;
211 else if (game.loc == objects[EGGS].plac)
215 move(EGGS, objects[EGGS].plac);
216 pspeak(EGGS, look, k, true);
220 if (game.loc == LOC_GIANTROOM) {
223 /* This is new begavior in Open Adventure - sounds better when
224 * player isn't in the Giant Room. */
225 rspeak(WELL_POINTLESS);
227 game.foobar = WORD_EMPTY;
232 static void blast(void)
233 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
235 if (game.prop[ROD2] == STATE_NOTFOUND ||
237 rspeak(REQUIRES_DYNAMITE);
240 game.bonus = SPLATTER_MESSAGE;
241 else if (game.loc == LOC_NE)
242 game.bonus = DEFEAT_MESSAGE;
244 game.bonus = VICTORY_MESSAGE;
250 static int vbreak(verb_t verb, obj_t obj)
251 /* Break. Only works for mirror in repository and, of course, the vase. */
256 rspeak(BREAK_MIRROR);
263 if (game.prop[VASE] == VASE_WHOLE) {
265 drop(VASE, game.loc);
266 state_change(VASE, VASE_BROKEN);
267 game.fixed[VASE] = IS_FIXED;
271 speak(actions[verb].message);
273 return (GO_CLEAROBJ);
276 static int brief(void)
277 /* Brief. Intransitive only. Suppress long descriptions after first time. */
281 rspeak(BRIEF_CONFIRM);
285 static int vcarry(verb_t verb, obj_t obj)
286 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
287 * take one without the other). Liquids also special, since they depend on
288 * status of bottle. Also various side effects, etc. */
290 if (obj == INTRANSITIVE) {
291 /* Carry, no object given yet. OK if only one object present. */
292 if (game.atloc[game.loc] == NO_OBJECT ||
293 game.link[game.atloc[game.loc]] != 0 ||
294 atdwrf(game.loc) > 0)
296 obj = game.atloc[game.loc];
300 speak(actions[verb].message);
305 rspeak(REMOVE_MESSAGE);
310 if (game.fixed[obj] != IS_FREE) {
311 /* Next guard tests whether plant is tiny or stashed */
312 if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
316 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) {
317 rspeak(BEAR_CHAINED);
320 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) {
321 rspeak(STILL_LOCKED);
329 rspeak(DOUGHNUT_HOLES);
336 if (obj == RUG && game.prop[RUG] == RUG_HOVER) {
341 rspeak(HAND_PASSTHROUGH);
352 if (TOTING(BOTTLE)) {
353 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
354 return (fill(verb, BOTTLE));
355 } else if (game.prop[BOTTLE] != EMPTY_BOTTLE)
359 rspeak(NO_CONTAINER);
365 if (game.holdng >= INVLIMIT) {
371 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
372 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
378 rspeak(CANNOT_CARRY);
385 game.prop[BIRD] = BIRD_CAGED;
389 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
390 /* expression maps BIRD to CAGE and CAGE to BIRD */
391 carry(BIRD + CAGE - obj, game.loc);
392 carry(obj, game.loc);
393 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
394 game.place[LIQUID()] = CARRIED;
395 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
396 game.prop[obj] = STATE_FOUND;
397 game.prop[CAVITY] = CAVITY_EMPTY;
403 static int chain(verb_t verb)
404 /* Do something to the bear's chain */
407 if (game.prop[BEAR] == UNTAMED_BEAR) {
411 if (game.prop[CHAIN] == CHAIN_HEAP) {
412 rspeak(ALREADY_UNLOCKED);
415 game.prop[CHAIN] = CHAIN_HEAP;
416 game.fixed[CHAIN] = IS_FREE;
417 if (game.prop[BEAR] != BEAR_DEAD)
418 game.prop[BEAR] = CONTENTED_BEAR;
420 switch (game.prop[BEAR]) {
423 /* Can't be reached as long as the only way for the bear to die
424 * is from a bridge collapse. Leave in in case this changes, but
425 * exclude from coverage testing. */
426 game.fixed[BEAR] = IS_FIXED;
430 game.fixed[BEAR] = IS_FREE;
432 rspeak(CHAIN_UNLOCKED);
436 if (game.prop[CHAIN] != CHAIN_HEAP) {
437 rspeak(ALREADY_LOCKED);
440 if (game.loc != objects[CHAIN].plac) {
445 game.prop[CHAIN] = CHAIN_FIXED;
448 drop(CHAIN, game.loc);
449 game.fixed[CHAIN] = IS_FIXED;
451 rspeak(CHAIN_LOCKED);
455 static int discard(verb_t verb, obj_t obj)
456 /* Discard object. "Throw" also comes here for most objects. Special cases for
457 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
458 * Drop coins at vending machine for extra batteries. */
460 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
463 speak(actions[verb].message);
466 if (obj == BIRD && HERE(SNAKE)) {
467 rspeak(BIRD_ATTACKS);
471 /* Set game.prop for use by travel options */
472 game.prop[SNAKE] = SNAKE_CHASED;
474 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
476 game.prop[obj] = STATE_IN_CAVITY;
477 game.prop[CAVITY] = CAVITY_FULL;
478 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
479 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
482 else if (TOTING(RUG))
486 if (!TOTING(RUG) || obj == RUBY) {
487 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
490 k = objects[SAPPH].plac;
491 move(RUG + NOBJECTS, k);
494 } else if (obj == COINS && HERE(VEND)) {
496 drop(BATTERY, game.loc);
497 pspeak(BATTERY, look, FRESH_BATTERIES, true);
499 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
503 } else if (obj == BEAR && AT(TROLL)) {
504 state_change(TROLL, TROLL_GONE);
505 move(TROLL, LOC_NOWHERE);
506 move(TROLL + NOBJECTS, IS_FREE);
507 move(TROLL2, objects[TROLL].plac);
508 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
510 } else if (obj != VASE ||
511 game.loc == objects[PILLOW].plac) {
514 state_change(VASE, AT(PILLOW)
517 if (game.prop[VASE] != VASE_WHOLE)
518 game.fixed[VASE] = IS_FIXED;
523 if (obj == BOTTLE && k != NO_OBJECT)
524 game.place[k] = LOC_NOWHERE;
525 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
526 drop(BIRD, game.loc);
530 game.prop[BIRD] = BIRD_UNCAGED;
531 if (FOREST(game.loc))
532 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
536 static int drink(verb_t verb, obj_t obj)
537 /* Drink. If no object, assume water and look for it here. If water is in
538 * the bottle, drink that, else must be at a water loc, so drink stream. */
540 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
541 (LIQUID() != WATER || !HERE(BOTTLE))) {
547 state_change(DRAGON, DRAGON_BLOODLESS);
552 if (obj != INTRANSITIVE && obj != WATER) {
553 rspeak(RIDICULOUS_ATTEMPT);
556 if (LIQUID() == WATER && HERE(BOTTLE)) {
557 game.place[WATER] = LOC_NOWHERE;
558 state_change(BOTTLE, EMPTY_BOTTLE);
562 speak(actions[verb].message);
566 static int eat(verb_t verb, obj_t obj)
567 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
568 * ok, some things lose appetite, rest are ridiculous. */
576 rspeak(THANKS_DELICIOUS);
587 rspeak(LOST_APPETITE);
590 speak(actions[verb].message);
595 static int extinguish(verb_t verb, obj_t obj)
596 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
598 if (obj == INTRANSITIVE) {
599 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
601 if (HERE(URN) && game.prop[URN] == URN_LIT)
603 if (obj == INTRANSITIVE)
609 if (game.prop[URN] != URN_EMPTY) {
610 state_change(URN, URN_DARK);
612 pspeak(URN, change, URN_DARK, true);
616 state_change(LAMP, LAMP_DARK);
617 rspeak(DARK(game.loc) ?
623 rspeak(BEYOND_POWER);
626 speak(actions[verb].message);
631 static int feed(verb_t verb, obj_t obj)
632 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
633 * mad. Bear, special. */
640 if (game.prop[DRAGON] != DRAGON_BARS)
641 rspeak(RIDICULOUS_ATTEMPT);
643 rspeak(NOTHING_EDIBLE);
646 if (!game.closed && HERE(BIRD)) {
648 rspeak(BIRD_DEVOURED);
650 rspeak(NOTHING_EDIBLE);
660 speak(actions[verb].message);
663 if (game.prop[BEAR] == BEAR_DEAD) {
664 rspeak(RIDICULOUS_ATTEMPT);
667 if (game.prop[BEAR] == UNTAMED_BEAR) {
670 game.fixed[AXE] = IS_FREE;
671 game.prop[AXE] = AXE_HERE;
672 state_change(BEAR, SITTING_BEAR);
674 rspeak(NOTHING_EDIBLE);
677 speak(actions[verb].message);
683 speak(actions[verb].message);
691 int fill(verb_t verb, obj_t obj)
692 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
696 if (LIQLOC(game.loc) == NO_OBJECT) {
697 rspeak(FILL_INVALID);
701 rspeak(ARENT_CARRYING);
704 rspeak(SHATTER_VASE);
705 game.prop[VASE] = VASE_BROKEN;
706 game.fixed[VASE] = IS_FIXED;
707 drop(VASE, game.loc);
712 if (game.prop[URN] != URN_EMPTY) {
717 rspeak(FILL_INVALID);
723 game.prop[BOTTLE] = EMPTY_BOTTLE;
727 game.prop[URN] = URN_DARK;
728 game.prop[BOTTLE] = EMPTY_BOTTLE;
733 rspeak(FILL_INVALID);
736 game.place[k] = LOC_NOWHERE;
739 if (obj != INTRANSITIVE && obj != BOTTLE) {
740 speak(actions[verb].message);
743 if (obj == INTRANSITIVE && !HERE(BOTTLE))
746 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
750 if (LIQUID() != NO_OBJECT) {
754 if (LIQLOC(game.loc) == NO_OBJECT) {
759 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
763 game.place[LIQUID()] = CARRIED;
767 static int find(verb_t verb, obj_t obj)
768 /* Find. Might be carrying it, or it might be here. Else give caveat. */
771 rspeak(ALREADY_CARRYING);
776 rspeak(NEEDED_NEARBY);
781 (LIQUID() == obj && AT(BOTTLE)) ||
782 obj == LIQLOC(game.loc) ||
783 (obj == DWARF && atdwrf(game.loc) > 0)) {
789 speak(actions[verb].message);
793 static int fly(verb_t verb, obj_t obj)
794 /* Fly. Snide remarks unless hovering rug is here. */
796 if (obj == INTRANSITIVE) {
801 if (game.prop[RUG] != RUG_HOVER) {
802 rspeak(RUG_NOTHING2);
809 speak(actions[verb].message);
812 if (game.prop[RUG] != RUG_HOVER) {
813 rspeak(RUG_NOTHING1);
816 game.oldlc2 = game.oldloc;
817 game.oldloc = game.loc;
819 if (game.prop[SAPPH] == STATE_NOTFOUND) {
820 game.newloc = game.place[SAPPH];
823 game.newloc = LOC_CLIFF;
829 static int inven(void)
830 /* Inventory. If object, treat same as find. Else report on current burden. */
833 for (obj_t i = 1; i <= NOBJECTS; i++) {
841 pspeak(i, touch, -1, false);
850 static int light(verb_t verb, obj_t obj)
851 /* Light. Applicable only to lamp and urn. */
853 if (obj == INTRANSITIVE) {
855 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
859 if (HERE(URN) && game.prop[URN] == URN_DARK) {
869 state_change(URN, game.prop[URN] == URN_EMPTY ?
874 if (game.limit < 0) {
878 state_change(LAMP, LAMP_BRIGHT);
883 speak(actions[verb].message);
888 static int listen(void)
889 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
891 long sound = locations[game.loc].sound;
892 if (sound != SILENT) {
894 if (!locations[game.loc].loud)
898 for (obj_t i = 1; i <= NOBJECTS; i++) {
900 objects[i].sounds[0] == NULL ||
903 int mi = game.prop[i];
904 /* (ESR) Some unpleasant magic on object states here. Ideally
905 * we'd have liked the bird to be a normal object that we can
906 * use state_change() on; can't do it, because there are
907 * actually two different series of per-state birdsounds
908 * depending on whether player has drunk dragon's blood. */
910 mi += 3 * game.blooded;
911 long packed_zzword = token_to_packed(game.zzword);
912 pspeak(i, hear, mi, true, packed_zzword);
914 if (i == BIRD && mi == BIRD_ENDSTATE)
922 static int lock(verb_t verb, obj_t obj)
923 /* Lock, unlock, no object given. Assume various things if present. */
925 if (obj == INTRANSITIVE) {
936 if (obj == INTRANSITIVE) {
937 rspeak(NOTHING_LOCKED);
942 /* Lock, unlock object. Special stuff for opening clam/oyster
957 game.clock2 = PANICTIME;
960 state_change(GRATE, (verb == LOCK) ?
970 else if (!TOTING(TRIDENT))
971 rspeak(OYSTER_OPENER);
974 drop(OYSTER, game.loc);
975 drop(PEARL, LOC_CULDESAC);
983 rspeak(OYSTER_OPENER);
986 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
992 rspeak(CANNOT_UNLOCK);
995 speak(actions[verb].message);
1001 static int pour(verb_t verb, obj_t obj)
1002 /* Pour. If no object, or object is bottle, assume contents of bottle.
1003 * special tests for pouring water or oil on plant or rusty door. */
1005 if (obj == BOTTLE ||
1006 obj == INTRANSITIVE)
1008 if (obj == NO_OBJECT)
1011 speak(actions[verb].message);
1015 if (obj != OIL && obj != WATER) {
1019 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1020 return fill(verb, URN);
1021 game.prop[BOTTLE] = EMPTY_BOTTLE;
1022 game.place[obj] = LOC_NOWHERE;
1030 /* cycle through the three plant states */
1031 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1032 game.prop[PLANT2] = game.prop[PLANT];
1035 rspeak(SHAKING_LEAVES);
1039 state_change(DOOR, (obj == OIL) ?
1046 static int quit(void)
1047 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1049 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1050 terminate(quitgame);
1054 static int read(struct command_t command)
1055 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1057 if (command.obj == INTRANSITIVE) {
1058 command.obj = NO_OBJECT;
1059 for (int i = 1; i <= NOBJECTS; i++) {
1060 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1061 command.obj = command.obj * NOBJECTS + i;
1063 if (command.obj > NOBJECTS ||
1064 command.obj == NO_OBJECT ||
1069 if (DARK(game.loc)) {
1070 sspeak(NO_SEE, command.raw1);
1071 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1072 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1073 } else if (objects[command.obj].texts[0] == NULL ||
1074 game.prop[command.obj] == STATE_NOTFOUND) {
1075 speak(actions[command.verb].message);
1077 pspeak(command.obj, study, game.prop[command.obj], true);
1081 static int reservoir(void)
1082 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1084 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1085 rspeak(NOTHING_HAPPENS);
1089 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1093 game.oldlc2 = game.loc;
1094 game.newloc = LOC_NOWHERE;
1096 return GO_TERMINATE;
1101 static int rub(verb_t verb, obj_t obj)
1102 /* Rub. Yields various snide remarks except for lit urn. */
1104 if (obj == URN && game.prop[URN] == URN_LIT) {
1106 drop(AMBER, game.loc);
1107 game.prop[AMBER] = AMBER_IN_ROCK;
1109 drop(CAVITY, game.loc);
1111 } else if (obj != LAMP) {
1112 rspeak(PECULIAR_NOTHING);
1114 speak(actions[verb].message);
1119 static int say(struct command_t *command)
1120 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1122 if (command->wd2 > 0) {
1123 command->wd1 = command->wd2;
1124 strncpy(command->raw1, command->raw2, LINESIZE - 1);
1126 char word1[TOKLEN + 1];
1127 packed_to_token(command->wd1, word1);
1130 get_vocab_metadata(word1, &wd, &type);
1140 /* FIXME: scribbles on the interpreter's command block */
1141 wordclear(&command->wd2);
1144 sspeak(OKEY_DOKEY, command->raw1);
1148 static int throw_support(long spk)
1151 drop(AXE, game.loc);
1155 static int throw (struct command_t *command)
1156 /* Throw. Same as discard unless axe. Then same as attack except
1157 * ignore bird, and if dwarf is present then one might be killed.
1158 * (Only way to do so!) Axe also special for dragon, bear, and
1159 * troll. Treasures special for troll. */
1161 if (!TOTING(command->obj)) {
1162 speak(actions[command->verb].message);
1165 if (objects[command->obj].is_treasure && AT(TROLL)) {
1166 /* Snarf a treasure for the troll. */
1167 drop(command->obj, LOC_NOWHERE);
1168 move(TROLL, LOC_NOWHERE);
1169 move(TROLL + NOBJECTS, IS_FREE);
1170 drop(TROLL2, objects[TROLL].plac);
1171 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1173 rspeak(TROLL_SATISFIED);
1176 if (command->obj == FOOD && HERE(BEAR)) {
1177 /* But throwing food is another story. */
1178 command->obj = BEAR;
1179 return (feed(command->verb, command->obj));
1181 if (command->obj != AXE)
1182 return (discard(command->verb, command->obj));
1184 if (atdwrf(game.loc) <= 0) {
1185 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1186 return throw_support(DRAGON_SCALES);
1188 return throw_support(TROLL_RETURNS);
1190 return throw_support(OGRE_DODGE);
1191 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1192 /* This'll teach him to throw the axe at the bear! */
1193 drop(AXE, game.loc);
1194 game.fixed[AXE] = IS_FIXED;
1196 state_change(AXE, AXE_LOST);
1199 command->obj = INTRANSITIVE;
1200 return (attack(command));
1203 if (randrange(NDWARVES + 1) < game.dflag) {
1204 return throw_support(DWARF_DODGES);
1206 long i = atdwrf(game.loc);
1207 game.dseen[i] = false;
1208 game.dloc[i] = LOC_NOWHERE;
1209 return throw_support((++game.dkill == 1) ?
1216 static int wake(verb_t verb, obj_t obj)
1217 /* Wake. Only use is to disturb the dwarves. */
1221 speak(actions[verb].message);
1225 return GO_DWARFWAKE;
1229 static int wave(verb_t verb, obj_t obj)
1230 /* Wave. No effect unless waving rod at fissure or at bird. */
1237 speak(((!TOTING(obj)) && (obj != ROD ||
1239 arbitrary_messages[ARENT_CARRYING] :
1240 actions[verb].message);
1244 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1245 drop(JADE, game.loc);
1246 game.prop[JADE] = STATE_FOUND;
1248 rspeak(NECKLACE_FLY);
1252 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1255 return GO_DWARFWAKE;
1259 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1265 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1269 state_change(FISSURE,
1270 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1275 int action(struct command_t *command)
1276 /* Analyse a verb. Remember what it was, go back for object if second word
1277 * unless verb is "say", which snarfs arbitrary second word.
1280 if (command->part == unknown) {
1281 /* Analyse an object word. See if the thing is here, whether
1282 * we've got a verb yet, and so on. Object must be here
1283 * unless verb is "find" or "invent(ory)" (and no new verb
1284 * yet to be analysed). Water and oil are also funny, since
1285 * they are never actually dropped at any location, but might
1286 * be here inside the bottle or urn or as a feature of the
1288 if (HERE(command->obj))
1290 else if (command->obj == GRATE) {
1291 if (game.loc == LOC_START ||
1292 game.loc == LOC_VALLEY ||
1293 game.loc == LOC_SLIT) {
1294 command->obj = DPRSSN;
1296 if (game.loc == LOC_COBBLE ||
1297 game.loc == LOC_DEBRIS ||
1298 game.loc == LOC_AWKWARD ||
1299 game.loc == LOC_BIRD ||
1300 game.loc == LOC_PITTOP) {
1301 command->obj = ENTRNC;
1303 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1305 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1306 command->obj == LIQLOC(game.loc))
1308 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1311 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1312 command->obj = PLANT2;
1314 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1316 rspeak(KNIVES_VANISH);
1318 } else if (command->obj == ROD && HERE(ROD2)) {
1319 command->obj = ROD2;
1321 } else if ((command->verb == FIND ||
1322 command->verb == INVENTORY) && command->wd2 <= 0)
1325 sspeak(NO_SEE, command->raw1);
1329 if (command->wd2 > 0)
1331 if (command->verb != 0)
1332 command->part = transitive;
1335 switch (command->part) {
1337 if (command->wd2 > 0 && command->verb != SAY)
1339 if (command->verb == SAY)
1340 command->obj = command->wd2;
1341 if (command->obj == NO_OBJECT ||
1342 command->obj == INTRANSITIVE) {
1343 /* Analyse an intransitive verb (ie, no object given yet). */
1344 switch (command->verb) {
1346 return vcarry(command->verb, INTRANSITIVE);
1352 return lock(command->verb, INTRANSITIVE);
1355 return (GO_CLEAROBJ);
1358 return lock(command->verb, INTRANSITIVE);
1360 return light(command->verb, INTRANSITIVE);
1362 return extinguish(command->verb, INTRANSITIVE);
1368 speak(actions[command->verb].message);
1372 command->obj = INTRANSITIVE;
1373 return attack(command);
1375 return pour(command->verb, INTRANSITIVE);
1377 return eat(command->verb, INTRANSITIVE);
1379 return drink(command->verb, INTRANSITIVE);
1393 return fill(command->verb, INTRANSITIVE);
1405 return bigwords(command->id1);
1409 command->obj = INTRANSITIVE;
1410 return read(*command);
1420 return fly(command->verb, INTRANSITIVE);
1426 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1431 /* Analyse a transitive verb. */
1432 switch (command->verb) {
1434 return vcarry(command->verb, command->obj);
1436 return discard(command->verb, command->obj);
1438 return say(command);
1440 return lock(command->verb, command->obj);
1443 return (GO_CLEAROBJ);
1446 return lock(command->verb, command->obj);
1448 return light(command->verb, command->obj);
1450 return extinguish(command->verb, command->obj);
1452 return wave(command->verb, command->obj);
1454 speak(actions[command->verb].message);
1458 speak(actions[command->verb].message);
1462 return attack(command);
1464 return pour(command->verb, command->obj);
1466 return eat(command->verb, command->obj);
1468 return drink(command->verb, command->obj);
1470 return rub(command->verb, command->obj);
1472 return throw (command);
1474 speak(actions[command->verb].message);
1478 return find(command->verb, command->obj);
1480 return find(command->verb, command->obj);
1482 return feed(command->verb, command->obj);
1484 return fill(command->verb, command->obj);
1489 speak(actions[command->verb].message);
1497 speak(actions[command->verb].message);
1501 speak(actions[command->verb].message);
1505 return read(*command);
1507 return vbreak(command->verb, command->obj);
1509 return wake(command->verb, command->obj);
1511 speak(actions[command->verb].message);
1515 speak(actions[command->verb].message);
1519 return fly(command->verb, command->obj);
1521 speak(actions[command->verb].message);
1527 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1530 /* Unknown verb, couldn't deduce object - might need hint */
1531 sspeak(WHAT_DO, command->raw1);
1532 return GO_CHECKHINT;
1534 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE