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 */
208 bool is_oyster = (obj == OYSTER);
213 if (!TOTING(TRIDENT)) {
214 rspeak(is_oyster ? OYSTER_OPENER : CLAM_OPENER);
218 rspeak( is_oyster ? DROP_OYSTER : DROP_CLAM);
224 drop(OYSTER, game.loc);
225 drop(PEARL, LOC_CULDESAC);
227 rspeak(is_oyster ? OYSTER_OPENS : PEARL_FALLS);
231 static void blast(void)
232 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
234 if (game.prop[ROD2] < 0 || !game.closed)
235 rspeak(REQUIRES_DYNAMITE);
237 game.bonus = VICTORY_MESSAGE;
238 if (game.loc == LOC_NE)
239 game.bonus = DEFEAT_MESSAGE;
241 game.bonus = SPLATTER_MESSAGE;
247 static int vbreak(token_t verb, token_t obj)
248 /* Break. Only works for mirror in repository and, of course, the vase. */
252 rspeak(BREAK_MIRROR);
259 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
261 drop(VASE, game.loc);
262 state_change(VASE, VASE_BROKEN);
263 game.fixed[VASE] = -1;
266 rspeak(actions[verb].message);
267 return (GO_CLEAROBJ);
270 static int brief(void)
271 /* Brief. Intransitive only. Suppress long descriptions after first time. */
275 rspeak(BRIEF_CONFIRM);
279 static int vcarry(token_t verb, token_t obj)
280 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
281 * take one without the other). Liquids also special, since they depend on
282 * status of bottle. Also various side effects, etc. */
285 if (obj == INTRANSITIVE) {
286 /* Carry, no object given yet. OK if only one object present. */
287 if (game.atloc[game.loc] == 0 ||
288 game.link[game.atloc[game.loc]] != 0 ||
289 atdwrf(game.loc) > 0)
291 obj = game.atloc[game.loc];
295 rspeak(ALREADY_CARRYING);
299 if (obj == PLANT && game.prop[PLANT] <= 0)
301 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
303 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
308 spk = DOUGHNUT_HOLES;
311 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
314 spk = HAND_PASSTHROUGH;
316 rspeak(REMOVE_MESSAGE);
320 if (game.fixed[obj] != 0) {
324 if (obj == WATER || obj == OIL) {
325 if (!HERE(BOTTLE) || LIQUID() != obj) {
326 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
327 return (fill(verb, BOTTLE));
329 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
341 if (game.holdng >= INVLIMIT) {
344 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
345 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
354 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
358 game.prop[BIRD] = BIRD_CAGED;
360 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
361 carry(BIRD + CAGE - obj, game.loc);
362 carry(obj, game.loc);
363 if (obj == BOTTLE && LIQUID() != 0)
364 game.place[LIQUID()] = CARRIED;
365 if (GSTONE(obj) && game.prop[obj] != 0) {
366 game.prop[obj] = STATE_GROUND;
367 game.prop[CAVITY] = CAVITY_EMPTY;
373 static int chain(token_t verb)
374 /* Do something to the bear's chain */
378 spk = CHAIN_UNLOCKED;
379 if (game.prop[BEAR] == UNTAMED_BEAR)
381 if (game.prop[CHAIN] == CHAIN_HEAP)
382 spk = ALREADY_UNLOCKED;
383 if (spk != CHAIN_UNLOCKED) {
387 game.prop[CHAIN] = CHAIN_HEAP;
388 game.fixed[CHAIN] = CHAIN_HEAP;
389 if (game.prop[BEAR] != BEAR_DEAD)
390 game.prop[BEAR] = CONTENTED_BEAR;
391 /* FIXME: Arithmetic on state numbers */
392 game.fixed[BEAR] = 2 - game.prop[BEAR];
395 if (game.prop[CHAIN] != CHAIN_HEAP)
396 spk = ALREADY_LOCKED;
397 if (game.loc != objects[CHAIN].plac)
399 if (spk != CHAIN_LOCKED) {
403 game.prop[CHAIN] = CHAIN_FIXED;
405 drop(CHAIN, game.loc);
406 game.fixed[CHAIN] = -1;
412 static int discard(token_t verb, token_t obj, bool just_do_it)
413 /* Discard object. "Throw" also comes here for most objects. Special cases for
414 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
415 * Drop coins at vending machine for extra batteries. */
417 int spk = actions[verb].message;
419 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
425 if (obj == BIRD && HERE(SNAKE)) {
426 rspeak(BIRD_ATTACKS);
430 /* Set game.prop for use by travel options */
431 game.prop[SNAKE] = SNAKE_CHASED;
433 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
436 game.prop[CAVITY] = CAVITY_FULL;
437 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || (obj == RUBY &&
438 game.prop[RUG] == RUG_HOVER))) {
445 if (spk != RUG_WIGGLES) {
446 /* FIXME: Arithmetic on state numbers */
447 int k = 2 - game.prop[RUG];
450 k = objects[SAPPH].plac;
451 move(RUG + NOBJECTS, k);
454 } else if (obj == COINS && HERE(VEND)) {
456 drop(BATTERY, game.loc);
457 pspeak(BATTERY, look, FRESH_BATTERIES, true);
459 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
463 } else if (obj == BEAR && AT(TROLL)) {
464 rspeak(TROLL_SCAMPERS);
465 move(TROLL, LOC_NOWHERE);
466 move(TROLL + NOBJECTS, LOC_NOWHERE);
467 move(TROLL2, objects[TROLL].plac);
468 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
470 game.prop[TROLL] = TROLL_GONE;
471 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
474 game.prop[VASE] = VASE_BROKEN;
476 game.prop[VASE] = VASE_WHOLE;
477 pspeak(VASE, look, game.prop[VASE] + 1, true);
478 if (game.prop[VASE] != VASE_WHOLE)
479 game.fixed[VASE] = -1;
485 if (obj == BOTTLE && k != 0)
486 game.place[k] = LOC_NOWHERE;
487 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
488 drop(BIRD, game.loc);
492 game.prop[BIRD] = BIRD_UNCAGED;
493 if (FOREST(game.loc))
494 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
498 static int drink(token_t verb, token_t obj)
499 /* Drink. If no object, assume water and look for it here. If water is in
500 * the bottle, drink that, else must be at a water loc, so drink stream. */
502 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
505 if (obj != NO_OBJECT && obj != WATER) {
506 rspeak(RIDICULOUS_ATTEMPT);
507 } else if (LIQUID() == WATER && HERE(BOTTLE)) {
508 game.prop[BOTTLE] = EMPTY_BOTTLE;
509 game.place[WATER] = LOC_NOWHERE;
510 rspeak(BOTTLE_EMPTY);
512 rspeak(actions[verb].message);
516 state_change(DRAGON, DRAGON_BLOODLESS);
522 static int eat(token_t verb, token_t obj)
523 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
524 * ok, some things lose appetite, rest are ridiculous. */
526 if (obj == INTRANSITIVE) {
530 rspeak(THANKS_DELICIOUS);
535 rspeak(THANKS_DELICIOUS);
538 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
539 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
541 rspeak(LOST_APPETITE);
544 rspeak(actions[verb].message);
548 static int extinguish(token_t verb, int obj)
549 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
551 if (obj == INTRANSITIVE) {
552 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
554 if (HERE(URN) && game.prop[URN] == URN_LIT)
556 if (obj == INTRANSITIVE ||
557 (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT &&
558 HERE(URN) && game.prop[URN] == URN_LIT))
563 if (game.prop[URN] != URN_EMPTY) {
564 state_change(URN, URN_DARK);
566 pspeak(URN, change, URN_DARK, true);
569 } else if (obj == LAMP) {
570 state_change(LAMP, LAMP_DARK);
571 rspeak(DARK(game.loc) ? PITCH_DARK : NO_MESSAGE);
572 } else if (obj == DRAGON || obj == VOLCANO) {
573 rspeak(BEYOND_POWER);
576 rspeak(actions[verb].message);
581 static int feed(token_t verb, token_t obj)
582 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
583 * mad. Bear, special. */
585 int spk = actions[verb].message;
589 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
590 spk = NOTHING_EDIBLE;
591 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
592 spk = RIDICULOUS_ATTEMPT;
595 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
599 } else if (obj == DWARF) {
604 } else if (obj == BEAR) {
605 if (game.prop[BEAR] == UNTAMED_BEAR)
606 spk = NOTHING_EDIBLE;
607 if (game.prop[BEAR] == BEAR_DEAD)
608 spk = RIDICULOUS_ATTEMPT;
611 game.prop[BEAR] = SITTING_BEAR;
616 } else if (obj == OGRE) {
626 int fill(token_t verb, token_t obj)
627 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
631 int spk = actions[verb].message;
633 spk = ARENT_CARRYING;
634 if (LIQLOC(game.loc) == 0)
636 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
640 rspeak(SHATTER_VASE);
641 game.prop[VASE] = VASE_BROKEN;
642 game.fixed[VASE] = -1;
643 return (discard(verb, obj, true));
644 } else if (obj == URN) {
646 if (game.prop[URN] != URN_EMPTY) {
652 if (k == 0 || !HERE(BOTTLE)) {
656 game.place[k] = LOC_NOWHERE;
657 game.prop[BOTTLE] = EMPTY_BOTTLE;
659 game.prop[URN] = URN_DARK;
660 spk = WATER_URN + game.prop[URN];
663 } else if (obj != NO_OBJECT && obj != BOTTLE) {
666 } else if (obj == NO_OBJECT && !HERE(BOTTLE))
669 if (LIQLOC(game.loc) == 0)
671 if (HERE(URN) && game.prop[URN] != URN_EMPTY)
675 if (spk == BOTTLED_WATER) {
676 /* FIXME: Arithmetic on property values */
677 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
680 game.place[k] = CARRIED;
688 static int find(token_t verb, token_t obj)
689 /* Find. Might be carrying it, or it might be here. Else give caveat. */
691 int spk = actions[verb].message;
693 (LIQUID() == obj && AT(BOTTLE)) ||
694 obj == LIQLOC(game.loc) ||
695 (obj == DWARF && atdwrf(game.loc) > 0))
700 spk = ALREADY_CARRYING;
705 static int fly(token_t verb, token_t obj)
706 /* Fly. Snide remarks unless hovering rug is here. */
708 if (obj == INTRANSITIVE) {
713 if (game.prop[RUG] != RUG_HOVER) {
714 rspeak(RUG_NOTHING2);
721 rspeak(actions[verb].message);
724 if (game.prop[RUG] != RUG_HOVER) {
725 rspeak(RUG_NOTHING1);
728 game.oldlc2 = game.oldloc;
729 game.oldloc = game.loc;
730 /* FIXME: Arithmetic on location values */
731 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
733 if (game.prop[SAPPH] >= 0) {
741 static int inven(void)
742 /* Inventory. If object, treat same as find. Else report on current burden. */
745 for (int i = 1; i <= NOBJECTS; i++) {
746 if (i == BEAR || !TOTING(i))
750 pspeak(i, touch, -1, false);
759 static int light(token_t verb, token_t obj)
760 /* Light. Applicable only to lamp and urn. */
762 if (obj == INTRANSITIVE) {
763 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
765 if (HERE(URN) && game.prop[URN] == URN_DARK)
767 if (obj == INTRANSITIVE ||
768 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
769 HERE(URN) && game.prop[URN] == URN_DARK))
774 state_change(URN, game.prop[URN] == URN_EMPTY ? URN_EMPTY : URN_LIT);
778 rspeak(actions[verb].message);
781 if (game.limit < 0) {
785 state_change(LAMP, LAMP_BRIGHT);
793 static int listen(void)
794 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
796 long sound = locations[game.loc].sound;
797 if (sound != SILENT) {
799 if (!locations[game.loc].loud)
803 for (int i = 1; i <= NOBJECTS; i++) {
804 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
806 int mi = game.prop[i];
808 mi += 3 * game.blooded;
809 long packed_zzword = token_to_packed(game.zzword);
810 pspeak(i, hear, mi, true, packed_zzword);
812 /* FIXME: Magic number, sensitive to bird state logic */
813 if (i == BIRD && game.prop[i] == 5)
821 static int lock(token_t verb, token_t obj)
822 /* Lock, unlock, no object given. Assume various things if present. */
824 if (obj == INTRANSITIVE) {
835 if (obj == NO_OBJECT || obj == INTRANSITIVE) {
836 rspeak(NOTHING_LOCKED);
841 /* Lock, unlock object. Special stuff for opening clam/oyster
843 int spk = actions[verb].message;
844 if (obj == CLAM || obj == OYSTER)
845 return bivalve(verb, obj);
847 spk = (game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR;
852 if (obj == GRATE || obj == CHAIN) {
860 game.clock2 = PANICTIME;
863 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
872 static int pour(token_t verb, token_t obj)
873 /* Pour. If no object, or object is bottle, assume contents of bottle.
874 * special tests for pouring water or oil on plant or rusty door. */
876 if (obj == BOTTLE || obj == NO_OBJECT)
878 if (obj == NO_OBJECT)
881 rspeak(actions[verb].message);
885 if (obj != OIL && obj != WATER) {
889 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
890 return fill(verb, URN);
891 game.prop[BOTTLE] = EMPTY_BOTTLE;
892 game.place[obj] = LOC_NOWHERE;
893 if (!(AT(PLANT) || AT(DOOR))) {
899 rspeak(SHAKING_LEAVES);
902 pspeak(PLANT, look, game.prop[PLANT] + 3, true);
903 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
904 game.prop[PLANT2] = game.prop[PLANT];
907 state_change(DOOR, (obj == OIL) ? DOOR_UNRUSTED : DOOR_RUSTED);
912 static int quit(void)
913 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
915 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
920 static int read(struct command_t command)
921 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
923 if (command.obj == INTRANSITIVE) {
925 for (int i = 1; i <= NOBJECTS; i++) {
926 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
927 command.obj = command.obj * NOBJECTS + i;
929 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
933 if (DARK(game.loc)) {
934 rspeak(NO_SEE, command.wd1, command.wd1x);
935 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
936 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
937 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
938 rspeak(actions[command.verb].message);
940 pspeak(command.obj, study, game.prop[command.obj], true);
944 static int reservoir(void)
945 /* Z'ZZZ (word gets recomputed at startup; different each game). */
947 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
948 rspeak(NOTHING_HAPPENS);
951 pspeak(RESER, look, game.prop[RESER] + 1, true);
952 game.prop[RESER] = 1 - game.prop[RESER];
956 game.oldlc2 = game.loc;
964 static int rub(token_t verb, token_t obj)
965 /* Rub. Yields various snide remarks except for lit urn. */
967 if (obj == URN && game.prop[URN] == URN_LIT) {
969 drop(AMBER, game.loc);
970 game.prop[AMBER] = AMBER_IN_ROCK;
972 drop(CAVITY, game.loc);
974 } else if (obj != LAMP) {
975 rspeak(PECULIAR_NOTHING);
977 rspeak(actions[verb].message);
982 static int say(struct command_t *command)
983 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
985 long a = command->wd1, b = command->wd1x;
986 if (command->wd2 > 0) {
989 command->wd1 = command->wd2;
992 packed_to_token(command->wd1, word1);
993 int wd = (int) get_vocab_id(word1);
994 /* FIXME: magic numbers */
995 if (wd == MOTION_WORD(XYZZY) || wd == MOTION_WORD(PLUGH) || wd == MOTION_WORD(PLOVER) || wd == ACTION_WORD(GIANTWORDS) || wd == ACTION_WORD(PART)) {
996 /* FIXME: scribbles on the interpreter's command block */
997 wordclear(&command->wd2);
1000 rspeak(OKEY_DOKEY, a, b);
1004 static int throw_support(long spk)
1007 drop(AXE, game.loc);
1011 static int throw (struct command_t *command)
1012 /* Throw. Same as discard unless axe. Then same as attack except
1013 * ignore bird, and if dwarf is present then one might be killed.
1014 * (Only way to do so!) Axe also special for dragon, bear, and
1015 * troll. Treasures special for troll. */
1017 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1018 command->obj = ROD2;
1019 if (!TOTING(command->obj)) {
1020 rspeak(actions[command->verb].message);
1023 if (objects[command->obj].is_treasure && AT(TROLL)) {
1024 /* Snarf a treasure for the troll. */
1025 drop(command->obj, LOC_NOWHERE);
1026 move(TROLL, LOC_NOWHERE);
1027 move(TROLL + NOBJECTS, LOC_NOWHERE);
1028 drop(TROLL2, objects[TROLL].plac);
1029 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1031 rspeak(TROLL_SATISFIED);
1034 if (command->obj == FOOD && HERE(BEAR)) {
1035 /* But throwing food is another story. */
1036 command->obj = BEAR;
1037 return (feed(command->verb, command->obj));
1039 if (command->obj != AXE)
1040 return (discard(command->verb, command->obj, false));
1042 if (atdwrf(game.loc) <= 0) {
1043 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1044 return throw_support(DRAGON_SCALES);
1046 return throw_support(TROLL_RETURNS);
1048 return throw_support(OGRE_DODGE);
1049 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1050 /* This'll teach him to throw the axe at the bear! */
1051 drop(AXE, game.loc);
1052 game.fixed[AXE] = -1;
1054 state_change(AXE, AXE_LOST);
1057 command->obj = NO_OBJECT;
1058 return (attack(command));
1061 if (randrange(NDWARVES + 1) < game.dflag) {
1062 return throw_support(DWARF_DODGES);
1064 long i = atdwrf(game.loc);
1065 game.dseen[i] = false;
1067 return throw_support((++game.dkill == 1)
1068 ? DWARF_SMOKE : KILLED_DWARF);
1073 static int wake(token_t verb, token_t obj)
1074 /* Wake. Only use is to disturb the dwarves. */
1076 if (obj != DWARF || !game.closed) {
1077 rspeak(actions[verb].message);
1081 return GO_DWARFWAKE;
1085 static int wave(token_t verb, token_t obj)
1086 /* Wave. No effect unless waving rod at fissure or at bird. */
1090 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1091 rspeak(((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2))) ? ARENT_CARRYING : actions[verb].message);
1095 if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1096 drop(JADE, game.loc);
1097 game.prop[JADE] = 0;
1099 rspeak(NECKLACE_FLY);
1103 rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY);
1104 return GO_DWARFWAKE;
1106 if (game.closng || !AT(FISSURE)) {
1107 rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY);
1111 rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY);
1113 /* FIXME: Arithemetic on property values */
1114 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1115 pspeak(FISSURE, look, 2 - game.prop[FISSURE], true);
1120 int action(struct command_t *command)
1121 /* Analyse a verb. Remember what it was, go back for object if second word
1122 * unless verb is "say", which snarfs arbitrary second word.
1125 if (command->part == unknown) {
1126 /* Analyse an object word. See if the thing is here, whether
1127 * we've got a verb yet, and so on. Object must be here
1128 * unless verb is "find" or "invent(ory)" (and no new verb
1129 * yet to be analysed). Water and oil are also funny, since
1130 * they are never actually dropped at any location, but might
1131 * be here inside the bottle or urn or as a feature of the
1133 if (HERE(command->obj))
1135 else if (command->obj == GRATE) {
1136 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1137 command->obj = DPRSSN;
1138 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1139 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1140 command->obj = ENTRNC;
1141 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1143 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1145 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1148 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1149 command->obj = PLANT2;
1151 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1153 rspeak(KNIVES_VANISH);
1155 } else if (command->obj == ROD && HERE(ROD2)) {
1156 command->obj = ROD2;
1158 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1161 rspeak(NO_SEE, command->wd1, command->wd1x);
1165 if (command->wd2 > 0)
1167 if (command->verb != 0)
1168 command->part = transitive;
1171 switch (command->part) {
1173 if (command->wd2 > 0 && command->verb != SAY)
1175 if (command->verb == SAY)
1176 command->obj = command->wd2;
1177 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1178 /* Analyse an intransitive verb (ie, no object given yet). */
1179 switch (command->verb) {
1181 return vcarry(command->verb, INTRANSITIVE);
1187 return lock(command->verb, INTRANSITIVE);
1190 return (GO_CLEAROBJ);
1193 return lock(command->verb, INTRANSITIVE);
1195 return light(command->verb, INTRANSITIVE);
1197 return extinguish(command->verb, INTRANSITIVE);
1203 rspeak(actions[command->verb].message);
1207 return attack(command);
1209 return pour(command->verb, command->obj);
1211 return eat(command->verb, INTRANSITIVE);
1213 return drink(command->verb, command->obj);
1227 return fill(command->verb, command->obj);
1235 return bigwords(command->wd1);
1239 command->obj = INTRANSITIVE;
1240 return read(*command);
1250 return fly(command->verb, INTRANSITIVE);
1256 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1261 /* Analyse a transitive verb. */
1262 switch (command->verb) {
1264 return vcarry(command->verb, command->obj);
1266 return discard(command->verb, command->obj, false);
1268 return say(command);
1270 return lock(command->verb, command->obj);
1273 return (GO_CLEAROBJ);
1276 return lock(command->verb, command->obj);
1278 return light(command->verb, command->obj);
1280 return extinguish(command->verb, command->obj);
1282 return wave(command->verb, command->obj);
1284 rspeak(actions[command->verb].message);
1288 rspeak(actions[command->verb].message);
1292 return attack(command);
1294 return pour(command->verb, command->obj);
1296 return eat(command->verb, command->obj);
1298 return drink(command->verb, command->obj);
1300 return rub(command->verb, command->obj);
1302 return throw (command);
1304 rspeak(actions[command->verb].message);
1308 return find(command->verb, command->obj);
1310 return find(command->verb, command->obj);
1312 return feed(command->verb, command->obj);
1314 return fill(command->verb, command->obj);
1319 rspeak(actions[command->verb].message);
1323 rspeak(actions[command->verb].message);
1327 rspeak(actions[command->verb].message);
1331 return read(*command);
1333 return vbreak(command->verb, command->obj);
1335 return wake(command->verb, command->obj);
1337 rspeak(actions[command->verb].message);
1341 rspeak(actions[command->verb].message);
1345 return fly(command->verb, command->obj);
1347 rspeak(actions[command->verb].message);
1353 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1356 /* Unknown verb, couldn't deduce object - might need hint */
1357 rspeak(WHAT_DO, command->wd1, command->wd1x);
1358 return GO_CHECKHINT;
1360 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE