6 static int fill(token_t, token_t);
8 static void state_change(long obj, long state)
10 game.prop[obj] = state;
11 pspeak(obj, change, state, true);
14 static int attack(struct command_t *command)
15 /* Attack. Assume target if unambiguous. "Throw" also links here.
16 * Attackable objects fall into two categories: enemies (snake,
17 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
18 * enemies, or no enemies but 2 others. */
20 vocab_t verb = command->verb;
21 vocab_t obj = command->obj;
23 long spk = actions[verb].message;
24 if (obj == NO_OBJECT || obj == INTRANSITIVE) {
26 if (atdwrf(game.loc) > 0) {
34 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
46 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
50 /* check for low-priority targets */
51 if (obj == NO_OBJECT) {
52 /* Can't attack bird or machine by throwing axe. */
53 if (HERE(BIRD) && verb != THROW) {
57 if (HERE(VEND) && verb != THROW) {
61 /* Clam and oyster both treated as clam for intransitive case;
63 if (HERE(CLAM) || HERE(OYSTER)) {
79 } else if (obj == VEND) {
81 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
87 if (obj == CLAM || obj == OYSTER)
88 spk = SHELL_IMPERVIOUS;
92 spk = BARE_HANDS_QUERY;
93 if (obj == DWARF && game.closed)
101 if (obj == OGRE && atdwrf(game.loc) > 0) {
103 rspeak(KNIFE_THROWN);
106 for (int i = 1; i < PIRATE; i++) {
107 if (game.dloc[i] == game.loc) {
109 game.dloc[i] = LOC_LONGWEST;
110 game.dseen[i] = false;
113 spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2;
114 } else if (obj == BEAR) {
115 switch (game.prop[BEAR]) {
129 } else if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
130 /* Fun stuff for dragon. If he insists on attacking it, win!
131 * Set game.prop to dead, move dragon to central loc (still
132 * fixed), move rug there (not fixed), and move him there,
133 * too. Then do a null motion to get new description. */
134 rspeak(BARE_HANDS_QUERY);
136 // FIXME: setting wd1 is a workaround for broken logic
137 command->wd1 = token_to_packed("Y");
139 // FIXME: setting wd1 is a workaround for broken logic
140 command->wd1 = token_to_packed("N");
143 state_change(DRAGON, DRAGON_DEAD);
144 game.prop[RUG] = RUG_FLOOR;
145 /* FIXME: Arithmetic on location values */
146 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
147 move(DRAGON + NOBJECTS, -1);
148 move(RUG + NOBJECTS, 0);
152 for (obj = 1; obj <= NOBJECTS; obj++) {
153 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
164 static int bigwords(token_t foo)
165 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
166 * Look up foo in special section of vocab to determine which word we've got.
167 * Last word zips the eggs back to the giant room (unless already there). */
170 packed_to_token(foo, word);
171 int k = (int) get_special_vocab_id(word);
172 int spk = NOTHING_HAPPENS;
173 if (game.foobar != 1 - k) {
174 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)
185 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
189 /* Bring back troll if we steal the eggs back from him before
191 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
192 game.prop[TROLL] = TROLL_PAIDONCE;
196 if (game.loc == objects[EGGS].plac)
198 move(EGGS, objects[EGGS].plac);
199 pspeak(EGGS, look, k, true);
205 static int bivalve(token_t verb, token_t obj)
206 /* Clam/oyster actions */
209 bool is_oyster = (obj == OYSTER);
210 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
212 spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
213 if (!TOTING(TRIDENT))
214 spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
217 if (spk == PEARL_FALLS) {
219 drop(OYSTER, game.loc);
220 drop(PEARL, LOC_CULDESAC);
226 static void blast(void)
227 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
229 if (game.prop[ROD2] < 0 || !game.closed)
230 rspeak(REQUIRES_DYNAMITE);
232 game.bonus = VICTORY_MESSAGE;
233 if (game.loc == LOC_NE)
234 game.bonus = DEFEAT_MESSAGE;
236 game.bonus = SPLATTER_MESSAGE;
242 static int vbreak(token_t verb, token_t obj)
243 /* Break. Only works for mirror in repository and, of course, the vase. */
247 rspeak(BREAK_MIRROR);
254 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
256 drop(VASE, game.loc);
257 state_change(VASE, VASE_BROKEN);
258 game.fixed[VASE] = -1;
261 rspeak(actions[verb].message);
262 return (GO_CLEAROBJ);
265 static int brief(void)
266 /* Brief. Intransitive only. Suppress long descriptions after first time. */
270 rspeak(BRIEF_CONFIRM);
274 static int vcarry(token_t verb, token_t obj)
275 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
276 * take one without the other). Liquids also special, since they depend on
277 * status of bottle. Also various side effects, etc. */
280 if (obj == INTRANSITIVE) {
281 /* Carry, no object given yet. OK if only one object present. */
282 if (game.atloc[game.loc] == 0 ||
283 game.link[game.atloc[game.loc]] != 0 ||
284 atdwrf(game.loc) > 0)
286 obj = game.atloc[game.loc];
290 rspeak(ALREADY_CARRYING);
294 if (obj == PLANT && game.prop[PLANT] <= 0)
296 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
298 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
303 spk = DOUGHNUT_HOLES;
306 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
309 spk = HAND_PASSTHROUGH;
311 rspeak(REMOVE_MESSAGE);
315 if (game.fixed[obj] != 0) {
319 if (obj == WATER || obj == OIL) {
320 if (!HERE(BOTTLE) || LIQUID() != obj) {
321 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
322 return (fill(verb, BOTTLE));
324 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
336 if (game.holdng >= INVLIMIT) {
339 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
340 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
349 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
353 game.prop[BIRD] = BIRD_CAGED;
355 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
356 carry(BIRD + CAGE - obj, game.loc);
357 carry(obj, game.loc);
358 if (obj == BOTTLE && LIQUID() != 0)
359 game.place[LIQUID()] = CARRIED;
360 if (GSTONE(obj) && game.prop[obj] != 0) {
361 game.prop[obj] = STATE_GROUND;
362 game.prop[CAVITY] = CAVITY_EMPTY;
368 static int chain(token_t verb)
369 /* Do something to the bear's chain */
373 spk = CHAIN_UNLOCKED;
374 if (game.prop[BEAR] == UNTAMED_BEAR)
376 if (game.prop[CHAIN] == CHAIN_HEAP)
377 spk = ALREADY_UNLOCKED;
378 if (spk != CHAIN_UNLOCKED) {
382 game.prop[CHAIN] = CHAIN_HEAP;
383 game.fixed[CHAIN] = CHAIN_HEAP;
384 if (game.prop[BEAR] != BEAR_DEAD)
385 game.prop[BEAR] = CONTENTED_BEAR;
386 /* FIXME: Arithmetic on state numbers */
387 game.fixed[BEAR] = 2 - game.prop[BEAR];
390 if (game.prop[CHAIN] != CHAIN_HEAP)
391 spk = ALREADY_LOCKED;
392 if (game.loc != objects[CHAIN].plac)
394 if (spk != CHAIN_LOCKED) {
398 game.prop[CHAIN] = CHAIN_FIXED;
400 drop(CHAIN, game.loc);
401 game.fixed[CHAIN] = -1;
407 static int discard(token_t verb, token_t obj, bool just_do_it)
408 /* Discard object. "Throw" also comes here for most objects. Special cases for
409 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
410 * Drop coins at vending machine for extra batteries. */
412 int spk = actions[verb].message;
414 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
420 if (obj == BIRD && HERE(SNAKE)) {
421 rspeak(BIRD_ATTACKS);
425 /* Set game.prop for use by travel options */
426 game.prop[SNAKE] = SNAKE_CHASED;
428 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
431 game.prop[CAVITY] = CAVITY_FULL;
432 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || (obj == RUBY &&
433 game.prop[RUG] == RUG_HOVER))) {
440 if (spk != RUG_WIGGLES) {
441 /* FIXME: Arithmetic on state numbers */
442 int k = 2 - game.prop[RUG];
445 k = objects[SAPPH].plac;
446 move(RUG + NOBJECTS, k);
449 } else if (obj == COINS && HERE(VEND)) {
451 drop(BATTERY, game.loc);
452 pspeak(BATTERY, look, FRESH_BATTERIES, true);
454 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
458 } else if (obj == BEAR && AT(TROLL)) {
459 rspeak(TROLL_SCAMPERS);
460 move(TROLL, LOC_NOWHERE);
461 move(TROLL + NOBJECTS, LOC_NOWHERE);
462 move(TROLL2, objects[TROLL].plac);
463 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
465 game.prop[TROLL] = TROLL_GONE;
466 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
469 game.prop[VASE] = VASE_BROKEN;
471 game.prop[VASE] = VASE_WHOLE;
472 pspeak(VASE, look, game.prop[VASE] + 1, true);
473 if (game.prop[VASE] != VASE_WHOLE)
474 game.fixed[VASE] = -1;
480 if (obj == BOTTLE && k != 0)
481 game.place[k] = LOC_NOWHERE;
482 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
483 drop(BIRD, game.loc);
487 game.prop[BIRD] = BIRD_UNCAGED;
488 if (FOREST(game.loc))
489 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
493 static int drink(token_t verb, token_t obj)
494 /* Drink. If no object, assume water and look for it here. If water is in
495 * the bottle, drink that, else must be at a water loc, so drink stream. */
497 if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
500 if (obj != NO_OBJECT && obj != WATER) {
501 rspeak(RIDICULOUS_ATTEMPT);
502 } else if (LIQUID() == WATER && HERE(BOTTLE)) {
503 game.prop[BOTTLE] = EMPTY_BOTTLE;
504 game.place[WATER] = LOC_NOWHERE;
505 rspeak(BOTTLE_EMPTY);
507 rspeak(actions[verb].message);
511 state_change(DRAGON, DRAGON_BLOODLESS);
517 static int eat(token_t verb, token_t obj)
518 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
519 * ok, some things lose appetite, rest are ridiculous. */
521 if (obj == INTRANSITIVE) {
525 rspeak(THANKS_DELICIOUS);
530 rspeak(THANKS_DELICIOUS);
533 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
534 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
536 rspeak(LOST_APPETITE);
539 rspeak(actions[verb].message);
543 static int extinguish(token_t verb, int obj)
544 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
546 if (obj == INTRANSITIVE) {
547 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
549 if (HERE(URN) && game.prop[URN] == URN_LIT)
551 if (obj == INTRANSITIVE ||
552 (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT &&
553 HERE(URN) && game.prop[URN] == URN_LIT))
558 if (game.prop[URN] != URN_EMPTY) {
559 state_change(URN, URN_DARK);
561 pspeak(URN, change, URN_DARK, true);
564 } else if (obj == LAMP) {
565 state_change(LAMP, LAMP_DARK);
566 rspeak(DARK(game.loc) ? PITCH_DARK : NO_MESSAGE);
567 } else if (obj == DRAGON || obj == VOLCANO) {
568 rspeak(BEYOND_POWER);
571 rspeak(actions[verb].message);
576 static int feed(token_t verb, token_t obj)
577 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
578 * mad. Bear, special. */
580 int spk = actions[verb].message;
584 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
585 spk = NOTHING_EDIBLE;
586 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
587 spk = RIDICULOUS_ATTEMPT;
590 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
594 } else if (obj == DWARF) {
599 } else if (obj == BEAR) {
600 if (game.prop[BEAR] == UNTAMED_BEAR)
601 spk = NOTHING_EDIBLE;
602 if (game.prop[BEAR] == BEAR_DEAD)
603 spk = RIDICULOUS_ATTEMPT;
606 game.prop[BEAR] = SITTING_BEAR;
611 } else if (obj == OGRE) {
621 int fill(token_t verb, token_t obj)
622 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
626 int spk = actions[verb].message;
628 spk = ARENT_CARRYING;
629 if (LIQLOC(game.loc) == 0)
631 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
635 rspeak(SHATTER_VASE);
636 game.prop[VASE] = VASE_BROKEN;
637 game.fixed[VASE] = -1;
638 return (discard(verb, obj, true));
639 } else if (obj == URN) {
641 if (game.prop[URN] != URN_EMPTY) {
647 if (k == 0 || !HERE(BOTTLE)) {
651 game.place[k] = LOC_NOWHERE;
652 game.prop[BOTTLE] = EMPTY_BOTTLE;
654 game.prop[URN] = URN_DARK;
655 spk = WATER_URN + game.prop[URN];
658 } else if (obj != NO_OBJECT && obj != BOTTLE) {
661 } else if (obj == NO_OBJECT && !HERE(BOTTLE))
664 if (LIQLOC(game.loc) == 0)
666 if (HERE(URN) && game.prop[URN] != URN_EMPTY)
670 if (spk == BOTTLED_WATER) {
671 /* FIXME: Arithmetic on property values */
672 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
675 game.place[k] = CARRIED;
683 static int find(token_t verb, token_t obj)
684 /* Find. Might be carrying it, or it might be here. Else give caveat. */
686 int spk = actions[verb].message;
688 (LIQUID() == obj && AT(BOTTLE)) ||
689 obj == LIQLOC(game.loc) ||
690 (obj == DWARF && atdwrf(game.loc) > 0))
695 spk = ALREADY_CARRYING;
700 static int fly(token_t verb, token_t obj)
701 /* Fly. Snide remarks unless hovering rug is here. */
703 int spk = actions[verb].message;
704 if (obj == INTRANSITIVE) {
705 if (game.prop[RUG] != RUG_HOVER)
709 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
721 if (game.prop[RUG] != RUG_HOVER) {
725 game.oldlc2 = game.oldloc;
726 game.oldloc = game.loc;
727 /* FIXME: Arithmetic on location values */
728 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
730 if (game.prop[SAPPH] >= 0)
736 static int inven(void)
737 /* Inventory. If object, treat same as find. Else report on current burden. */
740 for (int i = 1; i <= NOBJECTS; i++) {
741 if (i == BEAR || !TOTING(i))
745 pspeak(i, touch, -1, false);
754 static int light(token_t verb, token_t obj)
755 /* Light. Applicable only to lamp and urn. */
757 if (obj == INTRANSITIVE) {
758 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
760 if (HERE(URN) && game.prop[URN] == URN_DARK)
762 if (obj == INTRANSITIVE ||
763 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
764 HERE(URN) && game.prop[URN] == URN_DARK))
769 state_change(URN, game.prop[URN] == URN_EMPTY ? URN_EMPTY : URN_LIT);
773 rspeak(actions[verb].message);
776 if (game.limit < 0) {
780 state_change(LAMP, LAMP_BRIGHT);
788 static int listen(void)
789 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
792 int spk = ALL_SILENT;
793 k = locations[game.loc].sound;
796 if (locations[game.loc].loud)
801 for (int i = 1; i <= NOBJECTS; i++) {
802 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
804 int mi = game.prop[i];
806 mi += 3 * game.blooded;
807 long packed_zzword = token_to_packed(game.zzword);
808 pspeak(i, hear, mi, true, packed_zzword);
810 /* FIXME: Magic number, sensitive to bird state logic */
811 if (i == BIRD && game.prop[i] == 5)
818 static int lock(token_t verb, token_t obj)
819 /* Lock, unlock, no object given. Assume various things if present. */
821 int spk = actions[verb].message;
822 if (obj == INTRANSITIVE) {
823 spk = NOTHING_LOCKED;
834 if (obj == NO_OBJECT || obj == INTRANSITIVE) {
840 /* Lock, unlock object. Special stuff for opening clam/oyster
842 if (obj == CLAM || obj == OYSTER)
843 return bivalve(verb, obj);
846 if (obj == DOOR && game.prop[DOOR] == DOOR_UNRUSTED)
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