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] == 0)
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] == 0) {
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 pspeak(DRAGON, look, 3);
125 game.prop[DRAGON] = 1;
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] == 0)
174 game.prop[TROLL] = 1;
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. */
227 int spk = actions[verb].message;
230 if (obj == VASE && game.prop[VASE] == 0) {
232 drop(VASE, game.loc);
234 game.fixed[VASE] = -1;
237 if (obj == MIRROR && game.closed) {
238 rspeak(BREAK_MIRROR);
246 static int brief(void)
247 /* Brief. Intransitive only. Suppress long descriptions after first time. */
251 rspeak(BRIEF_CONFIRM);
255 static int vcarry(token_t verb, token_t obj)
256 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
257 * take one without the other). Liquids also special, since they depend on
258 * status of bottle. Also various side effects, etc. */
261 if (obj == INTRANSITIVE) {
262 /* Carry, no object given yet. OK if only one object present. */
263 if (game.atloc[game.loc] == 0 ||
264 game.link[game.atloc[game.loc]] != 0 ||
265 atdwrf(game.loc) > 0)
267 obj = game.atloc[game.loc];
271 rspeak(ALREADY_CARRYING);
275 if (obj == PLANT && game.prop[PLANT] <= 0)
277 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
279 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
284 spk = DOUGHNUT_HOLES;
287 if (obj == RUG && game.prop[RUG] == 2)
290 spk = HAND_PASSTHROUGH;
292 rspeak(REMOVE_MESSAGE);
296 if (game.fixed[obj] != 0) {
300 if (obj == WATER || obj == OIL) {
301 if (!HERE(BOTTLE) || LIQUID() != obj) {
302 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
303 return (fill(verb, BOTTLE));
305 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
317 if (game.holdng >= INVLIMIT) {
320 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
321 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
330 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
334 game.prop[BIRD] = BIRD_CAGED;
336 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
337 carry(BIRD + CAGE - obj, game.loc);
338 carry(obj, game.loc);
339 if (obj == BOTTLE && LIQUID() != 0)
340 game.place[LIQUID()] = CARRIED;
341 if (GSTONE(obj) && game.prop[obj] != 0) {
343 game.prop[CAVITY] = CAVITY_EMPTY;
349 static int chain(token_t verb)
350 /* Do something to the bear's chain */
354 spk = CHAIN_UNLOCKED;
355 if (game.prop[BEAR] == UNTAMED_BEAR)
357 if (game.prop[CHAIN] == 0)
358 spk = ALREADY_UNLOCKED;
359 if (spk != CHAIN_UNLOCKED) {
363 game.prop[CHAIN] = 0;
364 game.fixed[CHAIN] = 0;
365 if (game.prop[BEAR] != BEAR_DEAD)
366 game.prop[BEAR] = CONTENTED_BEAR;
367 /* FIXME: Arithmetic on state numbers */
368 game.fixed[BEAR] = 2 - game.prop[BEAR];
371 if (game.prop[CHAIN] != 0)
372 spk = ALREADY_LOCKED;
373 if (game.loc != objects[CHAIN].plac)
375 if (spk != CHAIN_LOCKED) {
379 game.prop[CHAIN] = 2;
381 drop(CHAIN, game.loc);
382 game.fixed[CHAIN] = -1;
388 static int discard(token_t verb, token_t obj, bool just_do_it)
389 /* Discard object. "Throw" also comes here for most objects. Special cases for
390 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
391 * Drop coins at vending machine for extra batteries. */
393 int spk = actions[verb].message;
395 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
401 if (obj == BIRD && HERE(SNAKE)) {
402 rspeak(BIRD_ATTACKS);
406 /* Set game.prop for use by travel options */
407 game.prop[SNAKE] = SNAKE_CHASED;
409 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
412 game.prop[CAVITY] = CAVITY_FULL;
413 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != 2) || (obj == RUBY &&
414 game.prop[RUG] == 2))) {
421 if (spk != RUG_WIGGLES) {
422 int k = 2 - game.prop[RUG];
425 k = objects[SAPPH].plac;
426 move(RUG + NOBJECTS, k);
429 } else if (obj == COINS && HERE(VEND)) {
431 drop(BATTERY, game.loc);
432 pspeak(BATTERY, look, FRESH_BATTERIES);
434 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
438 } else if (obj == BEAR && AT(TROLL)) {
439 rspeak(TROLL_SCAMPERS);
441 move(TROLL + NOBJECTS, 0);
442 move(TROLL2, objects[TROLL].plac);
443 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
445 game.prop[TROLL] = 2;
446 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
452 pspeak(VASE, look, game.prop[VASE] + 1);
453 if (game.prop[VASE] != 0)
454 game.fixed[VASE] = -1;
460 if (obj == BOTTLE && k != 0)
461 game.place[k] = LOC_NOWHERE;
462 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
463 drop(BIRD, game.loc);
467 game.prop[BIRD] = BIRD_UNCAGED;
468 if (FOREST(game.loc))
469 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
473 static int drink(token_t verb, token_t obj)
474 /* Drink. If no object, assume water and look for it here. If water is in
475 * the bottle, drink that, else must be at a water loc, so drink stream. */
477 int spk = actions[verb].message;
478 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
481 if (obj != 0 && obj != WATER)
482 spk = RIDICULOUS_ATTEMPT;
483 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
484 game.prop[BOTTLE] = EMPTY_BOTTLE;
485 game.place[WATER] = LOC_NOWHERE;
490 game.prop[DRAGON] = 2;
498 static int eat(token_t verb, token_t obj)
499 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
500 * ok, some things lose appetite, rest are ridiculous. */
502 int spk = actions[verb].message;
503 if (obj == INTRANSITIVE) {
507 spk = THANKS_DELICIOUS;
511 spk = THANKS_DELICIOUS;
513 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
514 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
522 static int extinguish(token_t verb, int obj)
523 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
525 int spk = actions[verb].message;
526 if (obj == INTRANSITIVE) {
527 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
529 if (HERE(URN) && game.prop[URN] == 2)
530 obj = obj * NOBJECTS + URN;
531 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS)
536 game.prop[URN] = game.prop[URN] / 2;
538 } else if (obj == LAMP) {
539 state_change(LAMP, LAMP_DARK);
540 spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
541 } else if (obj == DRAGON || obj == VOLCANO)
547 static int feed(token_t verb, token_t obj)
548 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
549 * mad. Bear, special. */
551 int spk = actions[verb].message;
555 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
556 spk = NOTHING_EDIBLE;
557 if (obj == DRAGON && game.prop[DRAGON] != 0)
558 spk = RIDICULOUS_ATTEMPT;
561 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
565 } else if (obj == DWARF) {
570 } else if (obj == BEAR) {
571 if (game.prop[BEAR] == UNTAMED_BEAR)
572 spk = NOTHING_EDIBLE;
573 if (game.prop[BEAR] == BEAR_DEAD)
574 spk = RIDICULOUS_ATTEMPT;
577 game.prop[BEAR] = SITTING_BEAR;
582 } else if (obj == OGRE) {
592 int fill(token_t verb, token_t obj)
593 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
597 int spk = actions[verb].message;
599 spk = ARENT_CARRYING;
600 if (LIQLOC(game.loc) == 0)
602 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
606 rspeak(SHATTER_VASE);
608 game.fixed[VASE] = -1;
609 return (discard(verb, obj, true));
610 } else if (obj == URN) {
612 if (game.prop[URN] != 0) {
618 if (k == 0 || !HERE(BOTTLE)) {
622 game.place[k] = LOC_NOWHERE;
623 game.prop[BOTTLE] = EMPTY_BOTTLE;
626 spk = WATER_URN + game.prop[URN];
629 } else if (obj != 0 && obj != BOTTLE) {
632 } else if (obj == 0 && !HERE(BOTTLE))
635 if (LIQLOC(game.loc) == 0)
637 if (HERE(URN) && game.prop[URN] != 0)
641 if (spk == BOTTLED_WATER) {
642 /* FIXME: Arithmetic on property values */
643 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
646 game.place[k] = CARRIED;
654 static int find(token_t verb, token_t obj)
655 /* Find. Might be carrying it, or it might be here. Else give caveat. */
657 int spk = actions[verb].message;
659 (LIQUID() == obj && AT(BOTTLE)) ||
660 obj == LIQLOC(game.loc) ||
661 (obj == DWARF && atdwrf(game.loc) > 0))
666 spk = ALREADY_CARRYING;
671 static int fly(token_t verb, token_t obj)
672 /* Fly. Snide remarks unless hovering rug is here. */
674 int spk = actions[verb].message;
675 if (obj == INTRANSITIVE) {
676 if (game.prop[RUG] != 2)
680 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
692 if (game.prop[RUG] != 2) {
696 game.oldlc2 = game.oldloc;
697 game.oldloc = game.loc;
698 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
700 if (game.prop[SAPPH] >= 0)
706 static int inven(void)
707 /* Inventory. If object, treat same as find. Else report on current burden. */
710 for (int i = 1; i <= NOBJECTS; i++) {
711 if (i == BEAR || !TOTING(i))
716 pspeak(i, touch, -1);
726 static int light(token_t verb, token_t obj)
727 /* Light. Applicable only to lamp and urn. */
729 int spk = actions[verb].message;
730 if (obj == INTRANSITIVE) {
731 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
733 if (HERE(URN) && game.prop[URN] == 1)
734 obj = obj * NOBJECTS + URN;
735 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS)
740 if (game.prop[URN] == 0) {
753 if (game.limit < 0) {
757 state_change(LAMP, LAMP_BRIGHT);
765 static int listen(void)
766 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
769 int spk = ALL_SILENT;
770 k = locations[game.loc].sound;
773 if (locations[game.loc].loud)
778 for (int i = 1; i <= NOBJECTS; i++) {
779 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
781 int mi = game.prop[i];
783 mi += 3 * game.blooded;
784 long packed_zzword = token_to_packed(game.zzword);
785 pspeak(i, hear, mi, packed_zzword);
787 /* FIXME: Magic number, sensitive to bird state logic */
788 if (i == BIRD && game.prop[i] == 5)
795 static int lock(token_t verb, token_t obj)
796 /* Lock, unlock, no object given. Assume various things if present. */
798 int spk = actions[verb].message;
799 if (obj == INTRANSITIVE) {
800 spk = NOTHING_LOCKED;
809 if (obj != 0 && HERE(CHAIN))
813 if (obj == 0 || obj == INTRANSITIVE) {
819 /* Lock, unlock object. Special stuff for opening clam/oyster
821 if (obj == CLAM || obj == OYSTER)
822 return bivalve(verb, obj);
825 if (obj == DOOR && game.prop[DOOR] == 1)
831 if (obj == GRATE || obj == CHAIN) {
839 game.clock2 = PANICTIME;
842 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
851 static int pour(token_t verb, token_t obj)
852 /* Pour. If no object, or object is bottle, assume contents of bottle.
853 * special tests for pouring water or oil on plant or rusty door. */
855 int spk = actions[verb].message;
856 if (obj == BOTTLE || obj == 0)
865 if (obj != OIL && obj != WATER) {
869 if (HERE(URN) && game.prop[URN] == 0)
870 return fill(verb, URN);
871 game.prop[BOTTLE] = EMPTY_BOTTLE;
872 game.place[obj] = LOC_NOWHERE;
874 if (!(AT(PLANT) || AT(DOOR))) {
879 spk = SHAKING_LEAVES;
884 pspeak(PLANT, look, game.prop[PLANT] + 3);
885 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
886 game.prop[PLANT2] = game.prop[PLANT];
892 spk = RUSTED_HINGES + game.prop[DOOR];
898 static int quit(void)
899 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
901 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
906 static int read(struct command_t command)
907 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
909 if (command.obj == INTRANSITIVE) {
911 for (int i = 1; i <= NOBJECTS; i++) {
912 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
913 command.obj = command.obj * NOBJECTS + i;
915 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
919 if (DARK(game.loc)) {
920 rspeak(NO_SEE, command.wd1, command.wd1x);
921 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
922 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
923 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
924 rspeak(actions[command.verb].message);
926 pspeak(command.obj, study, game.prop[command.obj]);
930 static int reservoir(void)
931 /* Z'ZZZ (word gets recomputed at startup; different each game). */
933 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
934 rspeak(NOTHING_HAPPENS);
937 pspeak(RESER, look, game.prop[RESER] + 1);
938 game.prop[RESER] = 1 - game.prop[RESER];
942 game.oldlc2 = game.loc;
950 static int rub(token_t verb, token_t obj)
951 /* Rub. Yields various snide remarks except for lit urn. */
953 int spk = actions[verb].message;
955 spk = PECULIAR_NOTHING;
956 if (obj == URN && game.prop[URN] == 2) {
958 drop(AMBER, game.loc);
959 game.prop[AMBER] = 1;
961 drop(CAVITY, game.loc);
968 static int say(struct command_t *command)
969 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
971 long a = command->wd1, b = command->wd1x;
972 if (command->wd2 > 0) {
975 command->wd1 = command->wd2;
977 //int wd = vocab(command->wd1, -1);
979 packed_to_token(command->wd1, word1);
980 int wd = (int) get_vocab_id(word1);
981 /* FIXME: magic numbers */
982 if (wd == XYZZY || wd == PLUGH || wd == PLOVER || wd == ACTION_WORD(GIANTWORDS) || wd == ACTION_WORD(PART)) {
983 /* FIXME: scribbles on the interpreter's command block */
984 wordclear(&command->wd2);
987 rspeak(OKEY_DOKEY, a, b);
991 static int throw_support(long spk)
998 static int throw (struct command_t *command)
999 /* Throw. Same as discard unless axe. Then same as attack except
1000 * ignore bird, and if dwarf is present then one might be killed.
1001 * (Only way to do so!) Axe also special for dragon, bear, and
1002 * troll. Treasures special for troll. */
1004 int spk = actions[command->verb].message;
1005 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1006 command->obj = ROD2;
1007 if (!TOTING(command->obj)) {
1011 if (objects[command->obj].is_treasure && AT(TROLL)) {
1012 spk = TROLL_SATISFIED;
1013 /* Snarf a treasure for the troll. */
1014 drop(command->obj, 0);
1016 move(TROLL + NOBJECTS, 0);
1017 drop(TROLL2, objects[TROLL].plac);
1018 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1023 if (command->obj == FOOD && HERE(BEAR)) {
1024 /* But throwing food is another story. */
1025 command->obj = BEAR;
1026 return (feed(command->verb, command->obj));
1028 if (command->obj != AXE)
1029 return (discard(command->verb, command->obj, false));
1031 int i = atdwrf(game.loc);
1033 if (AT(DRAGON) && game.prop[DRAGON] == 0)
1034 return throw_support(DRAGON_SCALES);
1036 return throw_support(TROLL_RETURNS);
1038 return throw_support(OGRE_DODGE);
1039 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1040 /* This'll teach him to throw the axe at the bear! */
1041 drop(AXE, game.loc);
1042 game.fixed[AXE] = -1;
1049 return (attack(command));
1052 if (randrange(NDWARVES + 1) < game.dflag) {
1053 return throw_support(DWARF_DODGES);
1055 game.dseen[i] = false;
1057 return throw_support((++game.dkill == 1)
1058 ? DWARF_SMOKE : KILLED_DWARF);
1063 static int wake(token_t verb, token_t obj)
1064 /* Wake. Only use is to disturb the dwarves. */
1066 if (obj != DWARF || !game.closed) {
1067 rspeak(actions[verb].message);
1071 return GO_DWARFWAKE;
1075 static int wave(token_t verb, token_t obj)
1076 /* Wave. No effect unless waving rod at fissure or at bird. */
1078 int spk = actions[verb].message;
1079 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))
1080 spk = ARENT_CARRYING;
1083 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1087 /* FIXME: Arithemetic on proprty values */
1089 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
1090 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1091 drop(JADE, game.loc);
1092 game.prop[JADE] = 0;
1100 return GO_DWARFWAKE;
1102 if (game.closng || !AT(FISSURE)) {
1108 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1109 pspeak(FISSURE, look, 2 - game.prop[FISSURE]);
1114 int action(struct command_t *command)
1115 /* Analyse a verb. Remember what it was, go back for object if second word
1116 * unless verb is "say", which snarfs arbitrary second word.
1119 token_t spk = actions[command->verb].message;
1121 if (command->part == unknown) {
1122 /* Analyse an object word. See if the thing is here, whether
1123 * we've got a verb yet, and so on. Object must be here
1124 * unless verb is "find" or "invent(ory)" (and no new verb
1125 * yet to be analysed). Water and oil are also funny, since
1126 * they are never actually dropped at any location, but might
1127 * be here inside the bottle or urn or as a feature of the
1129 if (HERE(command->obj))
1131 else if (command->obj == GRATE) {
1132 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1133 command->obj = DPRSSN;
1134 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1135 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1136 command->obj = ENTRNC;
1137 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1139 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1141 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1144 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1145 command->obj = PLANT2;
1147 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1149 spk = KNIVES_VANISH;
1152 } else if (command->obj == ROD && HERE(ROD2)) {
1153 command->obj = ROD2;
1155 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1158 rspeak(NO_SEE, command->wd1, command->wd1x);
1162 if (command->wd2 > 0)
1164 if (command->verb != 0)
1165 command->part = transitive;
1168 switch (command->part) {
1170 if (command->wd2 > 0 && command->verb != SAY)
1172 if (command->verb == SAY)
1173 command->obj = command->wd2;
1174 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1175 /* Analyse an intransitive verb (ie, no object given yet). */
1176 switch (command->verb) {
1178 return vcarry(command->verb, INTRANSITIVE);
1184 return lock(command->verb, INTRANSITIVE);
1187 return (GO_CLEAROBJ);
1190 return lock(command->verb, INTRANSITIVE);
1192 return light(command->verb, INTRANSITIVE);
1194 return extinguish(command->verb, INTRANSITIVE);
1204 return attack(command);
1206 return pour(command->verb, command->obj);
1208 return eat(command->verb, INTRANSITIVE);
1210 return drink(command->verb, command->obj);
1224 return fill(command->verb, command->obj);
1232 return bigwords(command->wd1);
1236 command->obj = INTRANSITIVE;
1237 return read(*command);
1247 return fly(command->verb, INTRANSITIVE);
1253 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1258 /* Analyse a transitive verb. */
1259 switch (command->verb) {
1261 return vcarry(command->verb, command->obj);
1263 return discard(command->verb, command->obj, false);
1265 return say(command);
1267 return lock(command->verb, command->obj);
1270 return (GO_CLEAROBJ);
1273 return lock(command->verb, command->obj);
1275 return light(command->verb, command->obj);
1277 return extinguish(command->verb, command->obj);
1279 return wave(command->verb, command->obj);
1289 return attack(command);
1291 return pour(command->verb, command->obj);
1293 return eat(command->verb, command->obj);
1295 return drink(command->verb, command->obj);
1297 return rub(command->verb, command->obj);
1299 return throw (command);
1305 return find(command->verb, command->obj);
1307 return find(command->verb, command->obj);
1309 return feed(command->verb, command->obj);
1311 return fill(command->verb, command->obj);
1328 return read(*command);
1330 return vbreak(command->verb, command->obj);
1332 return wake(command->verb, command->obj);
1342 return fly(command->verb, command->obj);
1350 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1353 /* Unknown verb, couldn't deduce object - might need hint */
1354 rspeak(WHAT_DO, command->wd1, command->wd1x);
1355 return GO_CHECKHINT;
1357 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE