6 static int fill(token_t, token_t);
8 static void state_change(long obj, long state)
10 game.prop[obj] = state;
11 pspeak(obj, change, state);
14 static int attack(struct command_t *command)
15 /* Attack. Assume target if unambiguous. "Throw" also links here.
16 * Attackable objects fall into two categories: enemies (snake,
17 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
18 * enemies, or no enemies but 2 others. */
20 vocab_t verb = command->verb;
21 vocab_t obj = command->obj;
22 long spk = actions[verb].message;
23 if (obj == 0 || obj == INTRANSITIVE) {
24 if (atdwrf(game.loc) > 0)
27 obj = obj * NOBJECTS + SNAKE;
28 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
29 obj = obj * NOBJECTS + DRAGON;
31 obj = obj * NOBJECTS + TROLL;
33 obj = obj * NOBJECTS + OGRE;
34 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR)
35 obj = obj * NOBJECTS + BEAR;
39 /* Can't attack bird or machine by throwing axe. */
40 if (HERE(BIRD) && verb != THROW)
42 if (HERE(VEND) && verb != THROW)
43 obj = obj * NOBJECTS + VEND;
44 /* Clam and oyster both treated as clam for intransitive case;
46 if (HERE(CLAM) || HERE(OYSTER))
47 obj = NOBJECTS * obj + CLAM;
60 } else if (obj == VEND) {
62 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
68 if (obj == CLAM || obj == OYSTER)
69 spk = SHELL_IMPERVIOUS;
73 spk = BARE_HANDS_QUERY;
74 if (obj == DWARF && game.closed)
82 if (obj == OGRE && atdwrf(game.loc) > 0) {
87 for (int i = 1; i < PIRATE; i++) {
88 if (game.dloc[i] == game.loc) {
90 game.dloc[i] = LOC_LONGWEST;
91 game.dseen[i] = false;
94 spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2;
95 } else if (obj == BEAR) {
96 switch (game.prop[BEAR]) {
110 } else if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
111 /* Fun stuff for dragon. If he insists on attacking it, win!
112 * Set game.prop to dead, move dragon to central loc (still
113 * fixed), move rug there (not fixed), and move him there,
114 * too. Then do a null motion to get new description. */
115 rspeak(BARE_HANDS_QUERY);
117 // FIXME: setting wd1 is a workaround for broken logic
118 command->wd1 = token_to_packed("Y");
120 // FIXME: setting wd1 is a workaround for broken logic
121 command->wd1 = token_to_packed("N");
124 state_change(DRAGON, DRAGON_DEAD);
125 game.prop[RUG] = RUG_FLOOR;
126 /* FIXME: Arithmetic on location values */
127 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
128 move(DRAGON + NOBJECTS, -1);
129 move(RUG + NOBJECTS, 0);
133 for (obj = 1; obj <= NOBJECTS; obj++) {
134 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
145 static int bigwords(token_t foo)
146 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
147 * Look up foo in section 3 of vocab to determine which word we've got. Last
148 * word zips the eggs back to the giant room (unless already there). */
150 //int k = vocab(foo, 3);
152 packed_to_token(foo, word);
153 int k = (int) get_special_vocab_id(word);
154 int spk = NOTHING_HAPPENS;
155 if (game.foobar != 1 - k) {
156 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)
167 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
171 /* Bring back troll if we steal the eggs back from him before
173 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
174 game.prop[TROLL] = TROLL_PAIDONCE;
178 if (game.loc == objects[EGGS].plac)
180 move(EGGS, objects[EGGS].plac);
181 pspeak(EGGS, look, k);
187 static int bivalve(token_t verb, token_t obj)
188 /* Clam/oyster actions */
191 bool is_oyster = (obj == OYSTER);
192 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
194 spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
195 if (!TOTING(TRIDENT))
196 spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
199 if (spk == PEARL_FALLS) {
201 drop(OYSTER, game.loc);
202 drop(PEARL, LOC_CULDESAC);
208 static void blast(void)
209 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
211 if (game.prop[ROD2] < 0 || !game.closed)
212 rspeak(REQUIRES_DYNAMITE);
214 game.bonus = VICTORY_MESSAGE;
215 if (game.loc == LOC_NE)
216 game.bonus = DEFEAT_MESSAGE;
218 game.bonus = SPLATTER_MESSAGE;
224 static int vbreak(token_t verb, token_t obj)
225 /* Break. Only works for mirror in repository and, of course, the vase. */
229 rspeak(BREAK_MIRROR);
236 if (obj == VASE && game.prop[VASE] == VASE_WHOLE) {
238 drop(VASE, game.loc);
239 state_change(VASE, VASE_BROKEN);
240 game.fixed[VASE] = -1;
243 rspeak(actions[verb].message);
244 return (GO_CLEAROBJ);
247 static int brief(void)
248 /* Brief. Intransitive only. Suppress long descriptions after first time. */
252 rspeak(BRIEF_CONFIRM);
256 static int vcarry(token_t verb, token_t obj)
257 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
258 * take one without the other). Liquids also special, since they depend on
259 * status of bottle. Also various side effects, etc. */
262 if (obj == INTRANSITIVE) {
263 /* Carry, no object given yet. OK if only one object present. */
264 if (game.atloc[game.loc] == 0 ||
265 game.link[game.atloc[game.loc]] != 0 ||
266 atdwrf(game.loc) > 0)
268 obj = game.atloc[game.loc];
272 rspeak(ALREADY_CARRYING);
276 if (obj == PLANT && game.prop[PLANT] <= 0)
278 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
280 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
285 spk = DOUGHNUT_HOLES;
288 if (obj == RUG && game.prop[RUG] == RUG_HOVER)
291 spk = HAND_PASSTHROUGH;
293 rspeak(REMOVE_MESSAGE);
297 if (game.fixed[obj] != 0) {
301 if (obj == WATER || obj == OIL) {
302 if (!HERE(BOTTLE) || LIQUID() != obj) {
303 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
304 return (fill(verb, BOTTLE));
306 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
318 if (game.holdng >= INVLIMIT) {
321 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
322 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
331 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
335 game.prop[BIRD] = BIRD_CAGED;
337 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
338 carry(BIRD + CAGE - obj, game.loc);
339 carry(obj, game.loc);
340 if (obj == BOTTLE && LIQUID() != 0)
341 game.place[LIQUID()] = CARRIED;
342 if (GSTONE(obj) && game.prop[obj] != 0) {
344 game.prop[CAVITY] = CAVITY_EMPTY;
350 static int chain(token_t verb)
351 /* Do something to the bear's chain */
355 spk = CHAIN_UNLOCKED;
356 if (game.prop[BEAR] == UNTAMED_BEAR)
358 if (game.prop[CHAIN] == CHAIN_HEAP)
359 spk = ALREADY_UNLOCKED;
360 if (spk != CHAIN_UNLOCKED) {
364 game.prop[CHAIN] = CHAIN_HEAP;
365 game.fixed[CHAIN] = CHAIN_HEAP;
366 if (game.prop[BEAR] != BEAR_DEAD)
367 game.prop[BEAR] = CONTENTED_BEAR;
368 /* FIXME: Arithmetic on state numbers */
369 game.fixed[BEAR] = 2 - game.prop[BEAR];
372 if (game.prop[CHAIN] != CHAIN_HEAP)
373 spk = ALREADY_LOCKED;
374 if (game.loc != objects[CHAIN].plac)
376 if (spk != CHAIN_LOCKED) {
380 game.prop[CHAIN] = CHAIN_FIXED;
382 drop(CHAIN, game.loc);
383 game.fixed[CHAIN] = -1;
389 static int discard(token_t verb, token_t obj, bool just_do_it)
390 /* Discard object. "Throw" also comes here for most objects. Special cases for
391 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
392 * Drop coins at vending machine for extra batteries. */
394 int spk = actions[verb].message;
396 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
402 if (obj == BIRD && HERE(SNAKE)) {
403 rspeak(BIRD_ATTACKS);
407 /* Set game.prop for use by travel options */
408 game.prop[SNAKE] = SNAKE_CHASED;
410 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
413 game.prop[CAVITY] = CAVITY_FULL;
414 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || (obj == RUBY &&
415 game.prop[RUG] == RUG_HOVER))) {
422 if (spk != RUG_WIGGLES) {
423 /* FIXME: Arithmetic on state numbers */
424 int k = 2 - game.prop[RUG];
427 k = objects[SAPPH].plac;
428 move(RUG + NOBJECTS, k);
431 } else if (obj == COINS && HERE(VEND)) {
433 drop(BATTERY, game.loc);
434 pspeak(BATTERY, look, FRESH_BATTERIES);
436 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
440 } else if (obj == BEAR && AT(TROLL)) {
441 rspeak(TROLL_SCAMPERS);
443 move(TROLL + NOBJECTS, 0);
444 move(TROLL2, objects[TROLL].plac);
445 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
447 game.prop[TROLL] = TROLL_GONE;
448 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
451 game.prop[VASE] = VASE_BROKEN;
453 game.prop[VASE] = VASE_WHOLE;
454 pspeak(VASE, look, game.prop[VASE] + 1);
455 if (game.prop[VASE] != VASE_WHOLE)
456 game.fixed[VASE] = -1;
462 if (obj == BOTTLE && k != 0)
463 game.place[k] = LOC_NOWHERE;
464 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
465 drop(BIRD, game.loc);
469 game.prop[BIRD] = BIRD_UNCAGED;
470 if (FOREST(game.loc))
471 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
475 static int drink(token_t verb, token_t obj)
476 /* Drink. If no object, assume water and look for it here. If water is in
477 * the bottle, drink that, else must be at a water loc, so drink stream. */
479 int spk = actions[verb].message;
480 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
483 if (obj != 0 && obj != WATER)
484 spk = RIDICULOUS_ATTEMPT;
485 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
486 game.prop[BOTTLE] = EMPTY_BOTTLE;
487 game.place[WATER] = LOC_NOWHERE;
493 state_change(DRAGON, DRAGON_BLOODLESS);
499 static int eat(token_t verb, token_t obj)
500 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
501 * ok, some things lose appetite, rest are ridiculous. */
503 int spk = actions[verb].message;
504 if (obj == INTRANSITIVE) {
508 spk = THANKS_DELICIOUS;
512 spk = THANKS_DELICIOUS;
514 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
515 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
523 static int extinguish(token_t verb, int obj)
524 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
526 int spk = actions[verb].message;
527 if (obj == INTRANSITIVE) {
528 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
530 if (HERE(URN) && game.prop[URN] == 2)
531 obj = obj * NOBJECTS + URN;
532 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS)
537 game.prop[URN] = game.prop[URN] / 2;
539 } else if (obj == LAMP) {
540 state_change(LAMP, LAMP_DARK);
541 spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
542 } else if (obj == DRAGON || obj == VOLCANO)
548 static int feed(token_t verb, token_t obj)
549 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
550 * mad. Bear, special. */
552 int spk = actions[verb].message;
556 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
557 spk = NOTHING_EDIBLE;
558 if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
559 spk = RIDICULOUS_ATTEMPT;
562 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
566 } else if (obj == DWARF) {
571 } else if (obj == BEAR) {
572 if (game.prop[BEAR] == UNTAMED_BEAR)
573 spk = NOTHING_EDIBLE;
574 if (game.prop[BEAR] == BEAR_DEAD)
575 spk = RIDICULOUS_ATTEMPT;
578 game.prop[BEAR] = SITTING_BEAR;
583 } else if (obj == OGRE) {
593 int fill(token_t verb, token_t obj)
594 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
598 int spk = actions[verb].message;
600 spk = ARENT_CARRYING;
601 if (LIQLOC(game.loc) == 0)
603 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
607 rspeak(SHATTER_VASE);
608 game.prop[VASE] = VASE_BROKEN;
609 game.fixed[VASE] = -1;
610 return (discard(verb, obj, true));
611 } else if (obj == URN) {
613 if (game.prop[URN] != 0) {
619 if (k == 0 || !HERE(BOTTLE)) {
623 game.place[k] = LOC_NOWHERE;
624 game.prop[BOTTLE] = EMPTY_BOTTLE;
627 spk = WATER_URN + game.prop[URN];
630 } else if (obj != 0 && obj != BOTTLE) {
633 } else if (obj == 0 && !HERE(BOTTLE))
636 if (LIQLOC(game.loc) == 0)
638 if (HERE(URN) && game.prop[URN] != 0)
642 if (spk == BOTTLED_WATER) {
643 /* FIXME: Arithmetic on property values */
644 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
647 game.place[k] = CARRIED;
655 static int find(token_t verb, token_t obj)
656 /* Find. Might be carrying it, or it might be here. Else give caveat. */
658 int spk = actions[verb].message;
660 (LIQUID() == obj && AT(BOTTLE)) ||
661 obj == LIQLOC(game.loc) ||
662 (obj == DWARF && atdwrf(game.loc) > 0))
667 spk = ALREADY_CARRYING;
672 static int fly(token_t verb, token_t obj)
673 /* Fly. Snide remarks unless hovering rug is here. */
675 int spk = actions[verb].message;
676 if (obj == INTRANSITIVE) {
677 if (game.prop[RUG] != RUG_HOVER)
681 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
693 if (game.prop[RUG] != RUG_HOVER) {
697 game.oldlc2 = game.oldloc;
698 game.oldloc = game.loc;
699 /* FIXME: Arithmetic on location values */
700 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
702 if (game.prop[SAPPH] >= 0)
708 static int inven(void)
709 /* Inventory. If object, treat same as find. Else report on current burden. */
712 for (int i = 1; i <= NOBJECTS; i++) {
713 if (i == BEAR || !TOTING(i))
718 pspeak(i, touch, -1);
728 static int light(token_t verb, token_t obj)
729 /* Light. Applicable only to lamp and urn. */
731 int spk = actions[verb].message;
732 if (obj == INTRANSITIVE) {
733 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
735 if (HERE(URN) && game.prop[URN] == 1)
736 obj = obj * NOBJECTS + URN;
737 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS)
742 if (game.prop[URN] == 0) {
755 if (game.limit < 0) {
759 state_change(LAMP, LAMP_BRIGHT);
767 static int listen(void)
768 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
771 int spk = ALL_SILENT;
772 k = locations[game.loc].sound;
775 if (locations[game.loc].loud)
780 for (int i = 1; i <= NOBJECTS; i++) {
781 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
783 int mi = game.prop[i];
785 mi += 3 * game.blooded;
786 long packed_zzword = token_to_packed(game.zzword);
787 pspeak(i, hear, mi, packed_zzword);
789 /* FIXME: Magic number, sensitive to bird state logic */
790 if (i == BIRD && game.prop[i] == 5)
797 static int lock(token_t verb, token_t obj)
798 /* Lock, unlock, no object given. Assume various things if present. */
800 int spk = actions[verb].message;
801 if (obj == INTRANSITIVE) {
802 spk = NOTHING_LOCKED;
811 if (obj != 0 && HERE(CHAIN))
815 if (obj == 0 || obj == INTRANSITIVE) {
821 /* Lock, unlock object. Special stuff for opening clam/oyster
823 if (obj == CLAM || obj == OYSTER)
824 return bivalve(verb, obj);
827 if (obj == DOOR && game.prop[DOOR] == 1)
833 if (obj == GRATE || obj == CHAIN) {
841 game.clock2 = PANICTIME;
844 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
853 static int pour(token_t verb, token_t obj)
854 /* Pour. If no object, or object is bottle, assume contents of bottle.
855 * special tests for pouring water or oil on plant or rusty door. */
857 int spk = actions[verb].message;
858 if (obj == BOTTLE || obj == 0)
867 if (obj != OIL && obj != WATER) {
871 if (HERE(URN) && game.prop[URN] == 0)
872 return fill(verb, URN);
873 game.prop[BOTTLE] = EMPTY_BOTTLE;
874 game.place[obj] = LOC_NOWHERE;
876 if (!(AT(PLANT) || AT(DOOR))) {
881 spk = SHAKING_LEAVES;
886 pspeak(PLANT, look, game.prop[PLANT] + 3);
887 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
888 game.prop[PLANT2] = game.prop[PLANT];
891 state_change(DOOR, (obj == OIL) ? DOOR_UNRUSTED: DOOR_RUSTED);
896 static int quit(void)
897 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
899 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
904 static int read(struct command_t command)
905 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
907 if (command.obj == INTRANSITIVE) {
909 for (int i = 1; i <= NOBJECTS; i++) {
910 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
911 command.obj = command.obj * NOBJECTS + i;
913 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
917 if (DARK(game.loc)) {
918 rspeak(NO_SEE, command.wd1, command.wd1x);
919 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
920 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
921 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
922 rspeak(actions[command.verb].message);
924 pspeak(command.obj, study, game.prop[command.obj]);
928 static int reservoir(void)
929 /* Z'ZZZ (word gets recomputed at startup; different each game). */
931 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
932 rspeak(NOTHING_HAPPENS);
935 pspeak(RESER, look, game.prop[RESER] + 1);
936 game.prop[RESER] = 1 - game.prop[RESER];
940 game.oldlc2 = game.loc;
948 static int rub(token_t verb, token_t obj)
949 /* Rub. Yields various snide remarks except for lit urn. */
951 int spk = actions[verb].message;
953 spk = PECULIAR_NOTHING;
954 if (obj == URN && game.prop[URN] == 2) {
956 drop(AMBER, game.loc);
957 game.prop[AMBER] = 1;
959 drop(CAVITY, game.loc);
966 static int say(struct command_t *command)
967 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
969 long a = command->wd1, b = command->wd1x;
970 if (command->wd2 > 0) {
973 command->wd1 = command->wd2;
975 //int wd = vocab(command->wd1, -1);
977 packed_to_token(command->wd1, word1);
978 int wd = (int) get_vocab_id(word1);
979 /* FIXME: magic numbers */
980 if (wd == XYZZY || wd == PLUGH || wd == PLOVER || wd == ACTION_WORD(GIANTWORDS) || wd == ACTION_WORD(PART)) {
981 /* FIXME: scribbles on the interpreter's command block */
982 wordclear(&command->wd2);
985 rspeak(OKEY_DOKEY, a, b);
989 static int throw_support(long spk)
996 static int throw (struct command_t *command)
997 /* Throw. Same as discard unless axe. Then same as attack except
998 * ignore bird, and if dwarf is present then one might be killed.
999 * (Only way to do so!) Axe also special for dragon, bear, and
1000 * troll. Treasures special for troll. */
1002 int spk = actions[command->verb].message;
1003 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
1004 command->obj = ROD2;
1005 if (!TOTING(command->obj)) {
1009 if (objects[command->obj].is_treasure && AT(TROLL)) {
1010 spk = TROLL_SATISFIED;
1011 /* Snarf a treasure for the troll. */
1012 drop(command->obj, 0);
1014 move(TROLL + NOBJECTS, 0);
1015 drop(TROLL2, objects[TROLL].plac);
1016 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
1021 if (command->obj == FOOD && HERE(BEAR)) {
1022 /* But throwing food is another story. */
1023 command->obj = BEAR;
1024 return (feed(command->verb, command->obj));
1026 if (command->obj != AXE)
1027 return (discard(command->verb, command->obj, false));
1029 int i = atdwrf(game.loc);
1031 if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
1032 return throw_support(DRAGON_SCALES);
1034 return throw_support(TROLL_RETURNS);
1036 return throw_support(OGRE_DODGE);
1037 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
1038 /* This'll teach him to throw the axe at the bear! */
1039 drop(AXE, game.loc);
1040 game.fixed[AXE] = -1;
1047 return (attack(command));
1050 if (randrange(NDWARVES + 1) < game.dflag) {
1051 return throw_support(DWARF_DODGES);
1053 game.dseen[i] = false;
1055 return throw_support((++game.dkill == 1)
1056 ? DWARF_SMOKE : KILLED_DWARF);
1061 static int wake(token_t verb, token_t obj)
1062 /* Wake. Only use is to disturb the dwarves. */
1064 if (obj != DWARF || !game.closed) {
1065 rspeak(actions[verb].message);
1069 return GO_DWARFWAKE;
1073 static int wave(token_t verb, token_t obj)
1074 /* Wave. No effect unless waving rod at fissure or at bird. */
1076 int spk = actions[verb].message;
1077 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))
1078 spk = ARENT_CARRYING;
1081 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1085 /* FIXME: Arithemetic on property values */
1087 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
1088 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1089 drop(JADE, game.loc);
1090 game.prop[JADE] = 0;
1098 return GO_DWARFWAKE;
1100 if (game.closng || !AT(FISSURE)) {
1106 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1107 pspeak(FISSURE, look, 2 - game.prop[FISSURE]);
1112 int action(struct command_t *command)
1113 /* Analyse a verb. Remember what it was, go back for object if second word
1114 * unless verb is "say", which snarfs arbitrary second word.
1117 token_t spk = actions[command->verb].message;
1119 if (command->part == unknown) {
1120 /* Analyse an object word. See if the thing is here, whether
1121 * we've got a verb yet, and so on. Object must be here
1122 * unless verb is "find" or "invent(ory)" (and no new verb
1123 * yet to be analysed). Water and oil are also funny, since
1124 * they are never actually dropped at any location, but might
1125 * be here inside the bottle or urn or as a feature of the
1127 if (HERE(command->obj))
1129 else if (command->obj == GRATE) {
1130 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1131 command->obj = DPRSSN;
1132 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1133 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1134 command->obj = ENTRNC;
1135 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1137 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1139 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1142 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1143 command->obj = PLANT2;
1145 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1147 spk = KNIVES_VANISH;
1150 } else if (command->obj == ROD && HERE(ROD2)) {
1151 command->obj = ROD2;
1153 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1156 rspeak(NO_SEE, command->wd1, command->wd1x);
1160 if (command->wd2 > 0)
1162 if (command->verb != 0)
1163 command->part = transitive;
1166 switch (command->part) {
1168 if (command->wd2 > 0 && command->verb != SAY)
1170 if (command->verb == SAY)
1171 command->obj = command->wd2;
1172 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1173 /* Analyse an intransitive verb (ie, no object given yet). */
1174 switch (command->verb) {
1176 return vcarry(command->verb, INTRANSITIVE);
1182 return lock(command->verb, INTRANSITIVE);
1185 return (GO_CLEAROBJ);
1188 return lock(command->verb, INTRANSITIVE);
1190 return light(command->verb, INTRANSITIVE);
1192 return extinguish(command->verb, INTRANSITIVE);
1202 return attack(command);
1204 return pour(command->verb, command->obj);
1206 return eat(command->verb, INTRANSITIVE);
1208 return drink(command->verb, command->obj);
1222 return fill(command->verb, command->obj);
1230 return bigwords(command->wd1);
1234 command->obj = INTRANSITIVE;
1235 return read(*command);
1245 return fly(command->verb, INTRANSITIVE);
1251 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1256 /* Analyse a transitive verb. */
1257 switch (command->verb) {
1259 return vcarry(command->verb, command->obj);
1261 return discard(command->verb, command->obj, false);
1263 return say(command);
1265 return lock(command->verb, command->obj);
1268 return (GO_CLEAROBJ);
1271 return lock(command->verb, command->obj);
1273 return light(command->verb, command->obj);
1275 return extinguish(command->verb, command->obj);
1277 return wave(command->verb, command->obj);
1287 return attack(command);
1289 return pour(command->verb, command->obj);
1291 return eat(command->verb, command->obj);
1293 return drink(command->verb, command->obj);
1295 return rub(command->verb, command->obj);
1297 return throw (command);
1303 return find(command->verb, command->obj);
1305 return find(command->verb, command->obj);
1307 return feed(command->verb, command->obj);
1309 return fill(command->verb, command->obj);
1326 return read(*command);
1328 return vbreak(command->verb, command->obj);
1330 return wake(command->verb, command->obj);
1340 return fly(command->verb, command->obj);
1348 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1351 /* Unknown verb, couldn't deduce object - might need hint */
1352 rspeak(WHAT_DO, command->wd1, command->wd1x);
1353 return GO_CHECKHINT;
1355 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE