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 ||
532 HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT &&
533 HERE(URN) && game.prop[URN] == URN_LIT)
538 if (game.prop[URN] != URN_EMPTY) {
539 state_change(URN, URN_DARK);
541 pspeak(URN, change, URN_DARK);
544 } else if (obj == LAMP) {
545 state_change(LAMP, LAMP_DARK);
546 rspeak(DARK(game.loc) ? PITCH_DARK : NO_MESSAGE);
547 } else if (obj == DRAGON || obj == VOLCANO) {
548 rspeak(BEYOND_POWER);
551 rspeak(actions[verb].message);
556 static int feed(token_t verb, token_t obj)
557 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
558 * mad. Bear, special. */
560 int spk = actions[verb].message;
564 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
565 spk = NOTHING_EDIBLE;
566 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
567 spk = RIDICULOUS_ATTEMPT;
570 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
574 } else if (obj == DWARF) {
579 } else if (obj == BEAR) {
580 if (game.prop[BEAR] == UNTAMED_BEAR)
581 spk = NOTHING_EDIBLE;
582 if (game.prop[BEAR] == BEAR_DEAD)
583 spk = RIDICULOUS_ATTEMPT;
586 game.prop[BEAR] = SITTING_BEAR;
591 } else if (obj == OGRE) {
601 int fill(token_t verb, token_t obj)
602 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
606 int spk = actions[verb].message;
608 spk = ARENT_CARRYING;
609 if (LIQLOC(game.loc) == 0)
611 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
615 rspeak(SHATTER_VASE);
616 game.prop[VASE] = VASE_BROKEN;
617 game.fixed[VASE] = -1;
618 return (discard(verb, obj, true));
619 } else if (obj == URN) {
621 if (game.prop[URN] != 0) {
627 if (k == 0 || !HERE(BOTTLE)) {
631 game.place[k] = LOC_NOWHERE;
632 game.prop[BOTTLE] = EMPTY_BOTTLE;
635 spk = WATER_URN + game.prop[URN];
638 } else if (obj != 0 && obj != BOTTLE) {
641 } else if (obj == 0 && !HERE(BOTTLE))
644 if (LIQLOC(game.loc) == 0)
646 if (HERE(URN) && game.prop[URN] != 0)
650 if (spk == BOTTLED_WATER) {
651 /* FIXME: Arithmetic on property values */
652 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
655 game.place[k] = CARRIED;
663 static int find(token_t verb, token_t obj)
664 /* Find. Might be carrying it, or it might be here. Else give caveat. */
666 int spk = actions[verb].message;
668 (LIQUID() == obj && AT(BOTTLE)) ||
669 obj == LIQLOC(game.loc) ||
670 (obj == DWARF && atdwrf(game.loc) > 0))
675 spk = ALREADY_CARRYING;
680 static int fly(token_t verb, token_t obj)
681 /* Fly. Snide remarks unless hovering rug is here. */
683 int spk = actions[verb].message;
684 if (obj == INTRANSITIVE) {
685 if (game.prop[RUG] != RUG_HOVER)
689 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
701 if (game.prop[RUG] != RUG_HOVER) {
705 game.oldlc2 = game.oldloc;
706 game.oldloc = game.loc;
707 /* FIXME: Arithmetic on location values */
708 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
710 if (game.prop[SAPPH] >= 0)
716 static int inven(void)
717 /* Inventory. If object, treat same as find. Else report on current burden. */
720 for (int i = 1; i <= NOBJECTS; i++) {
721 if (i == BEAR || !TOTING(i))
726 pspeak(i, touch, -1);
736 static int light(token_t verb, token_t obj)
737 /* Light. Applicable only to lamp and urn. */
739 if (obj == INTRANSITIVE) {
740 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
742 if (HERE(URN) && game.prop[URN] == URN_DARK)
744 if (obj == INTRANSITIVE ||
745 HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
746 HERE(URN) && game.prop[URN] == URN_DARK)
751 state_change(URN, game.prop[URN] == URN_EMPTY ? URN_EMPTY : URN_LIT);
755 rspeak(actions[verb].message);
758 if (game.limit < 0) {
762 state_change(LAMP, LAMP_BRIGHT);
770 static int listen(void)
771 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
774 int spk = ALL_SILENT;
775 k = locations[game.loc].sound;
778 if (locations[game.loc].loud)
783 for (int i = 1; i <= NOBJECTS; i++) {
784 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
786 int mi = game.prop[i];
788 mi += 3 * game.blooded;
789 long packed_zzword = token_to_packed(game.zzword);
790 pspeak(i, hear, mi, packed_zzword);
792 /* FIXME: Magic number, sensitive to bird state logic */
793 if (i == BIRD && game.prop[i] == 5)
800 static int lock(token_t verb, token_t obj)
801 /* Lock, unlock, no object given. Assume various things if present. */
803 int spk = actions[verb].message;
804 if (obj == INTRANSITIVE) {
805 spk = NOTHING_LOCKED;
816 if (obj == 0 || obj == INTRANSITIVE) {
822 /* Lock, unlock object. Special stuff for opening clam/oyster
824 if (obj == CLAM || obj == OYSTER)
825 return bivalve(verb, obj);
828 if (obj == DOOR && game.prop[DOOR] == 1)
834 if (obj == GRATE || obj == CHAIN) {
842 game.clock2 = PANICTIME;
845 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
854 static int pour(token_t verb, token_t obj)
855 /* Pour. If no object, or object is bottle, assume contents of bottle.
856 * special tests for pouring water or oil on plant or rusty door. */
858 int spk = actions[verb].message;
859 if (obj == BOTTLE || obj == 0)
868 if (obj != OIL && obj != WATER) {
872 if (HERE(URN) && game.prop[URN] == 0)
873 return fill(verb, URN);
874 game.prop[BOTTLE] = EMPTY_BOTTLE;
875 game.place[obj] = LOC_NOWHERE;
877 if (!(AT(PLANT) || AT(DOOR))) {
882 spk = SHAKING_LEAVES;
887 pspeak(PLANT, look, game.prop[PLANT] + 3);
888 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
889 game.prop[PLANT2] = game.prop[PLANT];
892 state_change(DOOR, (obj == OIL) ? DOOR_UNRUSTED : DOOR_RUSTED);
897 static int quit(void)
898 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
900 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
905 static int read(struct command_t command)
906 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
908 if (command.obj == INTRANSITIVE) {
910 for (int i = 1; i <= NOBJECTS; i++) {
911 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
912 command.obj = command.obj * NOBJECTS + i;
914 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
918 if (DARK(game.loc)) {
919 rspeak(NO_SEE, command.wd1, command.wd1x);
920 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
921 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
922 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
923 rspeak(actions[command.verb].message);
925 pspeak(command.obj, study, game.prop[command.obj]);
929 static int reservoir(void)
930 /* Z'ZZZ (word gets recomputed at startup; different each game). */
932 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
933 rspeak(NOTHING_HAPPENS);
936 pspeak(RESER, look, game.prop[RESER] + 1);
937 game.prop[RESER] = 1 - game.prop[RESER];
941 game.oldlc2 = game.loc;
949 static int rub(token_t verb, token_t obj)
950 /* Rub. Yields various snide remarks except for lit urn. */
952 int spk = actions[verb].message;
954 spk = PECULIAR_NOTHING;
955 if (obj == URN && game.prop[URN] == 2) {
957 drop(AMBER, game.loc);
958 game.prop[AMBER] = 1;
960 drop(CAVITY, game.loc);
967 static int say(struct command_t *command)
968 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
970 long a = command->wd1, b = command->wd1x;
971 if (command->wd2 > 0) {
974 command->wd1 = command->wd2;
976 //int wd = vocab(command->wd1, -1);
978 packed_to_token(command->wd1, word1);
979 int wd = (int) get_vocab_id(word1);
980 /* FIXME: magic numbers */
981 if (wd == XYZZY || wd == PLUGH || wd == PLOVER || wd == ACTION_WORD(GIANTWORDS) || wd == ACTION_WORD(PART)) {
982 /* FIXME: scribbles on the interpreter's command block */
983 wordclear(&command->wd2);
986 rspeak(OKEY_DOKEY, a, b);
990 static int throw_support(long spk)
997 static int throw (struct command_t *command)
998 /* Throw. Same as discard unless axe. Then same as attack except
999 * ignore bird, and if dwarf is present then one might be killed.
1000 * (Only way to do so!) Axe also special for dragon, bear, and
1001 * troll. Treasures special for troll. */
1003 int spk = actions[command->verb].message;
1004 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1005 command->obj = ROD2;
1006 if (!TOTING(command->obj)) {
1010 if (objects[command->obj].is_treasure && AT(TROLL)) {
1011 spk = TROLL_SATISFIED;
1012 /* Snarf a treasure for the troll. */
1013 drop(command->obj, 0);
1015 move(TROLL + NOBJECTS, 0);
1016 drop(TROLL2, objects[TROLL].plac);
1017 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1022 if (command->obj == FOOD && HERE(BEAR)) {
1023 /* But throwing food is another story. */
1024 command->obj = BEAR;
1025 return (feed(command->verb, command->obj));
1027 if (command->obj != AXE)
1028 return (discard(command->verb, command->obj, false));
1030 int i = atdwrf(game.loc);
1032 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1033 return throw_support(DRAGON_SCALES);
1035 return throw_support(TROLL_RETURNS);
1037 return throw_support(OGRE_DODGE);
1038 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1039 /* This'll teach him to throw the axe at the bear! */
1040 drop(AXE, game.loc);
1041 game.fixed[AXE] = -1;
1048 return (attack(command));
1051 if (randrange(NDWARVES + 1) < game.dflag) {
1052 return throw_support(DWARF_DODGES);
1054 game.dseen[i] = false;
1056 return throw_support((++game.dkill == 1)
1057 ? DWARF_SMOKE : KILLED_DWARF);
1062 static int wake(token_t verb, token_t obj)
1063 /* Wake. Only use is to disturb the dwarves. */
1065 if (obj != DWARF || !game.closed) {
1066 rspeak(actions[verb].message);
1070 return GO_DWARFWAKE;
1074 static int wave(token_t verb, token_t obj)
1075 /* Wave. No effect unless waving rod at fissure or at bird. */
1077 int spk = actions[verb].message;
1078 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))
1079 spk = ARENT_CARRYING;
1082 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1086 /* FIXME: Arithemetic on property values */
1088 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
1089 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1090 drop(JADE, game.loc);
1091 game.prop[JADE] = 0;
1099 return GO_DWARFWAKE;
1101 if (game.closng || !AT(FISSURE)) {
1107 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1108 pspeak(FISSURE, look, 2 - game.prop[FISSURE]);
1113 int action(struct command_t *command)
1114 /* Analyse a verb. Remember what it was, go back for object if second word
1115 * unless verb is "say", which snarfs arbitrary second word.
1118 token_t spk = actions[command->verb].message;
1120 if (command->part == unknown) {
1121 /* Analyse an object word. See if the thing is here, whether
1122 * we've got a verb yet, and so on. Object must be here
1123 * unless verb is "find" or "invent(ory)" (and no new verb
1124 * yet to be analysed). Water and oil are also funny, since
1125 * they are never actually dropped at any location, but might
1126 * be here inside the bottle or urn or as a feature of the
1128 if (HERE(command->obj))
1130 else if (command->obj == GRATE) {
1131 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1132 command->obj = DPRSSN;
1133 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1134 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1135 command->obj = ENTRNC;
1136 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1138 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1140 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1143 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1144 command->obj = PLANT2;
1146 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1148 spk = KNIVES_VANISH;
1151 } else if (command->obj == ROD && HERE(ROD2)) {
1152 command->obj = ROD2;
1154 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1157 rspeak(NO_SEE, command->wd1, command->wd1x);
1161 if (command->wd2 > 0)
1163 if (command->verb != 0)
1164 command->part = transitive;
1167 switch (command->part) {
1169 if (command->wd2 > 0 && command->verb != SAY)
1171 if (command->verb == SAY)
1172 command->obj = command->wd2;
1173 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1174 /* Analyse an intransitive verb (ie, no object given yet). */
1175 switch (command->verb) {
1177 return vcarry(command->verb, INTRANSITIVE);
1183 return lock(command->verb, INTRANSITIVE);
1186 return (GO_CLEAROBJ);
1189 return lock(command->verb, INTRANSITIVE);
1191 return light(command->verb, INTRANSITIVE);
1193 return extinguish(command->verb, INTRANSITIVE);
1203 return attack(command);
1205 return pour(command->verb, command->obj);
1207 return eat(command->verb, INTRANSITIVE);
1209 return drink(command->verb, command->obj);
1223 return fill(command->verb, command->obj);
1231 return bigwords(command->wd1);
1235 command->obj = INTRANSITIVE;
1236 return read(*command);
1246 return fly(command->verb, INTRANSITIVE);
1252 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1257 /* Analyse a transitive verb. */
1258 switch (command->verb) {
1260 return vcarry(command->verb, command->obj);
1262 return discard(command->verb, command->obj, false);
1264 return say(command);
1266 return lock(command->verb, command->obj);
1269 return (GO_CLEAROBJ);
1272 return lock(command->verb, command->obj);
1274 return light(command->verb, command->obj);
1276 return extinguish(command->verb, command->obj);
1278 return wave(command->verb, command->obj);
1288 return attack(command);
1290 return pour(command->verb, command->obj);
1292 return eat(command->verb, command->obj);
1294 return drink(command->verb, command->obj);
1296 return rub(command->verb, command->obj);
1298 return throw (command);
1304 return find(command->verb, command->obj);
1306 return find(command->verb, command->obj);
1308 return feed(command->verb, command->obj);
1310 return fill(command->verb, command->obj);
1327 return read(*command);
1329 return vbreak(command->verb, command->obj);
1331 return wake(command->verb, command->obj);
1341 return fly(command->verb, command->obj);
1349 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1352 /* Unknown verb, couldn't deduce object - might need hint */
1353 rspeak(WHAT_DO, command->wd1, command->wd1x);
1354 return GO_CHECKHINT;
1356 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE