7 static int fill(token_t, token_t);
9 static void state_change(long obj, long state)
11 game.prop[obj] = state;
12 pspeak(obj, change, state, true);
15 static int attack(struct command_t *command)
16 /* Attack. Assume target if unambiguous. "Throw" also links here.
17 * Attackable objects fall into two categories: enemies (snake,
18 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
19 * enemies, or no enemies but 2 others. */
21 vocab_t verb = command->verb;
22 vocab_t obj = command->obj;
24 long spk = actions[verb].message;
25 if (obj == NO_OBJECT ||
26 obj == INTRANSITIVE) {
28 if (atdwrf(game.loc) > 0) {
36 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
48 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
52 /* check for low-priority targets */
53 if (obj == NO_OBJECT) {
54 /* Can't attack bird or machine by throwing axe. */
55 if (HERE(BIRD) && verb != THROW) {
59 if (HERE(VEND) && verb != THROW) {
63 /* Clam and oyster both treated as clam for intransitive case;
65 if (HERE(CLAM) || HERE(OYSTER)) {
81 } else if (obj == VEND) {
83 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
91 spk = SHELL_IMPERVIOUS;
95 spk = BARE_HANDS_QUERY;
96 if (obj == DWARF && game.closed)
104 if (obj == OGRE && atdwrf(game.loc) > 0) {
106 rspeak(KNIFE_THROWN);
109 for (int i = 1; i < PIRATE; i++) {
110 if (game.dloc[i] == game.loc) {
112 game.dloc[i] = LOC_LONGWEST;
113 game.dseen[i] = false;
116 spk = (dwarves > 1) ?
119 } else if (obj == BEAR) {
120 switch (game.prop[BEAR]) {
134 } else if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
135 /* Fun stuff for dragon. If he insists on attacking it, win!
136 * Set game.prop to dead, move dragon to central loc (still
137 * fixed), move rug there (not fixed), and move him there,
138 * too. Then do a null motion to get new description. */
139 rspeak(BARE_HANDS_QUERY);
141 // FIXME: setting wd1 is a workaround for broken logic
142 command->wd1 = token_to_packed("Y");
144 // FIXME: setting wd1 is a workaround for broken logic
145 command->wd1 = token_to_packed("N");
148 state_change(DRAGON, DRAGON_DEAD);
149 game.prop[RUG] = RUG_FLOOR;
150 /* FIXME: Arithmetic on location values */
151 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
152 move(DRAGON + NOBJECTS, -1);
153 move(RUG + NOBJECTS, 0);
157 for (obj = 1; obj <= NOBJECTS; obj++) {
158 if (game.place[obj] == objects[DRAGON].plac ||
159 game.place[obj] == objects[DRAGON].fixd)
170 static int bigwords(token_t foo)
171 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
172 * Look up foo in special section of vocab to determine which word we've got.
173 * Last word zips the eggs back to the giant room (unless already there). */
175 char word[TOKLEN + 1];
176 packed_to_token(foo, word);
177 int k = (int) get_special_vocab_id(word);
178 if (game.foobar != 1 - k) {
179 if (game.foobar != 0 && game.loc == LOC_GIANTROOM) {
182 rspeak(NOTHING_HAPPENS);
192 if (game.place[EGGS] == objects[EGGS].plac ||
193 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
194 rspeak(NOTHING_HAPPENS);
197 /* Bring back troll if we steal the eggs back from him before
199 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
200 game.prop[TROLL] = TROLL_PAIDONCE;
204 if (game.loc == objects[EGGS].plac)
206 move(EGGS, objects[EGGS].plac);
207 pspeak(EGGS, look, k, true);
213 static void blast(void)
214 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
216 if (game.prop[ROD2] < 0 ||
218 rspeak(REQUIRES_DYNAMITE);
220 game.bonus = VICTORY_MESSAGE;
221 if (game.loc == LOC_NE)
222 game.bonus = DEFEAT_MESSAGE;
224 game.bonus = SPLATTER_MESSAGE;
230 static int vbreak(token_t verb, token_t obj)
231 /* Break. Only works for mirror in repository and, of course, the vase. */
235 rspeak(BREAK_MIRROR);
242 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
244 drop(VASE, game.loc);
245 state_change(VASE, VASE_BROKEN);
246 game.fixed[VASE] = -1;
249 rspeak(actions[verb].message);
250 return (GO_CLEAROBJ);
253 static int brief(void)
254 /* Brief. Intransitive only. Suppress long descriptions after first time. */
258 rspeak(BRIEF_CONFIRM);
262 static int vcarry(token_t verb, token_t obj)
263 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
264 * take one without the other). Liquids also special, since they depend on
265 * status of bottle. Also various side effects, etc. */
268 if (obj == INTRANSITIVE) {
269 /* Carry, no object given yet. OK if only one object present. */
270 if (game.atloc[game.loc] == 0 ||
271 game.link[game.atloc[game.loc]] != 0 ||
272 atdwrf(game.loc) > 0)
274 obj = game.atloc[game.loc];
278 rspeak(ALREADY_CARRYING);
282 if (obj == PLANT && game.prop[PLANT] <= 0)
284 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
286 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
291 spk = DOUGHNUT_HOLES;
294 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
297 spk = HAND_PASSTHROUGH;
299 rspeak(REMOVE_MESSAGE);
303 if (game.fixed[obj] != 0) {
311 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
312 return (fill(verb, BOTTLE));
314 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
326 if (game.holdng >= INVLIMIT) {
329 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
330 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
339 if (spk == CANNOT_CARRY ||
340 spk == BIRD_EVADES) {
344 game.prop[BIRD] = BIRD_CAGED;
346 /* FIXME: Arithmetic on state numbers */
349 (game.prop[BIRD] == BIRD_CAGED ||
350 -1 - game.prop[BIRD] == 1))
351 carry(BIRD + CAGE - obj, game.loc);
352 carry(obj, game.loc);
353 if (obj == BOTTLE && LIQUID() != 0)
354 game.place[LIQUID()] = CARRIED;
355 if (GSTONE(obj) && game.prop[obj] != 0) {
356 game.prop[obj] = STATE_GROUND;
357 game.prop[CAVITY] = CAVITY_EMPTY;
363 static int chain(token_t verb)
364 /* Do something to the bear's chain */
367 if (game.prop[BEAR] == UNTAMED_BEAR) {
371 if (game.prop[CHAIN] == CHAIN_HEAP) {
372 rspeak(ALREADY_UNLOCKED);
375 game.prop[CHAIN] = CHAIN_HEAP;
376 game.fixed[CHAIN] = CHAIN_HEAP;
377 if (game.prop[BEAR] != BEAR_DEAD)
378 game.prop[BEAR] = CONTENTED_BEAR;
380 switch (game.prop[BEAR]) {
382 game.fixed[BEAR] = -1;
385 game.fixed[BEAR] = 0;
387 rspeak(CHAIN_UNLOCKED);
391 if (game.prop[CHAIN] != CHAIN_HEAP) {
392 rspeak(ALREADY_LOCKED);
395 if (game.loc != objects[CHAIN].plac) {
400 game.prop[CHAIN] = CHAIN_FIXED;
403 drop(CHAIN, game.loc);
404 game.fixed[CHAIN] = -1;
406 rspeak(CHAIN_LOCKED);
410 static int discard(token_t verb, token_t obj, bool just_do_it)
411 /* Discard object. "Throw" also comes here for most objects. Special cases for
412 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
413 * Drop coins at vending machine for extra batteries. */
415 int spk = actions[verb].message;
417 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
423 if (obj == BIRD && HERE(SNAKE)) {
424 rspeak(BIRD_ATTACKS);
428 /* Set game.prop for use by travel options */
429 game.prop[SNAKE] = SNAKE_CHASED;
431 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
434 game.prop[CAVITY] = CAVITY_FULL;
435 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
436 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
443 if (spk != RUG_WIGGLES) {
444 /* FIXME: Arithmetic on state numbers */
445 int k = 2 - game.prop[RUG];
448 k = objects[SAPPH].plac;
449 move(RUG + NOBJECTS, k);
452 } else if (obj == COINS && HERE(VEND)) {
454 drop(BATTERY, game.loc);
455 pspeak(BATTERY, look, FRESH_BATTERIES, true);
457 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
461 } else if (obj == BEAR && AT(TROLL)) {
462 state_change(TROLL, TROLL_GONE);
463 move(TROLL, LOC_NOWHERE);
464 move(TROLL + NOBJECTS, LOC_NOWHERE);
465 move(TROLL2, objects[TROLL].plac);
466 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
468 } else if (obj != VASE ||
469 game.loc == objects[PILLOW].plac) {
472 game.prop[VASE] = VASE_BROKEN;
474 game.prop[VASE] = VASE_WHOLE;
475 pspeak(VASE, look, game.prop[VASE] + 1, true);
476 if (game.prop[VASE] != VASE_WHOLE)
477 game.fixed[VASE] = -1;
483 if (obj == BOTTLE && k != 0)
484 game.place[k] = LOC_NOWHERE;
485 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
486 drop(BIRD, game.loc);
490 game.prop[BIRD] = BIRD_UNCAGED;
491 if (FOREST(game.loc))
492 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
496 static int drink(token_t verb, token_t obj)
497 /* Drink. If no object, assume water and look for it here. If water is in
498 * the bottle, drink that, else must be at a water loc, so drink stream. */
500 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER &&
501 (LIQUID() != WATER || !HERE(BOTTLE))) {
507 state_change(DRAGON, DRAGON_BLOODLESS);
512 if (obj != NO_OBJECT && obj != WATER) {
513 rspeak(RIDICULOUS_ATTEMPT);
516 if (LIQUID() == WATER && HERE(BOTTLE)) {
517 game.prop[BOTTLE] = EMPTY_BOTTLE;
518 game.place[WATER] = LOC_NOWHERE;
519 rspeak(BOTTLE_EMPTY);
523 rspeak(actions[verb].message);
527 static int eat(token_t verb, token_t obj)
528 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
529 * ok, some things lose appetite, rest are ridiculous. */
531 if (obj == INTRANSITIVE) {
535 rspeak(THANKS_DELICIOUS);
540 rspeak(THANKS_DELICIOUS);
552 rspeak(LOST_APPETITE);
555 rspeak(actions[verb].message);
559 static int extinguish(token_t verb, int obj)
560 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
562 if (obj == INTRANSITIVE) {
563 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
565 if (HERE(URN) && game.prop[URN] == URN_LIT)
567 if (obj == INTRANSITIVE)
572 if (game.prop[URN] != URN_EMPTY) {
573 state_change(URN, URN_DARK);
575 pspeak(URN, change, URN_DARK, true);
581 state_change(LAMP, LAMP_DARK);
582 rspeak(DARK(game.loc) ?
590 rspeak(BEYOND_POWER);
594 rspeak(actions[verb].message);
598 static int feed(token_t verb, token_t obj)
599 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
600 * mad. Bear, special. */
602 int spk = actions[verb].message;
606 } else if (obj == SNAKE ||
609 spk = NOTHING_EDIBLE;
610 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
611 spk = RIDICULOUS_ATTEMPT;
614 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
618 } else if (obj == DWARF) {
623 } else if (obj == BEAR) {
624 if (game.prop[BEAR] == UNTAMED_BEAR)
625 spk = NOTHING_EDIBLE;
626 if (game.prop[BEAR] == BEAR_DEAD)
627 spk = RIDICULOUS_ATTEMPT;
630 game.prop[BEAR] = SITTING_BEAR;
635 } else if (obj == OGRE) {
645 int fill(token_t verb, token_t obj)
646 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
650 if (LIQLOC(game.loc) == NO_OBJECT) {
651 rspeak(FILL_INVALID);
655 rspeak(ARENT_CARRYING);
658 rspeak(SHATTER_VASE);
659 game.prop[VASE] = VASE_BROKEN;
660 game.fixed[VASE] = -1;
661 return (discard(verb, obj, true));
665 if (game.prop[URN] != URN_EMPTY) {
670 rspeak(FILL_INVALID);
676 game.prop[BOTTLE] = EMPTY_BOTTLE;
680 game.prop[URN] = URN_DARK;
681 game.prop[BOTTLE] = EMPTY_BOTTLE;
686 rspeak(FILL_INVALID);
689 game.place[k] = LOC_NOWHERE;
692 if (obj != NO_OBJECT && obj != BOTTLE) {
693 rspeak(actions[verb].message);
696 if (obj == NO_OBJECT && !HERE(BOTTLE))
699 if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
703 if (LIQUID() != NO_OBJECT) {
707 if (LIQLOC(game.loc) == NO_OBJECT) {
712 game.prop[BOTTLE] = (LIQLOC(game.loc) == OIL) ? OIL_BOTTLE : WATER_BOTTLE;
714 game.place[LIQUID()] = CARRIED;
718 rspeak(BOTTLED_WATER);
722 static int find(token_t verb, token_t obj)
723 /* Find. Might be carrying it, or it might be here. Else give caveat. */
726 rspeak(ALREADY_CARRYING);
731 rspeak(NEEDED_NEARBY);
736 (LIQUID() == obj && AT(BOTTLE)) ||
737 obj == LIQLOC(game.loc) ||
738 (obj == DWARF && atdwrf(game.loc) > 0)) {
744 rspeak(actions[verb].message);
748 static int fly(token_t verb, token_t obj)
749 /* Fly. Snide remarks unless hovering rug is here. */
751 if (obj == INTRANSITIVE) {
756 if (game.prop[RUG] != RUG_HOVER) {
757 rspeak(RUG_NOTHING2);
764 rspeak(actions[verb].message);
767 if (game.prop[RUG] != RUG_HOVER) {
768 rspeak(RUG_NOTHING1);
771 game.oldlc2 = game.oldloc;
772 game.oldloc = game.loc;
773 /* FIXME: Arithmetic on location values */
774 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
776 if (game.prop[SAPPH] >= 0) {
784 static int inven(void)
785 /* Inventory. If object, treat same as find. Else report on current burden. */
788 for (int i = 1; i <= NOBJECTS; i++) {
796 pspeak(i, touch, -1, false);
805 static int light(token_t verb, token_t obj)
806 /* Light. Applicable only to lamp and urn. */
808 if (obj == INTRANSITIVE) {
809 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
811 if (HERE(URN) && game.prop[URN] == URN_DARK)
813 if (obj == INTRANSITIVE ||
814 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
815 HERE(URN) && game.prop[URN] == URN_DARK))
820 state_change(URN, game.prop[URN] == URN_EMPTY ?
826 rspeak(actions[verb].message);
829 if (game.limit < 0) {
833 state_change(LAMP, LAMP_BRIGHT);
841 static int listen(void)
842 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
844 long sound = locations[game.loc].sound;
845 if (sound != SILENT) {
847 if (!locations[game.loc].loud)
851 for (int i = 1; i <= NOBJECTS; i++) {
853 objects[i].sounds[0] == NULL ||
856 int mi = game.prop[i];
858 mi += 3 * game.blooded;
859 long packed_zzword = token_to_packed(game.zzword);
860 pspeak(i, hear, mi, true, packed_zzword);
862 /* FIXME: Magic number, sensitive to bird state logic */
863 if (i == BIRD && game.prop[i] == 5)
871 static int lock(token_t verb, token_t obj)
872 /* Lock, unlock, no object given. Assume various things if present. */
874 if (obj == INTRANSITIVE) {
885 if (obj == INTRANSITIVE) {
886 rspeak(NOTHING_LOCKED);
891 /* Lock, unlock object. Special stuff for opening clam/oyster
901 game.clock2 = PANICTIME;
905 state_change(GRATE, (verb == LOCK) ?
919 else if (!TOTING(TRIDENT))
920 rspeak(OYSTER_OPENER);
923 drop(OYSTER, game.loc);
924 drop(PEARL, LOC_CULDESAC);
932 rspeak(OYSTER_OPENER);
936 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
942 rspeak(CANNOT_UNLOCK);
945 rspeak(actions[verb].message);
951 static int pour(token_t verb, token_t obj)
952 /* Pour. If no object, or object is bottle, assume contents of bottle.
953 * special tests for pouring water or oil on plant or rusty door. */
958 if (obj == NO_OBJECT)
961 rspeak(actions[verb].message);
965 if (obj != OIL && obj != WATER) {
969 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
970 return fill(verb, URN);
971 game.prop[BOTTLE] = EMPTY_BOTTLE;
972 game.place[obj] = LOC_NOWHERE;
980 /* cycle through the three plant states */
981 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
982 game.prop[PLANT2] = game.prop[PLANT];
985 rspeak(SHAKING_LEAVES);
989 state_change(DOOR, (obj == OIL) ?
996 static int quit(void)
997 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
999 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
1000 terminate(quitgame);
1004 static int read(struct command_t command)
1005 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1007 if (command.obj == INTRANSITIVE) {
1009 for (int i = 1; i <= NOBJECTS; i++) {
1010 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1011 command.obj = command.obj * NOBJECTS + i;
1013 if (command.obj > NOBJECTS ||
1019 if (DARK(game.loc)) {
1020 sspeak(NO_SEE, command.raw1);
1021 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1022 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1023 } else if (objects[command.obj].texts[0] == NULL ||
1024 game.prop[command.obj] < 0) {
1025 rspeak(actions[command.verb].message);
1027 pspeak(command.obj, study, game.prop[command.obj], true);
1031 static int reservoir(void)
1032 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1034 /* FIXME: Arithmetic on state numbers */
1035 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
1036 rspeak(NOTHING_HAPPENS);
1040 game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
1044 game.oldlc2 = game.loc;
1045 game.newloc = LOC_NOWHERE;
1047 return GO_TERMINATE;
1052 static int rub(token_t verb, token_t obj)
1053 /* Rub. Yields various snide remarks except for lit urn. */
1055 if (obj == URN && game.prop[URN] == URN_LIT) {
1057 drop(AMBER, game.loc);
1058 game.prop[AMBER] = AMBER_IN_ROCK;
1060 drop(CAVITY, game.loc);
1062 } else if (obj != LAMP) {
1063 rspeak(PECULIAR_NOTHING);
1065 rspeak(actions[verb].message);
1070 static int say(struct command_t *command)
1071 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1073 if (command->wd2 > 0) {
1074 command->wd1 = command->wd2;
1075 strcpy(command->raw1, command->raw2);
1077 char word1[TOKLEN + 1];
1078 packed_to_token(command->wd1, word1);
1079 int wd = (int) get_vocab_id(word1);
1080 /* FIXME: magic numbers */
1081 if (wd == MOTION_WORD(XYZZY) ||
1082 wd == MOTION_WORD(PLUGH) ||
1083 wd == MOTION_WORD(PLOVER) ||
1084 wd == ACTION_WORD(GIANTWORDS) ||
1085 wd == ACTION_WORD(PART)) {
1086 /* FIXME: scribbles on the interpreter's command block */
1087 wordclear(&command->wd2);
1090 sspeak(OKEY_DOKEY, command->raw1);
1094 static int throw_support(long spk)
1097 drop(AXE, game.loc);
1101 static int throw (struct command_t *command)
1102 /* Throw. Same as discard unless axe. Then same as attack except
1103 * ignore bird, and if dwarf is present then one might be killed.
1104 * (Only way to do so!) Axe also special for dragon, bear, and
1105 * troll. Treasures special for troll. */
1107 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1108 command->obj = ROD2;
1109 if (!TOTING(command->obj)) {
1110 rspeak(actions[command->verb].message);
1113 if (objects[command->obj].is_treasure && AT(TROLL)) {
1114 /* Snarf a treasure for the troll. */
1115 drop(command->obj, LOC_NOWHERE);
1116 move(TROLL, LOC_NOWHERE);
1117 move(TROLL + NOBJECTS, LOC_NOWHERE);
1118 drop(TROLL2, objects[TROLL].plac);
1119 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1121 rspeak(TROLL_SATISFIED);
1124 if (command->obj == FOOD && HERE(BEAR)) {
1125 /* But throwing food is another story. */
1126 command->obj = BEAR;
1127 return (feed(command->verb, command->obj));
1129 if (command->obj != AXE)
1130 return (discard(command->verb, command->obj, false));
1132 if (atdwrf(game.loc) <= 0) {
1133 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1134 return throw_support(DRAGON_SCALES);
1136 return throw_support(TROLL_RETURNS);
1138 return throw_support(OGRE_DODGE);
1139 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1140 /* This'll teach him to throw the axe at the bear! */
1141 drop(AXE, game.loc);
1142 game.fixed[AXE] = -1;
1144 state_change(AXE, AXE_LOST);
1147 command->obj = NO_OBJECT;
1148 return (attack(command));
1151 if (randrange(NDWARVES + 1) < game.dflag) {
1152 return throw_support(DWARF_DODGES);
1154 long i = atdwrf(game.loc);
1155 game.dseen[i] = false;
1156 game.dloc[i] = LOC_NOWHERE;
1157 return throw_support((++game.dkill == 1) ?
1164 static int wake(token_t verb, token_t obj)
1165 /* Wake. Only use is to disturb the dwarves. */
1169 rspeak(actions[verb].message);
1173 return GO_DWARFWAKE;
1177 static int wave(token_t verb, token_t obj)
1178 /* Wave. No effect unless waving rod at fissure or at bird. */
1185 rspeak(((!TOTING(obj)) && (obj != ROD ||
1188 actions[verb].message);
1192 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1193 drop(JADE, game.loc);
1194 game.prop[JADE] = 0;
1196 rspeak(NECKLACE_FLY);
1200 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1203 return GO_DWARFWAKE;
1207 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1213 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1217 state_change(FISSURE,
1218 game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
1223 int action(struct command_t *command)
1224 /* Analyse a verb. Remember what it was, go back for object if second word
1225 * unless verb is "say", which snarfs arbitrary second word.
1228 if (command->part == unknown) {
1229 /* Analyse an object word. See if the thing is here, whether
1230 * we've got a verb yet, and so on. Object must be here
1231 * unless verb is "find" or "invent(ory)" (and no new verb
1232 * yet to be analysed). Water and oil are also funny, since
1233 * they are never actually dropped at any location, but might
1234 * be here inside the bottle or urn or as a feature of the
1236 if (HERE(command->obj))
1238 else if (command->obj == GRATE) {
1239 if (game.loc == LOC_START ||
1240 game.loc == LOC_VALLEY ||
1241 game.loc == LOC_SLIT) {
1242 command->obj = DPRSSN;
1244 if (game.loc == LOC_COBBLE ||
1245 game.loc == LOC_DEBRIS ||
1246 game.loc == LOC_AWKWARD ||
1247 game.loc == LOC_BIRD ||
1248 game.loc == LOC_PITTOP) {
1249 command->obj = ENTRNC;
1251 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1253 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1254 command->obj == LIQLOC(game.loc))
1256 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1259 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1260 command->obj = PLANT2;
1262 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1264 rspeak(KNIVES_VANISH);
1266 } else if (command->obj == ROD && HERE(ROD2)) {
1267 command->obj = ROD2;
1269 } else if ((command->verb == FIND ||
1270 command->verb == INVENTORY) && command->wd2 <= 0)
1273 sspeak(NO_SEE, command->raw1);
1277 if (command->wd2 > 0)
1279 if (command->verb != 0)
1280 command->part = transitive;
1283 switch (command->part) {
1285 if (command->wd2 > 0 && command->verb != SAY)
1287 if (command->verb == SAY)
1288 command->obj = command->wd2;
1289 if (command->obj == 0 ||
1290 command->obj == INTRANSITIVE) {
1291 /* Analyse an intransitive verb (ie, no object given yet). */
1292 switch (command->verb) {
1294 return vcarry(command->verb, INTRANSITIVE);
1300 return lock(command->verb, INTRANSITIVE);
1303 return (GO_CLEAROBJ);
1306 return lock(command->verb, INTRANSITIVE);
1308 return light(command->verb, INTRANSITIVE);
1310 return extinguish(command->verb, INTRANSITIVE);
1316 rspeak(actions[command->verb].message);
1320 return attack(command);
1322 return pour(command->verb, command->obj);
1324 return eat(command->verb, INTRANSITIVE);
1326 return drink(command->verb, command->obj);
1340 return fill(command->verb, command->obj);
1348 return bigwords(command->wd1);
1352 command->obj = INTRANSITIVE;
1353 return read(*command);
1363 return fly(command->verb, INTRANSITIVE);
1369 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1374 /* Analyse a transitive verb. */
1375 switch (command->verb) {
1377 return vcarry(command->verb, command->obj);
1379 return discard(command->verb, command->obj, false);
1381 return say(command);
1383 return lock(command->verb, command->obj);
1386 return (GO_CLEAROBJ);
1389 return lock(command->verb, command->obj);
1391 return light(command->verb, command->obj);
1393 return extinguish(command->verb, command->obj);
1395 return wave(command->verb, command->obj);
1397 rspeak(actions[command->verb].message);
1401 rspeak(actions[command->verb].message);
1405 return attack(command);
1407 return pour(command->verb, command->obj);
1409 return eat(command->verb, command->obj);
1411 return drink(command->verb, command->obj);
1413 return rub(command->verb, command->obj);
1415 return throw (command);
1417 rspeak(actions[command->verb].message);
1421 return find(command->verb, command->obj);
1423 return find(command->verb, command->obj);
1425 return feed(command->verb, command->obj);
1427 return fill(command->verb, command->obj);
1432 rspeak(actions[command->verb].message);
1436 rspeak(actions[command->verb].message);
1440 rspeak(actions[command->verb].message);
1444 return read(*command);
1446 return vbreak(command->verb, command->obj);
1448 return wake(command->verb, command->obj);
1450 rspeak(actions[command->verb].message);
1454 rspeak(actions[command->verb].message);
1458 return fly(command->verb, command->obj);
1460 rspeak(actions[command->verb].message);
1466 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1469 /* Unknown verb, couldn't deduce object - might need hint */
1470 sspeak(WHAT_DO, command->raw1);
1471 return GO_CHECKHINT;
1473 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE