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);
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;
22 long spk = actions[verb].message;
23 if (obj == 0 || obj == INTRANSITIVE) {
24 if (atdwrf(game.loc) > 0)
27 obj = obj * NOBJECTS + SNAKE;
28 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
29 obj = obj * NOBJECTS + DRAGON;
31 obj = obj * NOBJECTS + TROLL;
33 obj = obj * NOBJECTS + OGRE;
34 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR)
35 obj = obj * NOBJECTS + BEAR;
39 /* Can't attack bird or machine by throwing axe. */
40 if (HERE(BIRD) && verb != THROW)
42 if (HERE(VEND) && verb != THROW)
43 obj = obj * NOBJECTS + VEND;
44 /* Clam and oyster both treated as clam for intransitive case;
46 if (HERE(CLAM) || HERE(OYSTER))
47 obj = NOBJECTS * obj + CLAM;
60 } else if (obj == VEND) {
62 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
68 if (obj == CLAM || obj == OYSTER)
69 spk = SHELL_IMPERVIOUS;
73 spk = BARE_HANDS_QUERY;
74 if (obj == DWARF && game.closed)
82 if (obj == OGRE && atdwrf(game.loc) > 0) {
87 for (int i = 1; i < PIRATE; i++) {
88 if (game.dloc[i] == game.loc) {
90 game.dloc[i] = LOC_LONGWEST;
91 game.dseen[i] = false;
94 spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2;
95 } else if (obj == BEAR) {
96 switch (game.prop[BEAR]) {
110 } else if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
111 /* Fun stuff for dragon. If he insists on attacking it, win!
112 * Set game.prop to dead, move dragon to central loc (still
113 * fixed), move rug there (not fixed), and move him there,
114 * too. Then do a null motion to get new description. */
115 rspeak(BARE_HANDS_QUERY);
117 // FIXME: setting wd1 is a workaround for broken logic
118 command->wd1 = token_to_packed("Y");
120 // FIXME: setting wd1 is a workaround for broken logic
121 command->wd1 = token_to_packed("N");
124 state_change(DRAGON, DRAGON_DEAD);
125 game.prop[RUG] = RUG_FLOOR;
126 /* FIXME: Arithmetic on location values */
127 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
128 move(DRAGON + NOBJECTS, -1);
129 move(RUG + NOBJECTS, 0);
133 for (obj = 1; obj <= NOBJECTS; obj++) {
134 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
145 static int bigwords(token_t foo)
146 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
147 * Look up foo in section 3 of vocab to determine which word we've got. Last
148 * word zips the eggs back to the giant room (unless already there). */
150 //int k = vocab(foo, 3);
152 packed_to_token(foo, word);
153 int k = (int) get_special_vocab_id(word);
154 int spk = NOTHING_HAPPENS;
155 if (game.foobar != 1 - k) {
156 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)
167 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
171 /* Bring back troll if we steal the eggs back from him before
173 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
174 game.prop[TROLL] = TROLL_PAIDONCE;
178 if (game.loc == objects[EGGS].plac)
180 move(EGGS, objects[EGGS].plac);
181 pspeak(EGGS, look, k);
187 static int bivalve(token_t verb, token_t obj)
188 /* Clam/oyster actions */
191 bool is_oyster = (obj == OYSTER);
192 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
194 spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
195 if (!TOTING(TRIDENT))
196 spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
199 if (spk == PEARL_FALLS) {
201 drop(OYSTER, game.loc);
202 drop(PEARL, LOC_CULDESAC);
208 static void blast(void)
209 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
211 if (game.prop[ROD2] < 0 || !game.closed)
212 rspeak(REQUIRES_DYNAMITE);
214 game.bonus = VICTORY_MESSAGE;
215 if (game.loc == LOC_NE)
216 game.bonus = DEFEAT_MESSAGE;
218 game.bonus = SPLATTER_MESSAGE;
224 static int vbreak(token_t verb, token_t obj)
225 /* Break. Only works for mirror in repository and, of course, the vase. */
229 rspeak(BREAK_MIRROR);
236 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
238 drop(VASE, game.loc);
239 state_change(VASE, VASE_BROKEN);
240 game.fixed[VASE] = -1;
243 rspeak(actions[verb].message);
244 return (GO_CLEAROBJ);
247 static int brief(void)
248 /* Brief. Intransitive only. Suppress long descriptions after first time. */
252 rspeak(BRIEF_CONFIRM);
256 static int vcarry(token_t verb, token_t obj)
257 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
258 * take one without the other). Liquids also special, since they depend on
259 * status of bottle. Also various side effects, etc. */
262 if (obj == INTRANSITIVE) {
263 /* Carry, no object given yet. OK if only one object present. */
264 if (game.atloc[game.loc] == 0 ||
265 game.link[game.atloc[game.loc]] != 0 ||
266 atdwrf(game.loc) > 0)
268 obj = game.atloc[game.loc];
272 rspeak(ALREADY_CARRYING);
276 if (obj == PLANT && game.prop[PLANT] <= 0)
278 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
280 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
285 spk = DOUGHNUT_HOLES;
288 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
291 spk = HAND_PASSTHROUGH;
293 rspeak(REMOVE_MESSAGE);
297 if (game.fixed[obj] != 0) {
301 if (obj == WATER || obj == OIL) {
302 if (!HERE(BOTTLE) || LIQUID() != obj) {
303 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
304 return (fill(verb, BOTTLE));
306 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
318 if (game.holdng >= INVLIMIT) {
321 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
322 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
331 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
335 game.prop[BIRD] = BIRD_CAGED;
337 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
338 carry(BIRD + CAGE - obj, game.loc);
339 carry(obj, game.loc);
340 if (obj == BOTTLE && LIQUID() != 0)
341 game.place[LIQUID()] = CARRIED;
342 if (GSTONE(obj) && game.prop[obj] != 0) {
344 game.prop[CAVITY] = CAVITY_EMPTY;
350 static int chain(token_t verb)
351 /* Do something to the bear's chain */
355 spk = CHAIN_UNLOCKED;
356 if (game.prop[BEAR] == UNTAMED_BEAR)
358 if (game.prop[CHAIN] == CHAIN_HEAP)
359 spk = ALREADY_UNLOCKED;
360 if (spk != CHAIN_UNLOCKED) {
364 game.prop[CHAIN] = CHAIN_HEAP;
365 game.fixed[CHAIN] = CHAIN_HEAP;
366 if (game.prop[BEAR] != BEAR_DEAD)
367 game.prop[BEAR] = CONTENTED_BEAR;
368 /* FIXME: Arithmetic on state numbers */
369 game.fixed[BEAR] = 2 - game.prop[BEAR];
372 if (game.prop[CHAIN] != CHAIN_HEAP)
373 spk = ALREADY_LOCKED;
374 if (game.loc != objects[CHAIN].plac)
376 if (spk != CHAIN_LOCKED) {
380 game.prop[CHAIN] = CHAIN_FIXED;
382 drop(CHAIN, game.loc);
383 game.fixed[CHAIN] = -1;
389 static int discard(token_t verb, token_t obj, bool just_do_it)
390 /* Discard object. "Throw" also comes here for most objects. Special cases for
391 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
392 * Drop coins at vending machine for extra batteries. */
394 int spk = actions[verb].message;
396 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
402 if (obj == BIRD && HERE(SNAKE)) {
403 rspeak(BIRD_ATTACKS);
407 /* Set game.prop for use by travel options */
408 game.prop[SNAKE] = SNAKE_CHASED;
410 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
413 game.prop[CAVITY] = CAVITY_FULL;
414 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || (obj == RUBY &&
415 game.prop[RUG] == RUG_HOVER))) {
422 if (spk != RUG_WIGGLES) {
423 /* FIXME: Arithmetic on state numbers */
424 int k = 2 - game.prop[RUG];
427 k = objects[SAPPH].plac;
428 move(RUG + NOBJECTS, k);
431 } else if (obj == COINS && HERE(VEND)) {
433 drop(BATTERY, game.loc);
434 pspeak(BATTERY, look, FRESH_BATTERIES);
436 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
440 } else if (obj == BEAR && AT(TROLL)) {
441 rspeak(TROLL_SCAMPERS);
443 move(TROLL + NOBJECTS, 0);
444 move(TROLL2, objects[TROLL].plac);
445 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
447 game.prop[TROLL] = TROLL_GONE;
448 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
451 game.prop[VASE] = VASE_BROKEN;
453 game.prop[VASE] = VASE_WHOLE;
454 pspeak(VASE, look, game.prop[VASE] + 1);
455 if (game.prop[VASE] != VASE_WHOLE)
456 game.fixed[VASE] = -1;
462 if (obj == BOTTLE && k != 0)
463 game.place[k] = LOC_NOWHERE;
464 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
465 drop(BIRD, game.loc);
469 game.prop[BIRD] = BIRD_UNCAGED;
470 if (FOREST(game.loc))
471 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
475 static int drink(token_t verb, token_t obj)
476 /* Drink. If no object, assume water and look for it here. If water is in
477 * the bottle, drink that, else must be at a water loc, so drink stream. */
479 int spk = actions[verb].message;
480 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
483 if (obj != 0 && obj != WATER)
484 spk = RIDICULOUS_ATTEMPT;
485 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
486 game.prop[BOTTLE] = EMPTY_BOTTLE;
487 game.place[WATER] = LOC_NOWHERE;
493 state_change(DRAGON, DRAGON_BLOODLESS);
499 static int eat(token_t verb, token_t obj)
500 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
501 * ok, some things lose appetite, rest are ridiculous. */
503 int spk = actions[verb].message;
504 if (obj == INTRANSITIVE) {
508 spk = THANKS_DELICIOUS;
512 spk = THANKS_DELICIOUS;
514 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
515 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
523 static int extinguish(token_t verb, int obj)
524 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
526 if (obj == INTRANSITIVE) {
527 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
529 if (HERE(URN) && game.prop[URN] == URN_LIT)
531 if (obj == INTRANSITIVE)
536 if (game.prop[URN] != URN_EMPTY) {
537 state_change(URN, URN_DARK);
539 pspeak(URN, change, URN_DARK);
542 } else if (obj == LAMP) {
543 state_change(LAMP, LAMP_DARK);
544 rspeak(DARK(game.loc) ? PITCH_DARK : NO_MESSAGE);
545 } else if (obj == DRAGON || obj == VOLCANO) {
546 rspeak(BEYOND_POWER);
549 rspeak(actions[verb].message);
554 static int feed(token_t verb, token_t obj)
555 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
556 * mad. Bear, special. */
558 int spk = actions[verb].message;
562 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
563 spk = NOTHING_EDIBLE;
564 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
565 spk = RIDICULOUS_ATTEMPT;
568 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
572 } else if (obj == DWARF) {
577 } else if (obj == BEAR) {
578 if (game.prop[BEAR] == UNTAMED_BEAR)
579 spk = NOTHING_EDIBLE;
580 if (game.prop[BEAR] == BEAR_DEAD)
581 spk = RIDICULOUS_ATTEMPT;
584 game.prop[BEAR] = SITTING_BEAR;
589 } else if (obj == OGRE) {
599 int fill(token_t verb, token_t obj)
600 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
604 int spk = actions[verb].message;
606 spk = ARENT_CARRYING;
607 if (LIQLOC(game.loc) == 0)
609 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
613 rspeak(SHATTER_VASE);
614 game.prop[VASE] = VASE_BROKEN;
615 game.fixed[VASE] = -1;
616 return (discard(verb, obj, true));
617 } else if (obj == URN) {
619 if (game.prop[URN] != 0) {
625 if (k == 0 || !HERE(BOTTLE)) {
629 game.place[k] = LOC_NOWHERE;
630 game.prop[BOTTLE] = EMPTY_BOTTLE;
633 spk = WATER_URN + game.prop[URN];
636 } else if (obj != 0 && obj != BOTTLE) {
639 } else if (obj == 0 && !HERE(BOTTLE))
642 if (LIQLOC(game.loc) == 0)
644 if (HERE(URN) && game.prop[URN] != 0)
648 if (spk == BOTTLED_WATER) {
649 /* FIXME: Arithmetic on property values */
650 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
653 game.place[k] = CARRIED;
661 static int find(token_t verb, token_t obj)
662 /* Find. Might be carrying it, or it might be here. Else give caveat. */
664 int spk = actions[verb].message;
666 (LIQUID() == obj && AT(BOTTLE)) ||
667 obj == LIQLOC(game.loc) ||
668 (obj == DWARF && atdwrf(game.loc) > 0))
673 spk = ALREADY_CARRYING;
678 static int fly(token_t verb, token_t obj)
679 /* Fly. Snide remarks unless hovering rug is here. */
681 int spk = actions[verb].message;
682 if (obj == INTRANSITIVE) {
683 if (game.prop[RUG] != RUG_HOVER)
687 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
699 if (game.prop[RUG] != RUG_HOVER) {
703 game.oldlc2 = game.oldloc;
704 game.oldloc = game.loc;
705 /* FIXME: Arithmetic on location values */
706 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
708 if (game.prop[SAPPH] >= 0)
714 static int inven(void)
715 /* Inventory. If object, treat same as find. Else report on current burden. */
718 for (int i = 1; i <= NOBJECTS; i++) {
719 if (i == BEAR || !TOTING(i))
724 pspeak(i, touch, -1);
734 static int light(token_t verb, token_t obj)
735 /* Light. Applicable only to lamp and urn. */
737 if (obj == INTRANSITIVE) {
738 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
740 if (HERE(URN) && game.prop[URN] == URN_DARK)
742 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS)
747 state_change(URN, game.prop[URN] == URN_EMPTY ? URN_EMPTY : URN_LIT);
751 rspeak(actions[verb].message);
754 if (game.limit < 0) {
758 state_change(LAMP, LAMP_BRIGHT);
766 static int listen(void)
767 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
770 int spk = ALL_SILENT;
771 k = locations[game.loc].sound;
774 if (locations[game.loc].loud)
779 for (int i = 1; i <= NOBJECTS; i++) {
780 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
782 int mi = game.prop[i];
784 mi += 3 * game.blooded;
785 long packed_zzword = token_to_packed(game.zzword);
786 pspeak(i, hear, mi, packed_zzword);
788 /* FIXME: Magic number, sensitive to bird state logic */
789 if (i == BIRD && game.prop[i] == 5)
796 static int lock(token_t verb, token_t obj)
797 /* Lock, unlock, no object given. Assume various things if present. */
799 int spk = actions[verb].message;
800 if (obj == INTRANSITIVE) {
801 spk = NOTHING_LOCKED;
810 if (obj != 0 && HERE(CHAIN))
814 if (obj == 0 || obj == INTRANSITIVE) {
820 /* Lock, unlock object. Special stuff for opening clam/oyster
822 if (obj == CLAM || obj == OYSTER)
823 return bivalve(verb, obj);
826 if (obj == DOOR && game.prop[DOOR] == 1)
832 if (obj == GRATE || obj == CHAIN) {
840 game.clock2 = PANICTIME;
843 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
852 static int pour(token_t verb, token_t obj)
853 /* Pour. If no object, or object is bottle, assume contents of bottle.
854 * special tests for pouring water or oil on plant or rusty door. */
856 int spk = actions[verb].message;
857 if (obj == BOTTLE || obj == 0)
866 if (obj != OIL && obj != WATER) {
870 if (HERE(URN) && game.prop[URN] == 0)
871 return fill(verb, URN);
872 game.prop[BOTTLE] = EMPTY_BOTTLE;
873 game.place[obj] = LOC_NOWHERE;
875 if (!(AT(PLANT) || AT(DOOR))) {
880 spk = SHAKING_LEAVES;
885 pspeak(PLANT, look, game.prop[PLANT] + 3);
886 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
887 game.prop[PLANT2] = game.prop[PLANT];
890 state_change(DOOR, (obj == OIL) ? DOOR_UNRUSTED : DOOR_RUSTED);
895 static int quit(void)
896 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
898 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
903 static int read(struct command_t command)
904 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
906 if (command.obj == INTRANSITIVE) {
908 for (int i = 1; i <= NOBJECTS; i++) {
909 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
910 command.obj = command.obj * NOBJECTS + i;
912 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
916 if (DARK(game.loc)) {
917 rspeak(NO_SEE, command.wd1, command.wd1x);
918 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
919 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
920 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
921 rspeak(actions[command.verb].message);
923 pspeak(command.obj, study, game.prop[command.obj]);
927 static int reservoir(void)
928 /* Z'ZZZ (word gets recomputed at startup; different each game). */
930 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
931 rspeak(NOTHING_HAPPENS);
934 pspeak(RESER, look, game.prop[RESER] + 1);
935 game.prop[RESER] = 1 - game.prop[RESER];
939 game.oldlc2 = game.loc;
947 static int rub(token_t verb, token_t obj)
948 /* Rub. Yields various snide remarks except for lit urn. */
950 int spk = actions[verb].message;
952 spk = PECULIAR_NOTHING;
953 if (obj == URN && game.prop[URN] == 2) {
955 drop(AMBER, game.loc);
956 game.prop[AMBER] = 1;
958 drop(CAVITY, game.loc);
965 static int say(struct command_t *command)
966 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
968 long a = command->wd1, b = command->wd1x;
969 if (command->wd2 > 0) {
972 command->wd1 = command->wd2;
974 //int wd = vocab(command->wd1, -1);
976 packed_to_token(command->wd1, word1);
977 int wd = (int) get_vocab_id(word1);
978 /* FIXME: magic numbers */
979 if (wd == XYZZY || wd == PLUGH || wd == PLOVER || wd == ACTION_WORD(GIANTWORDS) || wd == ACTION_WORD(PART)) {
980 /* FIXME: scribbles on the interpreter's command block */
981 wordclear(&command->wd2);
984 rspeak(OKEY_DOKEY, a, b);
988 static int throw_support(long spk)
995 static int throw (struct command_t *command)
996 /* Throw. Same as discard unless axe. Then same as attack except
997 * ignore bird, and if dwarf is present then one might be killed.
998 * (Only way to do so!) Axe also special for dragon, bear, and
999 * troll. Treasures special for troll. */
1001 int spk = actions[command->verb].message;
1002 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1003 command->obj = ROD2;
1004 if (!TOTING(command->obj)) {
1008 if (objects[command->obj].is_treasure && AT(TROLL)) {
1009 spk = TROLL_SATISFIED;
1010 /* Snarf a treasure for the troll. */
1011 drop(command->obj, 0);
1013 move(TROLL + NOBJECTS, 0);
1014 drop(TROLL2, objects[TROLL].plac);
1015 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1020 if (command->obj == FOOD && HERE(BEAR)) {
1021 /* But throwing food is another story. */
1022 command->obj = BEAR;
1023 return (feed(command->verb, command->obj));
1025 if (command->obj != AXE)
1026 return (discard(command->verb, command->obj, false));
1028 int i = atdwrf(game.loc);
1030 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1031 return throw_support(DRAGON_SCALES);
1033 return throw_support(TROLL_RETURNS);
1035 return throw_support(OGRE_DODGE);
1036 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1037 /* This'll teach him to throw the axe at the bear! */
1038 drop(AXE, game.loc);
1039 game.fixed[AXE] = -1;
1046 return (attack(command));
1049 if (randrange(NDWARVES + 1) < game.dflag) {
1050 return throw_support(DWARF_DODGES);
1052 game.dseen[i] = false;
1054 return throw_support((++game.dkill == 1)
1055 ? DWARF_SMOKE : KILLED_DWARF);
1060 static int wake(token_t verb, token_t obj)
1061 /* Wake. Only use is to disturb the dwarves. */
1063 if (obj != DWARF || !game.closed) {
1064 rspeak(actions[verb].message);
1068 return GO_DWARFWAKE;
1072 static int wave(token_t verb, token_t obj)
1073 /* Wave. No effect unless waving rod at fissure or at bird. */
1075 int spk = actions[verb].message;
1076 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))
1077 spk = ARENT_CARRYING;
1080 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1084 /* FIXME: Arithemetic on property values */
1086 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
1087 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1088 drop(JADE, game.loc);
1089 game.prop[JADE] = 0;
1097 return GO_DWARFWAKE;
1099 if (game.closng || !AT(FISSURE)) {
1105 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1106 pspeak(FISSURE, look, 2 - game.prop[FISSURE]);
1111 int action(struct command_t *command)
1112 /* Analyse a verb. Remember what it was, go back for object if second word
1113 * unless verb is "say", which snarfs arbitrary second word.
1116 token_t spk = actions[command->verb].message;
1118 if (command->part == unknown) {
1119 /* Analyse an object word. See if the thing is here, whether
1120 * we've got a verb yet, and so on. Object must be here
1121 * unless verb is "find" or "invent(ory)" (and no new verb
1122 * yet to be analysed). Water and oil are also funny, since
1123 * they are never actually dropped at any location, but might
1124 * be here inside the bottle or urn or as a feature of the
1126 if (HERE(command->obj))
1128 else if (command->obj == GRATE) {
1129 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1130 command->obj = DPRSSN;
1131 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1132 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1133 command->obj = ENTRNC;
1134 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1136 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1138 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1141 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1142 command->obj = PLANT2;
1144 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1146 spk = KNIVES_VANISH;
1149 } else if (command->obj == ROD && HERE(ROD2)) {
1150 command->obj = ROD2;
1152 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1155 rspeak(NO_SEE, command->wd1, command->wd1x);
1159 if (command->wd2 > 0)
1161 if (command->verb != 0)
1162 command->part = transitive;
1165 switch (command->part) {
1167 if (command->wd2 > 0 && command->verb != SAY)
1169 if (command->verb == SAY)
1170 command->obj = command->wd2;
1171 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1172 /* Analyse an intransitive verb (ie, no object given yet). */
1173 switch (command->verb) {
1175 return vcarry(command->verb, INTRANSITIVE);
1181 return lock(command->verb, INTRANSITIVE);
1184 return (GO_CLEAROBJ);
1187 return lock(command->verb, INTRANSITIVE);
1189 return light(command->verb, INTRANSITIVE);
1191 return extinguish(command->verb, INTRANSITIVE);
1201 return attack(command);
1203 return pour(command->verb, command->obj);
1205 return eat(command->verb, INTRANSITIVE);
1207 return drink(command->verb, command->obj);
1221 return fill(command->verb, command->obj);
1229 return bigwords(command->wd1);
1233 command->obj = INTRANSITIVE;
1234 return read(*command);
1244 return fly(command->verb, INTRANSITIVE);
1250 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1255 /* Analyse a transitive verb. */
1256 switch (command->verb) {
1258 return vcarry(command->verb, command->obj);
1260 return discard(command->verb, command->obj, false);
1262 return say(command);
1264 return lock(command->verb, command->obj);
1267 return (GO_CLEAROBJ);
1270 return lock(command->verb, command->obj);
1272 return light(command->verb, command->obj);
1274 return extinguish(command->verb, command->obj);
1276 return wave(command->verb, command->obj);
1286 return attack(command);
1288 return pour(command->verb, command->obj);
1290 return eat(command->verb, command->obj);
1292 return drink(command->verb, command->obj);
1294 return rub(command->verb, command->obj);
1296 return throw (command);
1302 return find(command->verb, command->obj);
1304 return find(command->verb, command->obj);
1306 return feed(command->verb, command->obj);
1308 return fill(command->verb, command->obj);
1325 return read(*command);
1327 return vbreak(command->verb, command->obj);
1329 return wake(command->verb, command->obj);
1339 return fly(command->verb, command->obj);
1347 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1350 /* Unknown verb, couldn't deduce object - might need hint */
1351 rspeak(WHAT_DO, command->wd1, command->wd1x);
1352 return GO_CHECKHINT;
1354 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE