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 speak(arbitrary_messages[NASTY_DRAGON]);
108 state_change(DRAGON, DRAGON_DEAD);
109 game.prop[RUG] = RUG_FLOOR;
110 /* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.
111 * The way it was computed before was worse; it depended on the
112 * two dragon locations being LOC_SECRET4 and LOC_SECRET6 and
113 * LOC_SECRET5 being right between them.
115 move(DRAGON + NOBJECTS, IS_FIXED);
116 move(RUG + NOBJECTS, IS_FREE);
117 move(DRAGON, LOC_SECRET5);
118 move(RUG, LOC_SECRET5);
119 drop(BLOOD, LOC_SECRET5);
120 for (obj_t i = 1; i <= NOBJECTS; i++) {
121 if (game.place[i] == objects[DRAGON].plac ||
122 game.place[i] == objects[DRAGON].fixd)
123 move(i, LOC_SECRET5);
125 game.loc = LOC_SECRET5;
131 if (atdwrf(game.loc) == 0)
134 rspeak(KNIFE_THROWN);
137 for (int i = 1; i < PIRATE; i++) {
138 if (game.dloc[i] == game.loc) {
140 game.dloc[i] = LOC_LONGWEST;
141 game.dseen[i] = false;
144 rspeak((dwarves > 1) ?
156 rspeak(SHELL_IMPERVIOUS);
159 rspeak(SNAKE_WARNING);
165 rspeak(BARE_HANDS_QUERY);
168 rspeak(ALREADY_DEAD);
174 speak(actions[verb].message);
179 static int bigwords(long id)
180 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
181 * Look up foo in special section of vocab to determine which word we've got.
182 * Last word zips the eggs back to the giant room (unless already there). */
184 if ((game.foobar == WORD_EMPTY && id == FEE) ||
185 (game.foobar == FEE && id == FIE) ||
186 (game.foobar == FIE && id == FOE) ||
187 (game.foobar == FOE && id == FOO) ||
188 (game.foobar == FOE && id == FUM)) {
190 if ((id != FOO) && (id != FUM)) {
194 game.foobar = WORD_EMPTY;
195 if (game.place[EGGS] == objects[EGGS].plac ||
196 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
197 rspeak(NOTHING_HAPPENS);
200 /* Bring back troll if we steal the eggs back from him before
202 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
203 game.prop[TROLL] = TROLL_PAIDONCE;
205 pspeak(EGGS, look, EGGS_VANISHED, true);
206 else if (game.loc == objects[EGGS].plac)
207 pspeak(EGGS, look, EGGS_HERE, true);
209 pspeak(EGGS, look, EGGS_DONE, true);
210 move(EGGS, objects[EGGS].plac);
215 if (game.loc == LOC_GIANTROOM) {
218 /* This is new begavior in Open Adventure - sounds better when
219 * player isn't in the Giant Room. */
220 rspeak(WELL_POINTLESS);
222 game.foobar = WORD_EMPTY;
227 static void blast(void)
228 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
230 if (game.prop[ROD2] == STATE_NOTFOUND ||
232 rspeak(REQUIRES_DYNAMITE);
235 game.bonus = splatter;
236 rspeak(SPLATTER_MESSAGE);
237 } else if (game.loc == LOC_NE) {
239 rspeak(DEFEAT_MESSAGE);
241 game.bonus = victory;
242 rspeak(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 state_change(MIRROR, MIRROR_BROKEN);
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) {
311 /* Next guard tests whether plant is tiny or stashed */
312 rspeak(game.prop[PLANT] <= PLANT_THIRSTY ? DEEP_ROOTS : YOU_JOKING);
315 rspeak( game.prop[BEAR] == SITTING_BEAR ? BEAR_CHAINED : YOU_JOKING);
318 rspeak( game.prop[BEAR] != UNTAMED_BEAR ? STILL_LOCKED : YOU_JOKING);
321 rspeak(game.prop[RUG] == RUG_HOVER ? RUG_HOVERS : YOU_JOKING);
327 rspeak(DOUGHNUT_HOLES);
333 rspeak(HAND_PASSTHROUGH);
345 if (!TOTING(BOTTLE)) {
346 rspeak(NO_CONTAINER);
349 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
350 return (fill(verb, BOTTLE));
358 if (game.holdng >= INVLIMIT) {
364 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
365 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
371 rspeak(CANNOT_CARRY);
378 game.prop[BIRD] = BIRD_CAGED;
382 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) {
383 /* expression maps BIRD to CAGE and CAGE to BIRD */
384 carry(BIRD + CAGE - obj, game.loc);
387 carry(obj, game.loc);
389 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
390 game.place[LIQUID()] = CARRIED;
392 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
393 game.prop[obj] = STATE_FOUND;
394 game.prop[CAVITY] = CAVITY_EMPTY;
400 static int chain(verb_t verb)
401 /* Do something to the bear's chain */
404 if (game.prop[BEAR] == UNTAMED_BEAR) {
408 if (game.prop[CHAIN] == CHAIN_HEAP) {
409 rspeak(ALREADY_UNLOCKED);
412 game.prop[CHAIN] = CHAIN_HEAP;
413 game.fixed[CHAIN] = IS_FREE;
414 if (game.prop[BEAR] != BEAR_DEAD)
415 game.prop[BEAR] = CONTENTED_BEAR;
417 switch (game.prop[BEAR]) {
420 /* Can't be reached as long as the only way for the bear to die
421 * is from a bridge collapse. Leave in in case this changes, but
422 * exclude from coverage testing. */
423 game.fixed[BEAR] = IS_FIXED;
427 game.fixed[BEAR] = IS_FREE;
429 rspeak(CHAIN_UNLOCKED);
433 if (game.prop[CHAIN] != CHAIN_HEAP) {
434 rspeak(ALREADY_LOCKED);
437 if (game.loc != objects[CHAIN].plac) {
442 game.prop[CHAIN] = CHAIN_FIXED;
445 drop(CHAIN, game.loc);
446 game.fixed[CHAIN] = IS_FIXED;
448 rspeak(CHAIN_LOCKED);
452 static int discard(verb_t verb, obj_t obj)
453 /* Discard object. "Throw" also comes here for most objects. Special cases for
454 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
455 * Drop coins at vending machine for extra batteries. */
457 if (obj == ROD && !TOTING(ROD) && TOTING(ROD2)) {
462 speak(actions[verb].message);
466 if (GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL) {
468 game.prop[obj] = STATE_IN_CAVITY;
469 game.prop[CAVITY] = CAVITY_FULL;
470 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
471 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
474 else if (TOTING(RUG))
478 if (!TOTING(RUG) || obj == RUBY) {
479 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
482 k = objects[SAPPH].plac;
483 move(RUG + NOBJECTS, k);
490 if (obj == COINS && HERE(VEND)) {
492 drop(BATTERY, game.loc);
493 pspeak(BATTERY, look, FRESH_BATTERIES, true);
499 if (obj == BOTTLE && LIQUID() != NO_OBJECT) {
500 game.place[LIQUID()] = LOC_NOWHERE;
503 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);
515 if (game.loc != objects[PILLOW].plac) {
516 state_change(VASE, AT(PILLOW)
519 if (game.prop[VASE] != VASE_WHOLE)
520 game.fixed[VASE] = IS_FIXED;
526 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) {
527 drop(BIRD, game.loc);
531 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
537 rspeak(BIRD_ATTACKS);
541 /* Set game.prop for use by travel options */
542 game.prop[SNAKE] = SNAKE_CHASED;
546 game.prop[BIRD] = FOREST(game.loc) ? BIRD_FOREST_UNCAGED : BIRD_UNCAGED;
556 static int drink(verb_t verb, obj_t obj)
557 /* Drink. If no object, assume water and look for it here. If water is in
558 * the bottle, drink that, else must be at a water loc, so drink stream. */
560 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
561 (LIQUID() != WATER || !HERE(BOTTLE))) {
567 state_change(DRAGON, DRAGON_BLOODLESS);
572 if (obj != INTRANSITIVE && obj != WATER) {
573 rspeak(RIDICULOUS_ATTEMPT);
576 if (LIQUID() == WATER && HERE(BOTTLE)) {
577 game.place[WATER] = LOC_NOWHERE;
578 state_change(BOTTLE, EMPTY_BOTTLE);
582 speak(actions[verb].message);
586 static int eat(verb_t verb, obj_t obj)
587 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
588 * ok, some things lose appetite, rest are ridiculous. */
596 rspeak(THANKS_DELICIOUS);
607 rspeak(LOST_APPETITE);
610 speak(actions[verb].message);
615 static int extinguish(verb_t verb, obj_t obj)
616 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
618 if (obj == INTRANSITIVE) {
619 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
621 if (HERE(URN) && game.prop[URN] == URN_LIT)
623 if (obj == INTRANSITIVE)
629 if (game.prop[URN] != URN_EMPTY) {
630 state_change(URN, URN_DARK);
632 pspeak(URN, change, URN_DARK, true);
636 state_change(LAMP, LAMP_DARK);
637 rspeak(DARK(game.loc) ?
643 rspeak(BEYOND_POWER);
646 speak(actions[verb].message);
651 static int feed(verb_t verb, obj_t obj)
652 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
653 * mad. Bear, special. */
660 if (game.prop[DRAGON] != DRAGON_BARS)
661 rspeak(RIDICULOUS_ATTEMPT);
663 rspeak(NOTHING_EDIBLE);
666 if (!game.closed && HERE(BIRD)) {
668 rspeak(BIRD_DEVOURED);
670 rspeak(NOTHING_EDIBLE);
680 speak(actions[verb].message);
683 if (game.prop[BEAR] == BEAR_DEAD) {
684 rspeak(RIDICULOUS_ATTEMPT);
687 if (game.prop[BEAR] == UNTAMED_BEAR) {
690 game.fixed[AXE] = IS_FREE;
691 game.prop[AXE] = AXE_HERE;
692 state_change(BEAR, SITTING_BEAR);
694 rspeak(NOTHING_EDIBLE);
697 speak(actions[verb].message);
703 speak(actions[verb].message);
711 int fill(verb_t verb, obj_t obj)
712 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
716 if (LIQLOC(game.loc) == NO_OBJECT) {
717 rspeak(FILL_INVALID);
721 rspeak(ARENT_CARRYING);
724 rspeak(SHATTER_VASE);
725 game.prop[VASE] = VASE_BROKEN;
726 game.fixed[VASE] = IS_FIXED;
727 drop(VASE, game.loc);
732 if (game.prop[URN] != URN_EMPTY) {
737 rspeak(FILL_INVALID);
743 game.prop[BOTTLE] = EMPTY_BOTTLE;
747 game.prop[URN] = URN_DARK;
748 game.prop[BOTTLE] = EMPTY_BOTTLE;
753 rspeak(FILL_INVALID);
756 game.place[k] = LOC_NOWHERE;
759 if (obj != INTRANSITIVE && obj != BOTTLE) {
760 speak(actions[verb].message);
763 if (obj == INTRANSITIVE && !HERE(BOTTLE))
766 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
770 if (LIQUID() != NO_OBJECT) {
774 if (LIQLOC(game.loc) == NO_OBJECT) {
779 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
783 game.place[LIQUID()] = CARRIED;
787 static int find(verb_t verb, obj_t obj)
788 /* Find. Might be carrying it, or it might be here. Else give caveat. */
791 rspeak(ALREADY_CARRYING);
796 rspeak(NEEDED_NEARBY);
801 (LIQUID() == obj && AT(BOTTLE)) ||
802 obj == LIQLOC(game.loc) ||
803 (obj == DWARF && atdwrf(game.loc) > 0)) {
809 speak(actions[verb].message);
813 static int fly(verb_t verb, obj_t obj)
814 /* Fly. Snide remarks unless hovering rug is here. */
816 if (obj == INTRANSITIVE) {
821 if (game.prop[RUG] != RUG_HOVER) {
822 rspeak(RUG_NOTHING2);
829 speak(actions[verb].message);
832 if (game.prop[RUG] != RUG_HOVER) {
833 rspeak(RUG_NOTHING1);
836 game.oldlc2 = game.oldloc;
837 game.oldloc = game.loc;
839 if (game.prop[SAPPH] == STATE_NOTFOUND) {
840 game.newloc = game.place[SAPPH];
843 game.newloc = LOC_CLIFF;
849 static int inven(void)
850 /* Inventory. If object, treat same as find. Else report on current burden. */
853 for (obj_t i = 1; i <= NOBJECTS; i++) {
861 pspeak(i, touch, -1, false);
870 static int light(verb_t verb, obj_t obj)
871 /* Light. Applicable only to lamp and urn. */
873 if (obj == INTRANSITIVE) {
875 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
879 if (HERE(URN) && game.prop[URN] == URN_DARK) {
889 state_change(URN, game.prop[URN] == URN_EMPTY ?
894 if (game.limit < 0) {
898 state_change(LAMP, LAMP_BRIGHT);
903 speak(actions[verb].message);
908 static int listen(void)
909 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
911 long sound = locations[game.loc].sound;
912 if (sound != SILENT) {
914 if (!locations[game.loc].loud)
918 for (obj_t i = 1; i <= NOBJECTS; i++) {
920 objects[i].sounds[0] == NULL ||
923 int mi = game.prop[i];
924 /* (ESR) Some unpleasant magic on object states here. Ideally
925 * we'd have liked the bird to be a normal object that we can
926 * use state_change() on; can't do it, because there are
927 * actually two different series of per-state birdsounds
928 * depending on whether player has drunk dragon's blood. */
930 mi += 3 * game.blooded;
931 long packed_zzword = token_to_packed(game.zzword);
932 pspeak(i, hear, mi, true, packed_zzword);
934 if (i == BIRD && mi == BIRD_ENDSTATE)
942 static int lock(verb_t verb, obj_t obj)
943 /* Lock, unlock, no object given. Assume various things if present. */
945 if (obj == INTRANSITIVE) {
956 if (obj == INTRANSITIVE) {
957 rspeak(NOTHING_LOCKED);
962 /* Lock, unlock object. Special stuff for opening clam/oyster
977 game.clock2 = PANICTIME;
980 state_change(GRATE, (verb == LOCK) ?
990 else if (!TOTING(TRIDENT))
994 drop(OYSTER, game.loc);
995 drop(PEARL, LOC_CULDESAC);
1002 else if (TOTING(OYSTER))
1003 rspeak(DROP_OYSTER);
1004 else if (!TOTING(TRIDENT))
1005 rspeak(OYSTER_OPENER);
1007 rspeak(OYSTER_OPENS);
1010 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
1016 rspeak(CANNOT_UNLOCK);
1019 speak(actions[verb].message);
1025 static int pour(verb_t verb, obj_t obj)
1026 /* Pour. If no object, or object is bottle, assume contents of bottle.
1027 * special tests for pouring water or oil on plant or rusty door. */
1029 if (obj == BOTTLE ||
1030 obj == INTRANSITIVE)
1032 if (obj == NO_OBJECT)
1035 speak(actions[verb].message);
1039 if (obj != OIL && obj != WATER) {
1043 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1044 return fill(verb, URN);
1045 game.prop[BOTTLE] = EMPTY_BOTTLE;
1046 game.place[obj] = LOC_NOWHERE;
1054 /* cycle through the three plant states */
1055 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1056 game.prop[PLANT2] = game.prop[PLANT];
1059 rspeak(SHAKING_LEAVES);
1063 state_change(DOOR, (obj == OIL) ?
1070 static int quit(void)
1071 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1073 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1074 terminate(quitgame);
1078 static int read(struct command_t command)
1079 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1081 if (command.obj == INTRANSITIVE) {
1082 command.obj = NO_OBJECT;
1083 for (int i = 1; i <= NOBJECTS; i++) {
1084 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1085 command.obj = command.obj * NOBJECTS + i;
1087 if (command.obj > NOBJECTS ||
1088 command.obj == NO_OBJECT ||
1093 if (DARK(game.loc)) {
1094 sspeak(NO_SEE, command.raw1);
1095 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1096 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1097 } else if (objects[command.obj].texts[0] == NULL ||
1098 game.prop[command.obj] == STATE_NOTFOUND) {
1099 speak(actions[command.verb].message);
1101 pspeak(command.obj, study, game.prop[command.obj], true);
1105 static int reservoir(void)
1106 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1108 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1109 rspeak(NOTHING_HAPPENS);
1113 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1117 game.oldlc2 = game.loc;
1118 game.newloc = LOC_NOWHERE;
1120 return GO_TERMINATE;
1125 static int rub(verb_t verb, obj_t obj)
1126 /* Rub. Yields various snide remarks except for lit urn. */
1128 if (obj == URN && game.prop[URN] == URN_LIT) {
1130 drop(AMBER, game.loc);
1131 game.prop[AMBER] = AMBER_IN_ROCK;
1133 drop(CAVITY, game.loc);
1135 } else if (obj != LAMP) {
1136 rspeak(PECULIAR_NOTHING);
1138 speak(actions[verb].message);
1143 static int say(struct command_t *command)
1144 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1146 if (command->wd2 > 0) {
1147 command->wd1 = command->wd2;
1148 strncpy(command->raw1, command->raw2, LINESIZE - 1);
1150 char word1[TOKLEN + 1];
1151 packed_to_token(command->wd1, word1);
1154 get_vocab_metadata(word1, &wd, &type);
1164 /* FIXME: scribbles on the interpreter's command block */
1165 wordclear(&command->wd2);
1168 sspeak(OKEY_DOKEY, command->raw1);
1172 static int throw_support(long spk)
1175 drop(AXE, game.loc);
1179 static int throw (struct command_t *command)
1180 /* Throw. Same as discard unless axe. Then same as attack except
1181 * ignore bird, and if dwarf is present then one might be killed.
1182 * (Only way to do so!) Axe also special for dragon, bear, and
1183 * troll. Treasures special for troll. */
1185 if (!TOTING(command->obj)) {
1186 speak(actions[command->verb].message);
1189 if (objects[command->obj].is_treasure && AT(TROLL)) {
1190 /* Snarf a treasure for the troll. */
1191 drop(command->obj, LOC_NOWHERE);
1192 move(TROLL, LOC_NOWHERE);
1193 move(TROLL + NOBJECTS, IS_FREE);
1194 drop(TROLL2, objects[TROLL].plac);
1195 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1197 rspeak(TROLL_SATISFIED);
1200 if (command->obj == FOOD && HERE(BEAR)) {
1201 /* But throwing food is another story. */
1202 command->obj = BEAR;
1203 return (feed(command->verb, command->obj));
1205 if (command->obj != AXE)
1206 return (discard(command->verb, command->obj));
1208 if (atdwrf(game.loc) <= 0) {
1209 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1210 return throw_support(DRAGON_SCALES);
1212 return throw_support(TROLL_RETURNS);
1214 return throw_support(OGRE_DODGE);
1215 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1216 /* This'll teach him to throw the axe at the bear! */
1217 drop(AXE, game.loc);
1218 game.fixed[AXE] = IS_FIXED;
1220 state_change(AXE, AXE_LOST);
1223 command->obj = INTRANSITIVE;
1224 return (attack(command));
1227 if (randrange(NDWARVES + 1) < game.dflag) {
1228 return throw_support(DWARF_DODGES);
1230 long i = atdwrf(game.loc);
1231 game.dseen[i] = false;
1232 game.dloc[i] = LOC_NOWHERE;
1233 return throw_support((++game.dkill == 1) ?
1240 static int wake(verb_t verb, obj_t obj)
1241 /* Wake. Only use is to disturb the dwarves. */
1245 speak(actions[verb].message);
1249 return GO_DWARFWAKE;
1253 static int wave(verb_t verb, obj_t obj)
1254 /* Wave. No effect unless waving rod at fissure or at bird. */
1261 speak(((!TOTING(obj)) && (obj != ROD ||
1263 arbitrary_messages[ARENT_CARRYING] :
1264 actions[verb].message);
1268 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1269 drop(JADE, game.loc);
1270 game.prop[JADE] = STATE_FOUND;
1272 rspeak(NECKLACE_FLY);
1276 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1279 return GO_DWARFWAKE;
1283 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1289 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1293 state_change(FISSURE,
1294 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1299 int action(struct command_t *command)
1300 /* Analyse a verb. Remember what it was, go back for object if second word
1301 * unless verb is "say", which snarfs arbitrary second word.
1304 if (command->part == unknown) {
1305 /* Analyse an object word. See if the thing is here, whether
1306 * we've got a verb yet, and so on. Object must be here
1307 * unless verb is "find" or "invent(ory)" (and no new verb
1308 * yet to be analysed). Water and oil are also funny, since
1309 * they are never actually dropped at any location, but might
1310 * be here inside the bottle or urn or as a feature of the
1312 if (HERE(command->obj))
1314 else if (command->obj == GRATE) {
1315 if (game.loc == LOC_START ||
1316 game.loc == LOC_VALLEY ||
1317 game.loc == LOC_SLIT) {
1318 command->obj = DPRSSN;
1320 if (game.loc == LOC_COBBLE ||
1321 game.loc == LOC_DEBRIS ||
1322 game.loc == LOC_AWKWARD ||
1323 game.loc == LOC_BIRD ||
1324 game.loc == LOC_PITTOP) {
1325 command->obj = ENTRNC;
1327 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1329 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1330 command->obj == LIQLOC(game.loc))
1332 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1335 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1336 command->obj = PLANT2;
1338 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1340 rspeak(KNIVES_VANISH);
1342 } else if (command->obj == ROD && HERE(ROD2)) {
1343 command->obj = ROD2;
1345 } else if ((command->verb == FIND ||
1346 command->verb == INVENTORY) && (command->id2 == WORD_EMPTY || command->id2 == WORD_NOT_FOUND))
1349 sspeak(NO_SEE, command->raw1);
1353 if (command->id2 != WORD_EMPTY && command->id2 != WORD_NOT_FOUND)
1355 if (command->verb != 0)
1356 command->part = transitive;
1359 switch (command->part) {
1361 if (command->wd2 > 0 && command->verb != SAY)
1363 if (command->verb == SAY)
1364 command->obj = command->wd2;
1365 if (command->obj == NO_OBJECT ||
1366 command->obj == INTRANSITIVE) {
1367 /* Analyse an intransitive verb (ie, no object given yet). */
1368 switch (command->verb) {
1370 return vcarry(command->verb, INTRANSITIVE);
1376 return lock(command->verb, INTRANSITIVE);
1379 return (GO_CLEAROBJ);
1382 return lock(command->verb, INTRANSITIVE);
1384 return light(command->verb, INTRANSITIVE);
1386 return extinguish(command->verb, INTRANSITIVE);
1392 speak(actions[command->verb].message);
1396 command->obj = INTRANSITIVE;
1397 return attack(command);
1399 return pour(command->verb, INTRANSITIVE);
1401 return eat(command->verb, INTRANSITIVE);
1403 return drink(command->verb, INTRANSITIVE);
1417 return fill(command->verb, INTRANSITIVE);
1429 return bigwords(command->id1);
1433 command->obj = INTRANSITIVE;
1434 return read(*command);
1444 return fly(command->verb, INTRANSITIVE);
1449 default: // LCOV_EXCL_LINE
1450 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1455 /* Analyse a transitive verb. */
1456 switch (command->verb) {
1458 return vcarry(command->verb, command->obj);
1460 return discard(command->verb, command->obj);
1462 return say(command);
1464 return lock(command->verb, command->obj);
1467 return (GO_CLEAROBJ);
1470 return lock(command->verb, command->obj);
1472 return light(command->verb, command->obj);
1474 return extinguish(command->verb, command->obj);
1476 return wave(command->verb, command->obj);
1478 speak(actions[command->verb].message);
1482 speak(actions[command->verb].message);
1486 return attack(command);
1488 return pour(command->verb, command->obj);
1490 return eat(command->verb, command->obj);
1492 return drink(command->verb, command->obj);
1494 return rub(command->verb, command->obj);
1496 return throw (command);
1498 speak(actions[command->verb].message);
1502 return find(command->verb, command->obj);
1504 return find(command->verb, command->obj);
1506 return feed(command->verb, command->obj);
1508 return fill(command->verb, command->obj);
1513 speak(actions[command->verb].message);
1521 speak(actions[command->verb].message);
1525 speak(actions[command->verb].message);
1529 return read(*command);
1531 return vbreak(command->verb, command->obj);
1533 return wake(command->verb, command->obj);
1535 speak(actions[command->verb].message);
1539 speak(actions[command->verb].message);
1543 return fly(command->verb, command->obj);
1545 speak(actions[command->verb].message);
1550 default: // LCOV_EXCL_LINE
1551 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1554 /* Unknown verb, couldn't deduce object - might need hint */
1555 sspeak(WHAT_DO, command->raw1);
1556 return GO_CHECKHINT;
1557 default: // LCOV_EXCL_LINE
1558 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE