6 static int fill(token_t, token_t);
8 static void state_change(long obj, long state)
10 game.prop[obj] = state;
11 pspeak(obj, change, state, true);
14 static int attack(struct command_t *command)
15 /* Attack. Assume target if unambiguous. "Throw" also links here.
16 * Attackable objects fall into two categories: enemies (snake,
17 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
18 * enemies, or no enemies but 2 others. */
20 vocab_t verb = command->verb;
21 vocab_t obj = command->obj;
23 long spk = actions[verb].message;
24 if (obj == NO_OBJECT ||
25 obj == INTRANSITIVE) {
27 if (atdwrf(game.loc) > 0) {
35 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
47 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
51 /* check for low-priority targets */
52 if (obj == NO_OBJECT) {
53 /* Can't attack bird or machine by throwing axe. */
54 if (HERE(BIRD) && verb != THROW) {
58 if (HERE(VEND) && verb != THROW) {
62 /* Clam and oyster both treated as clam for intransitive case;
64 if (HERE(CLAM) || HERE(OYSTER)) {
80 } else if (obj == VEND) {
82 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
90 spk = SHELL_IMPERVIOUS;
94 spk = BARE_HANDS_QUERY;
95 if (obj == DWARF && game.closed)
103 if (obj == OGRE && atdwrf(game.loc) > 0) {
105 rspeak(KNIFE_THROWN);
108 for (int i = 1; i < PIRATE; i++) {
109 if (game.dloc[i] == game.loc) {
111 game.dloc[i] = LOC_LONGWEST;
112 game.dseen[i] = false;
115 spk = (dwarves > 1) ?
118 } else if (obj == BEAR) {
119 switch (game.prop[BEAR]) {
133 } else if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
134 /* Fun stuff for dragon. If he insists on attacking it, win!
135 * Set game.prop to dead, move dragon to central loc (still
136 * fixed), move rug there (not fixed), and move him there,
137 * too. Then do a null motion to get new description. */
138 rspeak(BARE_HANDS_QUERY);
140 // FIXME: setting wd1 is a workaround for broken logic
141 command->wd1 = token_to_packed("Y");
143 // FIXME: setting wd1 is a workaround for broken logic
144 command->wd1 = token_to_packed("N");
147 state_change(DRAGON, DRAGON_DEAD);
148 game.prop[RUG] = RUG_FLOOR;
149 /* FIXME: Arithmetic on location values */
150 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
151 move(DRAGON + NOBJECTS, -1);
152 move(RUG + NOBJECTS, 0);
156 for (obj = 1; obj <= NOBJECTS; obj++) {
157 if (game.place[obj] == objects[DRAGON].plac ||
158 game.place[obj] == objects[DRAGON].fixd)
169 static int bigwords(token_t foo)
170 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
171 * Look up foo in special section of vocab to determine which word we've got.
172 * Last word zips the eggs back to the giant room (unless already there). */
175 packed_to_token(foo, word);
176 int k = (int) get_special_vocab_id(word);
177 int spk = NOTHING_HAPPENS;
178 if (game.foobar != 1 - k) {
179 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)
190 if (game.place[EGGS] == objects[EGGS].plac ||
191 (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
195 /* Bring back troll if we steal the eggs back from him before
197 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
198 game.prop[TROLL] = TROLL_PAIDONCE;
202 if (game.loc == objects[EGGS].plac)
204 move(EGGS, objects[EGGS].plac);
205 pspeak(EGGS, look, k, true);
211 static int bivalve(token_t verb, token_t obj)
212 /* Clam/oyster actions */
214 bool is_oyster = (obj == OYSTER);
219 if (!TOTING(TRIDENT)) {
234 drop(OYSTER, game.loc);
235 drop(PEARL, LOC_CULDESAC);
243 static void blast(void)
244 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
246 if (game.prop[ROD2] < 0 ||
248 rspeak(REQUIRES_DYNAMITE);
250 game.bonus = VICTORY_MESSAGE;
251 if (game.loc == LOC_NE)
252 game.bonus = DEFEAT_MESSAGE;
254 game.bonus = SPLATTER_MESSAGE;
260 static int vbreak(token_t verb, token_t obj)
261 /* Break. Only works for mirror in repository and, of course, the vase. */
265 rspeak(BREAK_MIRROR);
272 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
274 drop(VASE, game.loc);
275 state_change(VASE, VASE_BROKEN);
276 game.fixed[VASE] = -1;
279 rspeak(actions[verb].message);
280 return (GO_CLEAROBJ);
283 static int brief(void)
284 /* Brief. Intransitive only. Suppress long descriptions after first time. */
288 rspeak(BRIEF_CONFIRM);
292 static int vcarry(token_t verb, token_t obj)
293 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
294 * take one without the other). Liquids also special, since they depend on
295 * status of bottle. Also various side effects, etc. */
298 if (obj == INTRANSITIVE) {
299 /* Carry, no object given yet. OK if only one object present. */
300 if (game.atloc[game.loc] == 0 ||
301 game.link[game.atloc[game.loc]] != 0 ||
302 atdwrf(game.loc) > 0)
304 obj = game.atloc[game.loc];
308 rspeak(ALREADY_CARRYING);
312 if (obj == PLANT && game.prop[PLANT] <= 0)
314 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
316 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
321 spk = DOUGHNUT_HOLES;
324 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
327 spk = HAND_PASSTHROUGH;
329 rspeak(REMOVE_MESSAGE);
333 if (game.fixed[obj] != 0) {
341 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
342 return (fill(verb, BOTTLE));
344 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
356 if (game.holdng >= INVLIMIT) {
359 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
360 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
369 if (spk == CANNOT_CARRY ||
370 spk == BIRD_EVADES) {
374 game.prop[BIRD] = BIRD_CAGED;
376 /* FIXME: Arithmetic on state numbers */
379 (game.prop[BIRD] == BIRD_CAGED ||
380 -1 - game.prop[BIRD] == 1))
381 carry(BIRD + CAGE - obj, game.loc);
382 carry(obj, game.loc);
383 if (obj == BOTTLE && LIQUID() != 0)
384 game.place[LIQUID()] = CARRIED;
385 if (GSTONE(obj) && game.prop[obj] != 0) {
386 game.prop[obj] = STATE_GROUND;
387 game.prop[CAVITY] = CAVITY_EMPTY;
393 static int chain(token_t verb)
394 /* Do something to the bear's chain */
398 spk = CHAIN_UNLOCKED;
399 if (game.prop[BEAR] == UNTAMED_BEAR)
401 if (game.prop[CHAIN] == CHAIN_HEAP)
402 spk = ALREADY_UNLOCKED;
403 if (spk != CHAIN_UNLOCKED) {
407 game.prop[CHAIN] = CHAIN_HEAP;
408 game.fixed[CHAIN] = CHAIN_HEAP;
409 if (game.prop[BEAR] != BEAR_DEAD)
410 game.prop[BEAR] = CONTENTED_BEAR;
411 /* FIXME: Arithmetic on state numbers */
412 game.fixed[BEAR] = 2 - game.prop[BEAR];
415 if (game.prop[CHAIN] != CHAIN_HEAP)
416 spk = ALREADY_LOCKED;
417 if (game.loc != objects[CHAIN].plac)
419 if (spk != CHAIN_LOCKED) {
423 game.prop[CHAIN] = CHAIN_FIXED;
425 drop(CHAIN, game.loc);
426 game.fixed[CHAIN] = -1;
432 static int discard(token_t verb, token_t obj, bool just_do_it)
433 /* Discard object. "Throw" also comes here for most objects. Special cases for
434 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
435 * Drop coins at vending machine for extra batteries. */
437 int spk = actions[verb].message;
439 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
445 if (obj == BIRD && HERE(SNAKE)) {
446 rspeak(BIRD_ATTACKS);
450 /* Set game.prop for use by travel options */
451 game.prop[SNAKE] = SNAKE_CHASED;
453 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
456 game.prop[CAVITY] = CAVITY_FULL;
457 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
458 (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
465 if (spk != RUG_WIGGLES) {
466 /* FIXME: Arithmetic on state numbers */
467 int k = 2 - game.prop[RUG];
470 k = objects[SAPPH].plac;
471 move(RUG + NOBJECTS, k);
474 } else if (obj == COINS && HERE(VEND)) {
476 drop(BATTERY, game.loc);
477 pspeak(BATTERY, look, FRESH_BATTERIES, true);
479 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
483 } else if (obj == BEAR && AT(TROLL)) {
484 rspeak(TROLL_SCAMPERS);
485 move(TROLL, LOC_NOWHERE);
486 move(TROLL + NOBJECTS, LOC_NOWHERE);
487 move(TROLL2, objects[TROLL].plac);
488 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
490 game.prop[TROLL] = TROLL_GONE;
491 } else if (obj != VASE ||
492 game.loc == objects[PILLOW].plac) {
495 game.prop[VASE] = VASE_BROKEN;
497 game.prop[VASE] = VASE_WHOLE;
498 pspeak(VASE, look, game.prop[VASE] + 1, true);
499 if (game.prop[VASE] != VASE_WHOLE)
500 game.fixed[VASE] = -1;
506 if (obj == BOTTLE && k != 0)
507 game.place[k] = LOC_NOWHERE;
508 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
509 drop(BIRD, game.loc);
513 game.prop[BIRD] = BIRD_UNCAGED;
514 if (FOREST(game.loc))
515 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
519 static int drink(token_t verb, token_t obj)
520 /* Drink. If no object, assume water and look for it here. If water is in
521 * the bottle, drink that, else must be at a water loc, so drink stream. */
523 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER && (LIQUID() != WATER ||
527 if (obj != NO_OBJECT && obj != WATER) {
528 rspeak(RIDICULOUS_ATTEMPT);
529 } else if (LIQUID() == WATER && HERE(BOTTLE)) {
530 game.prop[BOTTLE] = EMPTY_BOTTLE;
531 game.place[WATER] = LOC_NOWHERE;
532 rspeak(BOTTLE_EMPTY);
534 rspeak(actions[verb].message);
538 state_change(DRAGON, DRAGON_BLOODLESS);
544 static int eat(token_t verb, token_t obj)
545 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
546 * ok, some things lose appetite, rest are ridiculous. */
548 if (obj == INTRANSITIVE) {
552 rspeak(THANKS_DELICIOUS);
557 rspeak(THANKS_DELICIOUS);
569 rspeak(LOST_APPETITE);
572 rspeak(actions[verb].message);
576 static int extinguish(token_t verb, int obj)
577 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
579 if (obj == INTRANSITIVE) {
580 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
582 if (HERE(URN) && game.prop[URN] == URN_LIT)
584 if (obj == INTRANSITIVE ||
585 (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT &&
586 HERE(URN) && game.prop[URN] == URN_LIT))
591 if (game.prop[URN] != URN_EMPTY) {
592 state_change(URN, URN_DARK);
594 pspeak(URN, change, URN_DARK, true);
597 } else if (obj == LAMP) {
598 state_change(LAMP, LAMP_DARK);
599 rspeak(DARK(game.loc) ?
603 } else if (obj == DRAGON ||
605 rspeak(BEYOND_POWER);
608 rspeak(actions[verb].message);
613 static int feed(token_t verb, token_t obj)
614 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
615 * mad. Bear, special. */
617 int spk = actions[verb].message;
621 } else if (obj == SNAKE ||
624 spk = NOTHING_EDIBLE;
625 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
626 spk = RIDICULOUS_ATTEMPT;
629 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
633 } else if (obj == DWARF) {
638 } else if (obj == BEAR) {
639 if (game.prop[BEAR] == UNTAMED_BEAR)
640 spk = NOTHING_EDIBLE;
641 if (game.prop[BEAR] == BEAR_DEAD)
642 spk = RIDICULOUS_ATTEMPT;
645 game.prop[BEAR] = SITTING_BEAR;
650 } else if (obj == OGRE) {
660 int fill(token_t verb, token_t obj)
661 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
665 int spk = actions[verb].message;
667 spk = ARENT_CARRYING;
668 if (LIQLOC(game.loc) == 0)
670 if (LIQLOC(game.loc) == 0 ||
675 rspeak(SHATTER_VASE);
676 game.prop[VASE] = VASE_BROKEN;
677 game.fixed[VASE] = -1;
678 return (discard(verb, obj, true));
679 } else if (obj == URN) {
681 if (game.prop[URN] != URN_EMPTY) {
692 game.place[k] = LOC_NOWHERE;
693 game.prop[BOTTLE] = EMPTY_BOTTLE;
695 game.prop[URN] = URN_DARK;
696 spk = WATER_URN + game.prop[URN];
699 } else if (obj != NO_OBJECT && obj != BOTTLE) {
702 } else if (obj == NO_OBJECT && !HERE(BOTTLE))
705 if (LIQLOC(game.loc) == 0)
707 if (HERE(URN) && game.prop[URN] != URN_EMPTY)
711 if (spk == BOTTLED_WATER) {
712 /* FIXME: Arithmetic on property values */
713 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
716 game.place[k] = CARRIED;
724 static int find(token_t verb, token_t obj)
725 /* Find. Might be carrying it, or it might be here. Else give caveat. */
727 int spk = actions[verb].message;
729 (LIQUID() == obj && AT(BOTTLE)) ||
730 obj == LIQLOC(game.loc) ||
731 (obj == DWARF && atdwrf(game.loc) > 0))
736 spk = ALREADY_CARRYING;
741 static int fly(token_t verb, token_t obj)
742 /* Fly. Snide remarks unless hovering rug is here. */
744 if (obj == INTRANSITIVE) {
749 if (game.prop[RUG] != RUG_HOVER) {
750 rspeak(RUG_NOTHING2);
757 rspeak(actions[verb].message);
760 if (game.prop[RUG] != RUG_HOVER) {
761 rspeak(RUG_NOTHING1);
764 game.oldlc2 = game.oldloc;
765 game.oldloc = game.loc;
766 /* FIXME: Arithmetic on location values */
767 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
769 if (game.prop[SAPPH] >= 0) {
777 static int inven(void)
778 /* Inventory. If object, treat same as find. Else report on current burden. */
781 for (int i = 1; i <= NOBJECTS; i++) {
787 pspeak(i, touch, -1, false);
796 static int light(token_t verb, token_t obj)
797 /* Light. Applicable only to lamp and urn. */
799 if (obj == INTRANSITIVE) {
800 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
802 if (HERE(URN) && game.prop[URN] == URN_DARK)
804 if (obj == INTRANSITIVE ||
805 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
806 HERE(URN) && game.prop[URN] == URN_DARK))
811 state_change(URN, game.prop[URN] == URN_EMPTY ?
817 rspeak(actions[verb].message);
820 if (game.limit < 0) {
824 state_change(LAMP, LAMP_BRIGHT);
832 static int listen(void)
833 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
835 long sound = locations[game.loc].sound;
836 if (sound != SILENT) {
838 if (!locations[game.loc].loud)
842 for (int i = 1; i <= NOBJECTS; i++) {
844 objects[i].sounds[0] == NULL ||
847 int mi = game.prop[i];
849 mi += 3 * game.blooded;
850 long packed_zzword = token_to_packed(game.zzword);
851 pspeak(i, hear, mi, true, packed_zzword);
853 /* FIXME: Magic number, sensitive to bird state logic */
854 if (i == BIRD && game.prop[i] == 5)
862 static int lock(token_t verb, token_t obj)
863 /* Lock, unlock, no object given. Assume various things if present. */
865 if (obj == INTRANSITIVE) {
876 if (obj == NO_OBJECT ||
877 obj == INTRANSITIVE) {
878 rspeak(NOTHING_LOCKED);
883 /* Lock, unlock object. Special stuff for opening clam/oyster
885 int spk = actions[verb].message;
886 if (obj == CLAM || obj == OYSTER)
887 return bivalve(verb, obj);
889 spk = (game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR;
903 game.clock2 = PANICTIME;
906 state_change(GRATE, (verb == LOCK) ?
917 static int pour(token_t verb, token_t obj)
918 /* Pour. If no object, or object is bottle, assume contents of bottle.
919 * special tests for pouring water or oil on plant or rusty door. */
924 if (obj == NO_OBJECT)
927 rspeak(actions[verb].message);
931 if (obj != OIL && obj != WATER) {
935 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
936 return fill(verb, URN);
937 game.prop[BOTTLE] = EMPTY_BOTTLE;
938 game.place[obj] = LOC_NOWHERE;
946 rspeak(SHAKING_LEAVES);
949 /* FIXME: Arithmetic on state numbers */
950 pspeak(PLANT, look, game.prop[PLANT] + 3, true);
951 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
952 game.prop[PLANT2] = game.prop[PLANT];
955 state_change(DOOR, (obj == OIL) ?
962 static int quit(void)
963 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
965 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
970 static int read(struct command_t command)
971 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
973 if (command.obj == INTRANSITIVE) {
975 for (int i = 1; i <= NOBJECTS; i++) {
976 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
977 command.obj = command.obj * NOBJECTS + i;
979 if (command.obj > NOBJECTS ||
985 if (DARK(game.loc)) {
986 rspeak(NO_SEE, command.wd1, command.wd1x);
987 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
988 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
989 } else if (objects[command.obj].texts[0] == NULL ||
990 game.prop[command.obj] < 0) {
991 rspeak(actions[command.verb].message);
993 pspeak(command.obj, study, game.prop[command.obj], true);
997 static int reservoir(void)
998 /* Z'ZZZ (word gets recomputed at startup; different each game). */
1000 /* FIXME: Arithmetic on state numbers */
1001 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
1002 rspeak(NOTHING_HAPPENS);
1005 /* FIXME: Arithmetic on state numbers */
1006 pspeak(RESER, look, game.prop[RESER] + 1, true);
1007 game.prop[RESER] = 1 - game.prop[RESER];
1011 game.oldlc2 = game.loc;
1012 game.newloc = LOC_NOWHERE;
1014 return GO_TERMINATE;
1019 static int rub(token_t verb, token_t obj)
1020 /* Rub. Yields various snide remarks except for lit urn. */
1022 if (obj == URN && game.prop[URN] == URN_LIT) {
1024 drop(AMBER, game.loc);
1025 game.prop[AMBER] = AMBER_IN_ROCK;
1027 drop(CAVITY, game.loc);
1029 } else if (obj != LAMP) {
1030 rspeak(PECULIAR_NOTHING);
1032 rspeak(actions[verb].message);
1037 static int say(struct command_t *command)
1038 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
1040 long a = command->wd1, b = command->wd1x;
1041 if (command->wd2 > 0) {
1044 command->wd1 = command->wd2;
1047 packed_to_token(command->wd1, word1);
1048 int wd = (int) get_vocab_id(word1);
1049 /* FIXME: magic numbers */
1050 if (wd == MOTION_WORD(XYZZY) ||
1051 wd == MOTION_WORD(PLUGH) ||
1052 wd == MOTION_WORD(PLOVER) ||
1053 wd == ACTION_WORD(GIANTWORDS) ||
1054 wd == ACTION_WORD(PART)) {
1055 /* FIXME: scribbles on the interpreter's command block */
1056 wordclear(&command->wd2);
1059 rspeak(OKEY_DOKEY, a, b);
1063 static int throw_support(long spk)
1066 drop(AXE, game.loc);
1070 static int throw (struct command_t *command)
1071 /* Throw. Same as discard unless axe. Then same as attack except
1072 * ignore bird, and if dwarf is present then one might be killed.
1073 * (Only way to do so!) Axe also special for dragon, bear, and
1074 * troll. Treasures special for troll. */
1076 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1077 command->obj = ROD2;
1078 if (!TOTING(command->obj)) {
1079 rspeak(actions[command->verb].message);
1082 if (objects[command->obj].is_treasure && AT(TROLL)) {
1083 /* Snarf a treasure for the troll. */
1084 drop(command->obj, LOC_NOWHERE);
1085 move(TROLL, LOC_NOWHERE);
1086 move(TROLL + NOBJECTS, LOC_NOWHERE);
1087 drop(TROLL2, objects[TROLL].plac);
1088 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1090 rspeak(TROLL_SATISFIED);
1093 if (command->obj == FOOD && HERE(BEAR)) {
1094 /* But throwing food is another story. */
1095 command->obj = BEAR;
1096 return (feed(command->verb, command->obj));
1098 if (command->obj != AXE)
1099 return (discard(command->verb, command->obj, false));
1101 if (atdwrf(game.loc) <= 0) {
1102 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1103 return throw_support(DRAGON_SCALES);
1105 return throw_support(TROLL_RETURNS);
1107 return throw_support(OGRE_DODGE);
1108 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1109 /* This'll teach him to throw the axe at the bear! */
1110 drop(AXE, game.loc);
1111 game.fixed[AXE] = -1;
1113 state_change(AXE, AXE_LOST);
1116 command->obj = NO_OBJECT;
1117 return (attack(command));
1120 if (randrange(NDWARVES + 1) < game.dflag) {
1121 return throw_support(DWARF_DODGES);
1123 long i = atdwrf(game.loc);
1124 game.dseen[i] = false;
1125 game.dloc[i] = LOC_NOWHERE;
1126 return throw_support((++game.dkill == 1) ?
1133 static int wake(token_t verb, token_t obj)
1134 /* Wake. Only use is to disturb the dwarves. */
1138 rspeak(actions[verb].message);
1142 return GO_DWARFWAKE;
1146 static int wave(token_t verb, token_t obj)
1147 /* Wave. No effect unless waving rod at fissure or at bird. */
1154 rspeak(((!TOTING(obj)) && (obj != ROD ||
1157 actions[verb].message);
1161 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1162 drop(JADE, game.loc);
1163 game.prop[JADE] = 0;
1165 rspeak(NECKLACE_FLY);
1169 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1172 return GO_DWARFWAKE;
1176 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1182 rspeak((game.prop[BIRD] == BIRD_CAGED) ?
1186 /* FIXME: Arithemetic on property values */
1187 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1188 pspeak(FISSURE, look, 2 - game.prop[FISSURE], true);
1193 int action(struct command_t *command)
1194 /* Analyse a verb. Remember what it was, go back for object if second word
1195 * unless verb is "say", which snarfs arbitrary second word.
1198 if (command->part == unknown) {
1199 /* Analyse an object word. See if the thing is here, whether
1200 * we've got a verb yet, and so on. Object must be here
1201 * unless verb is "find" or "invent(ory)" (and no new verb
1202 * yet to be analysed). Water and oil are also funny, since
1203 * they are never actually dropped at any location, but might
1204 * be here inside the bottle or urn or as a feature of the
1206 if (HERE(command->obj))
1208 else if (command->obj == GRATE) {
1209 if (game.loc == LOC_START ||
1210 game.loc == LOC_VALLEY ||
1211 game.loc == LOC_SLIT) {
1212 command->obj = DPRSSN;
1214 if (game.loc == LOC_COBBLE ||
1215 game.loc == LOC_DEBRIS ||
1216 game.loc == LOC_AWKWARD ||
1217 game.loc == LOC_BIRD ||
1218 game.loc == LOC_PITTOP) {
1219 command->obj = ENTRNC;
1221 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1223 else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
1224 command->obj == LIQLOC(game.loc))
1226 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1229 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1230 command->obj = PLANT2;
1232 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1234 rspeak(KNIVES_VANISH);
1236 } else if (command->obj == ROD && HERE(ROD2)) {
1237 command->obj = ROD2;
1239 } else if ((command->verb == FIND ||
1240 command->verb == INVENTORY) && command->wd2 <= 0)
1243 rspeak(NO_SEE, command->wd1, command->wd1x);
1247 if (command->wd2 > 0)
1249 if (command->verb != 0)
1250 command->part = transitive;
1253 switch (command->part) {
1255 if (command->wd2 > 0 && command->verb != SAY)
1257 if (command->verb == SAY)
1258 command->obj = command->wd2;
1259 if (command->obj == 0 ||
1260 command->obj == INTRANSITIVE) {
1261 /* Analyse an intransitive verb (ie, no object given yet). */
1262 switch (command->verb) {
1264 return vcarry(command->verb, INTRANSITIVE);
1270 return lock(command->verb, INTRANSITIVE);
1273 return (GO_CLEAROBJ);
1276 return lock(command->verb, INTRANSITIVE);
1278 return light(command->verb, INTRANSITIVE);
1280 return extinguish(command->verb, INTRANSITIVE);
1286 rspeak(actions[command->verb].message);
1290 return attack(command);
1292 return pour(command->verb, command->obj);
1294 return eat(command->verb, INTRANSITIVE);
1296 return drink(command->verb, command->obj);
1310 return fill(command->verb, command->obj);
1318 return bigwords(command->wd1);
1322 command->obj = INTRANSITIVE;
1323 return read(*command);
1333 return fly(command->verb, INTRANSITIVE);
1339 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1344 /* Analyse a transitive verb. */
1345 switch (command->verb) {
1347 return vcarry(command->verb, command->obj);
1349 return discard(command->verb, command->obj, false);
1351 return say(command);
1353 return lock(command->verb, command->obj);
1356 return (GO_CLEAROBJ);
1359 return lock(command->verb, command->obj);
1361 return light(command->verb, command->obj);
1363 return extinguish(command->verb, command->obj);
1365 return wave(command->verb, command->obj);
1367 rspeak(actions[command->verb].message);
1371 rspeak(actions[command->verb].message);
1375 return attack(command);
1377 return pour(command->verb, command->obj);
1379 return eat(command->verb, command->obj);
1381 return drink(command->verb, command->obj);
1383 return rub(command->verb, command->obj);
1385 return throw (command);
1387 rspeak(actions[command->verb].message);
1391 return find(command->verb, command->obj);
1393 return find(command->verb, command->obj);
1395 return feed(command->verb, command->obj);
1397 return fill(command->verb, command->obj);
1402 rspeak(actions[command->verb].message);
1406 rspeak(actions[command->verb].message);
1410 rspeak(actions[command->verb].message);
1414 return read(*command);
1416 return vbreak(command->verb, command->obj);
1418 return wake(command->verb, command->obj);
1420 rspeak(actions[command->verb].message);
1424 rspeak(actions[command->verb].message);
1428 return fly(command->verb, command->obj);
1430 rspeak(actions[command->verb].message);
1436 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1439 /* Unknown verb, couldn't deduce object - might need hint */
1440 rspeak(WHAT_DO, command->wd1, command->wd1x);
1441 return GO_CHECKHINT;
1443 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE