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(vocab_t 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;
270 speak(actions[verb].message);
272 return (GO_CLEAROBJ);
275 static int brief(void)
276 /* Brief. Intransitive only. Suppress full descriptions after first time. */
280 rspeak(BRIEF_CONFIRM);
284 static int vcarry(verb_t verb, obj_t obj)
285 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
286 * take one without the other). Liquids also special, since they depend on
287 * status of bottle. Also various side effects, etc. */
289 if (obj == INTRANSITIVE) {
290 /* Carry, no object given yet. OK if only one object present. */
291 if (game.atloc[game.loc] == NO_OBJECT ||
292 game.link[game.atloc[game.loc]] != 0 ||
293 atdwrf(game.loc) > 0)
295 obj = game.atloc[game.loc];
299 speak(actions[verb].message);
304 rspeak(REMOVE_MESSAGE);
309 if (game.fixed[obj] != IS_FREE) {
312 /* Next guard tests whether plant is tiny or stashed */
313 rspeak(game.prop[PLANT] <= PLANT_THIRSTY ? DEEP_ROOTS : YOU_JOKING);
316 rspeak( game.prop[BEAR] == SITTING_BEAR ? BEAR_CHAINED : YOU_JOKING);
319 rspeak( game.prop[BEAR] != UNTAMED_BEAR ? STILL_LOCKED : YOU_JOKING);
322 rspeak(game.prop[RUG] == RUG_HOVER ? RUG_HOVERS : YOU_JOKING);
328 rspeak(DOUGHNUT_HOLES);
334 rspeak(HAND_PASSTHROUGH);
346 if (!TOTING(BOTTLE)) {
347 rspeak(NO_CONTAINER);
350 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
351 return (fill(verb, BOTTLE));
359 if (game.holdng >= INVLIMIT) {
365 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
366 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
372 rspeak(CANNOT_CARRY);
379 game.prop[BIRD] = BIRD_CAGED;
383 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) {
384 /* expression maps BIRD to CAGE and CAGE to BIRD */
385 carry(BIRD + CAGE - obj, game.loc);
388 carry(obj, game.loc);
390 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
391 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]) {
421 /* Can't be reached until the bear can die in some way other
422 * than a bridge collapse. Leave in in case this changes, but
423 * exclude from coverage testing. */
424 game.fixed[BEAR] = IS_FIXED;
428 game.fixed[BEAR] = IS_FREE;
430 rspeak(CHAIN_UNLOCKED);
434 if (game.prop[CHAIN] != CHAIN_HEAP) {
435 rspeak(ALREADY_LOCKED);
438 if (game.loc != objects[CHAIN].plac) {
443 game.prop[CHAIN] = CHAIN_FIXED;
446 drop(CHAIN, game.loc);
447 game.fixed[CHAIN] = IS_FIXED;
449 rspeak(CHAIN_LOCKED);
453 static int discard(verb_t verb, obj_t obj)
454 /* Discard object. "Throw" also comes here for most objects. Special cases for
455 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
456 * Drop coins at vending machine for extra batteries. */
458 if (obj == ROD && !TOTING(ROD) && TOTING(ROD2)) {
463 speak(actions[verb].message);
467 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))) {
475 else if (TOTING(RUG))
479 if (!TOTING(RUG) || obj == RUBY) {
480 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
483 k = objects[SAPPH].plac;
484 move(RUG + NOBJECTS, k);
491 if (obj == COINS && HERE(VEND)) {
493 drop(BATTERY, game.loc);
494 pspeak(BATTERY, look, FRESH_BATTERIES, true);
500 if (obj == BOTTLE && LIQUID() != NO_OBJECT) {
501 game.place[LIQUID()] = LOC_NOWHERE;
504 if (obj == BEAR && AT(TROLL)) {
505 state_change(TROLL, TROLL_GONE);
506 move(TROLL, LOC_NOWHERE);
507 move(TROLL + NOBJECTS, IS_FREE);
508 move(TROLL2, objects[TROLL].plac);
509 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
516 if (game.loc != objects[PILLOW].plac) {
517 state_change(VASE, AT(PILLOW)
520 if (game.prop[VASE] != VASE_WHOLE)
521 game.fixed[VASE] = IS_FIXED;
527 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) {
528 drop(BIRD, game.loc);
532 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
538 rspeak(BIRD_ATTACKS);
542 /* Set game.prop for use by travel options */
543 game.prop[SNAKE] = SNAKE_CHASED;
547 game.prop[BIRD] = FOREST(game.loc) ? BIRD_FOREST_UNCAGED : BIRD_UNCAGED;
557 static int drink(verb_t verb, obj_t obj)
558 /* Drink. If no object, assume water and look for it here. If water is in
559 * the bottle, drink that, else must be at a water loc, so drink stream. */
561 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
562 (LIQUID() != WATER || !HERE(BOTTLE))) {
568 state_change(DRAGON, DRAGON_BLOODLESS);
573 if (obj != INTRANSITIVE && obj != WATER) {
574 rspeak(RIDICULOUS_ATTEMPT);
577 if (LIQUID() == WATER && HERE(BOTTLE)) {
578 game.place[WATER] = LOC_NOWHERE;
579 state_change(BOTTLE, EMPTY_BOTTLE);
583 speak(actions[verb].message);
587 static int eat(verb_t verb, obj_t obj)
588 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
589 * ok, some things lose appetite, rest are ridiculous. */
598 rspeak(THANKS_DELICIOUS);
609 rspeak(LOST_APPETITE);
612 speak(actions[verb].message);
617 static int extinguish(verb_t verb, obj_t obj)
618 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
620 if (obj == INTRANSITIVE) {
621 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
623 if (HERE(URN) && game.prop[URN] == URN_LIT)
625 if (obj == INTRANSITIVE)
631 if (game.prop[URN] != URN_EMPTY) {
632 state_change(URN, URN_DARK);
634 pspeak(URN, change, URN_DARK, true);
638 state_change(LAMP, LAMP_DARK);
639 rspeak(DARK(game.loc) ?
645 rspeak(BEYOND_POWER);
648 speak(actions[verb].message);
653 static int feed(verb_t verb, obj_t obj)
654 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
655 * mad. Bear, special. */
662 if (game.prop[DRAGON] != DRAGON_BARS)
663 rspeak(RIDICULOUS_ATTEMPT);
665 rspeak(NOTHING_EDIBLE);
668 if (!game.closed && HERE(BIRD)) {
670 rspeak(BIRD_DEVOURED);
672 rspeak(NOTHING_EDIBLE);
682 speak(actions[verb].message);
685 if (game.prop[BEAR] == BEAR_DEAD) {
686 rspeak(RIDICULOUS_ATTEMPT);
689 if (game.prop[BEAR] == UNTAMED_BEAR) {
692 game.fixed[AXE] = IS_FREE;
693 game.prop[AXE] = AXE_HERE;
694 state_change(BEAR, SITTING_BEAR);
696 rspeak(NOTHING_EDIBLE);
699 speak(actions[verb].message);
705 speak(actions[verb].message);
713 int fill(verb_t verb, obj_t obj)
714 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
718 if (LIQLOC(game.loc) == NO_OBJECT) {
719 rspeak(FILL_INVALID);
723 rspeak(ARENT_CARRYING);
726 rspeak(SHATTER_VASE);
727 game.prop[VASE] = VASE_BROKEN;
728 game.fixed[VASE] = IS_FIXED;
729 drop(VASE, game.loc);
734 if (game.prop[URN] != URN_EMPTY) {
739 rspeak(FILL_INVALID);
745 game.prop[BOTTLE] = EMPTY_BOTTLE;
749 game.prop[URN] = URN_DARK;
750 game.prop[BOTTLE] = EMPTY_BOTTLE;
755 rspeak(FILL_INVALID);
758 game.place[k] = LOC_NOWHERE;
761 if (obj != INTRANSITIVE && obj != BOTTLE) {
762 speak(actions[verb].message);
765 if (obj == INTRANSITIVE && !HERE(BOTTLE))
768 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
772 if (LIQUID() != NO_OBJECT) {
776 if (LIQLOC(game.loc) == NO_OBJECT) {
781 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
785 game.place[LIQUID()] = CARRIED;
789 static int find(verb_t verb, obj_t obj)
790 /* Find. Might be carrying it, or it might be here. Else give caveat. */
793 rspeak(ALREADY_CARRYING);
798 rspeak(NEEDED_NEARBY);
803 (LIQUID() == obj && AT(BOTTLE)) ||
804 obj == LIQLOC(game.loc) ||
805 (obj == DWARF && atdwrf(game.loc) > 0)) {
811 speak(actions[verb].message);
815 static int fly(verb_t verb, obj_t obj)
816 /* Fly. Snide remarks unless hovering rug is here. */
818 if (obj == INTRANSITIVE) {
823 if (game.prop[RUG] != RUG_HOVER) {
824 rspeak(RUG_NOTHING2);
831 speak(actions[verb].message);
834 if (game.prop[RUG] != RUG_HOVER) {
835 rspeak(RUG_NOTHING1);
838 game.oldlc2 = game.oldloc;
839 game.oldloc = game.loc;
841 if (game.prop[SAPPH] == STATE_NOTFOUND) {
842 game.newloc = game.place[SAPPH];
845 game.newloc = LOC_CLIFF;
851 static int inven(void)
852 /* Inventory. If object, treat same as find. Else report on current burden. */
855 for (obj_t i = 1; i <= NOBJECTS; i++) {
863 pspeak(i, touch, -1, false);
872 static int light(verb_t verb, obj_t obj)
873 /* Light. Applicable only to lamp and urn. */
875 if (obj == INTRANSITIVE) {
877 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
881 if (HERE(URN) && game.prop[URN] == URN_DARK) {
891 state_change(URN, game.prop[URN] == URN_EMPTY ?
896 if (game.limit < 0) {
900 state_change(LAMP, LAMP_BRIGHT);
905 speak(actions[verb].message);
910 static int listen(void)
911 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
913 vocab_t sound = locations[game.loc].sound;
914 if (sound != SILENT) {
916 if (!locations[game.loc].loud)
920 for (obj_t i = 1; i <= NOBJECTS; i++) {
922 objects[i].sounds[0] == NULL ||
925 int mi = game.prop[i];
926 /* (ESR) Some unpleasant magic on object states here. Ideally
927 * we'd have liked the bird to be a normal object that we can
928 * use state_change() on; can't do it, because there are
929 * actually two different series of per-state birdsounds
930 * depending on whether player has drunk dragon's blood. */
932 mi += 3 * game.blooded;
933 pspeak(i, hear, mi, true, game.zzword);
935 if (i == BIRD && mi == BIRD_ENDSTATE)
943 static int lock(verb_t verb, obj_t obj)
944 /* Lock, unlock, no object given. Assume various things if present. */
946 if (obj == INTRANSITIVE) {
957 if (obj == INTRANSITIVE) {
958 rspeak(NOTHING_LOCKED);
963 /* Lock, unlock object. Special stuff for opening clam/oyster
978 game.clock2 = PANICTIME;
981 state_change(GRATE, (verb == LOCK) ?
991 else if (!TOTING(TRIDENT))
995 drop(OYSTER, game.loc);
996 drop(PEARL, LOC_CULDESAC);
1003 else if (TOTING(OYSTER))
1004 rspeak(DROP_OYSTER);
1005 else if (!TOTING(TRIDENT))
1006 rspeak(OYSTER_OPENER);
1008 rspeak(OYSTER_OPENS);
1011 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
1017 rspeak(CANNOT_UNLOCK);
1020 speak(actions[verb].message);
1026 static int pour(verb_t verb, obj_t obj)
1027 /* Pour. If no object, or object is bottle, assume contents of bottle.
1028 * special tests for pouring water or oil on plant or rusty door. */
1030 if (obj == BOTTLE ||
1031 obj == INTRANSITIVE)
1033 if (obj == NO_OBJECT)
1036 speak(actions[verb].message);
1040 if (obj != OIL && obj != WATER) {
1044 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1045 return fill(verb, URN);
1046 game.prop[BOTTLE] = EMPTY_BOTTLE;
1047 game.place[obj] = LOC_NOWHERE;
1055 /* cycle through the three plant states */
1056 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1057 game.prop[PLANT2] = game.prop[PLANT];
1060 rspeak(SHAKING_LEAVES);
1064 state_change(DOOR, (obj == OIL) ?
1071 static int quit(void)
1072 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1074 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1075 terminate(quitgame);
1079 static int read(struct command_t command)
1080 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1082 if (command.obj == INTRANSITIVE) {
1083 command.obj = NO_OBJECT;
1084 for (int i = 1; i <= NOBJECTS; i++) {
1085 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1086 command.obj = command.obj * NOBJECTS + i;
1088 if (command.obj > NOBJECTS ||
1089 command.obj == NO_OBJECT ||
1094 if (DARK(game.loc)) {
1095 sspeak(NO_SEE, command.raw1);
1096 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1097 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1098 } else if (objects[command.obj].texts[0] == NULL ||
1099 game.prop[command.obj] == STATE_NOTFOUND) {
1100 speak(actions[command.verb].message);
1102 pspeak(command.obj, study, game.prop[command.obj], true);
1106 static int reservoir(void)
1107 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1109 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1110 rspeak(NOTHING_HAPPENS);
1114 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1118 game.oldlc2 = game.loc;
1119 game.newloc = LOC_NOWHERE;
1121 return GO_TERMINATE;
1126 static int rub(verb_t verb, obj_t obj)
1127 /* Rub. Yields various snide remarks except for lit urn. */
1129 if (obj == URN && game.prop[URN] == URN_LIT) {
1131 drop(AMBER, game.loc);
1132 game.prop[AMBER] = AMBER_IN_ROCK;
1134 drop(CAVITY, game.loc);
1136 } else if (obj != LAMP) {
1137 rspeak(PECULIAR_NOTHING);
1139 speak(actions[verb].message);
1144 static int say(struct command_t *command)
1145 /* Say. Echo WD2. Magic words override. */
1147 if (command->type2 == MOTION &&
1148 (command->id2 == XYZZY ||
1149 command->id2 == PLUGH ||
1150 command->id2 == PLOVER)) {
1153 if (command->type2 == ACTION &&
1154 (command->id2 == FEE ||
1155 command->id2 == FIE ||
1156 command->id2 == FOE ||
1157 command->id2 == FOO ||
1158 command->id2 == FUM ||
1159 command->id2 == PART)) {
1162 sspeak(OKEY_DOKEY, command->raw2);
1166 static int throw_support(vocab_t spk)
1169 drop(AXE, game.loc);
1173 static int throw (struct command_t *command)
1174 /* Throw. Same as discard unless axe. Then same as attack except
1175 * ignore bird, and if dwarf is present then one might be killed.
1176 * (Only way to do so!) Axe also special for dragon, bear, and
1177 * troll. Treasures special for troll. */
1179 if (!TOTING(command->obj)) {
1180 speak(actions[command->verb].message);
1183 if (objects[command->obj].is_treasure && AT(TROLL)) {
1184 /* Snarf a treasure for the troll. */
1185 drop(command->obj, LOC_NOWHERE);
1186 move(TROLL, LOC_NOWHERE);
1187 move(TROLL + NOBJECTS, IS_FREE);
1188 drop(TROLL2, objects[TROLL].plac);
1189 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1191 rspeak(TROLL_SATISFIED);
1194 if (command->obj == FOOD && HERE(BEAR)) {
1195 /* But throwing food is another story. */
1196 command->obj = BEAR;
1197 return (feed(command->verb, command->obj));
1199 if (command->obj != AXE)
1200 return (discard(command->verb, command->obj));
1202 if (atdwrf(game.loc) <= 0) {
1203 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1204 return throw_support(DRAGON_SCALES);
1206 return throw_support(TROLL_RETURNS);
1208 return throw_support(OGRE_DODGE);
1209 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1210 /* This'll teach him to throw the axe at the bear! */
1211 drop(AXE, game.loc);
1212 game.fixed[AXE] = IS_FIXED;
1214 state_change(AXE, AXE_LOST);
1217 command->obj = INTRANSITIVE;
1218 return (attack(command));
1221 if (randrange(NDWARVES + 1) < game.dflag) {
1222 return throw_support(DWARF_DODGES);
1224 int i = atdwrf(game.loc);
1225 game.dseen[i] = false;
1226 game.dloc[i] = LOC_NOWHERE;
1227 return throw_support((++game.dkill == 1) ?
1234 static int wake(verb_t verb, obj_t obj)
1235 /* Wake. Only use is to disturb the dwarves. */
1239 speak(actions[verb].message);
1243 return GO_DWARFWAKE;
1247 static int seed(verb_t verb, const char *arg)
1250 long seed = atol(arg);
1251 speak(actions[verb].message, arg);
1257 static int waste(verb_t verb, turn_t turns)
1260 game.limit -= turns;
1262 sprintf(newlim, "%ld", (long)game.limit);
1263 speak(actions[verb].message, newlim);
1267 static int wave(verb_t verb, obj_t obj)
1268 /* Wave. No effect unless waving rod at fissure or at bird. */
1275 speak(((!TOTING(obj)) && (obj != ROD ||
1277 arbitrary_messages[ARENT_CARRYING] :
1278 actions[verb].message);
1282 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1283 drop(JADE, game.loc);
1284 game.prop[JADE] = STATE_FOUND;
1286 rspeak(NECKLACE_FLY);
1290 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1293 return GO_DWARFWAKE;
1297 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1303 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1307 state_change(FISSURE,
1308 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1313 int action(struct command_t *command)
1314 /* Analyse a verb. Remember what it was, go back for object if second word
1315 * unless verb is "say", which snarfs arbitrary second word.
1318 if (command->part == unknown) {
1319 /* Analyse an object word. See if the thing is here, whether
1320 * we've got a verb yet, and so on. Object must be here
1321 * unless verb is "find" or "invent(ory)" (and no new verb
1322 * yet to be analysed). Water and oil are also funny, since
1323 * they are never actually dropped at any location, but might
1324 * be here inside the bottle or urn or as a feature of the
1326 if (HERE(command->obj))
1328 else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1330 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1331 command->obj == LIQLOC(game.loc))
1333 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1336 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1337 command->obj = PLANT2;
1339 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1341 rspeak(KNIVES_VANISH);
1343 } else if (command->obj == ROD && HERE(ROD2)) {
1344 command->obj = ROD2;
1346 } else if ((command->verb == FIND ||
1347 command->verb == INVENTORY) && (command->id2 == WORD_EMPTY || command->id2 == WORD_NOT_FOUND))
1350 sspeak(NO_SEE, command->raw1);
1354 if (command->id2 != WORD_EMPTY && command->id2 != WORD_NOT_FOUND)
1356 if (command->verb != 0)
1357 command->part = transitive;
1360 switch (command->part) {
1362 if (command->raw2[0] != '\0' && command->verb != SAY)
1364 if (command->verb == SAY)
1365 /* KEYS is not special, anything not NO_OBJECT or INTRANSITIVE
1366 * will do here. We're preventing interpretation as an intransitive
1367 * verb when the word is unknown. */
1368 command->obj = command->raw2[0] != '\0' ? KEYS : NO_OBJECT;
1369 if (command->obj == NO_OBJECT ||
1370 command->obj == INTRANSITIVE) {
1371 /* Analyse an intransitive verb (ie, no object given yet). */
1372 switch (command->verb) {
1374 return vcarry(command->verb, INTRANSITIVE);
1380 return lock(command->verb, INTRANSITIVE);
1383 return (GO_CLEAROBJ);
1386 return lock(command->verb, INTRANSITIVE);
1388 return light(command->verb, INTRANSITIVE);
1390 return extinguish(command->verb, INTRANSITIVE);
1396 speak(actions[command->verb].message);
1400 command->obj = INTRANSITIVE;
1401 return attack(command);
1403 return pour(command->verb, INTRANSITIVE);
1405 return eat(command->verb, INTRANSITIVE);
1407 return drink(command->verb, INTRANSITIVE);
1421 return fill(command->verb, INTRANSITIVE);
1433 return bigwords(command->id1);
1437 command->obj = INTRANSITIVE;
1438 return read(*command);
1448 return fly(command->verb, INTRANSITIVE);
1455 rspeak(NUMERIC_REQUIRED);
1457 default: // LCOV_EXCL_LINE
1458 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1463 /* Analyse a transitive verb. */
1464 switch (command->verb) {
1466 return vcarry(command->verb, command->obj);
1468 return discard(command->verb, command->obj);
1470 return say(command);
1472 return lock(command->verb, command->obj);
1475 return (GO_CLEAROBJ);
1478 return lock(command->verb, command->obj);
1480 return light(command->verb, command->obj);
1482 return extinguish(command->verb, command->obj);
1484 return wave(command->verb, command->obj);
1486 speak(actions[command->verb].message);
1490 speak(actions[command->verb].message);
1494 return attack(command);
1496 return pour(command->verb, command->obj);
1498 return eat(command->verb, command->obj);
1500 return drink(command->verb, command->obj);
1502 return rub(command->verb, command->obj);
1504 return throw (command);
1506 speak(actions[command->verb].message);
1510 return find(command->verb, command->obj);
1512 return find(command->verb, command->obj);
1514 return feed(command->verb, command->obj);
1516 return fill(command->verb, command->obj);
1521 speak(actions[command->verb].message);
1529 speak(actions[command->verb].message);
1533 speak(actions[command->verb].message);
1537 return read(*command);
1539 return vbreak(command->verb, command->obj);
1541 return wake(command->verb, command->obj);
1543 speak(actions[command->verb].message);
1547 speak(actions[command->verb].message);
1551 return fly(command->verb, command->obj);
1553 speak(actions[command->verb].message);
1559 return seed(command->verb, command->raw2);
1561 return waste(command->verb, (turn_t)atol(command->raw2));
1562 default: // LCOV_EXCL_LINE
1563 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1566 /* Unknown verb, couldn't deduce object - might need hint */
1567 sspeak(WHAT_DO, command->raw1);
1568 return GO_CHECKHINT;
1569 default: // LCOV_EXCL_LINE
1570 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE