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] == UNTAMED_BEAR)
32 obj = obj * NOBJECTS + BEAR;
33 if (obj > NOBJECTS) return GO_UNKNOWN;
35 /* Can't attack bird or machine by throwing axe. */
36 if (HERE(BIRD) && verb != THROW)obj = BIRD;
37 if (HERE(VEND) && verb != THROW)obj = obj * NOBJECTS + VEND;
38 /* Clam and oyster both treated as clam for intransitive case;
40 if (HERE(CLAM) || HERE(OYSTER))obj = NOBJECTS * obj + CLAM;
53 } else if (obj == VEND) {
55 game.prop[VEND]==VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
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] == SITTING_BEAR)
235 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
237 if (obj == URN)spk = URN_NOBUDGE;
238 if (obj == CAVITY)spk = DOUGHNUT_HOLES;
239 if (obj == BLOOD)spk = FEW_DROPS;
240 if (obj == RUG && game.prop[RUG] == 2)spk = RUG_HOVERS;
241 if (obj == SIGN)spk = HAND_PASSTHROUGH;
243 rspeak(REMOVE_MESSAGE);
247 if (game.fixed[obj] != 0) {
251 if (obj == WATER || obj == OIL) {
252 if (!HERE(BOTTLE) || LIQUID() != obj) {
253 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
254 return (fill(verb, BOTTLE));
256 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
258 if (!TOTING(BOTTLE))spk = NO_CONTAINER;
267 if (game.holdng >= INVLIMIT) {
270 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
271 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
276 if (!TOTING(CAGE))spk = CANNOT_CARRY;
277 if (TOTING(ROD))spk = BIRD_EVADES;
278 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
282 game.prop[BIRD] = BIRD_CAGED;
284 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
285 carry(BIRD + CAGE - obj, game.loc);
286 carry(obj, game.loc);
287 if (obj == BOTTLE && LIQUID() != 0)
288 game.place[LIQUID()] = CARRIED;
289 if (GSTONE(obj) && game.prop[obj] != 0) {
291 game.prop[CAVITY] = 1;
297 static int chain(token_t verb)
298 /* Do something to the bear's chain */
302 spk = CHAIN_UNLOCKED;
303 if (game.prop[BEAR] == UNTAMED_BEAR)
305 if (game.prop[CHAIN] == 0)
306 spk = ALREADY_UNLOCKED;
307 if (spk != CHAIN_UNLOCKED) {
311 game.prop[CHAIN] = 0;
312 game.fixed[CHAIN] = 0;
313 if (game.prop[BEAR] != BEAR_DEAD)
314 game.prop[BEAR] = CONTENTED_BEAR;
315 /* FIXME: Arithmetic on state numbers */
316 game.fixed[BEAR] = 2 - game.prop[BEAR];
319 if (game.prop[CHAIN] != 0)
320 spk = ALREADY_LOCKED;
321 if (game.loc != objects[CHAIN].plac)
323 if (spk != CHAIN_LOCKED) {
327 game.prop[CHAIN] = 2;
329 drop(CHAIN, game.loc);
330 game.fixed[CHAIN] = -1;
336 static int discard(token_t verb, token_t obj, bool just_do_it)
337 /* Discard object. "Throw" also comes here for most objects. Special cases for
338 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
339 * Drop coins at vending machine for extra batteries. */
341 int spk = actions[verb].message;
343 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj = ROD2;
348 if (obj == BIRD && HERE(SNAKE)) {
349 rspeak(BIRD_ATTACKS);
350 if (game.closed) return GO_DWARFWAKE;
352 /* Set game.prop for use by travel options */
353 game.prop[SNAKE] = 1;
355 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != 0)) {
358 game.prop[CAVITY] = 0;
359 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != 2) || (obj == RUBY &&
360 game.prop[RUG] == 2))) {
362 if (TOTING(RUG))spk = RUG_WIGGLES;
363 if (obj == RUBY)spk = RUG_SETTLES;
365 if (spk != RUG_WIGGLES) {
366 int k = 2 - game.prop[RUG];
368 if (k == 2) k = objects[SAPPH].plac;
369 move(RUG + NOBJECTS, k);
372 } else if (obj == COINS && HERE(VEND)) {
374 drop(BATTERY, game.loc);
375 pspeak(BATTERY, look, FRESH_BATTERIES);
377 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
381 } else if (obj == BEAR && AT(TROLL)) {
382 rspeak(TROLL_SCAMPERS);
384 move(TROLL + NOBJECTS, 0);
385 move(TROLL2, objects[TROLL].plac);
386 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
388 game.prop[TROLL] = 2;
389 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
393 if (AT(PILLOW))game.prop[VASE] = 0;
394 pspeak(VASE, look, game.prop[VASE] + 1);
395 if (game.prop[VASE] != 0)game.fixed[VASE] = -1;
399 if (k == obj)obj = BOTTLE;
400 if (obj == BOTTLE && k != 0)
401 game.place[k] = LOC_NOWHERE;
402 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
403 drop(BIRD, game.loc);
405 if (obj != BIRD) return GO_CLEAROBJ;
406 game.prop[BIRD] = BIRD_UNCAGED;
407 if (FOREST(game.loc))
408 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
412 static int drink(token_t verb, token_t obj)
413 /* Drink. If no object, assume water and look for it here. If water is in
414 * the bottle, drink that, else must be at a water loc, so drink stream. */
416 int spk = actions[verb].message;
417 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
420 if (obj != 0 && obj != WATER)spk = RIDICULOUS_ATTEMPT;
421 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
422 game.prop[BOTTLE] = EMPTY_BOTTLE;
423 game.place[WATER] = LOC_NOWHERE;
428 game.prop[DRAGON] = 2;
436 static int eat(token_t verb, token_t obj)
437 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
438 * ok, some things lose appetite, rest are ridiculous. */
440 int spk = actions[verb].message;
441 if (obj == INTRANSITIVE) {
445 spk = THANKS_DELICIOUS;
449 spk = THANKS_DELICIOUS;
451 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
452 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
453 OGRE)spk = LOST_APPETITE;
459 static int extinguish(token_t verb, int obj)
460 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
462 int spk = actions[verb].message;
463 if (obj == INTRANSITIVE) {
464 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
466 if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
467 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
471 game.prop[URN] = game.prop[URN] / 2;
473 } else if (obj == LAMP) {
474 state_change(LAMP, LAMP_DARK);
475 spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
476 } else if (obj == DRAGON || obj == VOLCANO)
482 static int feed(token_t verb, token_t obj)
483 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
484 * mad. Bear, special. */
486 int spk = actions[verb].message;
490 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
491 spk = NOTHING_EDIBLE;
492 if (obj == DRAGON && game.prop[DRAGON] != 0)spk = RIDICULOUS_ATTEMPT;
493 if (obj == TROLL)spk = TROLL_VICES;
494 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
498 } else if (obj == DWARF) {
503 } else if (obj == BEAR) {
504 if (game.prop[BEAR] == UNTAMED_BEAR)
505 spk = NOTHING_EDIBLE;
506 if (game.prop[BEAR] == BEAR_DEAD)
507 spk = RIDICULOUS_ATTEMPT;
510 game.prop[BEAR] = SITTING_BEAR;
515 } else if (obj == OGRE) {
525 int fill(token_t verb, token_t obj)
526 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
530 int spk = actions[verb].message;
532 spk = ARENT_CARRYING;
533 if (LIQLOC(game.loc) == 0)spk = FILL_INVALID;
534 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
538 rspeak(SHATTER_VASE);
540 game.fixed[VASE] = -1;
541 return (discard(verb, obj, true));
542 } else if (obj == URN) {
544 if (game.prop[URN] != 0) {
550 if (k == 0 || !HERE(BOTTLE)) {
554 game.place[k] = LOC_NOWHERE;
555 game.prop[BOTTLE] = EMPTY_BOTTLE;
556 if (k == OIL)game.prop[URN] = 1;
557 spk = WATER_URN + game.prop[URN];
560 } else if (obj != 0 && obj != BOTTLE) {
563 } else if (obj == 0 && !HERE(BOTTLE))
566 if (LIQLOC(game.loc) == 0)
568 if (HERE(URN) && game.prop[URN] != 0)
572 if (spk == BOTTLED_WATER) {
573 /* FIXME: Arithmetic on property values */
574 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
577 game.place[k] = CARRIED;
585 static int find(token_t verb, token_t obj)
586 /* Find. Might be carrying it, or it might be here. Else give caveat. */
588 int spk = actions[verb].message;
590 (LIQUID() == obj && AT(BOTTLE)) ||
591 obj == LIQLOC(game.loc) ||
592 (obj == DWARF && atdwrf(game.loc) > 0))
594 if (game.closed)spk = NEEDED_NEARBY;
595 if (TOTING(obj))spk = ALREADY_CARRYING;
600 static int fly(token_t verb, token_t obj)
601 /* Fly. Snide remarks unless hovering rug is here. */
603 int spk = actions[verb].message;
604 if (obj == INTRANSITIVE) {
605 if (game.prop[RUG] != 2)spk = RUG_NOTHING2;
606 if (!HERE(RUG))spk = FLAP_ARMS;
607 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
619 if (game.prop[RUG] != 2) {
623 game.oldlc2 = game.oldloc;
624 game.oldloc = game.loc;
625 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
627 if (game.prop[SAPPH] >= 0)
633 static int inven(void)
634 /* Inventory. If object, treat same as find. Else report on current burden. */
637 for (int i = 1; i <= NOBJECTS; i++) {
638 if (i == BEAR || !TOTING(i))
643 pspeak(i, touch, -1);
653 static int light(token_t verb, token_t obj)
654 /* Light. Applicable only to lamp and urn. */
656 int spk = actions[verb].message;
657 if (obj == INTRANSITIVE) {
658 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
660 if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
661 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
665 if (game.prop[URN] == 0) {
678 if (game.limit < 0) {
682 state_change(LAMP, LAMP_BRIGHT);
690 static int listen(void)
691 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
694 int spk = ALL_SILENT;
695 k = locations[game.loc].sound;
698 if (locations[game.loc].loud)
703 for (int i = 1; i <= NOBJECTS; i++) {
704 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
706 int mi = game.prop[i];
708 mi += 3 * game.blooded;
709 pspeak(i, hear, mi, game.zzword);
711 /* FIXME: Magic number, sensitive to bird state logic */
712 if (i == BIRD && game.prop[i] == 5)
719 static int lock(token_t verb, token_t obj)
720 /* Lock, unlock, no object given. Assume various things if present. */
722 int spk = actions[verb].message;
723 if (obj == INTRANSITIVE) {
724 spk = NOTHING_LOCKED;
725 if (HERE(CLAM))obj = CLAM;
726 if (HERE(OYSTER))obj = OYSTER;
727 if (AT(DOOR))obj = DOOR;
728 if (AT(GRATE))obj = GRATE;
729 if (obj != 0 && HERE(CHAIN)) return GO_UNKNOWN;
730 if (HERE(CHAIN))obj = CHAIN;
731 if (obj == 0 || obj == INTRANSITIVE) {
737 /* Lock, unlock object. Special stuff for opening clam/oyster
739 if (obj == CLAM || obj == OYSTER)
740 return bivalve(verb, obj);
741 if (obj == DOOR)spk = RUSTY_DOOR;
742 if (obj == DOOR && game.prop[DOOR] == 1)spk = OK_MAN;
743 if (obj == CAGE)spk = NO_LOCK;
744 if (obj == KEYS)spk = CANNOT_UNLOCK;
745 if (obj == GRATE || obj == CHAIN) {
752 if (!game.panic)game.clock2 = PANICTIME;
755 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
764 static int pour(token_t verb, token_t obj)
765 /* Pour. If no object, or object is bottle, assume contents of bottle.
766 * special tests for pouring water or oil on plant or rusty door. */
768 int spk = actions[verb].message;
769 if (obj == BOTTLE || obj == 0)obj = LIQUID();
770 if (obj == 0) return GO_UNKNOWN;
776 if (obj != OIL && obj != WATER) {
780 if (HERE(URN) && game.prop[URN] == 0)
781 return fill(verb, URN);
782 game.prop[BOTTLE] = EMPTY_BOTTLE;
783 game.place[obj] = LOC_NOWHERE;
785 if (!(AT(PLANT) || AT(DOOR))) {
790 spk = SHAKING_LEAVES;
795 pspeak(PLANT, look, game.prop[PLANT] + 3);
796 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
797 game.prop[PLANT2] = game.prop[PLANT];
801 if (obj == OIL)game.prop[DOOR] = 1;
802 spk = RUSTED_HINGES + game.prop[DOOR];
808 static int quit(void)
809 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
811 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
816 static int read(struct command_t command)
817 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
819 if (command.obj == INTRANSITIVE) {
821 for (int i = 1; i <= NOBJECTS; i++) {
822 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
823 command.obj = command.obj * NOBJECTS + i;
825 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
829 if (DARK(game.loc)) {
830 rspeak(NO_SEE, command.wd1, command.wd1x);
831 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
832 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
833 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
834 rspeak(actions[command.verb].message);
836 pspeak(command.obj, study, game.prop[command.obj]);
840 static int reservoir(void)
841 /* Z'ZZZ (word gets recomputed at startup; different each game). */
843 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
844 rspeak(NOTHING_HAPPENS);
847 pspeak(RESER, look, game.prop[RESER] + 1);
848 game.prop[RESER] = 1 - game.prop[RESER];
852 game.oldlc2 = game.loc;
860 static int rub(token_t verb, token_t obj)
861 /* Rub. Yields various snide remarks except for lit urn. */
863 int spk = actions[verb].message;
865 spk = PECULIAR_NOTHING;
866 if (obj == URN && game.prop[URN] == 2) {
868 drop(AMBER, game.loc);
869 game.prop[AMBER] = 1;
871 drop(CAVITY, game.loc);
878 static int say(struct command_t *command)
879 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
881 long a = command->wd1, b = command->wd1x;
882 if (command->wd2 > 0) {
885 command->wd1 = command->wd2;
887 int wd = vocab(command->wd1, -1);
888 /* FIXME: Magic numbers */
889 if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) {
890 /* FIXME: scribbles on the interpreter's command block */
891 wordclear(&command->wd2);
894 rspeak(OKEY_DOKEY, a, b);
898 static int throw_support(long spk)
905 static int throw (FILE *cmdin, struct command_t *command)
906 /* Throw. Same as discard unless axe. Then same as attack except
907 * ignore bird, and if dwarf is present then one might be killed.
908 * (Only way to do so!) Axe also special for dragon, bear, and
909 * troll. Treasures special for troll. */
911 int spk = actions[command->verb].message;
912 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))command->obj = ROD2;
913 if (!TOTING(command->obj)) {
917 if (objects[command->obj].is_treasure && AT(TROLL)) {
918 spk = TROLL_SATISFIED;
919 /* Snarf a treasure for the troll. */
920 drop(command->obj, 0);
922 move(TROLL + NOBJECTS, 0);
923 drop(TROLL2, objects[TROLL].plac);
924 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
929 if (command->obj == FOOD && HERE(BEAR)) {
930 /* But throwing food is another story. */
932 return (feed(command->verb, command->obj));
934 if (command->obj != AXE)
935 return (discard(command->verb, command->obj, false));
937 int i = atdwrf(game.loc);
939 if (AT(DRAGON) && game.prop[DRAGON] == 0)
940 return throw_support(DRAGON_SCALES);
942 return throw_support(TROLL_RETURNS);
944 return throw_support(OGRE_DODGE);
945 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
946 /* This'll teach him to throw the axe at the bear! */
948 game.fixed[AXE] = -1;
955 return (attack(cmdin, command));
958 if (randrange(NDWARVES + 1) < game.dflag) {
959 return throw_support(DWARF_DODGES);
961 game.dseen[i] = false;
963 return throw_support((++game.dkill == 1)
964 ? DWARF_SMOKE : KILLED_DWARF);
969 static int wake(token_t verb, token_t obj)
970 /* Wake. Only use is to disturb the dwarves. */
972 if (obj != DWARF || !game.closed) {
973 rspeak(actions[verb].message);
981 static int wave(token_t verb, token_t obj)
982 /* Wave. No effect unless waving rod at fissure or at bird. */
984 int spk = actions[verb].message;
985 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))spk = ARENT_CARRYING;
988 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
992 /* FIXME: Arithemetic on proprty values */
994 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
995 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
996 drop(JADE, game.loc);
1005 return GO_DWARFWAKE;
1007 if (game.closng || !AT(FISSURE)) {
1011 if (HERE(BIRD))rspeak(spk);
1012 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1013 pspeak(FISSURE, look, 2 - game.prop[FISSURE]);
1018 int action(FILE *input, struct command_t *command)
1019 /* Analyse a verb. Remember what it was, go back for object if second word
1020 * unless verb is "say", which snarfs arbitrary second word.
1023 token_t spk = actions[command->verb].message;
1025 if (command->part == unknown) {
1026 /* Analyse an object word. See if the thing is here, whether
1027 * we've got a verb yet, and so on. Object must be here
1028 * unless verb is "find" or "invent(ory)" (and no new verb
1029 * yet to be analysed). Water and oil are also funny, since
1030 * they are never actually dropped at any location, but might
1031 * be here inside the bottle or urn or as a feature of the
1033 if (HERE(command->obj))
1035 else if (command->obj == GRATE) {
1036 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1037 command->obj = DPRSSN;
1038 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1039 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1040 command->obj = ENTRNC;
1041 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1043 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1045 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1048 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1049 command->obj = PLANT2;
1051 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1053 spk = KNIVES_VANISH;
1056 } else if (command->obj == ROD && HERE(ROD2)) {
1057 command->obj = ROD2;
1059 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1062 rspeak(NO_SEE, command->wd1, command->wd1x);
1066 if (command->wd2 > 0)
1068 if (command->verb != 0)
1069 command->part = transitive;
1072 switch (command->part) {
1074 if (command->wd2 > 0 && command->verb != SAY)
1076 if (command->verb == SAY)command->obj = command->wd2;
1077 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1078 /* Analyse an intransitive verb (ie, no object given yet). */
1079 switch (command->verb) {
1081 return vcarry(command->verb, INTRANSITIVE);
1087 return lock(command->verb, INTRANSITIVE);
1090 return (GO_CLEAROBJ);
1093 return lock(command->verb, INTRANSITIVE);
1095 return light(command->verb, INTRANSITIVE);
1097 return extinguish(command->verb, INTRANSITIVE);
1107 return attack(input, command);
1109 return pour(command->verb, command->obj);
1111 return eat(command->verb, INTRANSITIVE);
1113 return drink(command->verb, command->obj);
1127 return fill(command->verb, command->obj);
1135 return bigwords(command->wd1);
1139 command->obj = INTRANSITIVE;
1140 return read(*command);
1150 return fly(command->verb, INTRANSITIVE);
1156 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1161 /* Analyse a transitive verb. */
1162 switch (command->verb) {
1164 return vcarry(command->verb, command->obj);
1166 return discard(command->verb, command->obj, false);
1168 return say(command);
1170 return lock(command->verb, command->obj);
1173 return (GO_CLEAROBJ);
1176 return lock(command->verb, command->obj);
1178 return light(command->verb, command->obj);
1180 return extinguish(command->verb, command->obj);
1182 return wave(command->verb, command->obj);
1192 return attack(input, command);
1194 return pour(command->verb, command->obj);
1196 return eat(command->verb, command->obj);
1198 return drink(command->verb, command->obj);
1200 return rub(command->verb, command->obj);
1202 return throw(input, command);
1208 return find(command->verb, command->obj);
1210 return find(command->verb, command->obj);
1212 return feed(command->verb, command->obj);
1214 return fill(command->verb, command->obj);
1231 return read(*command);
1233 return vbreak(command->verb, command->obj);
1235 return wake(command->verb, command->obj);
1245 return fly(command->verb, command->obj);
1253 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1256 /* Unknown verb, couldn't deduce object - might need hint */
1257 rspeak(WHAT_DO, command->wd1, command->wd1x);
1258 return GO_CHECKHINT;
1260 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE