7 static int fill(token_t, token_t);
9 static int attack(FILE *input, struct command_t *command)
10 /* Attack. Assume target if unambiguous. "Throw" also links here.
11 * Attackable objects fall into two categories: enemies (snake,
12 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
13 * enemies, or no enemies but 2 others. */
15 vocab_t verb = command->verb;
16 vocab_t obj = command->obj;
17 int spk = ACTSPK[verb];
18 if (obj == 0 || obj == INTRANSITIVE) {
19 if (ATDWRF(game.loc) > 0)
21 if (HERE(SNAKE))obj = obj * NOBJECTS + SNAKE;
22 if (AT(DRAGON) && game.prop[DRAGON] == 0)obj = obj * NOBJECTS + DRAGON;
23 if (AT(TROLL))obj = obj * NOBJECTS + TROLL;
24 if (AT(OGRE))obj = obj * NOBJECTS + OGRE;
25 if (HERE(BEAR) && game.prop[BEAR] == 0)obj = obj * NOBJECTS + BEAR;
26 if (obj > NOBJECTS) return GO_UNKNOWN;
28 /* Can't attack bird or machine by throwing axe. */
29 if (HERE(BIRD) && verb != THROW)obj = BIRD;
30 if (HERE(VEND) && verb != THROW)obj = obj * NOBJECTS + VEND;
31 /* Clam and oyster both treated as clam for intransitive case;
33 if (HERE(CLAM) || HERE(OYSTER))obj = NOBJECTS * obj + CLAM;
47 } else if (obj == VEND) {
48 PSPEAK(VEND, game.prop[VEND] + 2);
49 game.prop[VEND] = 3 - game.prop[VEND];
53 if (obj == 0)spk = NO_TARGET;
54 if (obj == CLAM || obj == OYSTER)spk = SHELL_IMPERVIOUS;
55 if (obj == SNAKE)spk = SNAKE_WARNING;
56 if (obj == DWARF)spk = BARE_HANDS_QUERY;
57 if (obj == DWARF && game.closed) return GO_DWARFWAKE;
58 if (obj == DRAGON)spk = ALREADY_DEAD;
59 if (obj == TROLL)spk = ROCKY_TROLL;
60 if (obj == OGRE)spk = OGRE_DODGE;
61 if (obj == OGRE && ATDWRF(game.loc) > 0) {
66 for (int i = 1; i < PIRATE; i++) {
67 if (game.dloc[i] == game.loc) {
69 game.dloc[i] = LOC_LONGWEST;
70 game.dseen[i] = false;
73 spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2;
74 } else if (obj == BEAR)
75 /* FIXME: Arithmetic on message numbers */
76 spk = BEAR_HANDS + (game.prop[BEAR] + 1) / 2;
77 else if (obj == DRAGON && game.prop[DRAGON] == 0) {
78 /* Fun stuff for dragon. If he insists on attacking it, win!
79 * Set game.prop to dead, move dragon to central loc (still
80 * fixed), move rug there (not fixed), and move him there,
81 * too. Then do a null motion to get new description. */
82 RSPEAK(BARE_HANDS_QUERY);
83 GETIN(input, &command->wd1, &command->wd1x, &command->wd2, &command->wd2x);
84 if (command->wd1 != MAKEWD(WORD_YINIT) && command->wd1 != MAKEWD(WORD_YES))
87 game.prop[DRAGON] = 1;
89 int k = (PLAC[DRAGON] + FIXD[DRAGON]) / 2;
90 MOVE(DRAGON + NOBJECTS, -1);
91 MOVE(RUG + NOBJECTS, 0);
95 for (obj = 1; obj <= NOBJECTS; obj++) {
96 if (game.place[obj] == PLAC[DRAGON] || game.place[obj] == FIXD[DRAGON])
107 static int bigwords(token_t foo)
108 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
109 * Look up foo in section 3 of vocab to determine which word we've got. Last
110 * word zips the eggs back to the giant room (unless already there). */
112 int k = VOCAB(foo, 3);
113 int spk = NOTHING_HAPPENS;
114 if (game.foobar != 1 - k) {
115 if (game.foobar != 0)spk = START_OVER;
125 if (game.place[EGGS] == PLAC[EGGS] || (TOTING(EGGS) && game.loc == PLAC[EGGS])) {
129 /* Bring back troll if we steal the eggs back from him before
131 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == 0)
132 game.prop[TROLL] = 1;
134 if (HERE(EGGS))k = 1;
135 if (game.loc == PLAC[EGGS])k = 0;
136 MOVE(EGGS, PLAC[EGGS]);
143 static int bivalve(token_t verb, token_t obj)
144 /* Clam/oyster actions */
147 bool is_oyster = (obj == OYSTER);
148 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
149 if (TOTING(obj))spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
150 if (!TOTING(TRIDENT))spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
151 if (verb == LOCK)spk = HUH_MAN;
152 if (spk == PEARL_FALLS) {
154 DROP(OYSTER, game.loc);
155 DROP(PEARL, LOC_CULDESAC);
161 static void blast(void)
162 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
164 if (game.prop[ROD2] < 0 || !game.closed)
165 RSPEAK(REQUIRES_DYNAMITE);
167 game.bonus = VICTORY_MESSAGE;
168 if (game.loc == LOC_NE)
169 game.bonus = DEFEAT_MESSAGE;
171 game.bonus = SPLATTER_MESSAGE;
177 static int vbreak(token_t verb, token_t obj)
178 /* Break. Only works for mirror in repository and, of course, the vase. */
180 int spk = ACTSPK[verb];
181 if (obj == MIRROR)spk = TOO_FAR;
182 if (obj == VASE && game.prop[VASE] == 0) {
183 if (TOTING(VASE))DROP(VASE, game.loc);
185 game.fixed[VASE] = -1;
188 if (obj == MIRROR && game.closed) {
189 RSPEAK(BREAK_MIRROR);
197 static int brief(void)
198 /* Brief. Intransitive only. Suppress long descriptions after first time. */
202 RSPEAK(BRIEF_CONFIRM);
206 static int carry(token_t verb, token_t obj)
207 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
208 * take one without the other). Liquids also special, since they depend on
209 * status of bottle. Also various side effects, etc. */
212 if (obj == INTRANSITIVE) {
213 /* Carry, no object given yet. OK if only one object present. */
214 if (game.atloc[game.loc] == 0 ||
215 game.link[game.atloc[game.loc]] != 0 ||
216 ATDWRF(game.loc) > 0)
218 obj = game.atloc[game.loc];
222 RSPEAK(ALREADY_CARRYING);
226 if (obj == PLANT && game.prop[PLANT] <= 0)spk = DEEP_ROOTS;
227 if (obj == BEAR && game.prop[BEAR] == 1)spk = BEAR_CHAINED;
228 if (obj == CHAIN && game.prop[BEAR] != 0)spk = STILL_LOCKED;
229 if (obj == URN)spk = URN_NOBUDGE;
230 if (obj == CAVITY)spk = DOUGHNUT_HOLES;
231 if (obj == BLOOD)spk = FEW_DROPS;
232 if (obj == RUG && game.prop[RUG] == 2)spk = RUG_HOVERS;
233 if (obj == SIGN)spk = HAND_PASSTHROUGH;
235 RSPEAK(REMOVE_MESSAGE);
239 if (game.fixed[obj] != 0) {
243 if (obj == WATER || obj == OIL) {
244 if (!HERE(BOTTLE) || LIQUID() != obj) {
245 if (TOTING(BOTTLE) && game.prop[BOTTLE] == 1)
246 return (fill(verb, BOTTLE));
248 if (game.prop[BOTTLE] != 1)spk = BOTTLE_FULL;
249 if (!TOTING(BOTTLE))spk = NO_CONTAINER;
258 if (game.holdng >= INVLIMIT) {
261 } else if (obj == BIRD && game.prop[BIRD] != 1 && -1 - game.prop[BIRD] != 1) {
262 if (game.prop[BIRD] == 2) {
267 if (!TOTING(CAGE))spk = CANNOT_CARRY;
268 if (TOTING(ROD))spk = BIRD_EVADES;
269 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
275 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == 1 || -1 - game.prop[BIRD] == 1))
276 CARRY(BIRD + CAGE - obj, game.loc);
277 CARRY(obj, game.loc);
278 if (obj == BOTTLE && LIQUID() != 0)
279 game.place[LIQUID()] = CARRIED;
280 if (GSTONE(obj) && game.prop[obj] != 0) {
282 game.prop[CAVITY] = 1;
288 static int chain(token_t verb)
289 /* Do something to the bear's chain */
293 spk = CHAIN_UNLOCKED;
294 if (game.prop[BEAR] == 0)spk = BEAR_BLOCKS;
295 if (game.prop[CHAIN] == 0)spk = ALREADY_UNLOCKED;
296 if (spk != CHAIN_UNLOCKED) {
300 game.prop[CHAIN] = 0;
301 game.fixed[CHAIN] = 0;
302 if (game.prop[BEAR] != 3)game.prop[BEAR] = 2;
303 game.fixed[BEAR] = 2 - game.prop[BEAR];
306 if (game.prop[CHAIN] != 0)spk = ALREADY_LOCKED;
307 if (game.loc != PLAC[CHAIN])spk = NO_LOCKSITE;
308 if (spk != CHAIN_LOCKED) {
312 game.prop[CHAIN] = 2;
313 if (TOTING(CHAIN))DROP(CHAIN, game.loc);
314 game.fixed[CHAIN] = -1;
320 static int discard(token_t verb, token_t obj, bool just_do_it)
321 /* Discard object. "Throw" also comes here for most objects. Special cases for
322 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
323 * Drop coins at vending machine for extra batteries. */
325 int spk = ACTSPK[verb];
327 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj = ROD2;
332 if (obj == BIRD && HERE(SNAKE)) {
333 RSPEAK(BIRD_ATTACKS);
334 if (game.closed) return GO_DWARFWAKE;
336 /* Set game.prop for use by travel options */
337 game.prop[SNAKE] = 1;
339 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != 0)) {
342 game.prop[CAVITY] = 0;
343 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != 2) || (obj == RUBY &&
344 game.prop[RUG] == 2))) {
346 if (TOTING(RUG))spk = RUG_WIGGLES;
347 if (obj == RUBY)spk = RUG_SETTLES;
349 if (spk != RUG_WIGGLES) {
350 int k = 2 - game.prop[RUG];
352 if (k == 2) k = PLAC[SAPPH];
353 MOVE(RUG + NOBJECTS, k);
356 } else if (obj == COINS && HERE(VEND)) {
358 DROP(BATTERY, game.loc);
361 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
366 } else if (obj == BEAR && AT(TROLL)) {
367 RSPEAK(TROLL_SCAMPERS);
369 MOVE(TROLL + NOBJECTS, 0);
370 MOVE(TROLL2, PLAC[TROLL]);
371 MOVE(TROLL2 + NOBJECTS, FIXD[TROLL]);
373 game.prop[TROLL] = 2;
374 } else if (obj != VASE || game.loc == PLAC[PILLOW]) {
378 if (AT(PILLOW))game.prop[VASE] = 0;
379 PSPEAK(VASE, game.prop[VASE] + 1);
380 if (game.prop[VASE] != 0)game.fixed[VASE] = -1;
384 if (k == obj)obj = BOTTLE;
385 if (obj == BOTTLE && k != 0)
386 game.place[k] = LOC_NOWHERE;
387 if (obj == CAGE && game.prop[BIRD] == 1)DROP(BIRD, game.loc);
389 if (obj != BIRD) return GO_CLEAROBJ;
391 if (FOREST(game.loc))game.prop[BIRD] = 2;
395 static int drink(token_t verb, token_t obj)
396 /* Drink. If no object, assume water and look for it here. If water is in
397 * the bottle, drink that, else must be at a water loc, so drink stream. */
399 int spk = ACTSPK[verb];
400 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
403 if (obj != 0 && obj != WATER)spk = RIDICULOUS_ATTEMPT;
404 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
405 game.prop[BOTTLE] = 1;
406 game.place[WATER] = LOC_NOWHERE;
411 game.prop[DRAGON] = 2;
412 OBJSND[BIRD] = OBJSND[BIRD] + 3;
419 static int eat(token_t verb, token_t obj)
420 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
421 * ok, some things lose appetite, rest are ridiculous. */
423 int spk = ACTSPK[verb];
424 if (obj == INTRANSITIVE) {
428 spk = THANKS_DELICIOUS;
432 spk = THANKS_DELICIOUS;
434 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
435 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
436 OGRE)spk = LOST_APPETITE;
442 static int extinguish(token_t verb, int obj)
443 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
445 int spk = ACTSPK[verb];
446 if (obj == INTRANSITIVE) {
447 if (HERE(LAMP) && game.prop[LAMP] == 1)obj = LAMP;
448 if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
449 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
453 game.prop[URN] = game.prop[URN] / 2;
455 } else if (obj == LAMP) {
458 spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
459 } else if (obj == DRAGON || obj == VOLCANO)
465 static int feed(token_t verb, token_t obj)
466 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
467 * mad. Bear, special. */
469 int spk = ACTSPK[verb];
473 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
474 spk = NOTHING_EDIBLE;
475 if (obj == DRAGON && game.prop[DRAGON] != 0)spk = RIDICULOUS_ATTEMPT;
476 if (obj == TROLL)spk = TROLL_VICES;
477 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
482 } else if (obj == DWARF) {
487 } else if (obj == BEAR) {
488 if (game.prop[BEAR] == 0)spk = NOTHING_EDIBLE;
489 if (game.prop[BEAR] == 3)spk = RIDICULOUS_ATTEMPT;
497 } else if (obj == OGRE) {
507 int fill(token_t verb, token_t obj)
508 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
512 int spk = ACTSPK[verb];
514 spk = ARENT_CARRYING;
515 if (LIQLOC(game.loc) == 0)spk = FILL_INVALID;
516 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
520 RSPEAK(SHATTER_VASE);
522 game.fixed[VASE] = -1;
523 return (discard(verb, obj, true));
524 } else if (obj == URN) {
526 if (game.prop[URN] != 0) {
532 if (k == 0 || !HERE(BOTTLE)) {
536 game.place[k] = LOC_NOWHERE;
537 game.prop[BOTTLE] = 1;
538 if (k == OIL)game.prop[URN] = 1;
539 spk = WATER_URN + game.prop[URN];
542 } else if (obj != 0 && obj != BOTTLE) {
545 } else if (obj == 0 && !HERE(BOTTLE))
548 if (LIQLOC(game.loc) == 0)
550 if (HERE(URN) && game.prop[URN] != 0)
554 if (spk == BOTTLED_WATER) {
555 game.prop[BOTTLE] = MOD(COND[game.loc], 4) / 2 * 2;
558 game.place[k] = CARRIED;
566 static int find(token_t verb, token_t obj)
567 /* Find. Might be carrying it, or it might be here. Else give caveat. */
569 int spk = ACTSPK[verb];
571 (LIQUID() == obj && AT(BOTTLE)) ||
572 obj == LIQLOC(game.loc) ||
573 (obj == DWARF && ATDWRF(game.loc) > 0))
575 if (game.closed)spk = NEEDED_NEARBY;
576 if (TOTING(obj))spk = ALREADY_CARRYING;
581 static int fly(token_t verb, token_t obj)
582 /* Fly. Snide remarks unless hovering rug is here. */
584 int spk = ACTSPK[verb];
585 if (obj == INTRANSITIVE) {
586 if (game.prop[RUG] != 2)spk = RUG_NOTHING2;
587 if (!HERE(RUG))spk = FLAP_ARMS;
588 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
600 if (game.prop[RUG] != 2) {
604 game.oldlc2 = game.oldloc;
605 game.oldloc = game.loc;
606 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
608 if (game.prop[SAPPH] >= 0)
614 static int inven(void)
615 /* Inventory. If object, treat same as find. Else report on current burden. */
618 for (int i = 1; i <= NOBJECTS; i++) {
619 if (i == BEAR || !TOTING(i))
634 static int light(token_t verb, token_t obj)
635 /* Light. Applicable only to lamp and urn. */
637 int spk = ACTSPK[verb];
638 if (obj == INTRANSITIVE) {
639 if (HERE(LAMP) && game.prop[LAMP] == 0 && game.limit >= 0)obj = LAMP;
640 if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
641 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
645 if (game.prop[URN] == 0) {
658 if (game.limit < 0) {
671 static int listen(void)
672 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
675 int spk = ALL_SILENT;
676 k = LOCSND[game.loc];
679 if (k < 0) return GO_CLEAROBJ;
682 SETPRM(1, game.zzword, 0);
683 for (int i = 1; i <= NOBJECTS; i++) {
684 if (!HERE(i) || OBJSND[i] == 0 || game.prop[i] < 0)
686 PSPEAK(i, OBJSND[i] + game.prop[i]);
688 if (i == BIRD && OBJSND[i] + game.prop[i] == 8)
695 static int lock(token_t verb, token_t obj)
696 /* Lock, unlock, no object given. Assume various things if present. */
698 int spk = ACTSPK[verb];
699 if (obj == INTRANSITIVE) {
700 spk = NOTHING_LOCKED;
701 if (HERE(CLAM))obj = CLAM;
702 if (HERE(OYSTER))obj = OYSTER;
703 if (AT(DOOR))obj = DOOR;
704 if (AT(GRATE))obj = GRATE;
705 if (obj != 0 && HERE(CHAIN)) return GO_UNKNOWN;
706 if (HERE(CHAIN))obj = CHAIN;
707 if (obj == 0 || obj == INTRANSITIVE) {
713 /* Lock, unlock object. Special stuff for opening clam/oyster
715 if (obj == CLAM || obj == OYSTER)
716 return bivalve(verb, obj);
717 if (obj == DOOR)spk = RUSTY_DOOR;
718 if (obj == DOOR && game.prop[DOOR] == 1)spk = OK_MAN;
719 if (obj == CAGE)spk = NO_LOCK;
720 if (obj == KEYS)spk = CANNOT_UNLOCK;
721 if (obj == GRATE || obj == CHAIN) {
728 if (!game.panic)game.clock2 = PANICTIME;
731 game.prop[GRATE] = (verb == LOCK) ? 0 : 1;
732 spk = game.prop[GRATE] ? GRATE_UNLOCKED : GRATE_LOCKED;
740 static int pour(token_t verb, token_t obj)
741 /* Pour. If no object, or object is bottle, assume contents of bottle.
742 * special tests for pouring water or oil on plant or rusty door. */
744 int spk = ACTSPK[verb];
745 if (obj == BOTTLE || obj == 0)obj = LIQUID();
746 if (obj == 0) return GO_UNKNOWN;
752 if (obj != OIL && obj != WATER) {
756 if (HERE(URN) && game.prop[URN] == 0)
757 return fill(verb, URN);
758 game.prop[BOTTLE] = 1;
759 game.place[obj] = LOC_NOWHERE;
761 if (!(AT(PLANT) || AT(DOOR))) {
766 spk = SHAKING_LEAVES;
771 PSPEAK(PLANT, game.prop[PLANT] + 3);
772 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
773 game.prop[PLANT2] = game.prop[PLANT];
777 if (obj == OIL)game.prop[DOOR] = 1;
778 spk = RUSTED_HINGES + game.prop[DOOR];
784 static int quit(void)
785 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
787 if (YES(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
792 static int read(struct command_t command)
793 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
795 if (command.obj == INTRANSITIVE) {
797 for (int i = 1; i <= NOBJECTS; i++) {
798 if (HERE(i) && OBJTXT[i] != 0 && game.prop[i] >= 0)
799 command.obj = command.obj * NOBJECTS + i;
801 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc)) return GO_UNKNOWN;
804 if (DARK(game.loc)) {
805 SETPRM(1, command.wd1, command.wd1x);
809 if (OBJTXT[command.obj] == 0 || game.prop[command.obj] < 0) {
810 RSPEAK(ACTSPK[command.verb]);
813 if (command.obj == OYSTER && !game.clshnt) {
814 game.clshnt = YES(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
817 PSPEAK(command.obj, OBJTXT[command.obj] + game.prop[command.obj]);
821 static int reservoir(void)
822 /* Z'ZZZ (word gets recomputed at startup; different each game). */
824 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
825 RSPEAK(NOTHING_HAPPENS);
828 PSPEAK(RESER, game.prop[RESER] + 1);
829 game.prop[RESER] = 1 - game.prop[RESER];
833 game.oldlc2 = game.loc;
841 static int rub(token_t verb, token_t obj)
842 /* Rub. Yields various snide remarks except for lit urn. */
844 int spk = ACTSPK[verb];
846 spk = PECULIAR_NOTHING;
847 if (obj == URN && game.prop[URN] == 2) {
849 DROP(AMBER, game.loc);
850 game.prop[AMBER] = 1;
852 DROP(CAVITY, game.loc);
859 static int say(struct command_t *command)
860 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
862 SETPRM(1, command->wd2, command->wd2x);
863 if (command->wd2 <= 0)
864 SETPRM(1, command->wd1, command->wd1x);
865 if (command->wd2 > 0)
866 command->wd1 = command->wd2;
867 int wd = VOCAB(command->wd1, -1);
868 /* FIXME: Magic numbers */
869 if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) {
870 /* FIXME: scribbles on the interpreter's command block */
871 wordclear(&command->wd2);
878 static int throw_support(long spk)
885 static int throw (FILE *cmdin, struct command_t *command)
886 /* Throw. Same as discard unless axe. Then same as attack except
887 * ignore bird, and if dwarf is present then one might be killed.
888 * (Only way to do so!) Axe also special for dragon, bear, and
889 * troll. Treasures special for troll. */
891 int spk = ACTSPK[command->verb];
892 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))command->obj = ROD2;
893 if (!TOTING(command->obj)) {
897 if (command->obj >= MINTRS && command->obj <= MAXTRS && AT(TROLL)) {
898 spk = TROLL_SATISFIED;
899 /* Snarf a treasure for the troll. */
900 DROP(command->obj, 0);
902 MOVE(TROLL + NOBJECTS, 0);
903 DROP(TROLL2, PLAC[TROLL]);
904 DROP(TROLL2 + NOBJECTS, FIXD[TROLL]);
909 if (command->obj == FOOD && HERE(BEAR)) {
910 /* But throwing food is another story. */
912 return (feed(command->verb, command->obj));
914 if (command->obj != AXE)
915 return (discard(command->verb, command->obj, false));
917 int i = ATDWRF(game.loc);
919 if (AT(DRAGON) && game.prop[DRAGON] == 0)
920 return throw_support(DRAGON_SCALES);
922 return throw_support(TROLL_RETURNS);
924 return throw_support(OGRE_DODGE);
925 else if (HERE(BEAR) && game.prop[BEAR] == 0) {
926 /* This'll teach him to throw the axe at the bear! */
928 game.fixed[AXE] = -1;
935 return (attack(cmdin, command));
938 if (randrange(NDWARVES + 1) < game.dflag) {
939 return throw_support(DWARF_DODGES);
941 game.dseen[i] = false;
943 return throw_support((++game.dkill == 1)
944 ? DWARF_SMOKE : KILLED_DWARF);
949 static int wake(token_t verb, token_t obj)
950 /* Wake. Only use is to disturb the dwarves. */
952 if (obj != DWARF || !game.closed) {
953 RSPEAK(ACTSPK[verb]);
961 static int wave(token_t verb, token_t obj)
962 /* Wave. No effect unless waving rod at fissure or at bird. */
964 int spk = ACTSPK[verb];
965 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))spk = ARENT_CARRYING;
968 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
972 if (HERE(BIRD))spk = FREE_FLY + MOD(game.prop[BIRD], 2);
973 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
974 DROP(JADE, game.loc);
985 if (game.closng || !AT(FISSURE)) {
989 if (HERE(BIRD))RSPEAK(spk);
990 game.prop[FISSURE] = 1 - game.prop[FISSURE];
991 PSPEAK(FISSURE, 2 - game.prop[FISSURE]);
996 int action(FILE *input, struct command_t *command)
997 /* Analyse a verb. Remember what it was, go back for object if second word
998 * unless verb is "say", which snarfs arbitrary second word.
1001 token_t spk = ACTSPK[command->verb];
1003 if (command->part == unknown) {
1004 /* Analyse an object word. See if the thing is here, whether
1005 * we've got a verb yet, and so on. Object must be here
1006 * unless verb is "find" or "invent(ory)" (and no new verb
1007 * yet to be analysed). Water and oil are also funny, since
1008 * they are never actually dropped at any location, but might
1009 * be here inside the bottle or urn or as a feature of the
1011 if (HERE(command->obj))
1013 else if (command->obj == GRATE) {
1014 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1015 command->obj = DPRSSN;
1016 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1017 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1018 command->obj = ENTRNC;
1019 if (command->obj != GRATE)
1021 } else if (command->obj == DWARF && ATDWRF(game.loc) > 0)
1023 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1025 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1028 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1029 command->obj = PLANT2;
1031 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1033 spk = KNIVES_VANISH;
1036 } else if (command->obj == ROD && HERE(ROD2)) {
1037 command->obj = ROD2;
1039 } else if ((command->verb == FIND || command->verb == INVENT) && command->wd2 <= 0)
1042 SETPRM(1, command->wd1, command->wd1x);
1047 if (command->wd2 > 0)
1049 if (command->verb != 0)
1050 command->part = transitive;
1053 switch (command->part) {
1055 if (command->wd2 > 0 && command->verb != SAY)
1057 if (command->verb == SAY)command->obj = command->wd2;
1058 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1059 /* Analyse an intransitive verb (ie, no object given yet). */
1060 switch (command->verb - 1) {
1062 return carry(command->verb, INTRANSITIVE);
1068 return lock(command->verb, INTRANSITIVE);
1069 case 4: { /* NOTHI */
1071 return (GO_CLEAROBJ);
1074 return lock(command->verb, INTRANSITIVE);
1076 return light(command->verb, INTRANSITIVE);
1078 return extinguish(command->verb, INTRANSITIVE);
1083 case 10: { /* WALK */
1087 case 11: /* ATTAC */
1088 return attack(input, command);
1090 return pour(command->verb, command->obj);
1092 return eat(command->verb, INTRANSITIVE);
1093 case 14: /* DRINK */
1094 return drink(command->verb, command->obj);
1103 case 19: /* INVEN */
1108 return fill(command->verb, command->obj);
1109 case 22: /* BLAST */
1116 return bigwords(command->wd1);
1117 case 25: /* BRIEF */
1120 command->obj = INTRANSITIVE;
1121 return read(*command);
1122 case 27: /* BREAK */
1131 return fly(command->verb, INTRANSITIVE);
1132 case 32: /* LISTE */
1137 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
1141 /* Analyse a transitive verb. */
1142 switch (command->verb - 1) {
1144 return carry(command->verb, command->obj);
1146 return discard(command->verb, command->obj, false);
1148 return say(command);
1150 return lock(command->verb, command->obj);
1151 case 4: { /* NOTHI */
1153 return (GO_CLEAROBJ);
1156 return lock(command->verb, command->obj);
1158 return light(command->verb, command->obj);
1160 return extinguish(command->verb, command->obj);
1162 return wave(command->verb, command->obj);
1163 case 9: { /* CALM */
1167 case 10: { /* WALK */
1171 case 11: /* ATTAC */
1172 return attack(input, command);
1174 return pour(command->verb, command->obj);
1176 return eat(command->verb, command->obj);
1177 case 14: /* DRINK */
1178 return drink(command->verb, command->obj);
1180 return rub(command->verb, command->obj);
1182 return throw(input, command);
1183 case 17: { /* QUIT */
1188 return find(command->verb, command->obj);
1189 case 19: /* INVEN */
1190 return find(command->verb, command->obj);
1192 return feed(command->verb, command->obj);
1194 return fill(command->verb, command->obj);
1195 case 22: /* BLAST */
1198 case 23: { /* SCOR */
1202 case 24: { /* FOO */
1206 case 25: { /* BRIEF */
1211 return read(*command);
1212 case 27: /* BREAK */
1213 return vbreak(command->verb, command->obj);
1215 return wake(command->verb, command->obj);
1216 case 29: { /* SUSP */
1220 case 30: { /* RESU */
1225 return fly(command->verb, command->obj);
1226 case 32: { /* LISTE */
1233 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
1235 /* Unknown verb, couldn't deduce object - might need hint */
1236 SETPRM(1, command->wd1, command->wd1x);
1238 return GO_CHECKHINT;
1240 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN);