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;
46 } else if (obj == VEND) {
47 bool blocking = (game.prop[VEND] == VEND_BLOCKS);
48 game.prop[VEND] = blocking ? VEND_UNBLOCKS : VEND_BLOCKS;
49 rspeak(blocking ? MACHINE_SWINGOUT : MACHINE_SWINGBACK);
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))
86 pspeak(DRAGON, look, 3);
87 game.prop[DRAGON] = 1;
89 int k = (object_descriptions[DRAGON].plac + object_descriptions[DRAGON].fixd) / 2;
90 MOVE(DRAGON + NOBJECTS, -1);
91 MOVE(RUG + NOBJECTS, 0);
95 for (obj = 1; obj <= NOBJECTS; obj++) {
96 if (game.place[obj] == object_descriptions[DRAGON].plac || game.place[obj] == object_descriptions[DRAGON].fixd)
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 && game.loc == LOC_GIANTROOM)spk = START_OVER;
125 if (game.place[EGGS] == object_descriptions[EGGS].plac || (TOTING(EGGS) && game.loc == object_descriptions[EGGS].plac)) {
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 == object_descriptions[EGGS].plac)k = 0;
136 MOVE(EGGS, object_descriptions[EGGS].plac);
137 pspeak(EGGS, look, k);
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] == EMPTY_BOTTLE)
246 return (fill(verb, BOTTLE));
248 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
250 if (!TOTING(BOTTLE))spk = NO_CONTAINER;
259 if (game.holdng >= INVLIMIT) {
262 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
263 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
268 if (!TOTING(CAGE))spk = CANNOT_CARRY;
269 if (TOTING(ROD))spk = BIRD_EVADES;
270 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
274 game.prop[BIRD] = BIRD_CAGED;
276 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
277 CARRY(BIRD + CAGE - obj, game.loc);
278 CARRY(obj, game.loc);
279 if (obj == BOTTLE && LIQUID() != 0)
280 game.place[LIQUID()] = CARRIED;
281 if (GSTONE(obj) && game.prop[obj] != 0) {
283 game.prop[CAVITY] = 1;
289 static int chain(token_t verb)
290 /* Do something to the bear's chain */
294 spk = CHAIN_UNLOCKED;
295 if (game.prop[BEAR] == 0)spk = BEAR_BLOCKS;
296 if (game.prop[CHAIN] == 0)spk = ALREADY_UNLOCKED;
297 if (spk != CHAIN_UNLOCKED) {
301 game.prop[CHAIN] = 0;
302 game.fixed[CHAIN] = 0;
303 if (game.prop[BEAR] != 3)game.prop[BEAR] = 2;
304 game.fixed[BEAR] = 2 - game.prop[BEAR];
307 if (game.prop[CHAIN] != 0)spk = ALREADY_LOCKED;
308 if (game.loc != object_descriptions[CHAIN].plac)spk = NO_LOCKSITE;
309 if (spk != CHAIN_LOCKED) {
313 game.prop[CHAIN] = 2;
314 if (TOTING(CHAIN))DROP(CHAIN, game.loc);
315 game.fixed[CHAIN] = -1;
321 static int discard(token_t verb, token_t obj, bool just_do_it)
322 /* Discard object. "Throw" also comes here for most objects. Special cases for
323 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
324 * Drop coins at vending machine for extra batteries. */
326 int spk = ACTSPK[verb];
328 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj = ROD2;
333 if (obj == BIRD && HERE(SNAKE)) {
334 rspeak(BIRD_ATTACKS);
335 if (game.closed) return GO_DWARFWAKE;
337 /* Set game.prop for use by travel options */
338 game.prop[SNAKE] = 1;
340 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != 0)) {
343 game.prop[CAVITY] = 0;
344 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != 2) || (obj == RUBY &&
345 game.prop[RUG] == 2))) {
347 if (TOTING(RUG))spk = RUG_WIGGLES;
348 if (obj == RUBY)spk = RUG_SETTLES;
350 if (spk != RUG_WIGGLES) {
351 int k = 2 - game.prop[RUG];
353 if (k == 2) k = object_descriptions[SAPPH].plac;
354 MOVE(RUG + NOBJECTS, k);
357 } else if (obj == COINS && HERE(VEND)) {
359 DROP(BATTERY, game.loc);
360 pspeak(BATTERY, look, FRESH_BATTERIES);
362 } 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, object_descriptions[TROLL].plac);
371 MOVE(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd);
373 game.prop[TROLL] = 2;
374 } else if (obj != VASE || game.loc == object_descriptions[PILLOW].plac) {
378 if (AT(PILLOW))game.prop[VASE] = 0;
379 pspeak(VASE, look, 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] == BIRD_CAGED)
388 DROP(BIRD, game.loc);
390 if (obj != BIRD) return GO_CLEAROBJ;
391 game.prop[BIRD] = BIRD_UNCAGED;
392 if (FOREST(game.loc))
393 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
397 static int drink(token_t verb, token_t obj)
398 /* Drink. If no object, assume water and look for it here. If water is in
399 * the bottle, drink that, else must be at a water loc, so drink stream. */
401 int spk = ACTSPK[verb];
402 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
405 if (obj != 0 && obj != WATER)spk = RIDICULOUS_ATTEMPT;
406 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
407 game.prop[BOTTLE] = EMPTY_BOTTLE;
408 game.place[WATER] = LOC_NOWHERE;
413 game.prop[DRAGON] = 2;
421 static int eat(token_t verb, token_t obj)
422 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
423 * ok, some things lose appetite, rest are ridiculous. */
425 int spk = ACTSPK[verb];
426 if (obj == INTRANSITIVE) {
430 spk = THANKS_DELICIOUS;
434 spk = THANKS_DELICIOUS;
436 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
437 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
438 OGRE)spk = LOST_APPETITE;
444 static int extinguish(token_t verb, int obj)
445 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
447 int spk = ACTSPK[verb];
448 if (obj == INTRANSITIVE) {
449 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
451 if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
452 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
456 game.prop[URN] = game.prop[URN] / 2;
458 } else if (obj == LAMP) {
459 game.prop[LAMP] = LAMP_DARK;
461 spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
462 } else if (obj == DRAGON || obj == VOLCANO)
468 static int feed(token_t verb, token_t obj)
469 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
470 * mad. Bear, special. */
472 int spk = ACTSPK[verb];
476 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
477 spk = NOTHING_EDIBLE;
478 if (obj == DRAGON && game.prop[DRAGON] != 0)spk = RIDICULOUS_ATTEMPT;
479 if (obj == TROLL)spk = TROLL_VICES;
480 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
484 } else if (obj == DWARF) {
489 } else if (obj == BEAR) {
490 if (game.prop[BEAR] == 0)spk = NOTHING_EDIBLE;
491 if (game.prop[BEAR] == 3)spk = RIDICULOUS_ATTEMPT;
499 } else if (obj == OGRE) {
509 int fill(token_t verb, token_t obj)
510 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
514 int spk = ACTSPK[verb];
516 spk = ARENT_CARRYING;
517 if (LIQLOC(game.loc) == 0)spk = FILL_INVALID;
518 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
522 rspeak(SHATTER_VASE);
524 game.fixed[VASE] = -1;
525 return (discard(verb, obj, true));
526 } else if (obj == URN) {
528 if (game.prop[URN] != 0) {
534 if (k == 0 || !HERE(BOTTLE)) {
538 game.place[k] = LOC_NOWHERE;
539 game.prop[BOTTLE] = EMPTY_BOTTLE;
540 if (k == OIL)game.prop[URN] = 1;
541 spk = WATER_URN + game.prop[URN];
544 } else if (obj != 0 && obj != BOTTLE) {
547 } else if (obj == 0 && !HERE(BOTTLE))
550 if (LIQLOC(game.loc) == 0)
552 if (HERE(URN) && game.prop[URN] != 0)
556 if (spk == BOTTLED_WATER) {
557 /* FIXME: Arithmetic on property values */
558 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
561 game.place[k] = CARRIED;
569 static int find(token_t verb, token_t obj)
570 /* Find. Might be carrying it, or it might be here. Else give caveat. */
572 int spk = ACTSPK[verb];
574 (LIQUID() == obj && AT(BOTTLE)) ||
575 obj == LIQLOC(game.loc) ||
576 (obj == DWARF && ATDWRF(game.loc) > 0))
578 if (game.closed)spk = NEEDED_NEARBY;
579 if (TOTING(obj))spk = ALREADY_CARRYING;
584 static int fly(token_t verb, token_t obj)
585 /* Fly. Snide remarks unless hovering rug is here. */
587 int spk = ACTSPK[verb];
588 if (obj == INTRANSITIVE) {
589 if (game.prop[RUG] != 2)spk = RUG_NOTHING2;
590 if (!HERE(RUG))spk = FLAP_ARMS;
591 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
603 if (game.prop[RUG] != 2) {
607 game.oldlc2 = game.oldloc;
608 game.oldloc = game.loc;
609 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
611 if (game.prop[SAPPH] >= 0)
617 static int inven(void)
618 /* Inventory. If object, treat same as find. Else report on current burden. */
621 for (int i = 1; i <= NOBJECTS; i++) {
622 if (i == BEAR || !TOTING(i))
627 pspeak(i, touch, -1);
637 static int light(token_t verb, token_t obj)
638 /* Light. Applicable only to lamp and urn. */
640 int spk = ACTSPK[verb];
641 if (obj == INTRANSITIVE) {
642 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
644 if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
645 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
649 if (game.prop[URN] == 0) {
662 if (game.limit < 0) {
666 game.prop[LAMP] = LAMP_BRIGHT;
675 static int listen(void)
676 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
679 int spk = ALL_SILENT;
680 k = locations[game.loc].sound;
683 if (locations[game.loc].loud)
688 for (int i = 1; i <= NOBJECTS; i++) {
689 if (!HERE(i) || object_descriptions[i].sounds[0] == NULL || game.prop[i] < 0)
691 int mi = game.prop[i];
693 mi += 3 * game.blooded;
694 pspeak(i, hear, mi, game.zzword);
696 /* FIXME: Magic number, sensitive to bird state logic */
697 if (i == BIRD && game.prop[i] == 5)
704 static int lock(token_t verb, token_t obj)
705 /* Lock, unlock, no object given. Assume various things if present. */
707 int spk = ACTSPK[verb];
708 if (obj == INTRANSITIVE) {
709 spk = NOTHING_LOCKED;
710 if (HERE(CLAM))obj = CLAM;
711 if (HERE(OYSTER))obj = OYSTER;
712 if (AT(DOOR))obj = DOOR;
713 if (AT(GRATE))obj = GRATE;
714 if (obj != 0 && HERE(CHAIN)) return GO_UNKNOWN;
715 if (HERE(CHAIN))obj = CHAIN;
716 if (obj == 0 || obj == INTRANSITIVE) {
722 /* Lock, unlock object. Special stuff for opening clam/oyster
724 if (obj == CLAM || obj == OYSTER)
725 return bivalve(verb, obj);
726 if (obj == DOOR)spk = RUSTY_DOOR;
727 if (obj == DOOR && game.prop[DOOR] == 1)spk = OK_MAN;
728 if (obj == CAGE)spk = NO_LOCK;
729 if (obj == KEYS)spk = CANNOT_UNLOCK;
730 if (obj == GRATE || obj == CHAIN) {
737 if (!game.panic)game.clock2 = PANICTIME;
740 game.prop[GRATE] = (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN;
741 spk = game.prop[GRATE] ? GRATE_UNLOCKED : GRATE_LOCKED;
749 static int pour(token_t verb, token_t obj)
750 /* Pour. If no object, or object is bottle, assume contents of bottle.
751 * special tests for pouring water or oil on plant or rusty door. */
753 int spk = ACTSPK[verb];
754 if (obj == BOTTLE || obj == 0)obj = LIQUID();
755 if (obj == 0) return GO_UNKNOWN;
761 if (obj != OIL && obj != WATER) {
765 if (HERE(URN) && game.prop[URN] == 0)
766 return fill(verb, URN);
767 game.prop[BOTTLE] = EMPTY_BOTTLE;
768 game.place[obj] = LOC_NOWHERE;
770 if (!(AT(PLANT) || AT(DOOR))) {
775 spk = SHAKING_LEAVES;
780 pspeak(PLANT, look, game.prop[PLANT] + 3);
781 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
782 game.prop[PLANT2] = game.prop[PLANT];
786 if (obj == OIL)game.prop[DOOR] = 1;
787 spk = RUSTED_HINGES + game.prop[DOOR];
793 static int quit(void)
794 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
796 if (YES(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
801 static int read(struct command_t command)
802 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
804 if (command.obj == INTRANSITIVE) {
806 for (int i = 1; i <= NOBJECTS; i++) {
807 if (HERE(i) && object_descriptions[i].texts[0] != NULL && game.prop[i] >= 0)
808 command.obj = command.obj * NOBJECTS + i;
810 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
814 if (DARK(game.loc)) {
815 rspeak(NO_SEE, command.wd1, command.wd1x);
816 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
817 game.clshnt = YES(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
818 } else if (object_descriptions[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
819 rspeak(ACTSPK[command.verb]);
821 pspeak(command.obj, study, game.prop[command.obj]);
825 static int reservoir(void)
826 /* Z'ZZZ (word gets recomputed at startup; different each game). */
828 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
829 rspeak(NOTHING_HAPPENS);
832 pspeak(RESER, look, game.prop[RESER] + 1);
833 game.prop[RESER] = 1 - game.prop[RESER];
837 game.oldlc2 = game.loc;
845 static int rub(token_t verb, token_t obj)
846 /* Rub. Yields various snide remarks except for lit urn. */
848 int spk = ACTSPK[verb];
850 spk = PECULIAR_NOTHING;
851 if (obj == URN && game.prop[URN] == 2) {
853 DROP(AMBER, game.loc);
854 game.prop[AMBER] = 1;
856 DROP(CAVITY, game.loc);
863 static int say(struct command_t *command)
864 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
866 long a = command->wd1, b = command->wd1x;
867 if (command->wd2 > 0) {
870 command->wd1 = command->wd2;
872 int wd = VOCAB(command->wd1, -1);
873 /* FIXME: Magic numbers */
874 if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) {
875 /* FIXME: scribbles on the interpreter's command block */
876 wordclear(&command->wd2);
879 rspeak(OKEY_DOKEY, a, b);
883 static int throw_support(long spk)
890 static int throw (FILE *cmdin, struct command_t *command)
891 /* Throw. Same as discard unless axe. Then same as attack except
892 * ignore bird, and if dwarf is present then one might be killed.
893 * (Only way to do so!) Axe also special for dragon, bear, and
894 * troll. Treasures special for troll. */
896 int spk = ACTSPK[command->verb];
897 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))command->obj = ROD2;
898 if (!TOTING(command->obj)) {
902 if (object_descriptions[command->obj].is_treasure && AT(TROLL)) {
903 spk = TROLL_SATISFIED;
904 /* Snarf a treasure for the troll. */
905 DROP(command->obj, 0);
907 MOVE(TROLL + NOBJECTS, 0);
908 DROP(TROLL2, object_descriptions[TROLL].plac);
909 DROP(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd);
914 if (command->obj == FOOD && HERE(BEAR)) {
915 /* But throwing food is another story. */
917 return (feed(command->verb, command->obj));
919 if (command->obj != AXE)
920 return (discard(command->verb, command->obj, false));
922 int i = ATDWRF(game.loc);
924 if (AT(DRAGON) && game.prop[DRAGON] == 0)
925 return throw_support(DRAGON_SCALES);
927 return throw_support(TROLL_RETURNS);
929 return throw_support(OGRE_DODGE);
930 else if (HERE(BEAR) && game.prop[BEAR] == 0) {
931 /* This'll teach him to throw the axe at the bear! */
933 game.fixed[AXE] = -1;
940 return (attack(cmdin, command));
943 if (randrange(NDWARVES + 1) < game.dflag) {
944 return throw_support(DWARF_DODGES);
946 game.dseen[i] = false;
948 return throw_support((++game.dkill == 1)
949 ? DWARF_SMOKE : KILLED_DWARF);
954 static int wake(token_t verb, token_t obj)
955 /* Wake. Only use is to disturb the dwarves. */
957 if (obj != DWARF || !game.closed) {
958 rspeak(ACTSPK[verb]);
966 static int wave(token_t verb, token_t obj)
967 /* Wave. No effect unless waving rod at fissure or at bird. */
969 int spk = ACTSPK[verb];
970 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))spk = ARENT_CARRYING;
973 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
977 /* FIXME: Arithemetic on proprty values */
979 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
980 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
981 DROP(JADE, game.loc);
992 if (game.closng || !AT(FISSURE)) {
996 if (HERE(BIRD))rspeak(spk);
997 game.prop[FISSURE] = 1 - game.prop[FISSURE];
998 pspeak(FISSURE, look, 2 - game.prop[FISSURE]);
1003 int action(FILE *input, struct command_t *command)
1004 /* Analyse a verb. Remember what it was, go back for object if second word
1005 * unless verb is "say", which snarfs arbitrary second word.
1008 token_t spk = ACTSPK[command->verb];
1010 if (command->part == unknown) {
1011 /* Analyse an object word. See if the thing is here, whether
1012 * we've got a verb yet, and so on. Object must be here
1013 * unless verb is "find" or "invent(ory)" (and no new verb
1014 * yet to be analysed). Water and oil are also funny, since
1015 * they are never actually dropped at any location, but might
1016 * be here inside the bottle or urn or as a feature of the
1018 if (HERE(command->obj))
1020 else if (command->obj == GRATE) {
1021 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1022 command->obj = DPRSSN;
1023 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1024 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1025 command->obj = ENTRNC;
1026 } else if (command->obj == DWARF && ATDWRF(game.loc) > 0)
1028 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1030 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1033 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1034 command->obj = PLANT2;
1036 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1038 spk = KNIVES_VANISH;
1041 } else if (command->obj == ROD && HERE(ROD2)) {
1042 command->obj = ROD2;
1044 } else if ((command->verb == FIND || command->verb == INVENT) && command->wd2 <= 0)
1047 rspeak(NO_SEE, command->wd1, command->wd1x);
1051 if (command->wd2 > 0)
1053 if (command->verb != 0)
1054 command->part = transitive;
1057 switch (command->part) {
1059 if (command->wd2 > 0 && command->verb != SAY)
1061 if (command->verb == SAY)command->obj = command->wd2;
1062 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1063 /* Analyse an intransitive verb (ie, no object given yet). */
1064 switch (command->verb - 1) {
1066 return carry(command->verb, INTRANSITIVE);
1072 return lock(command->verb, INTRANSITIVE);
1073 case 4: { /* NOTHI */
1075 return (GO_CLEAROBJ);
1078 return lock(command->verb, INTRANSITIVE);
1080 return light(command->verb, INTRANSITIVE);
1082 return extinguish(command->verb, INTRANSITIVE);
1087 case 10: { /* WALK */
1091 case 11: /* ATTAC */
1092 return attack(input, command);
1094 return pour(command->verb, command->obj);
1096 return eat(command->verb, INTRANSITIVE);
1097 case 14: /* DRINK */
1098 return drink(command->verb, command->obj);
1107 case 19: /* INVEN */
1112 return fill(command->verb, command->obj);
1113 case 22: /* BLAST */
1120 return bigwords(command->wd1);
1121 case 25: /* BRIEF */
1124 command->obj = INTRANSITIVE;
1125 return read(*command);
1126 case 27: /* BREAK */
1135 return fly(command->verb, INTRANSITIVE);
1136 case 32: /* LISTE */
1141 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
1145 /* Analyse a transitive verb. */
1146 switch (command->verb - 1) {
1148 return carry(command->verb, command->obj);
1150 return discard(command->verb, command->obj, false);
1152 return say(command);
1154 return lock(command->verb, command->obj);
1155 case 4: { /* NOTHI */
1157 return (GO_CLEAROBJ);
1160 return lock(command->verb, command->obj);
1162 return light(command->verb, command->obj);
1164 return extinguish(command->verb, command->obj);
1166 return wave(command->verb, command->obj);
1167 case 9: { /* CALM */
1171 case 10: { /* WALK */
1175 case 11: /* ATTAC */
1176 return attack(input, command);
1178 return pour(command->verb, command->obj);
1180 return eat(command->verb, command->obj);
1181 case 14: /* DRINK */
1182 return drink(command->verb, command->obj);
1184 return rub(command->verb, command->obj);
1186 return throw(input, command);
1187 case 17: { /* QUIT */
1192 return find(command->verb, command->obj);
1193 case 19: /* INVEN */
1194 return find(command->verb, command->obj);
1196 return feed(command->verb, command->obj);
1198 return fill(command->verb, command->obj);
1199 case 22: /* BLAST */
1202 case 23: { /* SCOR */
1206 case 24: { /* FOO */
1210 case 25: { /* BRIEF */
1215 return read(*command);
1216 case 27: /* BREAK */
1217 return vbreak(command->verb, command->obj);
1219 return wake(command->verb, command->obj);
1220 case 29: { /* SUSP */
1224 case 30: { /* RESU */
1229 return fly(command->verb, command->obj);
1230 case 32: { /* LISTE */
1237 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
1239 /* Unknown verb, couldn't deduce object - might need hint */
1240 rspeak(WHAT_DO, command->wd1, command->wd1x);
1241 return GO_CHECKHINT;
1243 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN);