6 static int fill(token_t, token_t);
8 static void state_change(long obj, long state)
10 game.prop[obj] = state;
11 pspeak(obj, change, state);
14 static int attack(struct command_t *command)
15 /* Attack. Assume target if unambiguous. "Throw" also links here.
16 * Attackable objects fall into two categories: enemies (snake,
17 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
18 * enemies, or no enemies but 2 others. */
20 vocab_t verb = command->verb;
21 vocab_t obj = command->obj;
22 long spk = actions[verb].message;
23 if (obj == 0 || obj == INTRANSITIVE) {
24 if (atdwrf(game.loc) > 0)
27 obj = obj * NOBJECTS + SNAKE;
28 if (AT(DRAGON) && game.prop[DRAGON] == 0)
29 obj = obj * NOBJECTS + DRAGON;
31 obj = obj * NOBJECTS + TROLL;
33 obj = obj * NOBJECTS + OGRE;
34 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR)
35 obj = obj * NOBJECTS + BEAR;
39 /* Can't attack bird or machine by throwing axe. */
40 if (HERE(BIRD) && verb != THROW)
42 if (HERE(VEND) && verb != THROW)
43 obj = obj * NOBJECTS + VEND;
44 /* Clam and oyster both treated as clam for intransitive case;
46 if (HERE(CLAM) || HERE(OYSTER))
47 obj = NOBJECTS * obj + CLAM;
60 } else if (obj == VEND) {
62 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
68 if (obj == CLAM || obj == OYSTER)
69 spk = SHELL_IMPERVIOUS;
73 spk = BARE_HANDS_QUERY;
74 if (obj == DWARF && game.closed)
82 if (obj == OGRE && atdwrf(game.loc) > 0) {
87 for (int i = 1; i < PIRATE; i++) {
88 if (game.dloc[i] == game.loc) {
90 game.dloc[i] = LOC_LONGWEST;
91 game.dseen[i] = false;
94 spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2;
95 } else if (obj == BEAR) {
96 switch (game.prop[BEAR]) {
97 case UNTAMED_BEAR: spk = BEAR_HANDS; break;
98 case SITTING_BEAR: spk = BEAR_CONFUSED; break;
99 case CONTENTED_BEAR: spk = BEAR_CONFUSED; break;
100 case BEAR_DEAD: spk = ALREADY_DEAD; break;
102 } else if (obj == DRAGON && game.prop[DRAGON] == 0) {
103 /* Fun stuff for dragon. If he insists on attacking it, win!
104 * Set game.prop to dead, move dragon to central loc (still
105 * fixed), move rug there (not fixed), and move him there,
106 * too. Then do a null motion to get new description. */
107 rspeak(BARE_HANDS_QUERY);
109 // FIXME: setting wd1 is a workaround for broken logic
110 command->wd1 = token_to_packed("Y");
112 // FIXME: setting wd1 is a workaround for broken logic
113 command->wd1 = token_to_packed("N");
116 pspeak(DRAGON, look, 3);
117 game.prop[DRAGON] = 1;
119 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
120 move(DRAGON + NOBJECTS, -1);
121 move(RUG + NOBJECTS, 0);
125 for (obj = 1; obj <= NOBJECTS; obj++) {
126 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
137 static int bigwords(token_t foo)
138 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
139 * Look up foo in section 3 of vocab to determine which word we've got. Last
140 * word zips the eggs back to the giant room (unless already there). */
142 //int k = vocab(foo, 3);
144 packed_to_token(foo, word);
145 int k = (int) get_special_vocab_id(word);
146 int spk = NOTHING_HAPPENS;
147 if (game.foobar != 1 - k) {
148 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)
159 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
163 /* Bring back troll if we steal the eggs back from him before
165 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == 0)
166 game.prop[TROLL] = 1;
170 if (game.loc == objects[EGGS].plac)
172 move(EGGS, objects[EGGS].plac);
173 pspeak(EGGS, look, k);
179 static int bivalve(token_t verb, token_t obj)
180 /* Clam/oyster actions */
183 bool is_oyster = (obj == OYSTER);
184 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
186 spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
187 if (!TOTING(TRIDENT))
188 spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
191 if (spk == PEARL_FALLS) {
193 drop(OYSTER, game.loc);
194 drop(PEARL, LOC_CULDESAC);
200 static void blast(void)
201 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
203 if (game.prop[ROD2] < 0 || !game.closed)
204 rspeak(REQUIRES_DYNAMITE);
206 game.bonus = VICTORY_MESSAGE;
207 if (game.loc == LOC_NE)
208 game.bonus = DEFEAT_MESSAGE;
210 game.bonus = SPLATTER_MESSAGE;
216 static int vbreak(token_t verb, token_t obj)
217 /* Break. Only works for mirror in repository and, of course, the vase. */
219 int spk = actions[verb].message;
222 if (obj == VASE && game.prop[VASE] == 0) {
224 drop(VASE, game.loc);
226 game.fixed[VASE] = -1;
229 if (obj == MIRROR && game.closed) {
230 rspeak(BREAK_MIRROR);
238 static int brief(void)
239 /* Brief. Intransitive only. Suppress long descriptions after first time. */
243 rspeak(BRIEF_CONFIRM);
247 static int vcarry(token_t verb, token_t obj)
248 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
249 * take one without the other). Liquids also special, since they depend on
250 * status of bottle. Also various side effects, etc. */
253 if (obj == INTRANSITIVE) {
254 /* Carry, no object given yet. OK if only one object present. */
255 if (game.atloc[game.loc] == 0 ||
256 game.link[game.atloc[game.loc]] != 0 ||
257 atdwrf(game.loc) > 0)
259 obj = game.atloc[game.loc];
263 rspeak(ALREADY_CARRYING);
267 if (obj == PLANT && game.prop[PLANT] <= 0)
269 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
271 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
276 spk = DOUGHNUT_HOLES;
279 if (obj == RUG && game.prop[RUG] == 2)
282 spk = HAND_PASSTHROUGH;
284 rspeak(REMOVE_MESSAGE);
288 if (game.fixed[obj] != 0) {
292 if (obj == WATER || obj == OIL) {
293 if (!HERE(BOTTLE) || LIQUID() != obj) {
294 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
295 return (fill(verb, BOTTLE));
297 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
309 if (game.holdng >= INVLIMIT) {
312 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
313 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
322 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
326 game.prop[BIRD] = BIRD_CAGED;
328 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
329 carry(BIRD + CAGE - obj, game.loc);
330 carry(obj, game.loc);
331 if (obj == BOTTLE && LIQUID() != 0)
332 game.place[LIQUID()] = CARRIED;
333 if (GSTONE(obj) && game.prop[obj] != 0) {
335 game.prop[CAVITY] = CAVITY_EMPTY;
341 static int chain(token_t verb)
342 /* Do something to the bear's chain */
346 spk = CHAIN_UNLOCKED;
347 if (game.prop[BEAR] == UNTAMED_BEAR)
349 if (game.prop[CHAIN] == 0)
350 spk = ALREADY_UNLOCKED;
351 if (spk != CHAIN_UNLOCKED) {
355 game.prop[CHAIN] = 0;
356 game.fixed[CHAIN] = 0;
357 if (game.prop[BEAR] != BEAR_DEAD)
358 game.prop[BEAR] = CONTENTED_BEAR;
359 /* FIXME: Arithmetic on state numbers */
360 game.fixed[BEAR] = 2 - game.prop[BEAR];
363 if (game.prop[CHAIN] != 0)
364 spk = ALREADY_LOCKED;
365 if (game.loc != objects[CHAIN].plac)
367 if (spk != CHAIN_LOCKED) {
371 game.prop[CHAIN] = 2;
373 drop(CHAIN, game.loc);
374 game.fixed[CHAIN] = -1;
380 static int discard(token_t verb, token_t obj, bool just_do_it)
381 /* Discard object. "Throw" also comes here for most objects. Special cases for
382 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
383 * Drop coins at vending machine for extra batteries. */
385 int spk = actions[verb].message;
387 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
393 if (obj == BIRD && HERE(SNAKE)) {
394 rspeak(BIRD_ATTACKS);
398 /* Set game.prop for use by travel options */
399 game.prop[SNAKE] = SNAKE_CHASED;
401 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
404 game.prop[CAVITY] = CAVITY_FULL;
405 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != 2) || (obj == RUBY &&
406 game.prop[RUG] == 2))) {
413 if (spk != RUG_WIGGLES) {
414 int k = 2 - game.prop[RUG];
417 k = objects[SAPPH].plac;
418 move(RUG + NOBJECTS, k);
421 } else if (obj == COINS && HERE(VEND)) {
423 drop(BATTERY, game.loc);
424 pspeak(BATTERY, look, FRESH_BATTERIES);
426 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
430 } else if (obj == BEAR && AT(TROLL)) {
431 rspeak(TROLL_SCAMPERS);
433 move(TROLL + NOBJECTS, 0);
434 move(TROLL2, objects[TROLL].plac);
435 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
437 game.prop[TROLL] = 2;
438 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
444 pspeak(VASE, look, game.prop[VASE] + 1);
445 if (game.prop[VASE] != 0)
446 game.fixed[VASE] = -1;
452 if (obj == BOTTLE && k != 0)
453 game.place[k] = LOC_NOWHERE;
454 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
455 drop(BIRD, game.loc);
459 game.prop[BIRD] = BIRD_UNCAGED;
460 if (FOREST(game.loc))
461 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
465 static int drink(token_t verb, token_t obj)
466 /* Drink. If no object, assume water and look for it here. If water is in
467 * the bottle, drink that, else must be at a water loc, so drink stream. */
469 int spk = actions[verb].message;
470 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
473 if (obj != 0 && obj != WATER)
474 spk = RIDICULOUS_ATTEMPT;
475 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
476 game.prop[BOTTLE] = EMPTY_BOTTLE;
477 game.place[WATER] = LOC_NOWHERE;
482 game.prop[DRAGON] = 2;
490 static int eat(token_t verb, token_t obj)
491 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
492 * ok, some things lose appetite, rest are ridiculous. */
494 int spk = actions[verb].message;
495 if (obj == INTRANSITIVE) {
499 spk = THANKS_DELICIOUS;
503 spk = THANKS_DELICIOUS;
505 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
506 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
514 static int extinguish(token_t verb, int obj)
515 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
517 int spk = actions[verb].message;
518 if (obj == INTRANSITIVE) {
519 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
521 if (HERE(URN) && game.prop[URN] == 2)
522 obj = obj * NOBJECTS + URN;
523 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS)
528 game.prop[URN] = game.prop[URN] / 2;
530 } else if (obj == LAMP) {
531 state_change(LAMP, LAMP_DARK);
532 spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
533 } else if (obj == DRAGON || obj == VOLCANO)
539 static int feed(token_t verb, token_t obj)
540 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
541 * mad. Bear, special. */
543 int spk = actions[verb].message;
547 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
548 spk = NOTHING_EDIBLE;
549 if (obj == DRAGON && game.prop[DRAGON] != 0)
550 spk = RIDICULOUS_ATTEMPT;
553 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
557 } else if (obj == DWARF) {
562 } else if (obj == BEAR) {
563 if (game.prop[BEAR] == UNTAMED_BEAR)
564 spk = NOTHING_EDIBLE;
565 if (game.prop[BEAR] == BEAR_DEAD)
566 spk = RIDICULOUS_ATTEMPT;
569 game.prop[BEAR] = SITTING_BEAR;
574 } else if (obj == OGRE) {
584 int fill(token_t verb, token_t obj)
585 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
589 int spk = actions[verb].message;
591 spk = ARENT_CARRYING;
592 if (LIQLOC(game.loc) == 0)
594 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
598 rspeak(SHATTER_VASE);
600 game.fixed[VASE] = -1;
601 return (discard(verb, obj, true));
602 } else if (obj == URN) {
604 if (game.prop[URN] != 0) {
610 if (k == 0 || !HERE(BOTTLE)) {
614 game.place[k] = LOC_NOWHERE;
615 game.prop[BOTTLE] = EMPTY_BOTTLE;
618 spk = WATER_URN + game.prop[URN];
621 } else if (obj != 0 && obj != BOTTLE) {
624 } else if (obj == 0 && !HERE(BOTTLE))
627 if (LIQLOC(game.loc) == 0)
629 if (HERE(URN) && game.prop[URN] != 0)
633 if (spk == BOTTLED_WATER) {
634 /* FIXME: Arithmetic on property values */
635 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
638 game.place[k] = CARRIED;
646 static int find(token_t verb, token_t obj)
647 /* Find. Might be carrying it, or it might be here. Else give caveat. */
649 int spk = actions[verb].message;
651 (LIQUID() == obj && AT(BOTTLE)) ||
652 obj == LIQLOC(game.loc) ||
653 (obj == DWARF && atdwrf(game.loc) > 0))
658 spk = ALREADY_CARRYING;
663 static int fly(token_t verb, token_t obj)
664 /* Fly. Snide remarks unless hovering rug is here. */
666 int spk = actions[verb].message;
667 if (obj == INTRANSITIVE) {
668 if (game.prop[RUG] != 2)
672 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
684 if (game.prop[RUG] != 2) {
688 game.oldlc2 = game.oldloc;
689 game.oldloc = game.loc;
690 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
692 if (game.prop[SAPPH] >= 0)
698 static int inven(void)
699 /* Inventory. If object, treat same as find. Else report on current burden. */
702 for (int i = 1; i <= NOBJECTS; i++) {
703 if (i == BEAR || !TOTING(i))
708 pspeak(i, touch, -1);
718 static int light(token_t verb, token_t obj)
719 /* Light. Applicable only to lamp and urn. */
721 int spk = actions[verb].message;
722 if (obj == INTRANSITIVE) {
723 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
725 if (HERE(URN) && game.prop[URN] == 1)
726 obj = obj * NOBJECTS + URN;
727 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS)
732 if (game.prop[URN] == 0) {
745 if (game.limit < 0) {
749 state_change(LAMP, LAMP_BRIGHT);
757 static int listen(void)
758 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
761 int spk = ALL_SILENT;
762 k = locations[game.loc].sound;
765 if (locations[game.loc].loud)
770 for (int i = 1; i <= NOBJECTS; i++) {
771 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
773 int mi = game.prop[i];
775 mi += 3 * game.blooded;
776 long packed_zzword = token_to_packed(game.zzword);
777 pspeak(i, hear, mi, packed_zzword);
779 /* FIXME: Magic number, sensitive to bird state logic */
780 if (i == BIRD && game.prop[i] == 5)
787 static int lock(token_t verb, token_t obj)
788 /* Lock, unlock, no object given. Assume various things if present. */
790 int spk = actions[verb].message;
791 if (obj == INTRANSITIVE) {
792 spk = NOTHING_LOCKED;
801 if (obj != 0 && HERE(CHAIN))
805 if (obj == 0 || obj == INTRANSITIVE) {
811 /* Lock, unlock object. Special stuff for opening clam/oyster
813 if (obj == CLAM || obj == OYSTER)
814 return bivalve(verb, obj);
817 if (obj == DOOR && game.prop[DOOR] == 1)
823 if (obj == GRATE || obj == CHAIN) {
831 game.clock2 = PANICTIME;
834 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
843 static int pour(token_t verb, token_t obj)
844 /* Pour. If no object, or object is bottle, assume contents of bottle.
845 * special tests for pouring water or oil on plant or rusty door. */
847 int spk = actions[verb].message;
848 if (obj == BOTTLE || obj == 0)
857 if (obj != OIL && obj != WATER) {
861 if (HERE(URN) && game.prop[URN] == 0)
862 return fill(verb, URN);
863 game.prop[BOTTLE] = EMPTY_BOTTLE;
864 game.place[obj] = LOC_NOWHERE;
866 if (!(AT(PLANT) || AT(DOOR))) {
871 spk = SHAKING_LEAVES;
876 pspeak(PLANT, look, game.prop[PLANT] + 3);
877 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
878 game.prop[PLANT2] = game.prop[PLANT];
884 spk = RUSTED_HINGES + game.prop[DOOR];
890 static int quit(void)
891 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
893 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
898 static int read(struct command_t command)
899 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
901 if (command.obj == INTRANSITIVE) {
903 for (int i = 1; i <= NOBJECTS; i++) {
904 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
905 command.obj = command.obj * NOBJECTS + i;
907 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
911 if (DARK(game.loc)) {
912 rspeak(NO_SEE, command.wd1, command.wd1x);
913 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
914 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
915 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
916 rspeak(actions[command.verb].message);
918 pspeak(command.obj, study, game.prop[command.obj]);
922 static int reservoir(void)
923 /* Z'ZZZ (word gets recomputed at startup; different each game). */
925 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
926 rspeak(NOTHING_HAPPENS);
929 pspeak(RESER, look, game.prop[RESER] + 1);
930 game.prop[RESER] = 1 - game.prop[RESER];
934 game.oldlc2 = game.loc;
942 static int rub(token_t verb, token_t obj)
943 /* Rub. Yields various snide remarks except for lit urn. */
945 int spk = actions[verb].message;
947 spk = PECULIAR_NOTHING;
948 if (obj == URN && game.prop[URN] == 2) {
950 drop(AMBER, game.loc);
951 game.prop[AMBER] = 1;
953 drop(CAVITY, game.loc);
960 static int say(struct command_t *command)
961 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
963 long a = command->wd1, b = command->wd1x;
964 if (command->wd2 > 0) {
967 command->wd1 = command->wd2;
969 //int wd = vocab(command->wd1, -1);
971 packed_to_token(command->wd1, word1);
972 int wd = (int) get_vocab_id(word1);
973 /* FIXME: magic numbers */
974 if (wd == XYZZY || wd == PLUGH || wd == PLOVER || wd == ACTION_WORD(GIANTWORDS) || wd == ACTION_WORD(PART)) {
975 /* FIXME: scribbles on the interpreter's command block */
976 wordclear(&command->wd2);
979 rspeak(OKEY_DOKEY, a, b);
983 static int throw_support(long spk)
990 static int throw (struct command_t *command)
991 /* Throw. Same as discard unless axe. Then same as attack except
992 * ignore bird, and if dwarf is present then one might be killed.
993 * (Only way to do so!) Axe also special for dragon, bear, and
994 * troll. Treasures special for troll. */
996 int spk = actions[command->verb].message;
997 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
999 if (!TOTING(command->obj)) {
1003 if (objects[command->obj].is_treasure && AT(TROLL)) {
1004 spk = TROLL_SATISFIED;
1005 /* Snarf a treasure for the troll. */
1006 drop(command->obj, 0);
1008 move(TROLL + NOBJECTS, 0);
1009 drop(TROLL2, objects[TROLL].plac);
1010 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1015 if (command->obj == FOOD && HERE(BEAR)) {
1016 /* But throwing food is another story. */
1017 command->obj = BEAR;
1018 return (feed(command->verb, command->obj));
1020 if (command->obj != AXE)
1021 return (discard(command->verb, command->obj, false));
1023 int i = atdwrf(game.loc);
1025 if (AT(DRAGON) && game.prop[DRAGON] == 0)
1026 return throw_support(DRAGON_SCALES);
1028 return throw_support(TROLL_RETURNS);
1030 return throw_support(OGRE_DODGE);
1031 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1032 /* This'll teach him to throw the axe at the bear! */
1033 drop(AXE, game.loc);
1034 game.fixed[AXE] = -1;
1041 return (attack(command));
1044 if (randrange(NDWARVES + 1) < game.dflag) {
1045 return throw_support(DWARF_DODGES);
1047 game.dseen[i] = false;
1049 return throw_support((++game.dkill == 1)
1050 ? DWARF_SMOKE : KILLED_DWARF);
1055 static int wake(token_t verb, token_t obj)
1056 /* Wake. Only use is to disturb the dwarves. */
1058 if (obj != DWARF || !game.closed) {
1059 rspeak(actions[verb].message);
1063 return GO_DWARFWAKE;
1067 static int wave(token_t verb, token_t obj)
1068 /* Wave. No effect unless waving rod at fissure or at bird. */
1070 int spk = actions[verb].message;
1071 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))
1072 spk = ARENT_CARRYING;
1075 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1079 /* FIXME: Arithemetic on proprty values */
1081 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
1082 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1083 drop(JADE, game.loc);
1084 game.prop[JADE] = 0;
1092 return GO_DWARFWAKE;
1094 if (game.closng || !AT(FISSURE)) {
1100 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1101 pspeak(FISSURE, look, 2 - game.prop[FISSURE]);
1106 int action(struct command_t *command)
1107 /* Analyse a verb. Remember what it was, go back for object if second word
1108 * unless verb is "say", which snarfs arbitrary second word.
1111 token_t spk = actions[command->verb].message;
1113 if (command->part == unknown) {
1114 /* Analyse an object word. See if the thing is here, whether
1115 * we've got a verb yet, and so on. Object must be here
1116 * unless verb is "find" or "invent(ory)" (and no new verb
1117 * yet to be analysed). Water and oil are also funny, since
1118 * they are never actually dropped at any location, but might
1119 * be here inside the bottle or urn or as a feature of the
1121 if (HERE(command->obj))
1123 else if (command->obj == GRATE) {
1124 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1125 command->obj = DPRSSN;
1126 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1127 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1128 command->obj = ENTRNC;
1129 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1131 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1133 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1136 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1137 command->obj = PLANT2;
1139 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1141 spk = KNIVES_VANISH;
1144 } else if (command->obj == ROD && HERE(ROD2)) {
1145 command->obj = ROD2;
1147 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1150 rspeak(NO_SEE, command->wd1, command->wd1x);
1154 if (command->wd2 > 0)
1156 if (command->verb != 0)
1157 command->part = transitive;
1160 switch (command->part) {
1162 if (command->wd2 > 0 && command->verb != SAY)
1164 if (command->verb == SAY)
1165 command->obj = command->wd2;
1166 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1167 /* Analyse an intransitive verb (ie, no object given yet). */
1168 switch (command->verb) {
1170 return vcarry(command->verb, INTRANSITIVE);
1176 return lock(command->verb, INTRANSITIVE);
1179 return (GO_CLEAROBJ);
1182 return lock(command->verb, INTRANSITIVE);
1184 return light(command->verb, INTRANSITIVE);
1186 return extinguish(command->verb, INTRANSITIVE);
1196 return attack(command);
1198 return pour(command->verb, command->obj);
1200 return eat(command->verb, INTRANSITIVE);
1202 return drink(command->verb, command->obj);
1216 return fill(command->verb, command->obj);
1224 return bigwords(command->wd1);
1228 command->obj = INTRANSITIVE;
1229 return read(*command);
1239 return fly(command->verb, INTRANSITIVE);
1245 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1250 /* Analyse a transitive verb. */
1251 switch (command->verb) {
1253 return vcarry(command->verb, command->obj);
1255 return discard(command->verb, command->obj, false);
1257 return say(command);
1259 return lock(command->verb, command->obj);
1262 return (GO_CLEAROBJ);
1265 return lock(command->verb, command->obj);
1267 return light(command->verb, command->obj);
1269 return extinguish(command->verb, command->obj);
1271 return wave(command->verb, command->obj);
1281 return attack(command);
1283 return pour(command->verb, command->obj);
1285 return eat(command->verb, command->obj);
1287 return drink(command->verb, command->obj);
1289 return rub(command->verb, command->obj);
1291 return throw (command);
1297 return find(command->verb, command->obj);
1299 return find(command->verb, command->obj);
1301 return feed(command->verb, command->obj);
1303 return fill(command->verb, command->obj);
1320 return read(*command);
1322 return vbreak(command->verb, command->obj);
1324 return wake(command->verb, command->obj);
1334 return fly(command->verb, command->obj);
1342 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1345 /* Unknown verb, couldn't deduce object - might need hint */
1346 rspeak(WHAT_DO, command->wd1, command->wd1x);
1347 return GO_CHECKHINT;
1349 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE