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) {
316 /* Next guard tests whether plant is tiny or stashed */
317 rspeak(game.prop[PLANT] <= PLANT_THIRSTY ? DEEP_ROOTS : YOU_JOKING);
320 rspeak( game.prop[BEAR] == SITTING_BEAR ? BEAR_CHAINED : YOU_JOKING);
323 rspeak( game.prop[BEAR] != UNTAMED_BEAR ? STILL_LOCKED : YOU_JOKING);
326 rspeak(game.prop[RUG] == RUG_HOVER ? RUG_HOVERS : YOU_JOKING);
332 rspeak(DOUGHNUT_HOLES);
338 rspeak(HAND_PASSTHROUGH);
350 if (!TOTING(BOTTLE)) {
351 rspeak(NO_CONTAINER);
354 if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
355 return (fill(verb, BOTTLE));
363 if (game.holdng >= INVLIMIT) {
369 if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
370 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
376 rspeak(CANNOT_CARRY);
383 game.prop[BIRD] = BIRD_CAGED;
387 (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) {
388 /* expression maps BIRD to CAGE and CAGE to BIRD */
389 carry(BIRD + CAGE - obj, game.loc);
392 carry(obj, game.loc);
394 if (obj == BOTTLE && LIQUID() != NO_OBJECT)
395 game.place[LIQUID()] = CARRIED;
397 if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
398 game.prop[obj] = STATE_FOUND;
399 game.prop[CAVITY] = CAVITY_EMPTY;
405 static int chain(verb_t verb)
406 /* Do something to the bear's chain */
409 if (game.prop[BEAR] == UNTAMED_BEAR) {
413 if (game.prop[CHAIN] == CHAIN_HEAP) {
414 rspeak(ALREADY_UNLOCKED);
417 game.prop[CHAIN] = CHAIN_HEAP;
418 game.fixed[CHAIN] = IS_FREE;
419 if (game.prop[BEAR] != BEAR_DEAD)
420 game.prop[BEAR] = CONTENTED_BEAR;
422 switch (game.prop[BEAR]) {
425 /* Can't be reached as long as the only way for the bear to die
426 * is from a bridge collapse. Leave in in case this changes, but
427 * exclude from coverage testing. */
428 game.fixed[BEAR] = IS_FIXED;
432 game.fixed[BEAR] = IS_FREE;
434 rspeak(CHAIN_UNLOCKED);
438 if (game.prop[CHAIN] != CHAIN_HEAP) {
439 rspeak(ALREADY_LOCKED);
442 if (game.loc != objects[CHAIN].plac) {
447 game.prop[CHAIN] = CHAIN_FIXED;
450 drop(CHAIN, game.loc);
451 game.fixed[CHAIN] = IS_FIXED;
453 rspeak(CHAIN_LOCKED);
457 static int discard(verb_t verb, obj_t obj)
458 /* Discard object. "Throw" also comes here for most objects. Special cases for
459 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
460 * Drop coins at vending machine for extra batteries. */
462 if (obj == ROD && !TOTING(ROD) && TOTING(ROD2)) {
467 speak(actions[verb].message);
471 if (GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL) {
473 game.prop[obj] = STATE_IN_CAVITY;
474 game.prop[CAVITY] = CAVITY_FULL;
475 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
476 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
479 else if (TOTING(RUG))
483 if (!TOTING(RUG) || obj == RUBY) {
484 int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
487 k = objects[SAPPH].plac;
488 move(RUG + NOBJECTS, k);
495 if (obj == COINS && HERE(VEND)) {
497 drop(BATTERY, game.loc);
498 pspeak(BATTERY, look, FRESH_BATTERIES, true);
504 if (obj == BOTTLE && LIQUID() != NO_OBJECT) {
505 game.place[LIQUID()] = LOC_NOWHERE;
508 if (obj == BEAR && AT(TROLL)) {
509 state_change(TROLL, TROLL_GONE);
510 move(TROLL, LOC_NOWHERE);
511 move(TROLL + NOBJECTS, IS_FREE);
512 move(TROLL2, objects[TROLL].plac);
513 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
520 if (game.loc != objects[PILLOW].plac) {
521 state_change(VASE, AT(PILLOW)
524 if (game.prop[VASE] != VASE_WHOLE)
525 game.fixed[VASE] = IS_FIXED;
531 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) {
532 drop(BIRD, game.loc);
536 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
542 rspeak(BIRD_ATTACKS);
546 /* Set game.prop for use by travel options */
547 game.prop[SNAKE] = SNAKE_CHASED;
551 game.prop[BIRD] = BIRD_UNCAGED;
552 if (FOREST(game.loc))
553 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
563 static int drink(verb_t verb, obj_t obj)
564 /* Drink. If no object, assume water and look for it here. If water is in
565 * the bottle, drink that, else must be at a water loc, so drink stream. */
567 if (obj == INTRANSITIVE && LIQLOC(game.loc) != WATER &&
568 (LIQUID() != WATER || !HERE(BOTTLE))) {
574 state_change(DRAGON, DRAGON_BLOODLESS);
579 if (obj != INTRANSITIVE && obj != WATER) {
580 rspeak(RIDICULOUS_ATTEMPT);
583 if (LIQUID() == WATER && HERE(BOTTLE)) {
584 game.place[WATER] = LOC_NOWHERE;
585 state_change(BOTTLE, EMPTY_BOTTLE);
589 speak(actions[verb].message);
593 static int eat(verb_t verb, obj_t obj)
594 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
595 * ok, some things lose appetite, rest are ridiculous. */
603 rspeak(THANKS_DELICIOUS);
614 rspeak(LOST_APPETITE);
617 speak(actions[verb].message);
622 static int extinguish(verb_t verb, obj_t obj)
623 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
625 if (obj == INTRANSITIVE) {
626 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
628 if (HERE(URN) && game.prop[URN] == URN_LIT)
630 if (obj == INTRANSITIVE)
636 if (game.prop[URN] != URN_EMPTY) {
637 state_change(URN, URN_DARK);
639 pspeak(URN, change, URN_DARK, true);
643 state_change(LAMP, LAMP_DARK);
644 rspeak(DARK(game.loc) ?
650 rspeak(BEYOND_POWER);
653 speak(actions[verb].message);
658 static int feed(verb_t verb, obj_t obj)
659 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
660 * mad. Bear, special. */
667 if (game.prop[DRAGON] != DRAGON_BARS)
668 rspeak(RIDICULOUS_ATTEMPT);
670 rspeak(NOTHING_EDIBLE);
673 if (!game.closed && HERE(BIRD)) {
675 rspeak(BIRD_DEVOURED);
677 rspeak(NOTHING_EDIBLE);
687 speak(actions[verb].message);
690 if (game.prop[BEAR] == BEAR_DEAD) {
691 rspeak(RIDICULOUS_ATTEMPT);
694 if (game.prop[BEAR] == UNTAMED_BEAR) {
697 game.fixed[AXE] = IS_FREE;
698 game.prop[AXE] = AXE_HERE;
699 state_change(BEAR, SITTING_BEAR);
701 rspeak(NOTHING_EDIBLE);
704 speak(actions[verb].message);
710 speak(actions[verb].message);
718 int fill(verb_t verb, obj_t obj)
719 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
723 if (LIQLOC(game.loc) == NO_OBJECT) {
724 rspeak(FILL_INVALID);
728 rspeak(ARENT_CARRYING);
731 rspeak(SHATTER_VASE);
732 game.prop[VASE] = VASE_BROKEN;
733 game.fixed[VASE] = IS_FIXED;
734 drop(VASE, game.loc);
739 if (game.prop[URN] != URN_EMPTY) {
744 rspeak(FILL_INVALID);
750 game.prop[BOTTLE] = EMPTY_BOTTLE;
754 game.prop[URN] = URN_DARK;
755 game.prop[BOTTLE] = EMPTY_BOTTLE;
760 rspeak(FILL_INVALID);
763 game.place[k] = LOC_NOWHERE;
766 if (obj != INTRANSITIVE && obj != BOTTLE) {
767 speak(actions[verb].message);
770 if (obj == INTRANSITIVE && !HERE(BOTTLE))
773 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
777 if (LIQUID() != NO_OBJECT) {
781 if (LIQLOC(game.loc) == NO_OBJECT) {
786 state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
790 game.place[LIQUID()] = CARRIED;
794 static int find(verb_t verb, obj_t obj)
795 /* Find. Might be carrying it, or it might be here. Else give caveat. */
798 rspeak(ALREADY_CARRYING);
803 rspeak(NEEDED_NEARBY);
808 (LIQUID() == obj && AT(BOTTLE)) ||
809 obj == LIQLOC(game.loc) ||
810 (obj == DWARF && atdwrf(game.loc) > 0)) {
816 speak(actions[verb].message);
820 static int fly(verb_t verb, obj_t obj)
821 /* Fly. Snide remarks unless hovering rug is here. */
823 if (obj == INTRANSITIVE) {
828 if (game.prop[RUG] != RUG_HOVER) {
829 rspeak(RUG_NOTHING2);
836 speak(actions[verb].message);
839 if (game.prop[RUG] != RUG_HOVER) {
840 rspeak(RUG_NOTHING1);
843 game.oldlc2 = game.oldloc;
844 game.oldloc = game.loc;
846 if (game.prop[SAPPH] == STATE_NOTFOUND) {
847 game.newloc = game.place[SAPPH];
850 game.newloc = LOC_CLIFF;
856 static int inven(void)
857 /* Inventory. If object, treat same as find. Else report on current burden. */
860 for (obj_t i = 1; i <= NOBJECTS; i++) {
868 pspeak(i, touch, -1, false);
877 static int light(verb_t verb, obj_t obj)
878 /* Light. Applicable only to lamp and urn. */
880 if (obj == INTRANSITIVE) {
882 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
886 if (HERE(URN) && game.prop[URN] == URN_DARK) {
896 state_change(URN, game.prop[URN] == URN_EMPTY ?
901 if (game.limit < 0) {
905 state_change(LAMP, LAMP_BRIGHT);
910 speak(actions[verb].message);
915 static int listen(void)
916 /* Listen. Intransitive only. Print stuff based on object sound proprties. */
918 long sound = locations[game.loc].sound;
919 if (sound != SILENT) {
921 if (!locations[game.loc].loud)
925 for (obj_t i = 1; i <= NOBJECTS; i++) {
927 objects[i].sounds[0] == NULL ||
930 int mi = game.prop[i];
931 /* (ESR) Some unpleasant magic on object states here. Ideally
932 * we'd have liked the bird to be a normal object that we can
933 * use state_change() on; can't do it, because there are
934 * actually two different series of per-state birdsounds
935 * depending on whether player has drunk dragon's blood. */
937 mi += 3 * game.blooded;
938 long packed_zzword = token_to_packed(game.zzword);
939 pspeak(i, hear, mi, true, packed_zzword);
941 if (i == BIRD && mi == BIRD_ENDSTATE)
949 static int lock(verb_t verb, obj_t obj)
950 /* Lock, unlock, no object given. Assume various things if present. */
952 if (obj == INTRANSITIVE) {
963 if (obj == INTRANSITIVE) {
964 rspeak(NOTHING_LOCKED);
969 /* Lock, unlock object. Special stuff for opening clam/oyster
984 game.clock2 = PANICTIME;
987 state_change(GRATE, (verb == LOCK) ?
997 else if (!TOTING(TRIDENT))
998 rspeak(OYSTER_OPENER);
1001 drop(OYSTER, game.loc);
1002 drop(PEARL, LOC_CULDESAC);
1003 rspeak(PEARL_FALLS);
1010 rspeak(OYSTER_OPENER);
1013 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
1019 rspeak(CANNOT_UNLOCK);
1022 speak(actions[verb].message);
1028 static int pour(verb_t verb, obj_t obj)
1029 /* Pour. If no object, or object is bottle, assume contents of bottle.
1030 * special tests for pouring water or oil on plant or rusty door. */
1032 if (obj == BOTTLE ||
1033 obj == INTRANSITIVE)
1035 if (obj == NO_OBJECT)
1038 speak(actions[verb].message);
1042 if (obj != OIL && obj != WATER) {
1046 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
1047 return fill(verb, URN);
1048 game.prop[BOTTLE] = EMPTY_BOTTLE;
1049 game.place[obj] = LOC_NOWHERE;
1057 /* cycle through the three plant states */
1058 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
1059 game.prop[PLANT2] = game.prop[PLANT];
1062 rspeak(SHAKING_LEAVES);
1066 state_change(DOOR, (obj == OIL) ?
1073 static int quit(void)
1074 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
1076 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1077 terminate(quitgame);
1081 static int read(struct command_t command)
1082 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1084 if (command.obj == INTRANSITIVE) {
1085 command.obj = NO_OBJECT;
1086 for (int i = 1; i <= NOBJECTS; i++) {
1087 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1088 command.obj = command.obj * NOBJECTS + i;
1090 if (command.obj > NOBJECTS ||
1091 command.obj == NO_OBJECT ||
1096 if (DARK(game.loc)) {
1097 sspeak(NO_SEE, command.raw1);
1098 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1099 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1100 } else if (objects[command.obj].texts[0] == NULL ||
1101 game.prop[command.obj] == STATE_NOTFOUND) {
1102 speak(actions[command.verb].message);
1104 pspeak(command.obj, study, game.prop[command.obj], true);
1108 static int reservoir(void)
1109 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1111 if (!AT(RESER) && game.loc != LOC_RESBOTTOM) {
1112 rspeak(NOTHING_HAPPENS);
1116 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1120 game.oldlc2 = game.loc;
1121 game.newloc = LOC_NOWHERE;
1123 return GO_TERMINATE;
1128 static int rub(verb_t verb, obj_t obj)
1129 /* Rub. Yields various snide remarks except for lit urn. */
1131 if (obj == URN && game.prop[URN] == URN_LIT) {
1133 drop(AMBER, game.loc);
1134 game.prop[AMBER] = AMBER_IN_ROCK;
1136 drop(CAVITY, game.loc);
1138 } else if (obj != LAMP) {
1139 rspeak(PECULIAR_NOTHING);
1141 speak(actions[verb].message);
1146 static int say(struct command_t *command)
1147 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1149 if (command->wd2 > 0) {
1150 command->wd1 = command->wd2;
1151 strncpy(command->raw1, command->raw2, LINESIZE - 1);
1153 char word1[TOKLEN + 1];
1154 packed_to_token(command->wd1, word1);
1157 get_vocab_metadata(word1, &wd, &type);
1167 /* FIXME: scribbles on the interpreter's command block */
1168 wordclear(&command->wd2);
1171 sspeak(OKEY_DOKEY, command->raw1);
1175 static int throw_support(long spk)
1178 drop(AXE, game.loc);
1182 static int throw (struct command_t *command)
1183 /* Throw. Same as discard unless axe. Then same as attack except
1184 * ignore bird, and if dwarf is present then one might be killed.
1185 * (Only way to do so!) Axe also special for dragon, bear, and
1186 * troll. Treasures special for troll. */
1188 if (!TOTING(command->obj)) {
1189 speak(actions[command->verb].message);
1192 if (objects[command->obj].is_treasure && AT(TROLL)) {
1193 /* Snarf a treasure for the troll. */
1194 drop(command->obj, LOC_NOWHERE);
1195 move(TROLL, LOC_NOWHERE);
1196 move(TROLL + NOBJECTS, IS_FREE);
1197 drop(TROLL2, objects[TROLL].plac);
1198 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1200 rspeak(TROLL_SATISFIED);
1203 if (command->obj == FOOD && HERE(BEAR)) {
1204 /* But throwing food is another story. */
1205 command->obj = BEAR;
1206 return (feed(command->verb, command->obj));
1208 if (command->obj != AXE)
1209 return (discard(command->verb, command->obj));
1211 if (atdwrf(game.loc) <= 0) {
1212 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1213 return throw_support(DRAGON_SCALES);
1215 return throw_support(TROLL_RETURNS);
1217 return throw_support(OGRE_DODGE);
1218 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1219 /* This'll teach him to throw the axe at the bear! */
1220 drop(AXE, game.loc);
1221 game.fixed[AXE] = IS_FIXED;
1223 state_change(AXE, AXE_LOST);
1226 command->obj = INTRANSITIVE;
1227 return (attack(command));
1230 if (randrange(NDWARVES + 1) < game.dflag) {
1231 return throw_support(DWARF_DODGES);
1233 long i = atdwrf(game.loc);
1234 game.dseen[i] = false;
1235 game.dloc[i] = LOC_NOWHERE;
1236 return throw_support((++game.dkill == 1) ?
1243 static int wake(verb_t verb, obj_t obj)
1244 /* Wake. Only use is to disturb the dwarves. */
1248 speak(actions[verb].message);
1252 return GO_DWARFWAKE;
1256 static int wave(verb_t verb, obj_t obj)
1257 /* Wave. No effect unless waving rod at fissure or at bird. */
1264 speak(((!TOTING(obj)) && (obj != ROD ||
1266 arbitrary_messages[ARENT_CARRYING] :
1267 actions[verb].message);
1271 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
1272 drop(JADE, game.loc);
1273 game.prop[JADE] = STATE_FOUND;
1275 rspeak(NECKLACE_FLY);
1279 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1282 return GO_DWARFWAKE;
1286 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1292 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1296 state_change(FISSURE,
1297 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1302 int action(struct command_t *command)
1303 /* Analyse a verb. Remember what it was, go back for object if second word
1304 * unless verb is "say", which snarfs arbitrary second word.
1307 if (command->part == unknown) {
1308 /* Analyse an object word. See if the thing is here, whether
1309 * we've got a verb yet, and so on. Object must be here
1310 * unless verb is "find" or "invent(ory)" (and no new verb
1311 * yet to be analysed). Water and oil are also funny, since
1312 * they are never actually dropped at any location, but might
1313 * be here inside the bottle or urn or as a feature of the
1315 if (HERE(command->obj))
1317 else if (command->obj == GRATE) {
1318 if (game.loc == LOC_START ||
1319 game.loc == LOC_VALLEY ||
1320 game.loc == LOC_SLIT) {
1321 command->obj = DPRSSN;
1323 if (game.loc == LOC_COBBLE ||
1324 game.loc == LOC_DEBRIS ||
1325 game.loc == LOC_AWKWARD ||
1326 game.loc == LOC_BIRD ||
1327 game.loc == LOC_PITTOP) {
1328 command->obj = ENTRNC;
1330 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1332 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1333 command->obj == LIQLOC(game.loc))
1335 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
1338 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
1339 command->obj = PLANT2;
1341 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1343 rspeak(KNIVES_VANISH);
1345 } else if (command->obj == ROD && HERE(ROD2)) {
1346 command->obj = ROD2;
1348 } else if ((command->verb == FIND ||
1349 command->verb == INVENTORY) && command->wd2 <= 0)
1352 sspeak(NO_SEE, command->raw1);
1356 if (command->wd2 > 0)
1358 if (command->verb != 0)
1359 command->part = transitive;
1362 switch (command->part) {
1364 if (command->wd2 > 0 && command->verb != SAY)
1366 if (command->verb == SAY)
1367 command->obj = command->wd2;
1368 if (command->obj == NO_OBJECT ||
1369 command->obj == INTRANSITIVE) {
1370 /* Analyse an intransitive verb (ie, no object given yet). */
1371 switch (command->verb) {
1373 return vcarry(command->verb, INTRANSITIVE);
1379 return lock(command->verb, INTRANSITIVE);
1382 return (GO_CLEAROBJ);
1385 return lock(command->verb, INTRANSITIVE);
1387 return light(command->verb, INTRANSITIVE);
1389 return extinguish(command->verb, INTRANSITIVE);
1395 speak(actions[command->verb].message);
1399 command->obj = INTRANSITIVE;
1400 return attack(command);
1402 return pour(command->verb, INTRANSITIVE);
1404 return eat(command->verb, INTRANSITIVE);
1406 return drink(command->verb, INTRANSITIVE);
1420 return fill(command->verb, INTRANSITIVE);
1432 return bigwords(command->id1);
1436 command->obj = INTRANSITIVE;
1437 return read(*command);
1447 return fly(command->verb, INTRANSITIVE);
1453 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1458 /* Analyse a transitive verb. */
1459 switch (command->verb) {
1461 return vcarry(command->verb, command->obj);
1463 return discard(command->verb, command->obj);
1465 return say(command);
1467 return lock(command->verb, command->obj);
1470 return (GO_CLEAROBJ);
1473 return lock(command->verb, command->obj);
1475 return light(command->verb, command->obj);
1477 return extinguish(command->verb, command->obj);
1479 return wave(command->verb, command->obj);
1481 speak(actions[command->verb].message);
1485 speak(actions[command->verb].message);
1489 return attack(command);
1491 return pour(command->verb, command->obj);
1493 return eat(command->verb, command->obj);
1495 return drink(command->verb, command->obj);
1497 return rub(command->verb, command->obj);
1499 return throw (command);
1501 speak(actions[command->verb].message);
1505 return find(command->verb, command->obj);
1507 return find(command->verb, command->obj);
1509 return feed(command->verb, command->obj);
1511 return fill(command->verb, command->obj);
1516 speak(actions[command->verb].message);
1524 speak(actions[command->verb].message);
1528 speak(actions[command->verb].message);
1532 return read(*command);
1534 return vbreak(command->verb, command->obj);
1536 return wake(command->verb, command->obj);
1538 speak(actions[command->verb].message);
1542 speak(actions[command->verb].message);
1546 return fly(command->verb, command->obj);
1548 speak(actions[command->verb].message);
1554 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1557 /* Unknown verb, couldn't deduce object - might need hint */
1558 sspeak(WHAT_DO, command->raw1);
1559 return GO_CHECKHINT;
1561 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE