7 static int fill(token_t, token_t);
9 static void state_change(long obj, long state)
11 game.prop[obj] = state;
12 pspeak(obj, change, state);
15 static int attack(FILE *input, struct command_t *command)
16 /* Attack. Assume target if unambiguous. "Throw" also links here.
17 * Attackable objects fall into two categories: enemies (snake,
18 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
19 * enemies, or no enemies but 2 others. */
21 vocab_t verb = command->verb;
22 vocab_t obj = command->obj;
23 long spk = actions[verb].message;
24 if (obj == 0 || obj == INTRANSITIVE) {
25 if (atdwrf(game.loc) > 0)
27 if (HERE(SNAKE))obj = obj * NOBJECTS + SNAKE;
28 if (AT(DRAGON) && game.prop[DRAGON] == 0)obj = obj * NOBJECTS + DRAGON;
29 if (AT(TROLL))obj = obj * NOBJECTS + TROLL;
30 if (AT(OGRE))obj = obj * NOBJECTS + OGRE;
31 if (HERE(BEAR) && game.prop[BEAR] == 0)obj = obj * NOBJECTS + BEAR;
32 if (obj > NOBJECTS) return GO_UNKNOWN;
34 /* Can't attack bird or machine by throwing axe. */
35 if (HERE(BIRD) && verb != THROW)obj = BIRD;
36 if (HERE(VEND) && verb != THROW)obj = obj * NOBJECTS + VEND;
37 /* Clam and oyster both treated as clam for intransitive case;
39 if (HERE(CLAM) || HERE(OYSTER))obj = NOBJECTS * obj + CLAM;
52 } else if (obj == VEND) {
53 bool blocking = (game.prop[VEND] == VEND_BLOCKS);
54 game.prop[VEND] = blocking ? VEND_UNBLOCKS : VEND_BLOCKS;
55 rspeak(blocking ? MACHINE_SWINGOUT : MACHINE_SWINGBACK);
59 if (obj == 0)spk = NO_TARGET;
60 if (obj == CLAM || obj == OYSTER)spk = SHELL_IMPERVIOUS;
61 if (obj == SNAKE)spk = SNAKE_WARNING;
62 if (obj == DWARF)spk = BARE_HANDS_QUERY;
63 if (obj == DWARF && game.closed) return GO_DWARFWAKE;
64 if (obj == DRAGON)spk = ALREADY_DEAD;
65 if (obj == TROLL)spk = ROCKY_TROLL;
66 if (obj == OGRE)spk = OGRE_DODGE;
67 if (obj == OGRE && atdwrf(game.loc) > 0) {
72 for (int i = 1; i < PIRATE; i++) {
73 if (game.dloc[i] == game.loc) {
75 game.dloc[i] = LOC_LONGWEST;
76 game.dseen[i] = false;
79 spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2;
80 } else if (obj == BEAR)
81 /* FIXME: Arithmetic on message numbers */
82 spk = BEAR_HANDS + (game.prop[BEAR] + 1) / 2;
83 else if (obj == DRAGON && game.prop[DRAGON] == 0) {
84 /* Fun stuff for dragon. If he insists on attacking it, win!
85 * Set game.prop to dead, move dragon to central loc (still
86 * fixed), move rug there (not fixed), and move him there,
87 * too. Then do a null motion to get new description. */
88 rspeak(BARE_HANDS_QUERY);
89 GETIN(input, &command->wd1, &command->wd1x, &command->wd2, &command->wd2x);
90 if (command->wd1 != MAKEWD(WORD_YINIT) && command->wd1 != MAKEWD(WORD_YES))
92 pspeak(DRAGON, look, 3);
93 game.prop[DRAGON] = 1;
95 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
96 move(DRAGON + NOBJECTS, -1);
97 move(RUG + NOBJECTS, 0);
101 for (obj = 1; obj <= NOBJECTS; obj++) {
102 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
113 static int bigwords(token_t foo)
114 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
115 * Look up foo in section 3 of vocab to determine which word we've got. Last
116 * word zips the eggs back to the giant room (unless already there). */
118 int k = vocab(foo, 3);
119 int spk = NOTHING_HAPPENS;
120 if (game.foobar != 1 - k) {
121 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)spk = START_OVER;
131 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
135 /* Bring back troll if we steal the eggs back from him before
137 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == 0)
138 game.prop[TROLL] = 1;
140 if (HERE(EGGS))k = 1;
141 if (game.loc == objects[EGGS].plac)k = 0;
142 move(EGGS, objects[EGGS].plac);
143 pspeak(EGGS, look, k);
149 static int bivalve(token_t verb, token_t obj)
150 /* Clam/oyster actions */
153 bool is_oyster = (obj == OYSTER);
154 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
155 if (TOTING(obj))spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
156 if (!TOTING(TRIDENT))spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
157 if (verb == LOCK)spk = HUH_MAN;
158 if (spk == PEARL_FALLS) {
160 drop(OYSTER, game.loc);
161 drop(PEARL, LOC_CULDESAC);
167 static void blast(void)
168 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
170 if (game.prop[ROD2] < 0 || !game.closed)
171 rspeak(REQUIRES_DYNAMITE);
173 game.bonus = VICTORY_MESSAGE;
174 if (game.loc == LOC_NE)
175 game.bonus = DEFEAT_MESSAGE;
177 game.bonus = SPLATTER_MESSAGE;
183 static int vbreak(token_t verb, token_t obj)
184 /* Break. Only works for mirror in repository and, of course, the vase. */
186 int spk = actions[verb].message;
187 if (obj == MIRROR)spk = TOO_FAR;
188 if (obj == VASE && game.prop[VASE] == 0) {
189 if (TOTING(VASE))drop(VASE, game.loc);
191 game.fixed[VASE] = -1;
194 if (obj == MIRROR && game.closed) {
195 rspeak(BREAK_MIRROR);
203 static int brief(void)
204 /* Brief. Intransitive only. Suppress long descriptions after first time. */
208 rspeak(BRIEF_CONFIRM);
212 static int vcarry(token_t verb, token_t obj)
213 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
214 * take one without the other). Liquids also special, since they depend on
215 * status of bottle. Also various side effects, etc. */
218 if (obj == INTRANSITIVE) {
219 /* Carry, no object given yet. OK if only one object present. */
220 if (game.atloc[game.loc] == 0 ||
221 game.link[game.atloc[game.loc]] != 0 ||
222 atdwrf(game.loc) > 0)
224 obj = game.atloc[game.loc];
228 rspeak(ALREADY_CARRYING);
232 if (obj == PLANT && game.prop[PLANT] <= 0)spk = DEEP_ROOTS;
233 if (obj == BEAR && game.prop[BEAR] == 1)spk = BEAR_CHAINED;
234 if (obj == CHAIN && game.prop[BEAR] != 0)spk = STILL_LOCKED;
235 if (obj == URN)spk = URN_NOBUDGE;
236 if (obj == CAVITY)spk = DOUGHNUT_HOLES;
237 if (obj == BLOOD)spk = FEW_DROPS;
238 if (obj == RUG && game.prop[RUG] == 2)spk = RUG_HOVERS;
239 if (obj == SIGN)spk = HAND_PASSTHROUGH;
241 rspeak(REMOVE_MESSAGE);
245 if (game.fixed[obj] != 0) {
249 if (obj == WATER || obj == OIL) {
250 if (!HERE(BOTTLE) || LIQUID() != obj) {
251 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
252 return (fill(verb, BOTTLE));
254 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
256 if (!TOTING(BOTTLE))spk = NO_CONTAINER;
265 if (game.holdng >= INVLIMIT) {
268 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
269 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
274 if (!TOTING(CAGE))spk = CANNOT_CARRY;
275 if (TOTING(ROD))spk = BIRD_EVADES;
276 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
280 game.prop[BIRD] = BIRD_CAGED;
282 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
283 carry(BIRD + CAGE - obj, game.loc);
284 carry(obj, game.loc);
285 if (obj == BOTTLE && LIQUID() != 0)
286 game.place[LIQUID()] = CARRIED;
287 if (GSTONE(obj) && game.prop[obj] != 0) {
289 game.prop[CAVITY] = 1;
295 static int chain(token_t verb)
296 /* Do something to the bear's chain */
300 spk = CHAIN_UNLOCKED;
301 if (game.prop[BEAR] == 0)spk = BEAR_BLOCKS;
302 if (game.prop[CHAIN] == 0)spk = ALREADY_UNLOCKED;
303 if (spk != CHAIN_UNLOCKED) {
307 game.prop[CHAIN] = 0;
308 game.fixed[CHAIN] = 0;
309 if (game.prop[BEAR] != 3)game.prop[BEAR] = 2;
310 game.fixed[BEAR] = 2 - game.prop[BEAR];
313 if (game.prop[CHAIN] != 0)spk = ALREADY_LOCKED;
314 if (game.loc != objects[CHAIN].plac)spk = NO_LOCKSITE;
315 if (spk != CHAIN_LOCKED) {
319 game.prop[CHAIN] = 2;
320 if (TOTING(CHAIN))drop(CHAIN, game.loc);
321 game.fixed[CHAIN] = -1;
327 static int discard(token_t verb, token_t obj, bool just_do_it)
328 /* Discard object. "Throw" also comes here for most objects. Special cases for
329 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
330 * Drop coins at vending machine for extra batteries. */
332 int spk = actions[verb].message;
334 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj = ROD2;
339 if (obj == BIRD && HERE(SNAKE)) {
340 rspeak(BIRD_ATTACKS);
341 if (game.closed) return GO_DWARFWAKE;
343 /* Set game.prop for use by travel options */
344 game.prop[SNAKE] = 1;
346 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != 0)) {
349 game.prop[CAVITY] = 0;
350 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != 2) || (obj == RUBY &&
351 game.prop[RUG] == 2))) {
353 if (TOTING(RUG))spk = RUG_WIGGLES;
354 if (obj == RUBY)spk = RUG_SETTLES;
356 if (spk != RUG_WIGGLES) {
357 int k = 2 - game.prop[RUG];
359 if (k == 2) k = objects[SAPPH].plac;
360 move(RUG + NOBJECTS, k);
363 } else if (obj == COINS && HERE(VEND)) {
365 drop(BATTERY, game.loc);
366 pspeak(BATTERY, look, FRESH_BATTERIES);
368 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
372 } else if (obj == BEAR && AT(TROLL)) {
373 rspeak(TROLL_SCAMPERS);
375 move(TROLL + NOBJECTS, 0);
376 move(TROLL2, objects[TROLL].plac);
377 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
379 game.prop[TROLL] = 2;
380 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
384 if (AT(PILLOW))game.prop[VASE] = 0;
385 pspeak(VASE, look, game.prop[VASE] + 1);
386 if (game.prop[VASE] != 0)game.fixed[VASE] = -1;
390 if (k == obj)obj = BOTTLE;
391 if (obj == BOTTLE && k != 0)
392 game.place[k] = LOC_NOWHERE;
393 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
394 drop(BIRD, game.loc);
396 if (obj != BIRD) return GO_CLEAROBJ;
397 game.prop[BIRD] = BIRD_UNCAGED;
398 if (FOREST(game.loc))
399 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
403 static int drink(token_t verb, token_t obj)
404 /* Drink. If no object, assume water and look for it here. If water is in
405 * the bottle, drink that, else must be at a water loc, so drink stream. */
407 int spk = actions[verb].message;
408 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
411 if (obj != 0 && obj != WATER)spk = RIDICULOUS_ATTEMPT;
412 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
413 game.prop[BOTTLE] = EMPTY_BOTTLE;
414 game.place[WATER] = LOC_NOWHERE;
419 game.prop[DRAGON] = 2;
427 static int eat(token_t verb, token_t obj)
428 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
429 * ok, some things lose appetite, rest are ridiculous. */
431 int spk = actions[verb].message;
432 if (obj == INTRANSITIVE) {
436 spk = THANKS_DELICIOUS;
440 spk = THANKS_DELICIOUS;
442 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
443 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
444 OGRE)spk = LOST_APPETITE;
450 static int extinguish(token_t verb, int obj)
451 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
453 int spk = actions[verb].message;
454 if (obj == INTRANSITIVE) {
455 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
457 if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
458 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
462 game.prop[URN] = game.prop[URN] / 2;
464 } else if (obj == LAMP) {
465 state_change(LAMP, LAMP_DARK);
466 spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
467 } else if (obj == DRAGON || obj == VOLCANO)
473 static int feed(token_t verb, token_t obj)
474 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
475 * mad. Bear, special. */
477 int spk = actions[verb].message;
481 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
482 spk = NOTHING_EDIBLE;
483 if (obj == DRAGON && game.prop[DRAGON] != 0)spk = RIDICULOUS_ATTEMPT;
484 if (obj == TROLL)spk = TROLL_VICES;
485 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
489 } else if (obj == DWARF) {
494 } else if (obj == BEAR) {
495 if (game.prop[BEAR] == 0)spk = NOTHING_EDIBLE;
496 if (game.prop[BEAR] == 3)spk = RIDICULOUS_ATTEMPT;
504 } else if (obj == OGRE) {
514 int fill(token_t verb, token_t obj)
515 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
519 int spk = actions[verb].message;
521 spk = ARENT_CARRYING;
522 if (LIQLOC(game.loc) == 0)spk = FILL_INVALID;
523 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
527 rspeak(SHATTER_VASE);
529 game.fixed[VASE] = -1;
530 return (discard(verb, obj, true));
531 } else if (obj == URN) {
533 if (game.prop[URN] != 0) {
539 if (k == 0 || !HERE(BOTTLE)) {
543 game.place[k] = LOC_NOWHERE;
544 game.prop[BOTTLE] = EMPTY_BOTTLE;
545 if (k == OIL)game.prop[URN] = 1;
546 spk = WATER_URN + game.prop[URN];
549 } else if (obj != 0 && obj != BOTTLE) {
552 } else if (obj == 0 && !HERE(BOTTLE))
555 if (LIQLOC(game.loc) == 0)
557 if (HERE(URN) && game.prop[URN] != 0)
561 if (spk == BOTTLED_WATER) {
562 /* FIXME: Arithmetic on property values */
563 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
566 game.place[k] = CARRIED;
574 static int find(token_t verb, token_t obj)
575 /* Find. Might be carrying it, or it might be here. Else give caveat. */
577 int spk = actions[verb].message;
579 (LIQUID() == obj && AT(BOTTLE)) ||
580 obj == LIQLOC(game.loc) ||
581 (obj == DWARF && atdwrf(game.loc) > 0))
583 if (game.closed)spk = NEEDED_NEARBY;
584 if (TOTING(obj))spk = ALREADY_CARRYING;
589 static int fly(token_t verb, token_t obj)
590 /* Fly. Snide remarks unless hovering rug is here. */
592 int spk = actions[verb].message;
593 if (obj == INTRANSITIVE) {
594 if (game.prop[RUG] != 2)spk = RUG_NOTHING2;
595 if (!HERE(RUG))spk = FLAP_ARMS;
596 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
608 if (game.prop[RUG] != 2) {
612 game.oldlc2 = game.oldloc;
613 game.oldloc = game.loc;
614 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
616 if (game.prop[SAPPH] >= 0)
622 static int inven(void)
623 /* Inventory. If object, treat same as find. Else report on current burden. */
626 for (int i = 1; i <= NOBJECTS; i++) {
627 if (i == BEAR || !TOTING(i))
632 pspeak(i, touch, -1);
642 static int light(token_t verb, token_t obj)
643 /* Light. Applicable only to lamp and urn. */
645 int spk = actions[verb].message;
646 if (obj == INTRANSITIVE) {
647 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
649 if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
650 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
654 if (game.prop[URN] == 0) {
667 if (game.limit < 0) {
671 state_change(LAMP, LAMP_BRIGHT);
679 static int listen(void)
680 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
683 int spk = ALL_SILENT;
684 k = locations[game.loc].sound;
687 if (locations[game.loc].loud)
692 for (int i = 1; i <= NOBJECTS; i++) {
693 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
695 int mi = game.prop[i];
697 mi += 3 * game.blooded;
698 pspeak(i, hear, mi, game.zzword);
700 /* FIXME: Magic number, sensitive to bird state logic */
701 if (i == BIRD && game.prop[i] == 5)
708 static int lock(token_t verb, token_t obj)
709 /* Lock, unlock, no object given. Assume various things if present. */
711 int spk = actions[verb].message;
712 if (obj == INTRANSITIVE) {
713 spk = NOTHING_LOCKED;
714 if (HERE(CLAM))obj = CLAM;
715 if (HERE(OYSTER))obj = OYSTER;
716 if (AT(DOOR))obj = DOOR;
717 if (AT(GRATE))obj = GRATE;
718 if (obj != 0 && HERE(CHAIN)) return GO_UNKNOWN;
719 if (HERE(CHAIN))obj = CHAIN;
720 if (obj == 0 || obj == INTRANSITIVE) {
726 /* Lock, unlock object. Special stuff for opening clam/oyster
728 if (obj == CLAM || obj == OYSTER)
729 return bivalve(verb, obj);
730 if (obj == DOOR)spk = RUSTY_DOOR;
731 if (obj == DOOR && game.prop[DOOR] == 1)spk = OK_MAN;
732 if (obj == CAGE)spk = NO_LOCK;
733 if (obj == KEYS)spk = CANNOT_UNLOCK;
734 if (obj == GRATE || obj == CHAIN) {
741 if (!game.panic)game.clock2 = PANICTIME;
744 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
753 static int pour(token_t verb, token_t obj)
754 /* Pour. If no object, or object is bottle, assume contents of bottle.
755 * special tests for pouring water or oil on plant or rusty door. */
757 int spk = actions[verb].message;
758 if (obj == BOTTLE || obj == 0)obj = LIQUID();
759 if (obj == 0) return GO_UNKNOWN;
765 if (obj != OIL && obj != WATER) {
769 if (HERE(URN) && game.prop[URN] == 0)
770 return fill(verb, URN);
771 game.prop[BOTTLE] = EMPTY_BOTTLE;
772 game.place[obj] = LOC_NOWHERE;
774 if (!(AT(PLANT) || AT(DOOR))) {
779 spk = SHAKING_LEAVES;
784 pspeak(PLANT, look, game.prop[PLANT] + 3);
785 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
786 game.prop[PLANT2] = game.prop[PLANT];
790 if (obj == OIL)game.prop[DOOR] = 1;
791 spk = RUSTED_HINGES + game.prop[DOOR];
797 static int quit(void)
798 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
800 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
805 static int read(struct command_t command)
806 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
808 if (command.obj == INTRANSITIVE) {
810 for (int i = 1; i <= NOBJECTS; i++) {
811 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
812 command.obj = command.obj * NOBJECTS + i;
814 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
818 if (DARK(game.loc)) {
819 rspeak(NO_SEE, command.wd1, command.wd1x);
820 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
821 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
822 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
823 rspeak(actions[command.verb].message);
825 pspeak(command.obj, study, game.prop[command.obj]);
829 static int reservoir(void)
830 /* Z'ZZZ (word gets recomputed at startup; different each game). */
832 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
833 rspeak(NOTHING_HAPPENS);
836 pspeak(RESER, look, game.prop[RESER] + 1);
837 game.prop[RESER] = 1 - game.prop[RESER];
841 game.oldlc2 = game.loc;
849 static int rub(token_t verb, token_t obj)
850 /* Rub. Yields various snide remarks except for lit urn. */
852 int spk = actions[verb].message;
854 spk = PECULIAR_NOTHING;
855 if (obj == URN && game.prop[URN] == 2) {
857 drop(AMBER, game.loc);
858 game.prop[AMBER] = 1;
860 drop(CAVITY, game.loc);
867 static int say(struct command_t *command)
868 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
870 long a = command->wd1, b = command->wd1x;
871 if (command->wd2 > 0) {
874 command->wd1 = command->wd2;
876 int wd = vocab(command->wd1, -1);
877 /* FIXME: Magic numbers */
878 if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) {
879 /* FIXME: scribbles on the interpreter's command block */
880 wordclear(&command->wd2);
883 rspeak(OKEY_DOKEY, a, b);
887 static int throw_support(long spk)
894 static int throw (FILE *cmdin, struct command_t *command)
895 /* Throw. Same as discard unless axe. Then same as attack except
896 * ignore bird, and if dwarf is present then one might be killed.
897 * (Only way to do so!) Axe also special for dragon, bear, and
898 * troll. Treasures special for troll. */
900 int spk = actions[command->verb].message;
901 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))command->obj = ROD2;
902 if (!TOTING(command->obj)) {
906 if (objects[command->obj].is_treasure && AT(TROLL)) {
907 spk = TROLL_SATISFIED;
908 /* Snarf a treasure for the troll. */
909 drop(command->obj, 0);
911 move(TROLL + NOBJECTS, 0);
912 drop(TROLL2, objects[TROLL].plac);
913 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
918 if (command->obj == FOOD && HERE(BEAR)) {
919 /* But throwing food is another story. */
921 return (feed(command->verb, command->obj));
923 if (command->obj != AXE)
924 return (discard(command->verb, command->obj, false));
926 int i = atdwrf(game.loc);
928 if (AT(DRAGON) && game.prop[DRAGON] == 0)
929 return throw_support(DRAGON_SCALES);
931 return throw_support(TROLL_RETURNS);
933 return throw_support(OGRE_DODGE);
934 else if (HERE(BEAR) && game.prop[BEAR] == 0) {
935 /* This'll teach him to throw the axe at the bear! */
937 game.fixed[AXE] = -1;
944 return (attack(cmdin, command));
947 if (randrange(NDWARVES + 1) < game.dflag) {
948 return throw_support(DWARF_DODGES);
950 game.dseen[i] = false;
952 return throw_support((++game.dkill == 1)
953 ? DWARF_SMOKE : KILLED_DWARF);
958 static int wake(token_t verb, token_t obj)
959 /* Wake. Only use is to disturb the dwarves. */
961 if (obj != DWARF || !game.closed) {
962 rspeak(actions[verb].message);
970 static int wave(token_t verb, token_t obj)
971 /* Wave. No effect unless waving rod at fissure or at bird. */
973 int spk = actions[verb].message;
974 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))spk = ARENT_CARRYING;
977 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
981 /* FIXME: Arithemetic on proprty values */
983 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
984 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
985 drop(JADE, game.loc);
996 if (game.closng || !AT(FISSURE)) {
1000 if (HERE(BIRD))rspeak(spk);
1001 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1002 pspeak(FISSURE, look, 2 - game.prop[FISSURE]);
1007 int action(FILE *input, struct command_t *command)
1008 /* Analyse a verb. Remember what it was, go back for object if second word
1009 * unless verb is "say", which snarfs arbitrary second word.
1012 token_t spk = actions[command->verb].message;
1014 if (command->part == unknown) {
1015 /* Analyse an object word. See if the thing is here, whether
1016 * we've got a verb yet, and so on. Object must be here
1017 * unless verb is "find" or "invent(ory)" (and no new verb
1018 * yet to be analysed). Water and oil are also funny, since
1019 * they are never actually dropped at any location, but might
1020 * be here inside the bottle or urn or as a feature of the
1022 if (HERE(command->obj))
1024 else if (command->obj == GRATE) {
1025 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1026 command->obj = DPRSSN;
1027 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1028 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1029 command->obj = ENTRNC;
1030 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1032 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1034 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1037 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1038 command->obj = PLANT2;
1040 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1042 spk = KNIVES_VANISH;
1045 } else if (command->obj == ROD && HERE(ROD2)) {
1046 command->obj = ROD2;
1048 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1051 rspeak(NO_SEE, command->wd1, command->wd1x);
1055 if (command->wd2 > 0)
1057 if (command->verb != 0)
1058 command->part = transitive;
1061 switch (command->part) {
1063 if (command->wd2 > 0 && command->verb != SAY)
1065 if (command->verb == SAY)command->obj = command->wd2;
1066 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1067 /* Analyse an intransitive verb (ie, no object given yet). */
1068 switch (command->verb) {
1070 return vcarry(command->verb, INTRANSITIVE);
1076 return lock(command->verb, INTRANSITIVE);
1079 return (GO_CLEAROBJ);
1082 return lock(command->verb, INTRANSITIVE);
1084 return light(command->verb, INTRANSITIVE);
1086 return extinguish(command->verb, INTRANSITIVE);
1096 return attack(input, command);
1098 return pour(command->verb, command->obj);
1100 return eat(command->verb, INTRANSITIVE);
1102 return drink(command->verb, command->obj);
1116 return fill(command->verb, command->obj);
1124 return bigwords(command->wd1);
1128 command->obj = INTRANSITIVE;
1129 return read(*command);
1139 return fly(command->verb, INTRANSITIVE);
1145 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1150 /* Analyse a transitive verb. */
1151 switch (command->verb) {
1153 return vcarry(command->verb, command->obj);
1155 return discard(command->verb, command->obj, false);
1157 return say(command);
1159 return lock(command->verb, command->obj);
1162 return (GO_CLEAROBJ);
1165 return lock(command->verb, command->obj);
1167 return light(command->verb, command->obj);
1169 return extinguish(command->verb, command->obj);
1171 return wave(command->verb, command->obj);
1181 return attack(input, command);
1183 return pour(command->verb, command->obj);
1185 return eat(command->verb, command->obj);
1187 return drink(command->verb, command->obj);
1189 return rub(command->verb, command->obj);
1191 return throw(input, command);
1197 return find(command->verb, command->obj);
1199 return find(command->verb, command->obj);
1201 return feed(command->verb, command->obj);
1203 return fill(command->verb, command->obj);
1220 return read(*command);
1222 return vbreak(command->verb, command->obj);
1224 return wake(command->verb, command->obj);
1234 return fly(command->verb, command->obj);
1242 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1245 /* Unknown verb, couldn't deduce object - might need hint */
1246 rspeak(WHAT_DO, command->wd1, command->wd1x);
1247 return GO_CHECKHINT;
1249 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE