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 if (obj == INTRANSITIVE) {
26 long spk = actions[verb].message;
27 if (obj == NO_OBJECT || obj == INTRANSITIVE) {
29 if (atdwrf(game.loc) > 0) {
37 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
49 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
53 /* check for low-priority targets */
54 if (obj == NO_OBJECT) {
55 /* Can't attack bird or machine by throwing axe. */
56 if (HERE(BIRD) && verb != THROW) {
60 if (HERE(VEND) && verb != THROW) {
64 /* Clam and oyster both treated as clam for intransitive case;
66 if (HERE(CLAM) || HERE(OYSTER)) {
82 } else if (obj == VEND) {
84 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
90 if (obj == CLAM || obj == OYSTER)
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) ? OGRE_PANIC1 : OGRE_PANIC2;
117 } else if (obj == BEAR) {
118 switch (game.prop[BEAR]) {
132 } else if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
133 /* Fun stuff for dragon. If he insists on attacking it, win!
134 * Set game.prop to dead, move dragon to central loc (still
135 * fixed), move rug there (not fixed), and move him there,
136 * too. Then do a null motion to get new description. */
137 rspeak(BARE_HANDS_QUERY);
139 // FIXME: setting wd1 is a workaround for broken logic
140 command->wd1 = token_to_packed("Y");
142 // FIXME: setting wd1 is a workaround for broken logic
143 command->wd1 = token_to_packed("N");
146 state_change(DRAGON, DRAGON_DEAD);
147 game.prop[RUG] = RUG_FLOOR;
148 /* FIXME: Arithmetic on location values */
149 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
150 move(DRAGON + NOBJECTS, -1);
151 move(RUG + NOBJECTS, 0);
155 for (obj = 1; obj <= NOBJECTS; obj++) {
156 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
167 static int bigwords(token_t foo)
168 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
169 * Look up foo in special section of vocab to determine which word we've got.
170 * Last word zips the eggs back to the giant room (unless already there). */
173 packed_to_token(foo, word);
174 int k = (int) get_special_vocab_id(word);
175 int spk = NOTHING_HAPPENS;
176 if (game.foobar != 1 - k) {
177 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)
188 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
192 /* Bring back troll if we steal the eggs back from him before
194 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
195 game.prop[TROLL] = TROLL_PAIDONCE;
199 if (game.loc == objects[EGGS].plac)
201 move(EGGS, objects[EGGS].plac);
202 pspeak(EGGS, look, k, true);
208 static int bivalve(token_t verb, token_t obj)
209 /* Clam/oyster actions */
212 bool is_oyster = (obj == OYSTER);
213 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
215 spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
216 if (!TOTING(TRIDENT))
217 spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
220 if (spk == PEARL_FALLS) {
222 drop(OYSTER, game.loc);
223 drop(PEARL, LOC_CULDESAC);
229 static void blast(void)
230 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
232 if (game.prop[ROD2] < 0 || !game.closed)
233 rspeak(REQUIRES_DYNAMITE);
235 game.bonus = VICTORY_MESSAGE;
236 if (game.loc == LOC_NE)
237 game.bonus = DEFEAT_MESSAGE;
239 game.bonus = SPLATTER_MESSAGE;
245 static int vbreak(token_t verb, token_t obj)
246 /* Break. Only works for mirror in repository and, of course, the vase. */
250 rspeak(BREAK_MIRROR);
257 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
259 drop(VASE, game.loc);
260 state_change(VASE, VASE_BROKEN);
261 game.fixed[VASE] = -1;
264 rspeak(actions[verb].message);
265 return (GO_CLEAROBJ);
268 static int brief(void)
269 /* Brief. Intransitive only. Suppress long descriptions after first time. */
273 rspeak(BRIEF_CONFIRM);
277 static int vcarry(token_t verb, token_t obj)
278 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
279 * take one without the other). Liquids also special, since they depend on
280 * status of bottle. Also various side effects, etc. */
283 if (obj == INTRANSITIVE) {
284 /* Carry, no object given yet. OK if only one object present. */
285 if (game.atloc[game.loc] == 0 ||
286 game.link[game.atloc[game.loc]] != 0 ||
287 atdwrf(game.loc) > 0)
289 obj = game.atloc[game.loc];
293 rspeak(ALREADY_CARRYING);
297 if (obj == PLANT && game.prop[PLANT] <= 0)
299 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
301 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
306 spk = DOUGHNUT_HOLES;
309 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
312 spk = HAND_PASSTHROUGH;
314 rspeak(REMOVE_MESSAGE);
318 if (game.fixed[obj] != 0) {
322 if (obj == WATER || obj == OIL) {
323 if (!HERE(BOTTLE) || LIQUID() != obj) {
324 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
325 return (fill(verb, BOTTLE));
327 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
339 if (game.holdng >= INVLIMIT) {
342 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
343 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
352 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
356 game.prop[BIRD] = BIRD_CAGED;
358 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
359 carry(BIRD + CAGE - obj, game.loc);
360 carry(obj, game.loc);
361 if (obj == BOTTLE && LIQUID() != 0)
362 game.place[LIQUID()] = CARRIED;
363 if (GSTONE(obj) && game.prop[obj] != 0) {
364 game.prop[obj] = STATE_GROUND;
365 game.prop[CAVITY] = CAVITY_EMPTY;
371 static int chain(token_t verb)
372 /* Do something to the bear's chain */
376 spk = CHAIN_UNLOCKED;
377 if (game.prop[BEAR] == UNTAMED_BEAR)
379 if (game.prop[CHAIN] == CHAIN_HEAP)
380 spk = ALREADY_UNLOCKED;
381 if (spk != CHAIN_UNLOCKED) {
385 game.prop[CHAIN] = CHAIN_HEAP;
386 game.fixed[CHAIN] = CHAIN_HEAP;
387 if (game.prop[BEAR] != BEAR_DEAD)
388 game.prop[BEAR] = CONTENTED_BEAR;
389 /* FIXME: Arithmetic on state numbers */
390 game.fixed[BEAR] = 2 - game.prop[BEAR];
393 if (game.prop[CHAIN] != CHAIN_HEAP)
394 spk = ALREADY_LOCKED;
395 if (game.loc != objects[CHAIN].plac)
397 if (spk != CHAIN_LOCKED) {
401 game.prop[CHAIN] = CHAIN_FIXED;
403 drop(CHAIN, game.loc);
404 game.fixed[CHAIN] = -1;
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) || (obj == RUBY &&
436 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 rspeak(TROLL_SCAMPERS);
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 game.prop[TROLL] = TROLL_GONE;
469 } else if (obj != VASE || 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 && (LIQUID() != WATER || !HERE(BOTTLE)))
503 if (obj != NO_OBJECT && obj != WATER) {
504 rspeak(RIDICULOUS_ATTEMPT);
505 } else if (LIQUID() == WATER && HERE(BOTTLE)) {
506 game.prop[BOTTLE] = EMPTY_BOTTLE;
507 game.place[WATER] = LOC_NOWHERE;
508 rspeak(BOTTLE_EMPTY);
510 rspeak(actions[verb].message);
514 state_change(DRAGON, DRAGON_BLOODLESS);
520 static int eat(token_t verb, token_t obj)
521 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
522 * ok, some things lose appetite, rest are ridiculous. */
524 int spk = actions[verb].message;
525 if (obj == INTRANSITIVE) {
529 spk = THANKS_DELICIOUS;
533 spk = THANKS_DELICIOUS;
535 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
536 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
544 static int extinguish(token_t verb, int obj)
545 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
547 if (obj == INTRANSITIVE) {
548 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
550 if (HERE(URN) && game.prop[URN] == URN_LIT)
552 if (obj == INTRANSITIVE ||
553 (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT &&
554 HERE(URN) && game.prop[URN] == URN_LIT))
559 if (game.prop[URN] != URN_EMPTY) {
560 state_change(URN, URN_DARK);
562 pspeak(URN, change, URN_DARK, true);
565 } else if (obj == LAMP) {
566 state_change(LAMP, LAMP_DARK);
567 rspeak(DARK(game.loc) ? PITCH_DARK : NO_MESSAGE);
568 } else if (obj == DRAGON || obj == VOLCANO) {
569 rspeak(BEYOND_POWER);
572 rspeak(actions[verb].message);
577 static int feed(token_t verb, token_t obj)
578 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
579 * mad. Bear, special. */
581 int spk = actions[verb].message;
585 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
586 spk = NOTHING_EDIBLE;
587 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
588 spk = RIDICULOUS_ATTEMPT;
591 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
595 } else if (obj == DWARF) {
600 } else if (obj == BEAR) {
601 if (game.prop[BEAR] == UNTAMED_BEAR)
602 spk = NOTHING_EDIBLE;
603 if (game.prop[BEAR] == BEAR_DEAD)
604 spk = RIDICULOUS_ATTEMPT;
607 game.prop[BEAR] = SITTING_BEAR;
612 } else if (obj == OGRE) {
622 int fill(token_t verb, token_t obj)
623 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
627 int spk = actions[verb].message;
629 spk = ARENT_CARRYING;
630 if (LIQLOC(game.loc) == 0)
632 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
636 rspeak(SHATTER_VASE);
637 game.prop[VASE] = VASE_BROKEN;
638 game.fixed[VASE] = -1;
639 return (discard(verb, obj, true));
640 } else if (obj == URN) {
642 if (game.prop[URN] != URN_EMPTY) {
648 if (k == 0 || !HERE(BOTTLE)) {
652 game.place[k] = LOC_NOWHERE;
653 game.prop[BOTTLE] = EMPTY_BOTTLE;
655 game.prop[URN] = URN_DARK;
656 spk = WATER_URN + game.prop[URN];
659 } else if (obj != NO_OBJECT && obj != BOTTLE) {
662 } else if (obj == NO_OBJECT && !HERE(BOTTLE))
665 if (LIQLOC(game.loc) == 0)
667 if (HERE(URN) && game.prop[URN] != URN_EMPTY)
671 if (spk == BOTTLED_WATER) {
672 /* FIXME: Arithmetic on property values */
673 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
676 game.place[k] = CARRIED;
684 static int find(token_t verb, token_t obj)
685 /* Find. Might be carrying it, or it might be here. Else give caveat. */
687 int spk = actions[verb].message;
689 (LIQUID() == obj && AT(BOTTLE)) ||
690 obj == LIQLOC(game.loc) ||
691 (obj == DWARF && atdwrf(game.loc) > 0))
696 spk = ALREADY_CARRYING;
701 static int fly(token_t verb, token_t obj)
702 /* Fly. Snide remarks unless hovering rug is here. */
704 int spk = actions[verb].message;
705 if (obj == INTRANSITIVE) {
706 if (game.prop[RUG] != RUG_HOVER)
710 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
722 if (game.prop[RUG] != RUG_HOVER) {
726 game.oldlc2 = game.oldloc;
727 game.oldloc = game.loc;
728 /* FIXME: Arithmetic on location values */
729 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
731 if (game.prop[SAPPH] >= 0)
737 static int inven(void)
738 /* Inventory. If object, treat same as find. Else report on current burden. */
741 for (int i = 1; i <= NOBJECTS; i++) {
742 if (i == BEAR || !TOTING(i))
746 pspeak(i, touch, -1, false);
755 static int light(token_t verb, token_t obj)
756 /* Light. Applicable only to lamp and urn. */
758 if (obj == INTRANSITIVE) {
759 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
761 if (HERE(URN) && game.prop[URN] == URN_DARK)
763 if (obj == INTRANSITIVE ||
764 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
765 HERE(URN) && game.prop[URN] == URN_DARK))
770 state_change(URN, game.prop[URN] == URN_EMPTY ? URN_EMPTY : URN_LIT);
774 rspeak(actions[verb].message);
777 if (game.limit < 0) {
781 state_change(LAMP, LAMP_BRIGHT);
789 static int listen(void)
790 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
793 int spk = ALL_SILENT;
794 k = locations[game.loc].sound;
797 if (locations[game.loc].loud)
802 for (int i = 1; i <= NOBJECTS; i++) {
803 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
805 int mi = game.prop[i];
807 mi += 3 * game.blooded;
808 long packed_zzword = token_to_packed(game.zzword);
809 pspeak(i, hear, mi, true, packed_zzword);
811 /* FIXME: Magic number, sensitive to bird state logic */
812 if (i == BIRD && game.prop[i] == 5)
819 static int lock(token_t verb, token_t obj)
820 /* Lock, unlock, no object given. Assume various things if present. */
822 int spk = actions[verb].message;
823 if (obj == INTRANSITIVE) {
824 spk = NOTHING_LOCKED;
835 if (obj == NO_OBJECT || obj == INTRANSITIVE) {
841 /* Lock, unlock object. Special stuff for opening clam/oyster
843 if (obj == CLAM || obj == OYSTER)
844 return bivalve(verb, obj);
847 if (obj == DOOR && game.prop[DOOR] == DOOR_UNRUSTED)
853 if (obj == GRATE || obj == CHAIN) {
861 game.clock2 = PANICTIME;
864 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
873 static int pour(token_t verb, token_t obj)
874 /* Pour. If no object, or object is bottle, assume contents of bottle.
875 * special tests for pouring water or oil on plant or rusty door. */
877 int spk = actions[verb].message;
878 if (obj == BOTTLE || obj == NO_OBJECT)
880 if (obj == NO_OBJECT)
887 if (obj != OIL && obj != WATER) {
891 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
892 return fill(verb, URN);
893 game.prop[BOTTLE] = EMPTY_BOTTLE;
894 game.place[obj] = LOC_NOWHERE;
896 if (!(AT(PLANT) || AT(DOOR))) {
901 spk = SHAKING_LEAVES;
906 pspeak(PLANT, look, game.prop[PLANT] + 3, true);
907 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
908 game.prop[PLANT2] = game.prop[PLANT];
911 state_change(DOOR, (obj == OIL) ? DOOR_UNRUSTED : DOOR_RUSTED);
916 static int quit(void)
917 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
919 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
924 static int read(struct command_t command)
925 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
927 if (command.obj == INTRANSITIVE) {
929 for (int i = 1; i <= NOBJECTS; i++) {
930 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
931 command.obj = command.obj * NOBJECTS + i;
933 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
937 if (DARK(game.loc)) {
938 rspeak(NO_SEE, command.wd1, command.wd1x);
939 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
940 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
941 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
942 rspeak(actions[command.verb].message);
944 pspeak(command.obj, study, game.prop[command.obj], true);
948 static int reservoir(void)
949 /* Z'ZZZ (word gets recomputed at startup; different each game). */
951 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
952 rspeak(NOTHING_HAPPENS);
955 pspeak(RESER, look, game.prop[RESER] + 1, true);
956 game.prop[RESER] = 1 - game.prop[RESER];
960 game.oldlc2 = game.loc;
968 static int rub(token_t verb, token_t obj)
969 /* Rub. Yields various snide remarks except for lit urn. */
971 if (obj == URN && game.prop[URN] == URN_LIT) {
973 drop(AMBER, game.loc);
974 game.prop[AMBER] = AMBER_IN_ROCK;
976 drop(CAVITY, game.loc);
978 } else if (obj != LAMP) {
979 rspeak(PECULIAR_NOTHING);
981 rspeak(actions[verb].message);
986 static int say(struct command_t *command)
987 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
989 long a = command->wd1, b = command->wd1x;
990 if (command->wd2 > 0) {
993 command->wd1 = command->wd2;
996 packed_to_token(command->wd1, word1);
997 int wd = (int) get_vocab_id(word1);
998 /* FIXME: magic numbers */
999 if (wd == MOTION_WORD(XYZZY) || wd == MOTION_WORD(PLUGH) || wd == MOTION_WORD(PLOVER) || wd == ACTION_WORD(GIANTWORDS) || wd == ACTION_WORD(PART)) {
1000 /* FIXME: scribbles on the interpreter's command block */
1001 wordclear(&command->wd2);
1004 rspeak(OKEY_DOKEY, a, b);
1008 static int throw_support(long spk)
1011 drop(AXE, game.loc);
1015 static int throw (struct command_t *command)
1016 /* Throw. Same as discard unless axe. Then same as attack except
1017 * ignore bird, and if dwarf is present then one might be killed.
1018 * (Only way to do so!) Axe also special for dragon, bear, and
1019 * troll. Treasures special for troll. */
1021 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1022 command->obj = ROD2;
1023 if (!TOTING(command->obj)) {
1024 rspeak(actions[command->verb].message);
1027 if (objects[command->obj].is_treasure && AT(TROLL)) {
1028 /* Snarf a treasure for the troll. */
1029 drop(command->obj, LOC_NOWHERE);
1030 move(TROLL, LOC_NOWHERE);
1031 move(TROLL + NOBJECTS, LOC_NOWHERE);
1032 drop(TROLL2, objects[TROLL].plac);
1033 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1035 rspeak(TROLL_SATISFIED);
1038 if (command->obj == FOOD && HERE(BEAR)) {
1039 /* But throwing food is another story. */
1040 command->obj = BEAR;
1041 return (feed(command->verb, command->obj));
1043 if (command->obj != AXE)
1044 return (discard(command->verb, command->obj, false));
1046 if (atdwrf(game.loc) <= 0) {
1047 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1048 return throw_support(DRAGON_SCALES);
1050 return throw_support(TROLL_RETURNS);
1052 return throw_support(OGRE_DODGE);
1053 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1054 /* This'll teach him to throw the axe at the bear! */
1055 drop(AXE, game.loc);
1056 game.fixed[AXE] = -1;
1058 state_change(AXE, AXE_LOST);
1061 command->obj = NO_OBJECT;
1062 return (attack(command));
1065 if (randrange(NDWARVES + 1) < game.dflag) {
1066 return throw_support(DWARF_DODGES);
1068 long i = atdwrf(game.loc);
1069 game.dseen[i] = false;
1071 return throw_support((++game.dkill == 1)
1072 ? DWARF_SMOKE : KILLED_DWARF);
1077 static int wake(token_t verb, token_t obj)
1078 /* Wake. Only use is to disturb the dwarves. */
1080 if (obj != DWARF || !game.closed) {
1081 rspeak(actions[verb].message);
1085 return GO_DWARFWAKE;
1089 static token_t birdspeak(void)
1091 switch (game.prop[BIRD]) {
1099 static int wave(token_t verb, token_t obj)
1100 /* Wave. No effect unless waving rod at fissure or at bird. */
1104 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1105 rspeak(((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2))) ? ARENT_CARRYING : actions[verb].message);
1109 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1110 drop(JADE, game.loc);
1111 game.prop[JADE] = 0;
1113 rspeak(NECKLACE_FLY);
1117 rspeak(birdspeak());
1118 return GO_DWARFWAKE;
1120 if (game.closng || !AT(FISSURE)) {
1121 rspeak(birdspeak());
1125 rspeak(birdspeak());
1127 /* FIXME: Arithemetic on property values */
1128 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1129 pspeak(FISSURE, look, 2 - game.prop[FISSURE], true);
1134 int action(struct command_t *command)
1135 /* Analyse a verb. Remember what it was, go back for object if second word
1136 * unless verb is "say", which snarfs arbitrary second word.
1139 if (command->part == unknown) {
1140 /* Analyse an object word. See if the thing is here, whether
1141 * we've got a verb yet, and so on. Object must be here
1142 * unless verb is "find" or "invent(ory)" (and no new verb
1143 * yet to be analysed). Water and oil are also funny, since
1144 * they are never actually dropped at any location, but might
1145 * be here inside the bottle or urn or as a feature of the
1147 if (HERE(command->obj))
1149 else if (command->obj == GRATE) {
1150 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1151 command->obj = DPRSSN;
1152 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1153 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1154 command->obj = ENTRNC;
1155 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1157 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1159 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1162 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1163 command->obj = PLANT2;
1165 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1167 rspeak(KNIVES_VANISH);
1169 } else if (command->obj == ROD && HERE(ROD2)) {
1170 command->obj = ROD2;
1172 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1175 rspeak(NO_SEE, command->wd1, command->wd1x);
1179 if (command->wd2 > 0)
1181 if (command->verb != 0)
1182 command->part = transitive;
1185 switch (command->part) {
1187 if (command->wd2 > 0 && command->verb != SAY)
1189 if (command->verb == SAY)
1190 command->obj = command->wd2;
1191 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1192 /* Analyse an intransitive verb (ie, no object given yet). */
1193 switch (command->verb) {
1195 return vcarry(command->verb, INTRANSITIVE);
1201 return lock(command->verb, INTRANSITIVE);
1204 return (GO_CLEAROBJ);
1207 return lock(command->verb, INTRANSITIVE);
1209 return light(command->verb, INTRANSITIVE);
1211 return extinguish(command->verb, INTRANSITIVE);
1217 rspeak(actions[command->verb].message);
1221 return attack(command);
1223 return pour(command->verb, command->obj);
1225 return eat(command->verb, INTRANSITIVE);
1227 return drink(command->verb, command->obj);
1241 return fill(command->verb, command->obj);
1249 return bigwords(command->wd1);
1253 command->obj = INTRANSITIVE;
1254 return read(*command);
1264 return fly(command->verb, INTRANSITIVE);
1270 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1275 /* Analyse a transitive verb. */
1276 switch (command->verb) {
1278 return vcarry(command->verb, command->obj);
1280 return discard(command->verb, command->obj, false);
1282 return say(command);
1284 return lock(command->verb, command->obj);
1287 return (GO_CLEAROBJ);
1290 return lock(command->verb, command->obj);
1292 return light(command->verb, command->obj);
1294 return extinguish(command->verb, command->obj);
1296 return wave(command->verb, command->obj);
1298 rspeak(actions[command->verb].message);
1302 rspeak(actions[command->verb].message);
1306 return attack(command);
1308 return pour(command->verb, command->obj);
1310 return eat(command->verb, command->obj);
1312 return drink(command->verb, command->obj);
1314 return rub(command->verb, command->obj);
1316 return throw (command);
1318 rspeak(actions[command->verb].message);
1322 return find(command->verb, command->obj);
1324 return find(command->verb, command->obj);
1326 return feed(command->verb, command->obj);
1328 return fill(command->verb, command->obj);
1333 rspeak(actions[command->verb].message);
1337 rspeak(actions[command->verb].message);
1341 rspeak(actions[command->verb].message);
1345 return read(*command);
1347 return vbreak(command->verb, command->obj);
1349 return wake(command->verb, command->obj);
1351 rspeak(actions[command->verb].message);
1355 rspeak(actions[command->verb].message);
1359 return fly(command->verb, command->obj);
1361 rspeak(actions[command->verb].message);
1367 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1370 /* Unknown verb, couldn't deduce object - might need hint */
1371 rspeak(WHAT_DO, command->wd1, command->wd1x);
1372 return GO_CHECKHINT;
1374 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE