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(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);
91 // FIXME: setting wd1 is a workaround for broken logic
92 command->wd1 = token_to_packed("Y");
96 // FIXME: setting wd1 is a workaround for broken logic
97 command->wd1 = token_to_packed("N");
100 pspeak(DRAGON, look, 3);
101 game.prop[DRAGON] = 1;
103 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
104 move(DRAGON + NOBJECTS, -1);
105 move(RUG + NOBJECTS, 0);
109 for (obj = 1; obj <= NOBJECTS; obj++) {
110 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
121 static int bigwords(token_t foo)
122 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
123 * Look up foo in section 3 of vocab to determine which word we've got. Last
124 * word zips the eggs back to the giant room (unless already there). */
126 //int k = vocab(foo, 3);
128 packed_to_token(foo, word);
129 int k = (int) get_special_vocab_id(word);
130 int spk = NOTHING_HAPPENS;
131 if (game.foobar != 1 - k) {
132 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)spk = START_OVER;
142 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
146 /* Bring back troll if we steal the eggs back from him before
148 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == 0)
149 game.prop[TROLL] = 1;
151 if (HERE(EGGS))k = 1;
152 if (game.loc == objects[EGGS].plac)k = 0;
153 move(EGGS, objects[EGGS].plac);
154 pspeak(EGGS, look, k);
160 static int bivalve(token_t verb, token_t obj)
161 /* Clam/oyster actions */
164 bool is_oyster = (obj == OYSTER);
165 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
166 if (TOTING(obj))spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
167 if (!TOTING(TRIDENT))spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
168 if (verb == LOCK)spk = HUH_MAN;
169 if (spk == PEARL_FALLS) {
171 drop(OYSTER, game.loc);
172 drop(PEARL, LOC_CULDESAC);
178 static void blast(void)
179 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
181 if (game.prop[ROD2] < 0 || !game.closed)
182 rspeak(REQUIRES_DYNAMITE);
184 game.bonus = VICTORY_MESSAGE;
185 if (game.loc == LOC_NE)
186 game.bonus = DEFEAT_MESSAGE;
188 game.bonus = SPLATTER_MESSAGE;
194 static int vbreak(token_t verb, token_t obj)
195 /* Break. Only works for mirror in repository and, of course, the vase. */
197 int spk = actions[verb].message;
198 if (obj == MIRROR)spk = TOO_FAR;
199 if (obj == VASE && game.prop[VASE] == 0) {
200 if (TOTING(VASE))drop(VASE, game.loc);
202 game.fixed[VASE] = -1;
205 if (obj == MIRROR && game.closed) {
206 rspeak(BREAK_MIRROR);
214 static int brief(void)
215 /* Brief. Intransitive only. Suppress long descriptions after first time. */
219 rspeak(BRIEF_CONFIRM);
223 static int vcarry(token_t verb, token_t obj)
224 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
225 * take one without the other). Liquids also special, since they depend on
226 * status of bottle. Also various side effects, etc. */
229 if (obj == INTRANSITIVE) {
230 /* Carry, no object given yet. OK if only one object present. */
231 if (game.atloc[game.loc] == 0 ||
232 game.link[game.atloc[game.loc]] != 0 ||
233 atdwrf(game.loc) > 0)
235 obj = game.atloc[game.loc];
239 rspeak(ALREADY_CARRYING);
243 if (obj == PLANT && game.prop[PLANT] <= 0)spk = DEEP_ROOTS;
244 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
246 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
248 if (obj == URN)spk = URN_NOBUDGE;
249 if (obj == CAVITY)spk = DOUGHNUT_HOLES;
250 if (obj == BLOOD)spk = FEW_DROPS;
251 if (obj == RUG && game.prop[RUG] == 2)spk = RUG_HOVERS;
252 if (obj == SIGN)spk = HAND_PASSTHROUGH;
254 rspeak(REMOVE_MESSAGE);
258 if (game.fixed[obj] != 0) {
262 if (obj == WATER || obj == OIL) {
263 if (!HERE(BOTTLE) || LIQUID() != obj) {
264 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
265 return (fill(verb, BOTTLE));
267 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
269 if (!TOTING(BOTTLE))spk = NO_CONTAINER;
278 if (game.holdng >= INVLIMIT) {
281 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
282 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
287 if (!TOTING(CAGE))spk = CANNOT_CARRY;
288 if (TOTING(ROD))spk = BIRD_EVADES;
289 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
293 game.prop[BIRD] = BIRD_CAGED;
295 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
296 carry(BIRD + CAGE - obj, game.loc);
297 carry(obj, game.loc);
298 if (obj == BOTTLE && LIQUID() != 0)
299 game.place[LIQUID()] = CARRIED;
300 if (GSTONE(obj) && game.prop[obj] != 0) {
302 game.prop[CAVITY] = CAVITY_EMPTY;
308 static int chain(token_t verb)
309 /* Do something to the bear's chain */
313 spk = CHAIN_UNLOCKED;
314 if (game.prop[BEAR] == UNTAMED_BEAR)
316 if (game.prop[CHAIN] == 0)
317 spk = ALREADY_UNLOCKED;
318 if (spk != CHAIN_UNLOCKED) {
322 game.prop[CHAIN] = 0;
323 game.fixed[CHAIN] = 0;
324 if (game.prop[BEAR] != BEAR_DEAD)
325 game.prop[BEAR] = CONTENTED_BEAR;
326 /* FIXME: Arithmetic on state numbers */
327 game.fixed[BEAR] = 2 - game.prop[BEAR];
330 if (game.prop[CHAIN] != 0)
331 spk = ALREADY_LOCKED;
332 if (game.loc != objects[CHAIN].plac)
334 if (spk != CHAIN_LOCKED) {
338 game.prop[CHAIN] = 2;
340 drop(CHAIN, game.loc);
341 game.fixed[CHAIN] = -1;
347 static int discard(token_t verb, token_t obj, bool just_do_it)
348 /* Discard object. "Throw" also comes here for most objects. Special cases for
349 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
350 * Drop coins at vending machine for extra batteries. */
352 int spk = actions[verb].message;
354 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj = ROD2;
359 if (obj == BIRD && HERE(SNAKE)) {
360 rspeak(BIRD_ATTACKS);
361 if (game.closed) return GO_DWARFWAKE;
363 /* Set game.prop for use by travel options */
364 game.prop[SNAKE] = SNAKE_CHASED;
366 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
369 game.prop[CAVITY] = CAVITY_FULL;
370 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != 2) || (obj == RUBY &&
371 game.prop[RUG] == 2))) {
373 if (TOTING(RUG))spk = RUG_WIGGLES;
374 if (obj == RUBY)spk = RUG_SETTLES;
376 if (spk != RUG_WIGGLES) {
377 int k = 2 - game.prop[RUG];
379 if (k == 2) k = objects[SAPPH].plac;
380 move(RUG + NOBJECTS, k);
383 } else if (obj == COINS && HERE(VEND)) {
385 drop(BATTERY, game.loc);
386 pspeak(BATTERY, look, FRESH_BATTERIES);
388 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
392 } else if (obj == BEAR && AT(TROLL)) {
393 rspeak(TROLL_SCAMPERS);
395 move(TROLL + NOBJECTS, 0);
396 move(TROLL2, objects[TROLL].plac);
397 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
399 game.prop[TROLL] = 2;
400 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
404 if (AT(PILLOW))game.prop[VASE] = 0;
405 pspeak(VASE, look, game.prop[VASE] + 1);
406 if (game.prop[VASE] != 0)game.fixed[VASE] = -1;
410 if (k == obj)obj = BOTTLE;
411 if (obj == BOTTLE && k != 0)
412 game.place[k] = LOC_NOWHERE;
413 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
414 drop(BIRD, game.loc);
416 if (obj != BIRD) return GO_CLEAROBJ;
417 game.prop[BIRD] = BIRD_UNCAGED;
418 if (FOREST(game.loc))
419 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
423 static int drink(token_t verb, token_t obj)
424 /* Drink. If no object, assume water and look for it here. If water is in
425 * the bottle, drink that, else must be at a water loc, so drink stream. */
427 int spk = actions[verb].message;
428 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
431 if (obj != 0 && obj != WATER)spk = RIDICULOUS_ATTEMPT;
432 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
433 game.prop[BOTTLE] = EMPTY_BOTTLE;
434 game.place[WATER] = LOC_NOWHERE;
439 game.prop[DRAGON] = 2;
447 static int eat(token_t verb, token_t obj)
448 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
449 * ok, some things lose appetite, rest are ridiculous. */
451 int spk = actions[verb].message;
452 if (obj == INTRANSITIVE) {
456 spk = THANKS_DELICIOUS;
460 spk = THANKS_DELICIOUS;
462 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
463 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
464 OGRE)spk = LOST_APPETITE;
470 static int extinguish(token_t verb, int obj)
471 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
473 int spk = actions[verb].message;
474 if (obj == INTRANSITIVE) {
475 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
477 if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
478 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
482 game.prop[URN] = game.prop[URN] / 2;
484 } else if (obj == LAMP) {
485 state_change(LAMP, LAMP_DARK);
486 spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
487 } else if (obj == DRAGON || obj == VOLCANO)
493 static int feed(token_t verb, token_t obj)
494 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
495 * mad. Bear, special. */
497 int spk = actions[verb].message;
501 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
502 spk = NOTHING_EDIBLE;
503 if (obj == DRAGON && game.prop[DRAGON] != 0)spk = RIDICULOUS_ATTEMPT;
504 if (obj == TROLL)spk = TROLL_VICES;
505 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
509 } else if (obj == DWARF) {
514 } else if (obj == BEAR) {
515 if (game.prop[BEAR] == UNTAMED_BEAR)
516 spk = NOTHING_EDIBLE;
517 if (game.prop[BEAR] == BEAR_DEAD)
518 spk = RIDICULOUS_ATTEMPT;
521 game.prop[BEAR] = SITTING_BEAR;
526 } else if (obj == OGRE) {
536 int fill(token_t verb, token_t obj)
537 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
541 int spk = actions[verb].message;
543 spk = ARENT_CARRYING;
544 if (LIQLOC(game.loc) == 0)spk = FILL_INVALID;
545 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
549 rspeak(SHATTER_VASE);
551 game.fixed[VASE] = -1;
552 return (discard(verb, obj, true));
553 } else if (obj == URN) {
555 if (game.prop[URN] != 0) {
561 if (k == 0 || !HERE(BOTTLE)) {
565 game.place[k] = LOC_NOWHERE;
566 game.prop[BOTTLE] = EMPTY_BOTTLE;
567 if (k == OIL)game.prop[URN] = 1;
568 spk = WATER_URN + game.prop[URN];
571 } else if (obj != 0 && obj != BOTTLE) {
574 } else if (obj == 0 && !HERE(BOTTLE))
577 if (LIQLOC(game.loc) == 0)
579 if (HERE(URN) && game.prop[URN] != 0)
583 if (spk == BOTTLED_WATER) {
584 /* FIXME: Arithmetic on property values */
585 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
588 game.place[k] = CARRIED;
596 static int find(token_t verb, token_t obj)
597 /* Find. Might be carrying it, or it might be here. Else give caveat. */
599 int spk = actions[verb].message;
601 (LIQUID() == obj && AT(BOTTLE)) ||
602 obj == LIQLOC(game.loc) ||
603 (obj == DWARF && atdwrf(game.loc) > 0))
605 if (game.closed)spk = NEEDED_NEARBY;
606 if (TOTING(obj))spk = ALREADY_CARRYING;
611 static int fly(token_t verb, token_t obj)
612 /* Fly. Snide remarks unless hovering rug is here. */
614 int spk = actions[verb].message;
615 if (obj == INTRANSITIVE) {
616 if (game.prop[RUG] != 2)spk = RUG_NOTHING2;
617 if (!HERE(RUG))spk = FLAP_ARMS;
618 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
630 if (game.prop[RUG] != 2) {
634 game.oldlc2 = game.oldloc;
635 game.oldloc = game.loc;
636 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
638 if (game.prop[SAPPH] >= 0)
644 static int inven(void)
645 /* Inventory. If object, treat same as find. Else report on current burden. */
648 for (int i = 1; i <= NOBJECTS; i++) {
649 if (i == BEAR || !TOTING(i))
654 pspeak(i, touch, -1);
664 static int light(token_t verb, token_t obj)
665 /* Light. Applicable only to lamp and urn. */
667 int spk = actions[verb].message;
668 if (obj == INTRANSITIVE) {
669 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
671 if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
672 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
676 if (game.prop[URN] == 0) {
689 if (game.limit < 0) {
693 state_change(LAMP, LAMP_BRIGHT);
701 static int listen(void)
702 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
705 int spk = ALL_SILENT;
706 k = locations[game.loc].sound;
709 if (locations[game.loc].loud)
714 for (int i = 1; i <= NOBJECTS; i++) {
715 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
717 int mi = game.prop[i];
719 mi += 3 * game.blooded;
720 long packed_zzword = token_to_packed(game.zzword);
721 pspeak(i, hear, mi, packed_zzword);
723 /* FIXME: Magic number, sensitive to bird state logic */
724 if (i == BIRD && game.prop[i] == 5)
731 static int lock(token_t verb, token_t obj)
732 /* Lock, unlock, no object given. Assume various things if present. */
734 int spk = actions[verb].message;
735 if (obj == INTRANSITIVE) {
736 spk = NOTHING_LOCKED;
737 if (HERE(CLAM))obj = CLAM;
738 if (HERE(OYSTER))obj = OYSTER;
739 if (AT(DOOR))obj = DOOR;
740 if (AT(GRATE))obj = GRATE;
741 if (obj != 0 && HERE(CHAIN)) return GO_UNKNOWN;
742 if (HERE(CHAIN))obj = CHAIN;
743 if (obj == 0 || obj == INTRANSITIVE) {
749 /* Lock, unlock object. Special stuff for opening clam/oyster
751 if (obj == CLAM || obj == OYSTER)
752 return bivalve(verb, obj);
753 if (obj == DOOR)spk = RUSTY_DOOR;
754 if (obj == DOOR && game.prop[DOOR] == 1)spk = OK_MAN;
755 if (obj == CAGE)spk = NO_LOCK;
756 if (obj == KEYS)spk = CANNOT_UNLOCK;
757 if (obj == GRATE || obj == CHAIN) {
764 if (!game.panic)game.clock2 = PANICTIME;
767 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
776 static int pour(token_t verb, token_t obj)
777 /* Pour. If no object, or object is bottle, assume contents of bottle.
778 * special tests for pouring water or oil on plant or rusty door. */
780 int spk = actions[verb].message;
781 if (obj == BOTTLE || obj == 0)obj = LIQUID();
782 if (obj == 0) return GO_UNKNOWN;
788 if (obj != OIL && obj != WATER) {
792 if (HERE(URN) && game.prop[URN] == 0)
793 return fill(verb, URN);
794 game.prop[BOTTLE] = EMPTY_BOTTLE;
795 game.place[obj] = LOC_NOWHERE;
797 if (!(AT(PLANT) || AT(DOOR))) {
802 spk = SHAKING_LEAVES;
807 pspeak(PLANT, look, game.prop[PLANT] + 3);
808 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
809 game.prop[PLANT2] = game.prop[PLANT];
813 if (obj == OIL)game.prop[DOOR] = 1;
814 spk = RUSTED_HINGES + game.prop[DOOR];
820 static int quit(void)
821 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
823 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
828 static int read(struct command_t command)
829 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
831 if (command.obj == INTRANSITIVE) {
833 for (int i = 1; i <= NOBJECTS; i++) {
834 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
835 command.obj = command.obj * NOBJECTS + i;
837 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
841 if (DARK(game.loc)) {
842 rspeak(NO_SEE, command.wd1, command.wd1x);
843 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
844 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
845 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
846 rspeak(actions[command.verb].message);
848 pspeak(command.obj, study, game.prop[command.obj]);
852 static int reservoir(void)
853 /* Z'ZZZ (word gets recomputed at startup; different each game). */
855 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
856 rspeak(NOTHING_HAPPENS);
859 pspeak(RESER, look, game.prop[RESER] + 1);
860 game.prop[RESER] = 1 - game.prop[RESER];
864 game.oldlc2 = game.loc;
872 static int rub(token_t verb, token_t obj)
873 /* Rub. Yields various snide remarks except for lit urn. */
875 int spk = actions[verb].message;
877 spk = PECULIAR_NOTHING;
878 if (obj == URN && game.prop[URN] == 2) {
880 drop(AMBER, game.loc);
881 game.prop[AMBER] = 1;
883 drop(CAVITY, game.loc);
890 static int say(struct command_t *command)
891 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
893 long a = command->wd1, b = command->wd1x;
894 if (command->wd2 > 0) {
897 command->wd1 = command->wd2;
899 //int wd = vocab(command->wd1, -1);
901 packed_to_token(command->wd1, word1);
902 int wd = (int) get_vocab_id(word1);
903 /* FIXME: Magic numbers */
904 if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) {
905 /* FIXME: scribbles on the interpreter's command block */
906 wordclear(&command->wd2);
909 rspeak(OKEY_DOKEY, a, b);
913 static int throw_support(long spk)
920 static int throw (struct command_t *command)
921 /* Throw. Same as discard unless axe. Then same as attack except
922 * ignore bird, and if dwarf is present then one might be killed.
923 * (Only way to do so!) Axe also special for dragon, bear, and
924 * troll. Treasures special for troll. */
926 int spk = actions[command->verb].message;
927 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))command->obj = ROD2;
928 if (!TOTING(command->obj)) {
932 if (objects[command->obj].is_treasure && AT(TROLL)) {
933 spk = TROLL_SATISFIED;
934 /* Snarf a treasure for the troll. */
935 drop(command->obj, 0);
937 move(TROLL + NOBJECTS, 0);
938 drop(TROLL2, objects[TROLL].plac);
939 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
944 if (command->obj == FOOD && HERE(BEAR)) {
945 /* But throwing food is another story. */
947 return (feed(command->verb, command->obj));
949 if (command->obj != AXE)
950 return (discard(command->verb, command->obj, false));
952 int i = atdwrf(game.loc);
954 if (AT(DRAGON) && game.prop[DRAGON] == 0)
955 return throw_support(DRAGON_SCALES);
957 return throw_support(TROLL_RETURNS);
959 return throw_support(OGRE_DODGE);
960 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
961 /* This'll teach him to throw the axe at the bear! */
963 game.fixed[AXE] = -1;
970 return (attack(command));
973 if (randrange(NDWARVES + 1) < game.dflag) {
974 return throw_support(DWARF_DODGES);
976 game.dseen[i] = false;
978 return throw_support((++game.dkill == 1)
979 ? DWARF_SMOKE : KILLED_DWARF);
984 static int wake(token_t verb, token_t obj)
985 /* Wake. Only use is to disturb the dwarves. */
987 if (obj != DWARF || !game.closed) {
988 rspeak(actions[verb].message);
996 static int wave(token_t verb, token_t obj)
997 /* Wave. No effect unless waving rod at fissure or at bird. */
999 int spk = actions[verb].message;
1000 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))spk = ARENT_CARRYING;
1003 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1007 /* FIXME: Arithemetic on proprty values */
1009 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
1010 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1011 drop(JADE, game.loc);
1012 game.prop[JADE] = 0;
1020 return GO_DWARFWAKE;
1022 if (game.closng || !AT(FISSURE)) {
1026 if (HERE(BIRD))rspeak(spk);
1027 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1028 pspeak(FISSURE, look, 2 - game.prop[FISSURE]);
1033 int action(struct command_t *command)
1034 /* Analyse a verb. Remember what it was, go back for object if second word
1035 * unless verb is "say", which snarfs arbitrary second word.
1038 token_t spk = actions[command->verb].message;
1040 if (command->part == unknown) {
1041 /* Analyse an object word. See if the thing is here, whether
1042 * we've got a verb yet, and so on. Object must be here
1043 * unless verb is "find" or "invent(ory)" (and no new verb
1044 * yet to be analysed). Water and oil are also funny, since
1045 * they are never actually dropped at any location, but might
1046 * be here inside the bottle or urn or as a feature of the
1048 if (HERE(command->obj))
1050 else if (command->obj == GRATE) {
1051 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1052 command->obj = DPRSSN;
1053 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1054 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1055 command->obj = ENTRNC;
1056 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1058 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1060 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1063 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1064 command->obj = PLANT2;
1066 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1068 spk = KNIVES_VANISH;
1071 } else if (command->obj == ROD && HERE(ROD2)) {
1072 command->obj = ROD2;
1074 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1077 rspeak(NO_SEE, command->wd1, command->wd1x);
1081 if (command->wd2 > 0)
1083 if (command->verb != 0)
1084 command->part = transitive;
1087 switch (command->part) {
1089 if (command->wd2 > 0 && command->verb != SAY)
1091 if (command->verb == SAY)command->obj = command->wd2;
1092 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1093 /* Analyse an intransitive verb (ie, no object given yet). */
1094 switch (command->verb) {
1096 return vcarry(command->verb, INTRANSITIVE);
1102 return lock(command->verb, INTRANSITIVE);
1105 return (GO_CLEAROBJ);
1108 return lock(command->verb, INTRANSITIVE);
1110 return light(command->verb, INTRANSITIVE);
1112 return extinguish(command->verb, INTRANSITIVE);
1122 return attack(command);
1124 return pour(command->verb, command->obj);
1126 return eat(command->verb, INTRANSITIVE);
1128 return drink(command->verb, command->obj);
1142 return fill(command->verb, command->obj);
1150 return bigwords(command->wd1);
1154 command->obj = INTRANSITIVE;
1155 return read(*command);
1165 return fly(command->verb, INTRANSITIVE);
1171 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1176 /* Analyse a transitive verb. */
1177 switch (command->verb) {
1179 return vcarry(command->verb, command->obj);
1181 return discard(command->verb, command->obj, false);
1183 return say(command);
1185 return lock(command->verb, command->obj);
1188 return (GO_CLEAROBJ);
1191 return lock(command->verb, command->obj);
1193 return light(command->verb, command->obj);
1195 return extinguish(command->verb, command->obj);
1197 return wave(command->verb, command->obj);
1207 return attack(command);
1209 return pour(command->verb, command->obj);
1211 return eat(command->verb, command->obj);
1213 return drink(command->verb, command->obj);
1215 return rub(command->verb, command->obj);
1217 return throw(command);
1223 return find(command->verb, command->obj);
1225 return find(command->verb, command->obj);
1227 return feed(command->verb, command->obj);
1229 return fill(command->verb, command->obj);
1246 return read(*command);
1248 return vbreak(command->verb, command->obj);
1250 return wake(command->verb, command->obj);
1260 return fly(command->verb, command->obj);
1268 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1271 /* Unknown verb, couldn't deduce object - might need hint */
1272 rspeak(WHAT_DO, command->wd1, command->wd1x);
1273 return GO_CHECKHINT;
1275 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE