6 static int fill(token_t, token_t);
8 static void state_change(long obj, long state)
10 game.prop[obj] = state;
11 pspeak(obj, change, state);
14 static int attack(struct command_t *command)
15 /* Attack. Assume target if unambiguous. "Throw" also links here.
16 * Attackable objects fall into two categories: enemies (snake,
17 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
18 * enemies, or no enemies but 2 others. */
20 vocab_t verb = command->verb;
21 vocab_t obj = command->obj;
22 long spk = actions[verb].message;
23 if (obj == 0 || obj == INTRANSITIVE) {
24 if (atdwrf(game.loc) > 0)
26 if (HERE(SNAKE))obj = obj * NOBJECTS + SNAKE;
27 if (AT(DRAGON) && game.prop[DRAGON] == 0)obj = obj * NOBJECTS + DRAGON;
28 if (AT(TROLL))obj = obj * NOBJECTS + TROLL;
29 if (AT(OGRE))obj = obj * NOBJECTS + OGRE;
30 if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR)
31 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) {
54 game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
58 if (obj == 0)spk = NO_TARGET;
59 if (obj == CLAM || obj == OYSTER)spk = SHELL_IMPERVIOUS;
60 if (obj == SNAKE)spk = SNAKE_WARNING;
61 if (obj == DWARF)spk = BARE_HANDS_QUERY;
62 if (obj == DWARF && game.closed) return GO_DWARFWAKE;
63 if (obj == DRAGON)spk = ALREADY_DEAD;
64 if (obj == TROLL)spk = ROCKY_TROLL;
65 if (obj == OGRE)spk = OGRE_DODGE;
66 if (obj == OGRE && atdwrf(game.loc) > 0) {
71 for (int i = 1; i < PIRATE; i++) {
72 if (game.dloc[i] == game.loc) {
74 game.dloc[i] = LOC_LONGWEST;
75 game.dseen[i] = false;
78 spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2;
79 } else if (obj == BEAR)
80 /* FIXME: Arithmetic on message numbers */
81 spk = BEAR_HANDS + (game.prop[BEAR] + 1) / 2;
82 else if (obj == DRAGON && game.prop[DRAGON] == 0) {
83 /* Fun stuff for dragon. If he insists on attacking it, win!
84 * Set game.prop to dead, move dragon to central loc (still
85 * fixed), move rug there (not fixed), and move him there,
86 * too. Then do a null motion to get new description. */
87 rspeak(BARE_HANDS_QUERY);
89 // FIXME: setting wd1 is a workaround for broken logic
90 command->wd1 = token_to_packed("Y");
92 // FIXME: setting wd1 is a workaround for broken logic
93 command->wd1 = token_to_packed("N");
96 pspeak(DRAGON, look, 3);
97 game.prop[DRAGON] = 1;
99 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
100 move(DRAGON + NOBJECTS, -1);
101 move(RUG + NOBJECTS, 0);
105 for (obj = 1; obj <= NOBJECTS; obj++) {
106 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
117 static int bigwords(token_t foo)
118 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
119 * Look up foo in section 3 of vocab to determine which word we've got. Last
120 * word zips the eggs back to the giant room (unless already there). */
122 //int k = vocab(foo, 3);
124 packed_to_token(foo, word);
125 int k = (int) get_special_vocab_id(word);
126 int spk = NOTHING_HAPPENS;
127 if (game.foobar != 1 - k) {
128 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)spk = START_OVER;
138 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
142 /* Bring back troll if we steal the eggs back from him before
144 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == 0)
145 game.prop[TROLL] = 1;
147 if (HERE(EGGS))k = 1;
148 if (game.loc == objects[EGGS].plac)k = 0;
149 move(EGGS, objects[EGGS].plac);
150 pspeak(EGGS, look, k);
156 static int bivalve(token_t verb, token_t obj)
157 /* Clam/oyster actions */
160 bool is_oyster = (obj == OYSTER);
161 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
162 if (TOTING(obj))spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
163 if (!TOTING(TRIDENT))spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
164 if (verb == LOCK)spk = HUH_MAN;
165 if (spk == PEARL_FALLS) {
167 drop(OYSTER, game.loc);
168 drop(PEARL, LOC_CULDESAC);
174 static void blast(void)
175 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
177 if (game.prop[ROD2] < 0 || !game.closed)
178 rspeak(REQUIRES_DYNAMITE);
180 game.bonus = VICTORY_MESSAGE;
181 if (game.loc == LOC_NE)
182 game.bonus = DEFEAT_MESSAGE;
184 game.bonus = SPLATTER_MESSAGE;
190 static int vbreak(token_t verb, token_t obj)
191 /* Break. Only works for mirror in repository and, of course, the vase. */
193 int spk = actions[verb].message;
194 if (obj == MIRROR)spk = TOO_FAR;
195 if (obj == VASE && game.prop[VASE] == 0) {
196 if (TOTING(VASE))drop(VASE, game.loc);
198 game.fixed[VASE] = -1;
201 if (obj == MIRROR && game.closed) {
202 rspeak(BREAK_MIRROR);
210 static int brief(void)
211 /* Brief. Intransitive only. Suppress long descriptions after first time. */
215 rspeak(BRIEF_CONFIRM);
219 static int vcarry(token_t verb, token_t obj)
220 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
221 * take one without the other). Liquids also special, since they depend on
222 * status of bottle. Also various side effects, etc. */
225 if (obj == INTRANSITIVE) {
226 /* Carry, no object given yet. OK if only one object present. */
227 if (game.atloc[game.loc] == 0 ||
228 game.link[game.atloc[game.loc]] != 0 ||
229 atdwrf(game.loc) > 0)
231 obj = game.atloc[game.loc];
235 rspeak(ALREADY_CARRYING);
239 if (obj == PLANT && game.prop[PLANT] <= 0)spk = DEEP_ROOTS;
240 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
242 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
244 if (obj == URN)spk = URN_NOBUDGE;
245 if (obj == CAVITY)spk = DOUGHNUT_HOLES;
246 if (obj == BLOOD)spk = FEW_DROPS;
247 if (obj == RUG && game.prop[RUG] == 2)spk = RUG_HOVERS;
248 if (obj == SIGN)spk = HAND_PASSTHROUGH;
250 rspeak(REMOVE_MESSAGE);
254 if (game.fixed[obj] != 0) {
258 if (obj == WATER || obj == OIL) {
259 if (!HERE(BOTTLE) || LIQUID() != obj) {
260 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
261 return (fill(verb, BOTTLE));
263 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
265 if (!TOTING(BOTTLE))spk = NO_CONTAINER;
274 if (game.holdng >= INVLIMIT) {
277 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
278 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
283 if (!TOTING(CAGE))spk = CANNOT_CARRY;
284 if (TOTING(ROD))spk = BIRD_EVADES;
285 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
289 game.prop[BIRD] = BIRD_CAGED;
291 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
292 carry(BIRD + CAGE - obj, game.loc);
293 carry(obj, game.loc);
294 if (obj == BOTTLE && LIQUID() != 0)
295 game.place[LIQUID()] = CARRIED;
296 if (GSTONE(obj) && game.prop[obj] != 0) {
298 game.prop[CAVITY] = CAVITY_EMPTY;
304 static int chain(token_t verb)
305 /* Do something to the bear's chain */
309 spk = CHAIN_UNLOCKED;
310 if (game.prop[BEAR] == UNTAMED_BEAR)
312 if (game.prop[CHAIN] == 0)
313 spk = ALREADY_UNLOCKED;
314 if (spk != CHAIN_UNLOCKED) {
318 game.prop[CHAIN] = 0;
319 game.fixed[CHAIN] = 0;
320 if (game.prop[BEAR] != BEAR_DEAD)
321 game.prop[BEAR] = CONTENTED_BEAR;
322 /* FIXME: Arithmetic on state numbers */
323 game.fixed[BEAR] = 2 - game.prop[BEAR];
326 if (game.prop[CHAIN] != 0)
327 spk = ALREADY_LOCKED;
328 if (game.loc != objects[CHAIN].plac)
330 if (spk != CHAIN_LOCKED) {
334 game.prop[CHAIN] = 2;
336 drop(CHAIN, game.loc);
337 game.fixed[CHAIN] = -1;
343 static int discard(token_t verb, token_t obj, bool just_do_it)
344 /* Discard object. "Throw" also comes here for most objects. Special cases for
345 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
346 * Drop coins at vending machine for extra batteries. */
348 int spk = actions[verb].message;
350 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj = ROD2;
355 if (obj == BIRD && HERE(SNAKE)) {
356 rspeak(BIRD_ATTACKS);
357 if (game.closed) return GO_DWARFWAKE;
359 /* Set game.prop for use by travel options */
360 game.prop[SNAKE] = SNAKE_CHASED;
362 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
365 game.prop[CAVITY] = CAVITY_FULL;
366 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != 2) || (obj == RUBY &&
367 game.prop[RUG] == 2))) {
369 if (TOTING(RUG))spk = RUG_WIGGLES;
370 if (obj == RUBY)spk = RUG_SETTLES;
372 if (spk != RUG_WIGGLES) {
373 int k = 2 - game.prop[RUG];
375 if (k == 2) k = objects[SAPPH].plac;
376 move(RUG + NOBJECTS, k);
379 } else if (obj == COINS && HERE(VEND)) {
381 drop(BATTERY, game.loc);
382 pspeak(BATTERY, look, FRESH_BATTERIES);
384 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
388 } else if (obj == BEAR && AT(TROLL)) {
389 rspeak(TROLL_SCAMPERS);
391 move(TROLL + NOBJECTS, 0);
392 move(TROLL2, objects[TROLL].plac);
393 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
395 game.prop[TROLL] = 2;
396 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
400 if (AT(PILLOW))game.prop[VASE] = 0;
401 pspeak(VASE, look, game.prop[VASE] + 1);
402 if (game.prop[VASE] != 0)game.fixed[VASE] = -1;
406 if (k == obj)obj = BOTTLE;
407 if (obj == BOTTLE && k != 0)
408 game.place[k] = LOC_NOWHERE;
409 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
410 drop(BIRD, game.loc);
412 if (obj != BIRD) return GO_CLEAROBJ;
413 game.prop[BIRD] = BIRD_UNCAGED;
414 if (FOREST(game.loc))
415 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
419 static int drink(token_t verb, token_t obj)
420 /* Drink. If no object, assume water and look for it here. If water is in
421 * the bottle, drink that, else must be at a water loc, so drink stream. */
423 int spk = actions[verb].message;
424 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
427 if (obj != 0 && obj != WATER)spk = RIDICULOUS_ATTEMPT;
428 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
429 game.prop[BOTTLE] = EMPTY_BOTTLE;
430 game.place[WATER] = LOC_NOWHERE;
435 game.prop[DRAGON] = 2;
443 static int eat(token_t verb, token_t obj)
444 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
445 * ok, some things lose appetite, rest are ridiculous. */
447 int spk = actions[verb].message;
448 if (obj == INTRANSITIVE) {
452 spk = THANKS_DELICIOUS;
456 spk = THANKS_DELICIOUS;
458 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
459 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
460 OGRE)spk = LOST_APPETITE;
466 static int extinguish(token_t verb, int obj)
467 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
469 int spk = actions[verb].message;
470 if (obj == INTRANSITIVE) {
471 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
473 if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
474 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
478 game.prop[URN] = game.prop[URN] / 2;
480 } else if (obj == LAMP) {
481 state_change(LAMP, LAMP_DARK);
482 spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
483 } else if (obj == DRAGON || obj == VOLCANO)
489 static int feed(token_t verb, token_t obj)
490 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
491 * mad. Bear, special. */
493 int spk = actions[verb].message;
497 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
498 spk = NOTHING_EDIBLE;
499 if (obj == DRAGON && game.prop[DRAGON] != 0)spk = RIDICULOUS_ATTEMPT;
500 if (obj == TROLL)spk = TROLL_VICES;
501 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
505 } else if (obj == DWARF) {
510 } else if (obj == BEAR) {
511 if (game.prop[BEAR] == UNTAMED_BEAR)
512 spk = NOTHING_EDIBLE;
513 if (game.prop[BEAR] == BEAR_DEAD)
514 spk = RIDICULOUS_ATTEMPT;
517 game.prop[BEAR] = SITTING_BEAR;
522 } else if (obj == OGRE) {
532 int fill(token_t verb, token_t obj)
533 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
537 int spk = actions[verb].message;
539 spk = ARENT_CARRYING;
540 if (LIQLOC(game.loc) == 0)spk = FILL_INVALID;
541 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
545 rspeak(SHATTER_VASE);
547 game.fixed[VASE] = -1;
548 return (discard(verb, obj, true));
549 } else if (obj == URN) {
551 if (game.prop[URN] != 0) {
557 if (k == 0 || !HERE(BOTTLE)) {
561 game.place[k] = LOC_NOWHERE;
562 game.prop[BOTTLE] = EMPTY_BOTTLE;
563 if (k == OIL)game.prop[URN] = 1;
564 spk = WATER_URN + game.prop[URN];
567 } else if (obj != 0 && obj != BOTTLE) {
570 } else if (obj == 0 && !HERE(BOTTLE))
573 if (LIQLOC(game.loc) == 0)
575 if (HERE(URN) && game.prop[URN] != 0)
579 if (spk == BOTTLED_WATER) {
580 /* FIXME: Arithmetic on property values */
581 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
584 game.place[k] = CARRIED;
592 static int find(token_t verb, token_t obj)
593 /* Find. Might be carrying it, or it might be here. Else give caveat. */
595 int spk = actions[verb].message;
597 (LIQUID() == obj && AT(BOTTLE)) ||
598 obj == LIQLOC(game.loc) ||
599 (obj == DWARF && atdwrf(game.loc) > 0))
601 if (game.closed)spk = NEEDED_NEARBY;
602 if (TOTING(obj))spk = ALREADY_CARRYING;
607 static int fly(token_t verb, token_t obj)
608 /* Fly. Snide remarks unless hovering rug is here. */
610 int spk = actions[verb].message;
611 if (obj == INTRANSITIVE) {
612 if (game.prop[RUG] != 2)spk = RUG_NOTHING2;
613 if (!HERE(RUG))spk = FLAP_ARMS;
614 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
626 if (game.prop[RUG] != 2) {
630 game.oldlc2 = game.oldloc;
631 game.oldloc = game.loc;
632 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
634 if (game.prop[SAPPH] >= 0)
640 static int inven(void)
641 /* Inventory. If object, treat same as find. Else report on current burden. */
644 for (int i = 1; i <= NOBJECTS; i++) {
645 if (i == BEAR || !TOTING(i))
650 pspeak(i, touch, -1);
660 static int light(token_t verb, token_t obj)
661 /* Light. Applicable only to lamp and urn. */
663 int spk = actions[verb].message;
664 if (obj == INTRANSITIVE) {
665 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
667 if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
668 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
672 if (game.prop[URN] == 0) {
685 if (game.limit < 0) {
689 state_change(LAMP, LAMP_BRIGHT);
697 static int listen(void)
698 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
701 int spk = ALL_SILENT;
702 k = locations[game.loc].sound;
705 if (locations[game.loc].loud)
710 for (int i = 1; i <= NOBJECTS; i++) {
711 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
713 int mi = game.prop[i];
715 mi += 3 * game.blooded;
716 long packed_zzword = token_to_packed(game.zzword);
717 pspeak(i, hear, mi, packed_zzword);
719 /* FIXME: Magic number, sensitive to bird state logic */
720 if (i == BIRD && game.prop[i] == 5)
727 static int lock(token_t verb, token_t obj)
728 /* Lock, unlock, no object given. Assume various things if present. */
730 int spk = actions[verb].message;
731 if (obj == INTRANSITIVE) {
732 spk = NOTHING_LOCKED;
733 if (HERE(CLAM))obj = CLAM;
734 if (HERE(OYSTER))obj = OYSTER;
735 if (AT(DOOR))obj = DOOR;
736 if (AT(GRATE))obj = GRATE;
737 if (obj != 0 && HERE(CHAIN)) return GO_UNKNOWN;
738 if (HERE(CHAIN))obj = CHAIN;
739 if (obj == 0 || obj == INTRANSITIVE) {
745 /* Lock, unlock object. Special stuff for opening clam/oyster
747 if (obj == CLAM || obj == OYSTER)
748 return bivalve(verb, obj);
749 if (obj == DOOR)spk = RUSTY_DOOR;
750 if (obj == DOOR && game.prop[DOOR] == 1)spk = OK_MAN;
751 if (obj == CAGE)spk = NO_LOCK;
752 if (obj == KEYS)spk = CANNOT_UNLOCK;
753 if (obj == GRATE || obj == CHAIN) {
760 if (!game.panic)game.clock2 = PANICTIME;
763 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
772 static int pour(token_t verb, token_t obj)
773 /* Pour. If no object, or object is bottle, assume contents of bottle.
774 * special tests for pouring water or oil on plant or rusty door. */
776 int spk = actions[verb].message;
777 if (obj == BOTTLE || obj == 0)obj = LIQUID();
778 if (obj == 0) return GO_UNKNOWN;
784 if (obj != OIL && obj != WATER) {
788 if (HERE(URN) && game.prop[URN] == 0)
789 return fill(verb, URN);
790 game.prop[BOTTLE] = EMPTY_BOTTLE;
791 game.place[obj] = LOC_NOWHERE;
793 if (!(AT(PLANT) || AT(DOOR))) {
798 spk = SHAKING_LEAVES;
803 pspeak(PLANT, look, game.prop[PLANT] + 3);
804 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
805 game.prop[PLANT2] = game.prop[PLANT];
809 if (obj == OIL)game.prop[DOOR] = 1;
810 spk = RUSTED_HINGES + game.prop[DOOR];
816 static int quit(void)
817 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
819 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
824 static int read(struct command_t command)
825 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
827 if (command.obj == INTRANSITIVE) {
829 for (int i = 1; i <= NOBJECTS; i++) {
830 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
831 command.obj = command.obj * NOBJECTS + i;
833 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
837 if (DARK(game.loc)) {
838 rspeak(NO_SEE, command.wd1, command.wd1x);
839 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
840 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
841 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
842 rspeak(actions[command.verb].message);
844 pspeak(command.obj, study, game.prop[command.obj]);
848 static int reservoir(void)
849 /* Z'ZZZ (word gets recomputed at startup; different each game). */
851 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
852 rspeak(NOTHING_HAPPENS);
855 pspeak(RESER, look, game.prop[RESER] + 1);
856 game.prop[RESER] = 1 - game.prop[RESER];
860 game.oldlc2 = game.loc;
868 static int rub(token_t verb, token_t obj)
869 /* Rub. Yields various snide remarks except for lit urn. */
871 int spk = actions[verb].message;
873 spk = PECULIAR_NOTHING;
874 if (obj == URN && game.prop[URN] == 2) {
876 drop(AMBER, game.loc);
877 game.prop[AMBER] = 1;
879 drop(CAVITY, game.loc);
886 static int say(struct command_t *command)
887 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
889 long a = command->wd1, b = command->wd1x;
890 if (command->wd2 > 0) {
893 command->wd1 = command->wd2;
895 //int wd = vocab(command->wd1, -1);
897 packed_to_token(command->wd1, word1);
898 int wd = (int) get_vocab_id(word1);
899 /* FIXME: Magic numbers */
900 if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) {
901 /* FIXME: scribbles on the interpreter's command block */
902 wordclear(&command->wd2);
905 rspeak(OKEY_DOKEY, a, b);
909 static int throw_support(long spk)
916 static int throw (struct command_t *command)
917 /* Throw. Same as discard unless axe. Then same as attack except
918 * ignore bird, and if dwarf is present then one might be killed.
919 * (Only way to do so!) Axe also special for dragon, bear, and
920 * troll. Treasures special for troll. */
922 int spk = actions[command->verb].message;
923 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))command->obj = ROD2;
924 if (!TOTING(command->obj)) {
928 if (objects[command->obj].is_treasure && AT(TROLL)) {
929 spk = TROLL_SATISFIED;
930 /* Snarf a treasure for the troll. */
931 drop(command->obj, 0);
933 move(TROLL + NOBJECTS, 0);
934 drop(TROLL2, objects[TROLL].plac);
935 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
940 if (command->obj == FOOD && HERE(BEAR)) {
941 /* But throwing food is another story. */
943 return (feed(command->verb, command->obj));
945 if (command->obj != AXE)
946 return (discard(command->verb, command->obj, false));
948 int i = atdwrf(game.loc);
950 if (AT(DRAGON) && game.prop[DRAGON] == 0)
951 return throw_support(DRAGON_SCALES);
953 return throw_support(TROLL_RETURNS);
955 return throw_support(OGRE_DODGE);
956 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
957 /* This'll teach him to throw the axe at the bear! */
959 game.fixed[AXE] = -1;
966 return (attack(command));
969 if (randrange(NDWARVES + 1) < game.dflag) {
970 return throw_support(DWARF_DODGES);
972 game.dseen[i] = false;
974 return throw_support((++game.dkill == 1)
975 ? DWARF_SMOKE : KILLED_DWARF);
980 static int wake(token_t verb, token_t obj)
981 /* Wake. Only use is to disturb the dwarves. */
983 if (obj != DWARF || !game.closed) {
984 rspeak(actions[verb].message);
992 static int wave(token_t verb, token_t obj)
993 /* Wave. No effect unless waving rod at fissure or at bird. */
995 int spk = actions[verb].message;
996 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))spk = ARENT_CARRYING;
999 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1003 /* FIXME: Arithemetic on proprty values */
1005 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
1006 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1007 drop(JADE, game.loc);
1008 game.prop[JADE] = 0;
1016 return GO_DWARFWAKE;
1018 if (game.closng || !AT(FISSURE)) {
1022 if (HERE(BIRD))rspeak(spk);
1023 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1024 pspeak(FISSURE, look, 2 - game.prop[FISSURE]);
1029 int action(struct command_t *command)
1030 /* Analyse a verb. Remember what it was, go back for object if second word
1031 * unless verb is "say", which snarfs arbitrary second word.
1034 token_t spk = actions[command->verb].message;
1036 if (command->part == unknown) {
1037 /* Analyse an object word. See if the thing is here, whether
1038 * we've got a verb yet, and so on. Object must be here
1039 * unless verb is "find" or "invent(ory)" (and no new verb
1040 * yet to be analysed). Water and oil are also funny, since
1041 * they are never actually dropped at any location, but might
1042 * be here inside the bottle or urn or as a feature of the
1044 if (HERE(command->obj))
1046 else if (command->obj == GRATE) {
1047 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1048 command->obj = DPRSSN;
1049 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1050 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1051 command->obj = ENTRNC;
1052 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1054 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1056 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1059 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1060 command->obj = PLANT2;
1062 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1064 spk = KNIVES_VANISH;
1067 } else if (command->obj == ROD && HERE(ROD2)) {
1068 command->obj = ROD2;
1070 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1073 rspeak(NO_SEE, command->wd1, command->wd1x);
1077 if (command->wd2 > 0)
1079 if (command->verb != 0)
1080 command->part = transitive;
1083 switch (command->part) {
1085 if (command->wd2 > 0 && command->verb != SAY)
1087 if (command->verb == SAY)command->obj = command->wd2;
1088 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1089 /* Analyse an intransitive verb (ie, no object given yet). */
1090 switch (command->verb) {
1092 return vcarry(command->verb, INTRANSITIVE);
1098 return lock(command->verb, INTRANSITIVE);
1101 return (GO_CLEAROBJ);
1104 return lock(command->verb, INTRANSITIVE);
1106 return light(command->verb, INTRANSITIVE);
1108 return extinguish(command->verb, INTRANSITIVE);
1118 return attack(command);
1120 return pour(command->verb, command->obj);
1122 return eat(command->verb, INTRANSITIVE);
1124 return drink(command->verb, command->obj);
1138 return fill(command->verb, command->obj);
1146 return bigwords(command->wd1);
1150 command->obj = INTRANSITIVE;
1151 return read(*command);
1161 return fly(command->verb, INTRANSITIVE);
1167 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1172 /* Analyse a transitive verb. */
1173 switch (command->verb) {
1175 return vcarry(command->verb, command->obj);
1177 return discard(command->verb, command->obj, false);
1179 return say(command);
1181 return lock(command->verb, command->obj);
1184 return (GO_CLEAROBJ);
1187 return lock(command->verb, command->obj);
1189 return light(command->verb, command->obj);
1191 return extinguish(command->verb, command->obj);
1193 return wave(command->verb, command->obj);
1203 return attack(command);
1205 return pour(command->verb, command->obj);
1207 return eat(command->verb, command->obj);
1209 return drink(command->verb, command->obj);
1211 return rub(command->verb, command->obj);
1213 return throw (command);
1219 return find(command->verb, command->obj);
1221 return find(command->verb, command->obj);
1223 return feed(command->verb, command->obj);
1225 return fill(command->verb, command->obj);
1242 return read(*command);
1244 return vbreak(command->verb, command->obj);
1246 return wake(command->verb, command->obj);
1256 return fly(command->verb, command->obj);
1264 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1267 /* Unknown verb, couldn't deduce object - might need hint */
1268 rspeak(WHAT_DO, command->wd1, command->wd1x);
1269 return GO_CHECKHINT;
1271 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE