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 if (obj == INTRANSITIVE) {
26 long spk = actions[verb].message;
27 if (obj == 0 || obj == INTRANSITIVE) {
29 if (atdwrf(game.loc) > 0) {
37 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
49 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
53 /* check for low-priority targets */
55 /* Can't attack bird or machine by throwing axe. */
56 if (HERE(BIRD) && verb != THROW) {
60 if (HERE(VEND) && verb != THROW) {
64 /* Clam and oyster both treated as clam for intransitive case;
66 if (HERE(CLAM) || HERE(OYSTER)) {
82 } else if (obj == VEND) {
84 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
90 if (obj == CLAM || obj == OYSTER)
91 spk = SHELL_IMPERVIOUS;
95 spk = BARE_HANDS_QUERY;
96 if (obj == DWARF && game.closed)
104 if (obj == OGRE && atdwrf(game.loc) > 0) {
106 rspeak(KNIFE_THROWN);
109 for (int i = 1; i < PIRATE; i++) {
110 if (game.dloc[i] == game.loc) {
112 game.dloc[i] = LOC_LONGWEST;
113 game.dseen[i] = false;
116 spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2;
117 } else if (obj == BEAR) {
118 switch (game.prop[BEAR]) {
132 } else if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
133 /* Fun stuff for dragon. If he insists on attacking it, win!
134 * Set game.prop to dead, move dragon to central loc (still
135 * fixed), move rug there (not fixed), and move him there,
136 * too. Then do a null motion to get new description. */
137 rspeak(BARE_HANDS_QUERY);
139 // FIXME: setting wd1 is a workaround for broken logic
140 command->wd1 = token_to_packed("Y");
142 // FIXME: setting wd1 is a workaround for broken logic
143 command->wd1 = token_to_packed("N");
146 state_change(DRAGON, DRAGON_DEAD);
147 game.prop[RUG] = RUG_FLOOR;
148 /* FIXME: Arithmetic on location values */
149 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
150 move(DRAGON + NOBJECTS, -1);
151 move(RUG + NOBJECTS, 0);
155 for (obj = 1; obj <= NOBJECTS; obj++) {
156 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
167 static int bigwords(token_t foo)
168 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
169 * Look up foo in section 3 of vocab to determine which word we've got. Last
170 * word zips the eggs back to the giant room (unless already there). */
172 //int k = vocab(foo, 3);
174 packed_to_token(foo, word);
175 int k = (int) get_special_vocab_id(word);
176 int spk = NOTHING_HAPPENS;
177 if (game.foobar != 1 - k) {
178 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)
189 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
193 /* Bring back troll if we steal the eggs back from him before
195 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
196 game.prop[TROLL] = TROLL_PAIDONCE;
200 if (game.loc == objects[EGGS].plac)
202 move(EGGS, objects[EGGS].plac);
203 pspeak(EGGS, look, k, true);
209 static int bivalve(token_t verb, token_t obj)
210 /* Clam/oyster actions */
213 bool is_oyster = (obj == OYSTER);
214 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
216 spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
217 if (!TOTING(TRIDENT))
218 spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
221 if (spk == PEARL_FALLS) {
223 drop(OYSTER, game.loc);
224 drop(PEARL, LOC_CULDESAC);
230 static void blast(void)
231 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
233 if (game.prop[ROD2] < 0 || !game.closed)
234 rspeak(REQUIRES_DYNAMITE);
236 game.bonus = VICTORY_MESSAGE;
237 if (game.loc == LOC_NE)
238 game.bonus = DEFEAT_MESSAGE;
240 game.bonus = SPLATTER_MESSAGE;
246 static int vbreak(token_t verb, token_t obj)
247 /* Break. Only works for mirror in repository and, of course, the vase. */
251 rspeak(BREAK_MIRROR);
258 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
260 drop(VASE, game.loc);
261 state_change(VASE, VASE_BROKEN);
262 game.fixed[VASE] = -1;
265 rspeak(actions[verb].message);
266 return (GO_CLEAROBJ);
269 static int brief(void)
270 /* Brief. Intransitive only. Suppress long descriptions after first time. */
274 rspeak(BRIEF_CONFIRM);
278 static int vcarry(token_t verb, token_t obj)
279 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
280 * take one without the other). Liquids also special, since they depend on
281 * status of bottle. Also various side effects, etc. */
284 if (obj == INTRANSITIVE) {
285 /* Carry, no object given yet. OK if only one object present. */
286 if (game.atloc[game.loc] == 0 ||
287 game.link[game.atloc[game.loc]] != 0 ||
288 atdwrf(game.loc) > 0)
290 obj = game.atloc[game.loc];
294 rspeak(ALREADY_CARRYING);
298 if (obj == PLANT && game.prop[PLANT] <= 0)
300 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
302 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
307 spk = DOUGHNUT_HOLES;
310 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
313 spk = HAND_PASSTHROUGH;
315 rspeak(REMOVE_MESSAGE);
319 if (game.fixed[obj] != 0) {
323 if (obj == WATER || obj == OIL) {
324 if (!HERE(BOTTLE) || LIQUID() != obj) {
325 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
326 return (fill(verb, BOTTLE));
328 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
340 if (game.holdng >= INVLIMIT) {
343 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
344 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
353 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
357 game.prop[BIRD] = BIRD_CAGED;
359 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
360 carry(BIRD + CAGE - obj, game.loc);
361 carry(obj, game.loc);
362 if (obj == BOTTLE && LIQUID() != 0)
363 game.place[LIQUID()] = CARRIED;
364 if (GSTONE(obj) && game.prop[obj] != 0) {
366 game.prop[CAVITY] = CAVITY_EMPTY;
372 static int chain(token_t verb)
373 /* Do something to the bear's chain */
377 spk = CHAIN_UNLOCKED;
378 if (game.prop[BEAR] == UNTAMED_BEAR)
380 if (game.prop[CHAIN] == CHAIN_HEAP)
381 spk = ALREADY_UNLOCKED;
382 if (spk != CHAIN_UNLOCKED) {
386 game.prop[CHAIN] = CHAIN_HEAP;
387 game.fixed[CHAIN] = CHAIN_HEAP;
388 if (game.prop[BEAR] != BEAR_DEAD)
389 game.prop[BEAR] = CONTENTED_BEAR;
390 /* FIXME: Arithmetic on state numbers */
391 game.fixed[BEAR] = 2 - game.prop[BEAR];
394 if (game.prop[CHAIN] != CHAIN_HEAP)
395 spk = ALREADY_LOCKED;
396 if (game.loc != objects[CHAIN].plac)
398 if (spk != CHAIN_LOCKED) {
402 game.prop[CHAIN] = CHAIN_FIXED;
404 drop(CHAIN, game.loc);
405 game.fixed[CHAIN] = -1;
411 static int discard(token_t verb, token_t obj, bool just_do_it)
412 /* Discard object. "Throw" also comes here for most objects. Special cases for
413 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
414 * Drop coins at vending machine for extra batteries. */
416 int spk = actions[verb].message;
418 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
424 if (obj == BIRD && HERE(SNAKE)) {
425 rspeak(BIRD_ATTACKS);
429 /* Set game.prop for use by travel options */
430 game.prop[SNAKE] = SNAKE_CHASED;
432 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
435 game.prop[CAVITY] = CAVITY_FULL;
436 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || (obj == RUBY &&
437 game.prop[RUG] == RUG_HOVER))) {
444 if (spk != RUG_WIGGLES) {
445 /* FIXME: Arithmetic on state numbers */
446 int k = 2 - game.prop[RUG];
449 k = objects[SAPPH].plac;
450 move(RUG + NOBJECTS, k);
453 } else if (obj == COINS && HERE(VEND)) {
455 drop(BATTERY, game.loc);
456 pspeak(BATTERY, look, FRESH_BATTERIES, true);
458 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
462 } else if (obj == BEAR && AT(TROLL)) {
463 rspeak(TROLL_SCAMPERS);
465 move(TROLL + NOBJECTS, 0);
466 move(TROLL2, objects[TROLL].plac);
467 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
469 game.prop[TROLL] = TROLL_GONE;
470 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
473 game.prop[VASE] = VASE_BROKEN;
475 game.prop[VASE] = VASE_WHOLE;
476 pspeak(VASE, look, game.prop[VASE] + 1, true);
477 if (game.prop[VASE] != VASE_WHOLE)
478 game.fixed[VASE] = -1;
484 if (obj == BOTTLE && k != 0)
485 game.place[k] = LOC_NOWHERE;
486 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
487 drop(BIRD, game.loc);
491 game.prop[BIRD] = BIRD_UNCAGED;
492 if (FOREST(game.loc))
493 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
497 static int drink(token_t verb, token_t obj)
498 /* Drink. If no object, assume water and look for it here. If water is in
499 * the bottle, drink that, else must be at a water loc, so drink stream. */
501 int spk = actions[verb].message;
502 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
505 if (obj != 0 && obj != WATER)
506 spk = RIDICULOUS_ATTEMPT;
507 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
508 game.prop[BOTTLE] = EMPTY_BOTTLE;
509 game.place[WATER] = LOC_NOWHERE;
515 state_change(DRAGON, DRAGON_BLOODLESS);
521 static int eat(token_t verb, token_t obj)
522 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
523 * ok, some things lose appetite, rest are ridiculous. */
525 int spk = actions[verb].message;
526 if (obj == INTRANSITIVE) {
530 spk = THANKS_DELICIOUS;
534 spk = THANKS_DELICIOUS;
536 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
537 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
545 static int extinguish(token_t verb, int obj)
546 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
548 if (obj == INTRANSITIVE) {
549 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
551 if (HERE(URN) && game.prop[URN] == URN_LIT)
553 if (obj == INTRANSITIVE ||
554 (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT &&
555 HERE(URN) && game.prop[URN] == URN_LIT))
560 if (game.prop[URN] != URN_EMPTY) {
561 state_change(URN, URN_DARK);
563 pspeak(URN, change, URN_DARK, true);
566 } else if (obj == LAMP) {
567 state_change(LAMP, LAMP_DARK);
568 rspeak(DARK(game.loc) ? PITCH_DARK : NO_MESSAGE);
569 } else if (obj == DRAGON || obj == VOLCANO) {
570 rspeak(BEYOND_POWER);
573 rspeak(actions[verb].message);
578 static int feed(token_t verb, token_t obj)
579 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
580 * mad. Bear, special. */
582 int spk = actions[verb].message;
586 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
587 spk = NOTHING_EDIBLE;
588 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
589 spk = RIDICULOUS_ATTEMPT;
592 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
596 } else if (obj == DWARF) {
601 } else if (obj == BEAR) {
602 if (game.prop[BEAR] == UNTAMED_BEAR)
603 spk = NOTHING_EDIBLE;
604 if (game.prop[BEAR] == BEAR_DEAD)
605 spk = RIDICULOUS_ATTEMPT;
608 game.prop[BEAR] = SITTING_BEAR;
613 } else if (obj == OGRE) {
623 int fill(token_t verb, token_t obj)
624 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
628 int spk = actions[verb].message;
630 spk = ARENT_CARRYING;
631 if (LIQLOC(game.loc) == 0)
633 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
637 rspeak(SHATTER_VASE);
638 game.prop[VASE] = VASE_BROKEN;
639 game.fixed[VASE] = -1;
640 return (discard(verb, obj, true));
641 } else if (obj == URN) {
643 if (game.prop[URN] != 0) {
649 if (k == 0 || !HERE(BOTTLE)) {
653 game.place[k] = LOC_NOWHERE;
654 game.prop[BOTTLE] = EMPTY_BOTTLE;
657 spk = WATER_URN + game.prop[URN];
660 } else if (obj != 0 && obj != BOTTLE) {
663 } else if (obj == 0 && !HERE(BOTTLE))
666 if (LIQLOC(game.loc) == 0)
668 if (HERE(URN) && game.prop[URN] != 0)
672 if (spk == BOTTLED_WATER) {
673 /* FIXME: Arithmetic on property values */
674 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
677 game.place[k] = CARRIED;
685 static int find(token_t verb, token_t obj)
686 /* Find. Might be carrying it, or it might be here. Else give caveat. */
688 int spk = actions[verb].message;
690 (LIQUID() == obj && AT(BOTTLE)) ||
691 obj == LIQLOC(game.loc) ||
692 (obj == DWARF && atdwrf(game.loc) > 0))
697 spk = ALREADY_CARRYING;
702 static int fly(token_t verb, token_t obj)
703 /* Fly. Snide remarks unless hovering rug is here. */
705 int spk = actions[verb].message;
706 if (obj == INTRANSITIVE) {
707 if (game.prop[RUG] != RUG_HOVER)
711 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
723 if (game.prop[RUG] != RUG_HOVER) {
727 game.oldlc2 = game.oldloc;
728 game.oldloc = game.loc;
729 /* FIXME: Arithmetic on location values */
730 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
732 if (game.prop[SAPPH] >= 0)
738 static int inven(void)
739 /* Inventory. If object, treat same as find. Else report on current burden. */
742 for (int i = 1; i <= NOBJECTS; i++) {
743 if (i == BEAR || !TOTING(i))
747 pspeak(i, touch, -1, false);
756 static int light(token_t verb, token_t obj)
757 /* Light. Applicable only to lamp and urn. */
759 if (obj == INTRANSITIVE) {
760 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
762 if (HERE(URN) && game.prop[URN] == URN_DARK)
764 if (obj == INTRANSITIVE ||
765 (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
766 HERE(URN) && game.prop[URN] == URN_DARK))
771 state_change(URN, game.prop[URN] == URN_EMPTY ? URN_EMPTY : URN_LIT);
775 rspeak(actions[verb].message);
778 if (game.limit < 0) {
782 state_change(LAMP, LAMP_BRIGHT);
790 static int listen(void)
791 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
794 int spk = ALL_SILENT;
795 k = locations[game.loc].sound;
798 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)
820 static int lock(token_t verb, token_t obj)
821 /* Lock, unlock, no object given. Assume various things if present. */
823 int spk = actions[verb].message;
824 if (obj == INTRANSITIVE) {
825 spk = NOTHING_LOCKED;
836 if (obj == 0 || obj == INTRANSITIVE) {
842 /* Lock, unlock object. Special stuff for opening clam/oyster
844 if (obj == CLAM || obj == OYSTER)
845 return bivalve(verb, obj);
848 if (obj == DOOR && game.prop[DOOR] == DOOR_UNRUSTED)
854 if (obj == GRATE || obj == CHAIN) {
862 game.clock2 = PANICTIME;
865 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
874 static int pour(token_t verb, token_t obj)
875 /* Pour. If no object, or object is bottle, assume contents of bottle.
876 * special tests for pouring water or oil on plant or rusty door. */
878 int spk = actions[verb].message;
879 if (obj == BOTTLE || obj == 0)
888 if (obj != OIL && obj != WATER) {
892 if (HERE(URN) && game.prop[URN] == URN_EMPTY)
893 return fill(verb, URN);
894 game.prop[BOTTLE] = EMPTY_BOTTLE;
895 game.place[obj] = LOC_NOWHERE;
897 if (!(AT(PLANT) || AT(DOOR))) {
902 spk = SHAKING_LEAVES;
907 pspeak(PLANT, look, game.prop[PLANT] + 3, true);
908 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
909 game.prop[PLANT2] = game.prop[PLANT];
912 state_change(DOOR, (obj == OIL) ? DOOR_UNRUSTED : DOOR_RUSTED);
917 static int quit(void)
918 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
920 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
925 static int read(struct command_t command)
926 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
928 if (command.obj == INTRANSITIVE) {
930 for (int i = 1; i <= NOBJECTS; i++) {
931 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
932 command.obj = command.obj * NOBJECTS + i;
934 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
938 if (DARK(game.loc)) {
939 rspeak(NO_SEE, command.wd1, command.wd1x);
940 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
941 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
942 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
943 rspeak(actions[command.verb].message);
945 pspeak(command.obj, study, game.prop[command.obj], true);
949 static int reservoir(void)
950 /* Z'ZZZ (word gets recomputed at startup; different each game). */
952 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
953 rspeak(NOTHING_HAPPENS);
956 pspeak(RESER, look, game.prop[RESER] + 1, true);
957 game.prop[RESER] = 1 - game.prop[RESER];
961 game.oldlc2 = game.loc;
969 static int rub(token_t verb, token_t obj)
970 /* Rub. Yields various snide remarks except for lit urn. */
972 int spk = actions[verb].message;
974 spk = PECULIAR_NOTHING;
975 if (obj == URN && game.prop[URN] == URN_LIT) {
977 drop(AMBER, game.loc);
978 game.prop[AMBER] = 1;
980 drop(CAVITY, game.loc);
987 static int say(struct command_t *command)
988 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
990 long a = command->wd1, b = command->wd1x;
991 if (command->wd2 > 0) {
994 command->wd1 = command->wd2;
996 //int wd = vocab(command->wd1, -1);
998 packed_to_token(command->wd1, word1);
999 int wd = (int) get_vocab_id(word1);
1000 /* FIXME: magic numbers */
1001 if (wd == XYZZY || wd == PLUGH || wd == PLOVER || wd == ACTION_WORD(GIANTWORDS) || wd == ACTION_WORD(PART)) {
1002 /* FIXME: scribbles on the interpreter's command block */
1003 wordclear(&command->wd2);
1006 rspeak(OKEY_DOKEY, a, b);
1010 static int throw_support(long spk)
1013 drop(AXE, game.loc);
1017 static int throw (struct command_t *command)
1018 /* Throw. Same as discard unless axe. Then same as attack except
1019 * ignore bird, and if dwarf is present then one might be killed.
1020 * (Only way to do so!) Axe also special for dragon, bear, and
1021 * troll. Treasures special for troll. */
1023 int spk = actions[command->verb].message;
1024 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1025 command->obj = ROD2;
1026 if (!TOTING(command->obj)) {
1030 if (objects[command->obj].is_treasure && AT(TROLL)) {
1031 spk = TROLL_SATISFIED;
1032 /* Snarf a treasure for the troll. */
1033 drop(command->obj, 0);
1035 move(TROLL + NOBJECTS, 0);
1036 drop(TROLL2, objects[TROLL].plac);
1037 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1042 if (command->obj == FOOD && HERE(BEAR)) {
1043 /* But throwing food is another story. */
1044 command->obj = BEAR;
1045 return (feed(command->verb, command->obj));
1047 if (command->obj != AXE)
1048 return (discard(command->verb, command->obj, false));
1050 int i = atdwrf(game.loc);
1052 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1053 return throw_support(DRAGON_SCALES);
1055 return throw_support(TROLL_RETURNS);
1057 return throw_support(OGRE_DODGE);
1058 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1059 /* This'll teach him to throw the axe at the bear! */
1060 drop(AXE, game.loc);
1061 game.fixed[AXE] = -1;
1068 return (attack(command));
1071 if (randrange(NDWARVES + 1) < game.dflag) {
1072 return throw_support(DWARF_DODGES);
1074 game.dseen[i] = false;
1076 return throw_support((++game.dkill == 1)
1077 ? DWARF_SMOKE : KILLED_DWARF);
1082 static int wake(token_t verb, token_t obj)
1083 /* Wake. Only use is to disturb the dwarves. */
1085 if (obj != DWARF || !game.closed) {
1086 rspeak(actions[verb].message);
1090 return GO_DWARFWAKE;
1094 static int wave(token_t verb, token_t obj)
1095 /* Wave. No effect unless waving rod at fissure or at bird. */
1097 int spk = actions[verb].message;
1098 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))
1099 spk = ARENT_CARRYING;
1102 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1106 /* FIXME: Arithemetic on property values */
1108 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
1109 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1110 drop(JADE, game.loc);
1111 game.prop[JADE] = 0;
1119 return GO_DWARFWAKE;
1121 if (game.closng || !AT(FISSURE)) {
1127 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1128 pspeak(FISSURE, look, 2 - game.prop[FISSURE], true);
1133 int action(struct command_t *command)
1134 /* Analyse a verb. Remember what it was, go back for object if second word
1135 * unless verb is "say", which snarfs arbitrary second word.
1138 token_t spk = actions[command->verb].message;
1140 if (command->part == unknown) {
1141 /* Analyse an object word. See if the thing is here, whether
1142 * we've got a verb yet, and so on. Object must be here
1143 * unless verb is "find" or "invent(ory)" (and no new verb
1144 * yet to be analysed). Water and oil are also funny, since
1145 * they are never actually dropped at any location, but might
1146 * be here inside the bottle or urn or as a feature of the
1148 if (HERE(command->obj))
1150 else if (command->obj == GRATE) {
1151 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1152 command->obj = DPRSSN;
1153 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1154 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1155 command->obj = ENTRNC;
1156 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1158 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1160 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1163 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1164 command->obj = PLANT2;
1166 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1168 spk = KNIVES_VANISH;
1171 } else if (command->obj == ROD && HERE(ROD2)) {
1172 command->obj = ROD2;
1174 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1177 rspeak(NO_SEE, command->wd1, command->wd1x);
1181 if (command->wd2 > 0)
1183 if (command->verb != 0)
1184 command->part = transitive;
1187 switch (command->part) {
1189 if (command->wd2 > 0 && command->verb != SAY)
1191 if (command->verb == SAY)
1192 command->obj = command->wd2;
1193 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1194 /* Analyse an intransitive verb (ie, no object given yet). */
1195 switch (command->verb) {
1197 return vcarry(command->verb, INTRANSITIVE);
1203 return lock(command->verb, INTRANSITIVE);
1206 return (GO_CLEAROBJ);
1209 return lock(command->verb, INTRANSITIVE);
1211 return light(command->verb, INTRANSITIVE);
1213 return extinguish(command->verb, INTRANSITIVE);
1223 return attack(command);
1225 return pour(command->verb, command->obj);
1227 return eat(command->verb, INTRANSITIVE);
1229 return drink(command->verb, command->obj);
1243 return fill(command->verb, command->obj);
1251 return bigwords(command->wd1);
1255 command->obj = INTRANSITIVE;
1256 return read(*command);
1266 return fly(command->verb, INTRANSITIVE);
1272 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1277 /* Analyse a transitive verb. */
1278 switch (command->verb) {
1280 return vcarry(command->verb, command->obj);
1282 return discard(command->verb, command->obj, false);
1284 return say(command);
1286 return lock(command->verb, command->obj);
1289 return (GO_CLEAROBJ);
1292 return lock(command->verb, command->obj);
1294 return light(command->verb, command->obj);
1296 return extinguish(command->verb, command->obj);
1298 return wave(command->verb, command->obj);
1308 return attack(command);
1310 return pour(command->verb, command->obj);
1312 return eat(command->verb, command->obj);
1314 return drink(command->verb, command->obj);
1316 return rub(command->verb, command->obj);
1318 return throw (command);
1324 return find(command->verb, command->obj);
1326 return find(command->verb, command->obj);
1328 return feed(command->verb, command->obj);
1330 return fill(command->verb, command->obj);
1347 return read(*command);
1349 return vbreak(command->verb, command->obj);
1351 return wake(command->verb, command->obj);
1361 return fly(command->verb, command->obj);
1369 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1372 /* Unknown verb, couldn't deduce object - might need hint */
1373 rspeak(WHAT_DO, command->wd1, command->wd1x);
1374 return GO_CHECKHINT;
1376 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE