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 || obj == INTRANSITIVE) {
26 if (atdwrf(game.loc) > 0) {
34 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
46 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
50 /* check for low-priority targets */
51 if (obj == NO_OBJECT) {
52 /* Can't attack bird or machine by throwing axe. */
53 if (HERE(BIRD) && verb != THROW) {
57 if (HERE(VEND) && verb != THROW) {
61 /* Clam and oyster both treated as clam for intransitive case;
63 if (HERE(CLAM) || HERE(OYSTER)) {
79 } else if (obj == VEND) {
81 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
87 if (obj == CLAM || obj == OYSTER)
88 spk = SHELL_IMPERVIOUS;
92 spk = BARE_HANDS_QUERY;
93 if (obj == DWARF && game.closed)
101 if (obj == OGRE && atdwrf(game.loc) > 0) {
103 rspeak(KNIFE_THROWN);
106 for (int i = 1; i < PIRATE; i++) {
107 if (game.dloc[i] == game.loc) {
109 game.dloc[i] = LOC_LONGWEST;
110 game.dseen[i] = false;
113 spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2;
114 } else if (obj == BEAR) {
115 switch (game.prop[BEAR]) {
129 } else if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
130 /* Fun stuff for dragon. If he insists on attacking it, win!
131 * Set game.prop to dead, move dragon to central loc (still
132 * fixed), move rug there (not fixed), and move him there,
133 * too. Then do a null motion to get new description. */
134 rspeak(BARE_HANDS_QUERY);
136 // FIXME: setting wd1 is a workaround for broken logic
137 command->wd1 = token_to_packed("Y");
139 // FIXME: setting wd1 is a workaround for broken logic
140 command->wd1 = token_to_packed("N");
143 state_change(DRAGON, DRAGON_DEAD);
144 game.prop[RUG] = RUG_FLOOR;
145 /* FIXME: Arithmetic on location values */
146 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
147 move(DRAGON + NOBJECTS, -1);
148 move(RUG + NOBJECTS, 0);
152 for (obj = 1; obj <= NOBJECTS; obj++) {
153 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
164 static int bigwords(token_t foo)
165 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
166 * Look up foo in special section of vocab to determine which word we've got.
167 * Last word zips the eggs back to the giant room (unless already there). */
170 packed_to_token(foo, word);
171 int k = (int) get_special_vocab_id(word);
172 int spk = NOTHING_HAPPENS;
173 if (game.foobar != 1 - k) {
174 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)
185 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
189 /* Bring back troll if we steal the eggs back from him before
191 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
192 game.prop[TROLL] = TROLL_PAIDONCE;
196 if (game.loc == objects[EGGS].plac)
198 move(EGGS, objects[EGGS].plac);
199 pspeak(EGGS, look, k, true);
205 static int bivalve(token_t verb, token_t obj)
206 /* Clam/oyster actions */
209 bool is_oyster = (obj == OYSTER);
210 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
212 spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
213 if (!TOTING(TRIDENT))
214 spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
217 if (spk == PEARL_FALLS) {
219 drop(OYSTER, game.loc);
220 drop(PEARL, LOC_CULDESAC);
226 static void blast(void)
227 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
229 if (game.prop[ROD2] < 0 || !game.closed)
230 rspeak(REQUIRES_DYNAMITE);
232 game.bonus = VICTORY_MESSAGE;
233 if (game.loc == LOC_NE)
234 game.bonus = DEFEAT_MESSAGE;
236 game.bonus = SPLATTER_MESSAGE;
242 static int vbreak(token_t verb, token_t obj)
243 /* Break. Only works for mirror in repository and, of course, the vase. */
247 rspeak(BREAK_MIRROR);
254 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
256 drop(VASE, game.loc);
257 state_change(VASE, VASE_BROKEN);
258 game.fixed[VASE] = -1;
261 rspeak(actions[verb].message);
262 return (GO_CLEAROBJ);
265 static int brief(void)
266 /* Brief. Intransitive only. Suppress long descriptions after first time. */
270 rspeak(BRIEF_CONFIRM);
274 static int vcarry(token_t verb, token_t obj)
275 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
276 * take one without the other). Liquids also special, since they depend on
277 * status of bottle. Also various side effects, etc. */
280 if (obj == INTRANSITIVE) {
281 /* Carry, no object given yet. OK if only one object present. */
282 if (game.atloc[game.loc] == 0 ||
283 game.link[game.atloc[game.loc]] != 0 ||
284 atdwrf(game.loc) > 0)
286 obj = game.atloc[game.loc];
290 rspeak(ALREADY_CARRYING);
294 if (obj == PLANT && game.prop[PLANT] <= 0)
296 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
298 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
303 spk = DOUGHNUT_HOLES;
306 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
309 spk = HAND_PASSTHROUGH;
311 rspeak(REMOVE_MESSAGE);
315 if (game.fixed[obj] != 0) {
319 if (obj == WATER || obj == OIL) {
320 if (!HERE(BOTTLE) || LIQUID() != obj) {
321 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
322 return (fill(verb, BOTTLE));
324 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
336 if (game.holdng >= INVLIMIT) {
339 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
340 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
349 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
353 game.prop[BIRD] = BIRD_CAGED;
355 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
356 carry(BIRD + CAGE - obj, game.loc);
357 carry(obj, game.loc);
358 if (obj == BOTTLE && LIQUID() != 0)
359 game.place[LIQUID()] = CARRIED;
360 if (GSTONE(obj) && game.prop[obj] != 0) {
361 game.prop[obj] = STATE_GROUND;
362 game.prop[CAVITY] = CAVITY_EMPTY;
368 static int chain(token_t verb)
369 /* Do something to the bear's chain */
373 spk = CHAIN_UNLOCKED;
374 if (game.prop[BEAR] == UNTAMED_BEAR)
376 if (game.prop[CHAIN] == CHAIN_HEAP)
377 spk = ALREADY_UNLOCKED;
378 if (spk != CHAIN_UNLOCKED) {
382 game.prop[CHAIN] = CHAIN_HEAP;
383 game.fixed[CHAIN] = CHAIN_HEAP;
384 if (game.prop[BEAR] != BEAR_DEAD)
385 game.prop[BEAR] = CONTENTED_BEAR;
386 /* FIXME: Arithmetic on state numbers */
387 game.fixed[BEAR] = 2 - game.prop[BEAR];
390 if (game.prop[CHAIN] != CHAIN_HEAP)
391 spk = ALREADY_LOCKED;
392 if (game.loc != objects[CHAIN].plac)
394 if (spk != CHAIN_LOCKED) {
398 game.prop[CHAIN] = CHAIN_FIXED;
400 drop(CHAIN, game.loc);
401 game.fixed[CHAIN] = -1;
407 static int discard(token_t verb, token_t obj, bool just_do_it)
408 /* Discard object. "Throw" also comes here for most objects. Special cases for
409 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
410 * Drop coins at vending machine for extra batteries. */
412 int spk = actions[verb].message;
414 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
420 if (obj == BIRD && HERE(SNAKE)) {
421 rspeak(BIRD_ATTACKS);
425 /* Set game.prop for use by travel options */
426 game.prop[SNAKE] = SNAKE_CHASED;
428 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
431 game.prop[CAVITY] = CAVITY_FULL;
432 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || (obj == RUBY &&
433 game.prop[RUG] == RUG_HOVER))) {
440 if (spk != RUG_WIGGLES) {
441 /* FIXME: Arithmetic on state numbers */
442 int k = 2 - game.prop[RUG];
445 k = objects[SAPPH].plac;
446 move(RUG + NOBJECTS, k);
449 } else if (obj == COINS && HERE(VEND)) {
451 drop(BATTERY, game.loc);
452 pspeak(BATTERY, look, FRESH_BATTERIES, true);
454 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
458 } else if (obj == BEAR && AT(TROLL)) {
459 rspeak(TROLL_SCAMPERS);
460 move(TROLL, LOC_NOWHERE);
461 move(TROLL + NOBJECTS, LOC_NOWHERE);
462 move(TROLL2, objects[TROLL].plac);
463 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
465 game.prop[TROLL] = TROLL_GONE;
466 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
469 game.prop[VASE] = VASE_BROKEN;
471 game.prop[VASE] = VASE_WHOLE;
472 pspeak(VASE, look, game.prop[VASE] + 1, true);
473 if (game.prop[VASE] != VASE_WHOLE)
474 game.fixed[VASE] = -1;
480 if (obj == BOTTLE && k != 0)
481 game.place[k] = LOC_NOWHERE;
482 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
483 drop(BIRD, game.loc);
487 game.prop[BIRD] = BIRD_UNCAGED;
488 if (FOREST(game.loc))
489 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
493 static int drink(token_t verb, token_t obj)
494 /* Drink. If no object, assume water and look for it here. If water is in
495 * the bottle, drink that, else must be at a water loc, so drink stream. */
497 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
500 if (obj != NO_OBJECT && obj != WATER) {
501 rspeak(RIDICULOUS_ATTEMPT);
502 } else if (LIQUID() == WATER && HERE(BOTTLE)) {
503 game.prop[BOTTLE] = EMPTY_BOTTLE;
504 game.place[WATER] = LOC_NOWHERE;
505 rspeak(BOTTLE_EMPTY);
507 rspeak(actions[verb].message);
511 state_change(DRAGON, DRAGON_BLOODLESS);
517 static int eat(token_t verb, token_t obj)
518 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
519 * ok, some things lose appetite, rest are ridiculous. */
521 int spk = actions[verb].message;
522 if (obj == INTRANSITIVE) {
526 spk = THANKS_DELICIOUS;
530 spk = THANKS_DELICIOUS;
532 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
533 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
541 static int extinguish(token_t verb, int obj)
542 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
544 if (obj == INTRANSITIVE) {
545 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
547 if (HERE(URN) && game.prop[URN] == URN_LIT)
549 if (obj == INTRANSITIVE ||
550 (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT &&
551 HERE(URN) && game.prop[URN] == URN_LIT))
556 if (game.prop[URN] != URN_EMPTY) {
557 state_change(URN, URN_DARK);
559 pspeak(URN, change, URN_DARK, true);
562 } else if (obj == LAMP) {
563 state_change(LAMP, LAMP_DARK);
564 rspeak(DARK(game.loc) ? PITCH_DARK : NO_MESSAGE);
565 } else if (obj == DRAGON || obj == VOLCANO) {
566 rspeak(BEYOND_POWER);
569 rspeak(actions[verb].message);
574 static int feed(token_t verb, token_t obj)
575 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
576 * mad. Bear, special. */
578 int spk = actions[verb].message;
582 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
583 spk = NOTHING_EDIBLE;
584 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
585 spk = RIDICULOUS_ATTEMPT;
588 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
592 } else if (obj == DWARF) {
597 } else if (obj == BEAR) {
598 if (game.prop[BEAR] == UNTAMED_BEAR)
599 spk = NOTHING_EDIBLE;
600 if (game.prop[BEAR] == BEAR_DEAD)
601 spk = RIDICULOUS_ATTEMPT;
604 game.prop[BEAR] = SITTING_BEAR;
609 } else if (obj == OGRE) {
619 int fill(token_t verb, token_t obj)
620 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
624 int spk = actions[verb].message;
626 spk = ARENT_CARRYING;
627 if (LIQLOC(game.loc) == 0)
629 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
633 rspeak(SHATTER_VASE);
634 game.prop[VASE] = VASE_BROKEN;
635 game.fixed[VASE] = -1;
636 return (discard(verb, obj, true));
637 } else if (obj == URN) {
639 if (game.prop[URN] != URN_EMPTY) {
645 if (k == 0 || !HERE(BOTTLE)) {
649 game.place[k] = LOC_NOWHERE;
650 game.prop[BOTTLE] = EMPTY_BOTTLE;
652 game.prop[URN] = URN_DARK;
653 spk = WATER_URN + game.prop[URN];
656 } else if (obj != NO_OBJECT && obj != BOTTLE) {
659 } else if (obj == NO_OBJECT && !HERE(BOTTLE))
662 if (LIQLOC(game.loc) == 0)
664 if (HERE(URN) && game.prop[URN] != URN_EMPTY)
668 if (spk == BOTTLED_WATER) {
669 /* FIXME: Arithmetic on property values */
670 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
673 game.place[k] = CARRIED;
681 static int find(token_t verb, token_t obj)
682 /* Find. Might be carrying it, or it might be here. Else give caveat. */
684 int spk = actions[verb].message;
686 (LIQUID() == obj && AT(BOTTLE)) ||
687 obj == LIQLOC(game.loc) ||
688 (obj == DWARF && atdwrf(game.loc) > 0))
693 spk = ALREADY_CARRYING;
698 static int fly(token_t verb, token_t obj)
699 /* Fly. Snide remarks unless hovering rug is here. */
701 int spk = actions[verb].message;
702 if (obj == INTRANSITIVE) {
703 if (game.prop[RUG] != RUG_HOVER)
707 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
719 if (game.prop[RUG] != RUG_HOVER) {
723 game.oldlc2 = game.oldloc;
724 game.oldloc = game.loc;
725 /* FIXME: Arithmetic on location values */
726 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
728 if (game.prop[SAPPH] >= 0)
734 static int inven(void)
735 /* Inventory. If object, treat same as find. Else report on current burden. */
738 for (int i = 1; i <= NOBJECTS; i++) {
739 if (i == BEAR || !TOTING(i))
743 pspeak(i, touch, -1, false);
752 static int light(token_t verb, token_t obj)
753 /* Light. Applicable only to lamp and urn. */
755 if (obj == INTRANSITIVE) {
756 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
758 if (HERE(URN) && game.prop[URN] == URN_DARK)
760 if (obj == INTRANSITIVE ||
761 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
762 HERE(URN) && game.prop[URN] == URN_DARK))
767 state_change(URN, game.prop[URN] == URN_EMPTY ? URN_EMPTY : URN_LIT);
771 rspeak(actions[verb].message);
774 if (game.limit < 0) {
778 state_change(LAMP, LAMP_BRIGHT);
786 static int listen(void)
787 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
790 int spk = ALL_SILENT;
791 k = locations[game.loc].sound;
794 if (locations[game.loc].loud)
799 for (int i = 1; i <= NOBJECTS; i++) {
800 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
802 int mi = game.prop[i];
804 mi += 3 * game.blooded;
805 long packed_zzword = token_to_packed(game.zzword);
806 pspeak(i, hear, mi, true, packed_zzword);
808 /* FIXME: Magic number, sensitive to bird state logic */
809 if (i == BIRD && game.prop[i] == 5)
816 static int lock(token_t verb, token_t obj)
817 /* Lock, unlock, no object given. Assume various things if present. */
819 int spk = actions[verb].message;
820 if (obj == INTRANSITIVE) {
821 spk = NOTHING_LOCKED;
832 if (obj == NO_OBJECT || obj == INTRANSITIVE) {
838 /* Lock, unlock object. Special stuff for opening clam/oyster
840 if (obj == CLAM || obj == OYSTER)
841 return bivalve(verb, obj);
844 if (obj == DOOR && game.prop[DOOR] == DOOR_UNRUSTED)
850 if (obj == GRATE || obj == CHAIN) {
858 game.clock2 = PANICTIME;
861 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
870 static int pour(token_t verb, token_t obj)
871 /* Pour. If no object, or object is bottle, assume contents of bottle.
872 * special tests for pouring water or oil on plant or rusty door. */
874 int spk = actions[verb].message;
875 if (obj == BOTTLE || obj == NO_OBJECT)
877 if (obj == NO_OBJECT)
884 if (obj != OIL && obj != WATER) {
888 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
889 return fill(verb, URN);
890 game.prop[BOTTLE] = EMPTY_BOTTLE;
891 game.place[obj] = LOC_NOWHERE;
893 if (!(AT(PLANT) || AT(DOOR))) {
898 spk = SHAKING_LEAVES;
903 pspeak(PLANT, look, game.prop[PLANT] + 3, true);
904 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
905 game.prop[PLANT2] = game.prop[PLANT];
908 state_change(DOOR, (obj == OIL) ? DOOR_UNRUSTED : DOOR_RUSTED);
913 static int quit(void)
914 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
916 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
921 static int read(struct command_t command)
922 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
924 if (command.obj == INTRANSITIVE) {
926 for (int i = 1; i <= NOBJECTS; i++) {
927 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
928 command.obj = command.obj * NOBJECTS + i;
930 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
934 if (DARK(game.loc)) {
935 rspeak(NO_SEE, command.wd1, command.wd1x);
936 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
937 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
938 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
939 rspeak(actions[command.verb].message);
941 pspeak(command.obj, study, game.prop[command.obj], true);
945 static int reservoir(void)
946 /* Z'ZZZ (word gets recomputed at startup; different each game). */
948 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
949 rspeak(NOTHING_HAPPENS);
952 pspeak(RESER, look, game.prop[RESER] + 1, true);
953 game.prop[RESER] = 1 - game.prop[RESER];
957 game.oldlc2 = game.loc;
965 static int rub(token_t verb, token_t obj)
966 /* Rub. Yields various snide remarks except for lit urn. */
968 if (obj == URN && game.prop[URN] == URN_LIT) {
970 drop(AMBER, game.loc);
971 game.prop[AMBER] = AMBER_IN_ROCK;
973 drop(CAVITY, game.loc);
975 } else if (obj != LAMP) {
976 rspeak(PECULIAR_NOTHING);
978 rspeak(actions[verb].message);
983 static int say(struct command_t *command)
984 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
986 long a = command->wd1, b = command->wd1x;
987 if (command->wd2 > 0) {
990 command->wd1 = command->wd2;
993 packed_to_token(command->wd1, word1);
994 int wd = (int) get_vocab_id(word1);
995 /* FIXME: magic numbers */
996 if (wd == MOTION_WORD(XYZZY) || wd == MOTION_WORD(PLUGH) || wd == MOTION_WORD(PLOVER) || wd == ACTION_WORD(GIANTWORDS) || wd == ACTION_WORD(PART)) {
997 /* FIXME: scribbles on the interpreter's command block */
998 wordclear(&command->wd2);
1001 rspeak(OKEY_DOKEY, a, b);
1005 static int throw_support(long spk)
1008 drop(AXE, game.loc);
1012 static int throw (struct command_t *command)
1013 /* Throw. Same as discard unless axe. Then same as attack except
1014 * ignore bird, and if dwarf is present then one might be killed.
1015 * (Only way to do so!) Axe also special for dragon, bear, and
1016 * troll. Treasures special for troll. */
1018 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1019 command->obj = ROD2;
1020 if (!TOTING(command->obj)) {
1021 rspeak(actions[command->verb].message);
1024 if (objects[command->obj].is_treasure && AT(TROLL)) {
1025 /* Snarf a treasure for the troll. */
1026 drop(command->obj, LOC_NOWHERE);
1027 move(TROLL, LOC_NOWHERE);
1028 move(TROLL + NOBJECTS, LOC_NOWHERE);
1029 drop(TROLL2, objects[TROLL].plac);
1030 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1032 rspeak(TROLL_SATISFIED);
1035 if (command->obj == FOOD && HERE(BEAR)) {
1036 /* But throwing food is another story. */
1037 command->obj = BEAR;
1038 return (feed(command->verb, command->obj));
1040 if (command->obj != AXE)
1041 return (discard(command->verb, command->obj, false));
1043 if (atdwrf(game.loc) <= 0) {
1044 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1045 return throw_support(DRAGON_SCALES);
1047 return throw_support(TROLL_RETURNS);
1049 return throw_support(OGRE_DODGE);
1050 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1051 /* This'll teach him to throw the axe at the bear! */
1052 drop(AXE, game.loc);
1053 game.fixed[AXE] = -1;
1055 state_change(AXE, AXE_LOST);
1058 command->obj = NO_OBJECT;
1059 return (attack(command));
1062 if (randrange(NDWARVES + 1) < game.dflag) {
1063 return throw_support(DWARF_DODGES);
1065 long i = atdwrf(game.loc);
1066 game.dseen[i] = false;
1068 return throw_support((++game.dkill == 1)
1069 ? DWARF_SMOKE : KILLED_DWARF);
1074 static int wake(token_t verb, token_t obj)
1075 /* Wake. Only use is to disturb the dwarves. */
1077 if (obj != DWARF || !game.closed) {
1078 rspeak(actions[verb].message);
1082 return GO_DWARFWAKE;
1086 static token_t birdspeak(void)
1088 switch (game.prop[BIRD]) {
1096 static int wave(token_t verb, token_t obj)
1097 /* Wave. No effect unless waving rod at fissure or at bird. */
1101 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1102 rspeak(((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2))) ? ARENT_CARRYING : actions[verb].message);
1106 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1107 drop(JADE, game.loc);
1108 game.prop[JADE] = 0;
1110 rspeak(NECKLACE_FLY);
1114 rspeak(birdspeak());
1115 return GO_DWARFWAKE;
1117 if (game.closng || !AT(FISSURE)) {
1118 rspeak(birdspeak());
1122 rspeak(birdspeak());
1124 /* FIXME: Arithemetic on property values */
1125 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1126 pspeak(FISSURE, look, 2 - game.prop[FISSURE], true);
1131 int action(struct command_t *command)
1132 /* Analyse a verb. Remember what it was, go back for object if second word
1133 * unless verb is "say", which snarfs arbitrary second word.
1136 if (command->part == unknown) {
1137 /* Analyse an object word. See if the thing is here, whether
1138 * we've got a verb yet, and so on. Object must be here
1139 * unless verb is "find" or "invent(ory)" (and no new verb
1140 * yet to be analysed). Water and oil are also funny, since
1141 * they are never actually dropped at any location, but might
1142 * be here inside the bottle or urn or as a feature of the
1144 if (HERE(command->obj))
1146 else if (command->obj == GRATE) {
1147 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1148 command->obj = DPRSSN;
1149 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1150 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1151 command->obj = ENTRNC;
1152 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1154 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1156 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1159 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1160 command->obj = PLANT2;
1162 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1164 rspeak(KNIVES_VANISH);
1166 } else if (command->obj == ROD && HERE(ROD2)) {
1167 command->obj = ROD2;
1169 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1172 rspeak(NO_SEE, command->wd1, command->wd1x);
1176 if (command->wd2 > 0)
1178 if (command->verb != 0)
1179 command->part = transitive;
1182 switch (command->part) {
1184 if (command->wd2 > 0 && command->verb != SAY)
1186 if (command->verb == SAY)
1187 command->obj = command->wd2;
1188 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1189 /* Analyse an intransitive verb (ie, no object given yet). */
1190 switch (command->verb) {
1192 return vcarry(command->verb, INTRANSITIVE);
1198 return lock(command->verb, INTRANSITIVE);
1201 return (GO_CLEAROBJ);
1204 return lock(command->verb, INTRANSITIVE);
1206 return light(command->verb, INTRANSITIVE);
1208 return extinguish(command->verb, INTRANSITIVE);
1214 rspeak(actions[command->verb].message);
1218 return attack(command);
1220 return pour(command->verb, command->obj);
1222 return eat(command->verb, INTRANSITIVE);
1224 return drink(command->verb, command->obj);
1238 return fill(command->verb, command->obj);
1246 return bigwords(command->wd1);
1250 command->obj = INTRANSITIVE;
1251 return read(*command);
1261 return fly(command->verb, INTRANSITIVE);
1267 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1272 /* Analyse a transitive verb. */
1273 switch (command->verb) {
1275 return vcarry(command->verb, command->obj);
1277 return discard(command->verb, command->obj, false);
1279 return say(command);
1281 return lock(command->verb, command->obj);
1284 return (GO_CLEAROBJ);
1287 return lock(command->verb, command->obj);
1289 return light(command->verb, command->obj);
1291 return extinguish(command->verb, command->obj);
1293 return wave(command->verb, command->obj);
1295 rspeak(actions[command->verb].message);
1299 rspeak(actions[command->verb].message);
1303 return attack(command);
1305 return pour(command->verb, command->obj);
1307 return eat(command->verb, command->obj);
1309 return drink(command->verb, command->obj);
1311 return rub(command->verb, command->obj);
1313 return throw (command);
1315 rspeak(actions[command->verb].message);
1319 return find(command->verb, command->obj);
1321 return find(command->verb, command->obj);
1323 return feed(command->verb, command->obj);
1325 return fill(command->verb, command->obj);
1330 rspeak(actions[command->verb].message);
1334 rspeak(actions[command->verb].message);
1338 rspeak(actions[command->verb].message);
1342 return read(*command);
1344 return vbreak(command->verb, command->obj);
1346 return wake(command->verb, command->obj);
1348 rspeak(actions[command->verb].message);
1352 rspeak(actions[command->verb].message);
1356 return fly(command->verb, command->obj);
1358 rspeak(actions[command->verb].message);
1364 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1367 /* Unknown verb, couldn't deduce object - might need hint */
1368 rspeak(WHAT_DO, command->wd1, command->wd1x);
1369 return GO_CHECKHINT;
1371 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE