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 int bivalve(token_t verb, token_t obj)
214 /* Clam/oyster actions */
216 bool is_oyster = (obj == OYSTER);
221 if (!TOTING(TRIDENT)) {
236 drop(OYSTER, game.loc);
237 drop(PEARL, LOC_CULDESAC);
245 static void blast(void)
246 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
248 if (game.prop[ROD2] < 0 ||
250 rspeak(REQUIRES_DYNAMITE);
252 game.bonus = VICTORY_MESSAGE;
253 if (game.loc == LOC_NE)
254 game.bonus = DEFEAT_MESSAGE;
256 game.bonus = SPLATTER_MESSAGE;
262 static int vbreak(token_t verb, token_t obj)
263 /* Break. Only works for mirror in repository and, of course, the vase. */
267 rspeak(BREAK_MIRROR);
274 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
276 drop(VASE, game.loc);
277 state_change(VASE, VASE_BROKEN);
278 game.fixed[VASE] = -1;
281 rspeak(actions[verb].message);
282 return (GO_CLEAROBJ);
285 static int brief(void)
286 /* Brief. Intransitive only. Suppress long descriptions after first time. */
290 rspeak(BRIEF_CONFIRM);
294 static int vcarry(token_t verb, token_t obj)
295 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
296 * take one without the other). Liquids also special, since they depend on
297 * status of bottle. Also various side effects, etc. */
300 if (obj == INTRANSITIVE) {
301 /* Carry, no object given yet. OK if only one object present. */
302 if (game.atloc[game.loc] == 0 ||
303 game.link[game.atloc[game.loc]] != 0 ||
304 atdwrf(game.loc) > 0)
306 obj = game.atloc[game.loc];
310 rspeak(ALREADY_CARRYING);
314 if (obj == PLANT && game.prop[PLANT] <= 0)
316 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
318 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
323 spk = DOUGHNUT_HOLES;
326 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
329 spk = HAND_PASSTHROUGH;
331 rspeak(REMOVE_MESSAGE);
335 if (game.fixed[obj] != 0) {
343 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
344 return (fill(verb, BOTTLE));
346 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
358 if (game.holdng >= INVLIMIT) {
361 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
362 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
371 if (spk == CANNOT_CARRY ||
372 spk == BIRD_EVADES) {
376 game.prop[BIRD] = BIRD_CAGED;
378 /* FIXME: Arithmetic on state numbers */
381 (game.prop[BIRD] == BIRD_CAGED ||
382 -1 - game.prop[BIRD] == 1))
383 carry(BIRD + CAGE - obj, game.loc);
384 carry(obj, game.loc);
385 if (obj == BOTTLE && LIQUID() != 0)
386 game.place[LIQUID()] = CARRIED;
387 if (GSTONE(obj) && game.prop[obj] != 0) {
388 game.prop[obj] = STATE_GROUND;
389 game.prop[CAVITY] = CAVITY_EMPTY;
395 static int chain(token_t verb)
396 /* Do something to the bear's chain */
400 spk = CHAIN_UNLOCKED;
401 if (game.prop[BEAR] == UNTAMED_BEAR)
403 if (game.prop[CHAIN] == CHAIN_HEAP)
404 spk = ALREADY_UNLOCKED;
405 if (spk != CHAIN_UNLOCKED) {
409 game.prop[CHAIN] = CHAIN_HEAP;
410 game.fixed[CHAIN] = CHAIN_HEAP;
411 if (game.prop[BEAR] != BEAR_DEAD)
412 game.prop[BEAR] = CONTENTED_BEAR;
413 /* FIXME: Arithmetic on state numbers */
414 game.fixed[BEAR] = 2 - game.prop[BEAR];
417 if (game.prop[CHAIN] != CHAIN_HEAP)
418 spk = ALREADY_LOCKED;
419 if (game.loc != objects[CHAIN].plac)
421 if (spk != CHAIN_LOCKED) {
425 game.prop[CHAIN] = CHAIN_FIXED;
427 drop(CHAIN, game.loc);
428 game.fixed[CHAIN] = -1;
434 static int discard(token_t verb, token_t obj, bool just_do_it)
435 /* Discard object. "Throw" also comes here for most objects. Special cases for
436 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
437 * Drop coins at vending machine for extra batteries. */
439 int spk = actions[verb].message;
441 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
447 if (obj == BIRD && HERE(SNAKE)) {
448 rspeak(BIRD_ATTACKS);
452 /* Set game.prop for use by travel options */
453 game.prop[SNAKE] = SNAKE_CHASED;
455 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
458 game.prop[CAVITY] = CAVITY_FULL;
459 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
460 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
467 if (spk != RUG_WIGGLES) {
468 /* FIXME: Arithmetic on state numbers */
469 int k = 2 - game.prop[RUG];
472 k = objects[SAPPH].plac;
473 move(RUG + NOBJECTS, k);
476 } else if (obj == COINS && HERE(VEND)) {
478 drop(BATTERY, game.loc);
479 pspeak(BATTERY, look, FRESH_BATTERIES, true);
481 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
485 } else if (obj == BEAR && AT(TROLL)) {
486 state_change(TROLL, TROLL_GONE);
487 move(TROLL, LOC_NOWHERE);
488 move(TROLL + NOBJECTS, LOC_NOWHERE);
489 move(TROLL2, objects[TROLL].plac);
490 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
492 } else if (obj != VASE ||
493 game.loc == objects[PILLOW].plac) {
496 game.prop[VASE] = VASE_BROKEN;
498 game.prop[VASE] = VASE_WHOLE;
499 pspeak(VASE, look, game.prop[VASE] + 1, true);
500 if (game.prop[VASE] != VASE_WHOLE)
501 game.fixed[VASE] = -1;
507 if (obj == BOTTLE && k != 0)
508 game.place[k] = LOC_NOWHERE;
509 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
510 drop(BIRD, game.loc);
514 game.prop[BIRD] = BIRD_UNCAGED;
515 if (FOREST(game.loc))
516 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
520 static int drink(token_t verb, token_t obj)
521 /* Drink. If no object, assume water and look for it here. If water is in
522 * the bottle, drink that, else must be at a water loc, so drink stream. */
524 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER && (LIQUID() != WATER ||
528 if (obj != NO_OBJECT && obj != WATER) {
529 rspeak(RIDICULOUS_ATTEMPT);
530 } else if (LIQUID() == WATER && HERE(BOTTLE)) {
531 game.prop[BOTTLE] = EMPTY_BOTTLE;
532 game.place[WATER] = LOC_NOWHERE;
533 rspeak(BOTTLE_EMPTY);
535 rspeak(actions[verb].message);
539 state_change(DRAGON, DRAGON_BLOODLESS);
545 static int eat(token_t verb, token_t obj)
546 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
547 * ok, some things lose appetite, rest are ridiculous. */
549 if (obj == INTRANSITIVE) {
553 rspeak(THANKS_DELICIOUS);
558 rspeak(THANKS_DELICIOUS);
570 rspeak(LOST_APPETITE);
573 rspeak(actions[verb].message);
577 static int extinguish(token_t verb, int obj)
578 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
580 if (obj == INTRANSITIVE) {
581 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
583 if (HERE(URN) && game.prop[URN] == URN_LIT)
585 if (obj == INTRANSITIVE ||
586 (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT &&
587 HERE(URN) && game.prop[URN] == URN_LIT))
592 if (game.prop[URN] != URN_EMPTY) {
593 state_change(URN, URN_DARK);
595 pspeak(URN, change, URN_DARK, true);
598 } else if (obj == LAMP) {
599 state_change(LAMP, LAMP_DARK);
600 rspeak(DARK(game.loc) ?
604 } else if (obj == DRAGON ||
606 rspeak(BEYOND_POWER);
609 rspeak(actions[verb].message);
614 static int feed(token_t verb, token_t obj)
615 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
616 * mad. Bear, special. */
618 int spk = actions[verb].message;
622 } else if (obj == SNAKE ||
625 spk = NOTHING_EDIBLE;
626 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
627 spk = RIDICULOUS_ATTEMPT;
630 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
634 } else if (obj == DWARF) {
639 } else if (obj == BEAR) {
640 if (game.prop[BEAR] == UNTAMED_BEAR)
641 spk = NOTHING_EDIBLE;
642 if (game.prop[BEAR] == BEAR_DEAD)
643 spk = RIDICULOUS_ATTEMPT;
646 game.prop[BEAR] = SITTING_BEAR;
651 } else if (obj == OGRE) {
661 int fill(token_t verb, token_t obj)
662 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
666 if (LIQLOC(game.loc) == NO_OBJECT) {
667 rspeak(FILL_INVALID);
671 rspeak(ARENT_CARRYING);
674 rspeak(SHATTER_VASE);
675 game.prop[VASE] = VASE_BROKEN;
676 game.fixed[VASE] = -1;
677 return (discard(verb, obj, true));
681 if (game.prop[URN] != URN_EMPTY) {
686 rspeak(FILL_INVALID);
692 game.prop[BOTTLE] = EMPTY_BOTTLE;
696 game.prop[URN] = URN_DARK;
697 game.prop[BOTTLE] = EMPTY_BOTTLE;
702 rspeak(FILL_INVALID);
705 game.place[k] = LOC_NOWHERE;
707 } else if (obj != NO_OBJECT && obj != BOTTLE) {
708 rspeak(actions[verb].message);
710 } else if (obj == NO_OBJECT && !HERE(BOTTLE))
712 int spk = BOTTLED_WATER;
713 if (LIQLOC(game.loc) == 0)
715 if (HERE(URN) && game.prop[URN] != URN_EMPTY)
719 if (spk == BOTTLED_WATER) {
720 /* FIXME: Arithmetic on property values */
721 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
723 game.place[LIQUID()] = CARRIED;
731 static int find(token_t verb, token_t obj)
732 /* Find. Might be carrying it, or it might be here. Else give caveat. */
735 rspeak(ALREADY_CARRYING);
740 rspeak(NEEDED_NEARBY);
745 (LIQUID() == obj && AT(BOTTLE)) ||
746 obj == LIQLOC(game.loc) ||
747 (obj == DWARF && atdwrf(game.loc) > 0)) {
753 rspeak(actions[verb].message);
757 static int fly(token_t verb, token_t obj)
758 /* Fly. Snide remarks unless hovering rug is here. */
760 if (obj == INTRANSITIVE) {
765 if (game.prop[RUG] != RUG_HOVER) {
766 rspeak(RUG_NOTHING2);
773 rspeak(actions[verb].message);
776 if (game.prop[RUG] != RUG_HOVER) {
777 rspeak(RUG_NOTHING1);
780 game.oldlc2 = game.oldloc;
781 game.oldloc = game.loc;
782 /* FIXME: Arithmetic on location values */
783 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
785 if (game.prop[SAPPH] >= 0) {
793 static int inven(void)
794 /* Inventory. If object, treat same as find. Else report on current burden. */
797 for (int i = 1; i <= NOBJECTS; i++) {
805 pspeak(i, touch, -1, false);
814 static int light(token_t verb, token_t obj)
815 /* Light. Applicable only to lamp and urn. */
817 if (obj == INTRANSITIVE) {
818 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
820 if (HERE(URN) && game.prop[URN] == URN_DARK)
822 if (obj == INTRANSITIVE ||
823 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
824 HERE(URN) && game.prop[URN] == URN_DARK))
829 state_change(URN, game.prop[URN] == URN_EMPTY ?
835 rspeak(actions[verb].message);
838 if (game.limit < 0) {
842 state_change(LAMP, LAMP_BRIGHT);
850 static int listen(void)
851 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
853 long sound = locations[game.loc].sound;
854 if (sound != SILENT) {
856 if (!locations[game.loc].loud)
860 for (int i = 1; i <= NOBJECTS; i++) {
862 objects[i].sounds[0] == NULL ||
865 int mi = game.prop[i];
867 mi += 3 * game.blooded;
868 long packed_zzword = token_to_packed(game.zzword);
869 pspeak(i, hear, mi, true, packed_zzword);
871 /* FIXME: Magic number, sensitive to bird state logic */
872 if (i == BIRD && game.prop[i] == 5)
880 static int lock(token_t verb, token_t obj)
881 /* Lock, unlock, no object given. Assume various things if present. */
883 if (obj == INTRANSITIVE) {
894 if (obj == INTRANSITIVE) {
895 rspeak(NOTHING_LOCKED);
900 /* Lock, unlock object. Special stuff for opening clam/oyster
910 game.clock2 = PANICTIME;
914 state_change(GRATE, (verb == LOCK) ?
927 return bivalve(verb, obj);
929 rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
935 rspeak(CANNOT_UNLOCK);
938 rspeak(actions[verb].message);
944 static int pour(token_t verb, token_t obj)
945 /* Pour. If no object, or object is bottle, assume contents of bottle.
946 * special tests for pouring water or oil on plant or rusty door. */
951 if (obj == NO_OBJECT)
954 rspeak(actions[verb].message);
958 if (obj != OIL && obj != WATER) {
962 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
963 return fill(verb, URN);
964 game.prop[BOTTLE] = EMPTY_BOTTLE;
965 game.place[obj] = LOC_NOWHERE;
973 /* cycle through the three plant states */
974 state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
975 game.prop[PLANT2] = game.prop[PLANT];
978 rspeak(SHAKING_LEAVES);
982 state_change(DOOR, (obj == OIL) ?
989 static int quit(void)
990 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
992 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
997 static int read(struct command_t command)
998 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
1000 if (command.obj == INTRANSITIVE) {
1002 for (int i = 1; i <= NOBJECTS; i++) {
1003 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
1004 command.obj = command.obj * NOBJECTS + i;
1006 if (command.obj > NOBJECTS ||
1012 if (DARK(game.loc)) {
1013 sspeak(NO_SEE, command.raw1);
1014 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
1015 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
1016 } else if (objects[command.obj].texts[0] == NULL ||
1017 game.prop[command.obj] < 0) {
1018 rspeak(actions[command.verb].message);
1020 pspeak(command.obj, study, game.prop[command.obj], true);
1024 static int reservoir(void)
1025 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1027 /* FIXME: Arithmetic on state numbers */
1028 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
1029 rspeak(NOTHING_HAPPENS);
1032 /* FIXME: Arithmetic on state numbers */
1033 pspeak(RESER, look, game.prop[RESER] + 1, true);
1034 game.prop[RESER] = 1 - game.prop[RESER];
1038 game.oldlc2 = game.loc;
1039 game.newloc = LOC_NOWHERE;
1041 return GO_TERMINATE;
1046 static int rub(token_t verb, token_t obj)
1047 /* Rub. Yields various snide remarks except for lit urn. */
1049 if (obj == URN && game.prop[URN] == URN_LIT) {
1051 drop(AMBER, game.loc);
1052 game.prop[AMBER] = AMBER_IN_ROCK;
1054 drop(CAVITY, game.loc);
1056 } else if (obj != LAMP) {
1057 rspeak(PECULIAR_NOTHING);
1059 rspeak(actions[verb].message);
1064 static int say(struct command_t *command)
1065 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1067 if (command->wd2 > 0) {
1068 command->wd1 = command->wd2;
1069 strcpy(command->raw1, command->raw2);
1071 char word1[TOKLEN + 1];
1072 packed_to_token(command->wd1, word1);
1073 int wd = (int) get_vocab_id(word1);
1074 /* FIXME: magic numbers */
1075 if (wd == MOTION_WORD(XYZZY) ||
1076 wd == MOTION_WORD(PLUGH) ||
1077 wd == MOTION_WORD(PLOVER) ||
1078 wd == ACTION_WORD(GIANTWORDS) ||
1079 wd == ACTION_WORD(PART)) {
1080 /* FIXME: scribbles on the interpreter's command block */
1081 wordclear(&command->wd2);
1084 sspeak(OKEY_DOKEY, command->raw1);
1088 static int throw_support(long spk)
1091 drop(AXE, game.loc);
1095 static int throw (struct command_t *command)
1096 /* Throw. Same as discard unless axe. Then same as attack except
1097 * ignore bird, and if dwarf is present then one might be killed.
1098 * (Only way to do so!) Axe also special for dragon, bear, and
1099 * troll. Treasures special for troll. */
1101 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1102 command->obj = ROD2;
1103 if (!TOTING(command->obj)) {
1104 rspeak(actions[command->verb].message);
1107 if (objects[command->obj].is_treasure && AT(TROLL)) {
1108 /* Snarf a treasure for the troll. */
1109 drop(command->obj, LOC_NOWHERE);
1110 move(TROLL, LOC_NOWHERE);
1111 move(TROLL + NOBJECTS, LOC_NOWHERE);
1112 drop(TROLL2, objects[TROLL].plac);
1113 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1115 rspeak(TROLL_SATISFIED);
1118 if (command->obj == FOOD && HERE(BEAR)) {
1119 /* But throwing food is another story. */
1120 command->obj = BEAR;
1121 return (feed(command->verb, command->obj));
1123 if (command->obj != AXE)
1124 return (discard(command->verb, command->obj, false));
1126 if (atdwrf(game.loc) <= 0) {
1127 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1128 return throw_support(DRAGON_SCALES);
1130 return throw_support(TROLL_RETURNS);
1132 return throw_support(OGRE_DODGE);
1133 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1134 /* This'll teach him to throw the axe at the bear! */
1135 drop(AXE, game.loc);
1136 game.fixed[AXE] = -1;
1138 state_change(AXE, AXE_LOST);
1141 command->obj = NO_OBJECT;
1142 return (attack(command));
1145 if (randrange(NDWARVES + 1) < game.dflag) {
1146 return throw_support(DWARF_DODGES);
1148 long i = atdwrf(game.loc);
1149 game.dseen[i] = false;
1150 game.dloc[i] = LOC_NOWHERE;
1151 return throw_support((++game.dkill == 1) ?
1158 static int wake(token_t verb, token_t obj)
1159 /* Wake. Only use is to disturb the dwarves. */
1163 rspeak(actions[verb].message);
1167 return GO_DWARFWAKE;
1171 static int wave(token_t verb, token_t obj)
1172 /* Wave. No effect unless waving rod at fissure or at bird. */
1179 rspeak(((!TOTING(obj)) && (obj != ROD ||
1182 actions[verb].message);
1186 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1187 drop(JADE, game.loc);
1188 game.prop[JADE] = 0;
1190 rspeak(NECKLACE_FLY);
1194 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1197 return GO_DWARFWAKE;
1201 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1207 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1211 /* FIXME: Arithemetic on property values */
1212 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1213 pspeak(FISSURE, look, 2 - game.prop[FISSURE], true);
1218 int action(struct command_t *command)
1219 /* Analyse a verb. Remember what it was, go back for object if second word
1220 * unless verb is "say", which snarfs arbitrary second word.
1223 if (command->part == unknown) {
1224 /* Analyse an object word. See if the thing is here, whether
1225 * we've got a verb yet, and so on. Object must be here
1226 * unless verb is "find" or "invent(ory)" (and no new verb
1227 * yet to be analysed). Water and oil are also funny, since
1228 * they are never actually dropped at any location, but might
1229 * be here inside the bottle or urn or as a feature of the
1231 if (HERE(command->obj))
1233 else if (command->obj == GRATE) {
1234 if (game.loc == LOC_START ||
1235 game.loc == LOC_VALLEY ||
1236 game.loc == LOC_SLIT) {
1237 command->obj = DPRSSN;
1239 if (game.loc == LOC_COBBLE ||
1240 game.loc == LOC_DEBRIS ||
1241 game.loc == LOC_AWKWARD ||
1242 game.loc == LOC_BIRD ||
1243 game.loc == LOC_PITTOP) {
1244 command->obj = ENTRNC;
1246 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1248 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1249 command->obj == LIQLOC(game.loc))
1251 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1254 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1255 command->obj = PLANT2;
1257 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1259 rspeak(KNIVES_VANISH);
1261 } else if (command->obj == ROD && HERE(ROD2)) {
1262 command->obj = ROD2;
1264 } else if ((command->verb == FIND ||
1265 command->verb == INVENTORY) && command->wd2 <= 0)
1268 sspeak(NO_SEE, command->raw1);
1272 if (command->wd2 > 0)
1274 if (command->verb != 0)
1275 command->part = transitive;
1278 switch (command->part) {
1280 if (command->wd2 > 0 && command->verb != SAY)
1282 if (command->verb == SAY)
1283 command->obj = command->wd2;
1284 if (command->obj == 0 ||
1285 command->obj == INTRANSITIVE) {
1286 /* Analyse an intransitive verb (ie, no object given yet). */
1287 switch (command->verb) {
1289 return vcarry(command->verb, INTRANSITIVE);
1295 return lock(command->verb, INTRANSITIVE);
1298 return (GO_CLEAROBJ);
1301 return lock(command->verb, INTRANSITIVE);
1303 return light(command->verb, INTRANSITIVE);
1305 return extinguish(command->verb, INTRANSITIVE);
1311 rspeak(actions[command->verb].message);
1315 return attack(command);
1317 return pour(command->verb, command->obj);
1319 return eat(command->verb, INTRANSITIVE);
1321 return drink(command->verb, command->obj);
1335 return fill(command->verb, command->obj);
1343 return bigwords(command->wd1);
1347 command->obj = INTRANSITIVE;
1348 return read(*command);
1358 return fly(command->verb, INTRANSITIVE);
1364 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1369 /* Analyse a transitive verb. */
1370 switch (command->verb) {
1372 return vcarry(command->verb, command->obj);
1374 return discard(command->verb, command->obj, false);
1376 return say(command);
1378 return lock(command->verb, command->obj);
1381 return (GO_CLEAROBJ);
1384 return lock(command->verb, command->obj);
1386 return light(command->verb, command->obj);
1388 return extinguish(command->verb, command->obj);
1390 return wave(command->verb, command->obj);
1392 rspeak(actions[command->verb].message);
1396 rspeak(actions[command->verb].message);
1400 return attack(command);
1402 return pour(command->verb, command->obj);
1404 return eat(command->verb, command->obj);
1406 return drink(command->verb, command->obj);
1408 return rub(command->verb, command->obj);
1410 return throw (command);
1412 rspeak(actions[command->verb].message);
1416 return find(command->verb, command->obj);
1418 return find(command->verb, command->obj);
1420 return feed(command->verb, command->obj);
1422 return fill(command->verb, command->obj);
1427 rspeak(actions[command->verb].message);
1431 rspeak(actions[command->verb].message);
1435 rspeak(actions[command->verb].message);
1439 return read(*command);
1441 return vbreak(command->verb, command->obj);
1443 return wake(command->verb, command->obj);
1445 rspeak(actions[command->verb].message);
1449 rspeak(actions[command->verb].message);
1453 return fly(command->verb, command->obj);
1455 rspeak(actions[command->verb].message);
1461 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1464 /* Unknown verb, couldn't deduce object - might need hint */
1465 sspeak(WHAT_DO, command->raw1);
1466 return GO_CHECKHINT;
1468 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE