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);
90 // FIXME: setting wd1 is a workaround for broken logic
91 command->wd1 = token_to_packed("Y");
95 // FIXME: setting wd1 is a workaround for broken logic
96 command->wd1 = token_to_packed("N");
99 pspeak(DRAGON, look, 3);
100 game.prop[DRAGON] = 1;
102 int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
103 move(DRAGON + NOBJECTS, -1);
104 move(RUG + NOBJECTS, 0);
108 for (obj = 1; obj <= NOBJECTS; obj++) {
109 if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
120 static int bigwords(token_t foo)
121 /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
122 * Look up foo in section 3 of vocab to determine which word we've got. Last
123 * word zips the eggs back to the giant room (unless already there). */
125 //int k = vocab(foo, 3);
127 packed_to_token(foo, word);
128 int k = (int) get_special_vocab_id(word);
129 int spk = NOTHING_HAPPENS;
130 if (game.foobar != 1 - k) {
131 if (game.foobar != 0 && game.loc == LOC_GIANTROOM)spk = START_OVER;
141 if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
145 /* Bring back troll if we steal the eggs back from him before
147 if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == 0)
148 game.prop[TROLL] = 1;
150 if (HERE(EGGS))k = 1;
151 if (game.loc == objects[EGGS].plac)k = 0;
152 move(EGGS, objects[EGGS].plac);
153 pspeak(EGGS, look, k);
159 static int bivalve(token_t verb, token_t obj)
160 /* Clam/oyster actions */
163 bool is_oyster = (obj == OYSTER);
164 spk = is_oyster ? OYSTER_OPENS : PEARL_FALLS;
165 if (TOTING(obj))spk = is_oyster ? DROP_OYSTER : DROP_CLAM;
166 if (!TOTING(TRIDENT))spk = is_oyster ? OYSTER_OPENER : CLAM_OPENER;
167 if (verb == LOCK)spk = HUH_MAN;
168 if (spk == PEARL_FALLS) {
170 drop(OYSTER, game.loc);
171 drop(PEARL, LOC_CULDESAC);
177 static void blast(void)
178 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
180 if (game.prop[ROD2] < 0 || !game.closed)
181 rspeak(REQUIRES_DYNAMITE);
183 game.bonus = VICTORY_MESSAGE;
184 if (game.loc == LOC_NE)
185 game.bonus = DEFEAT_MESSAGE;
187 game.bonus = SPLATTER_MESSAGE;
193 static int vbreak(token_t verb, token_t obj)
194 /* Break. Only works for mirror in repository and, of course, the vase. */
196 int spk = actions[verb].message;
197 if (obj == MIRROR)spk = TOO_FAR;
198 if (obj == VASE && game.prop[VASE] == 0) {
199 if (TOTING(VASE))drop(VASE, game.loc);
201 game.fixed[VASE] = -1;
204 if (obj == MIRROR && game.closed) {
205 rspeak(BREAK_MIRROR);
213 static int brief(void)
214 /* Brief. Intransitive only. Suppress long descriptions after first time. */
218 rspeak(BRIEF_CONFIRM);
222 static int vcarry(token_t verb, token_t obj)
223 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
224 * take one without the other). Liquids also special, since they depend on
225 * status of bottle. Also various side effects, etc. */
228 if (obj == INTRANSITIVE) {
229 /* Carry, no object given yet. OK if only one object present. */
230 if (game.atloc[game.loc] == 0 ||
231 game.link[game.atloc[game.loc]] != 0 ||
232 atdwrf(game.loc) > 0)
234 obj = game.atloc[game.loc];
238 rspeak(ALREADY_CARRYING);
242 if (obj == PLANT && game.prop[PLANT] <= 0)spk = DEEP_ROOTS;
243 if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
245 if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
247 if (obj == URN)spk = URN_NOBUDGE;
248 if (obj == CAVITY)spk = DOUGHNUT_HOLES;
249 if (obj == BLOOD)spk = FEW_DROPS;
250 if (obj == RUG && game.prop[RUG] == 2)spk = RUG_HOVERS;
251 if (obj == SIGN)spk = HAND_PASSTHROUGH;
253 rspeak(REMOVE_MESSAGE);
257 if (game.fixed[obj] != 0) {
261 if (obj == WATER || obj == OIL) {
262 if (!HERE(BOTTLE) || LIQUID() != obj) {
263 if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE)
264 return (fill(verb, BOTTLE));
266 if (game.prop[BOTTLE] != EMPTY_BOTTLE)
268 if (!TOTING(BOTTLE))spk = NO_CONTAINER;
277 if (game.holdng >= INVLIMIT) {
280 } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
281 if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
286 if (!TOTING(CAGE))spk = CANNOT_CARRY;
287 if (TOTING(ROD))spk = BIRD_EVADES;
288 if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
292 game.prop[BIRD] = BIRD_CAGED;
294 if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
295 carry(BIRD + CAGE - obj, game.loc);
296 carry(obj, game.loc);
297 if (obj == BOTTLE && LIQUID() != 0)
298 game.place[LIQUID()] = CARRIED;
299 if (GSTONE(obj) && game.prop[obj] != 0) {
301 game.prop[CAVITY] = CAVITY_EMPTY;
307 static int chain(token_t verb)
308 /* Do something to the bear's chain */
312 spk = CHAIN_UNLOCKED;
313 if (game.prop[BEAR] == UNTAMED_BEAR)
315 if (game.prop[CHAIN] == 0)
316 spk = ALREADY_UNLOCKED;
317 if (spk != CHAIN_UNLOCKED) {
321 game.prop[CHAIN] = 0;
322 game.fixed[CHAIN] = 0;
323 if (game.prop[BEAR] != BEAR_DEAD)
324 game.prop[BEAR] = CONTENTED_BEAR;
325 /* FIXME: Arithmetic on state numbers */
326 game.fixed[BEAR] = 2 - game.prop[BEAR];
329 if (game.prop[CHAIN] != 0)
330 spk = ALREADY_LOCKED;
331 if (game.loc != objects[CHAIN].plac)
333 if (spk != CHAIN_LOCKED) {
337 game.prop[CHAIN] = 2;
339 drop(CHAIN, game.loc);
340 game.fixed[CHAIN] = -1;
346 static int discard(token_t verb, token_t obj, bool just_do_it)
347 /* Discard object. "Throw" also comes here for most objects. Special cases for
348 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
349 * Drop coins at vending machine for extra batteries. */
351 int spk = actions[verb].message;
353 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj = ROD2;
358 if (obj == BIRD && HERE(SNAKE)) {
359 rspeak(BIRD_ATTACKS);
360 if (game.closed) return GO_DWARFWAKE;
362 /* Set game.prop for use by travel options */
363 game.prop[SNAKE] = SNAKE_CHASED;
365 } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
368 game.prop[CAVITY] = CAVITY_FULL;
369 if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != 2) || (obj == RUBY &&
370 game.prop[RUG] == 2))) {
372 if (TOTING(RUG))spk = RUG_WIGGLES;
373 if (obj == RUBY)spk = RUG_SETTLES;
375 if (spk != RUG_WIGGLES) {
376 int k = 2 - game.prop[RUG];
378 if (k == 2) k = objects[SAPPH].plac;
379 move(RUG + NOBJECTS, k);
382 } else if (obj == COINS && HERE(VEND)) {
384 drop(BATTERY, game.loc);
385 pspeak(BATTERY, look, FRESH_BATTERIES);
387 } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
391 } else if (obj == BEAR && AT(TROLL)) {
392 rspeak(TROLL_SCAMPERS);
394 move(TROLL + NOBJECTS, 0);
395 move(TROLL2, objects[TROLL].plac);
396 move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
398 game.prop[TROLL] = 2;
399 } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
403 if (AT(PILLOW))game.prop[VASE] = 0;
404 pspeak(VASE, look, game.prop[VASE] + 1);
405 if (game.prop[VASE] != 0)game.fixed[VASE] = -1;
409 if (k == obj)obj = BOTTLE;
410 if (obj == BOTTLE && k != 0)
411 game.place[k] = LOC_NOWHERE;
412 if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
413 drop(BIRD, game.loc);
415 if (obj != BIRD) return GO_CLEAROBJ;
416 game.prop[BIRD] = BIRD_UNCAGED;
417 if (FOREST(game.loc))
418 game.prop[BIRD] = BIRD_FOREST_UNCAGED;
422 static int drink(token_t verb, token_t obj)
423 /* Drink. If no object, assume water and look for it here. If water is in
424 * the bottle, drink that, else must be at a water loc, so drink stream. */
426 int spk = actions[verb].message;
427 if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
430 if (obj != 0 && obj != WATER)spk = RIDICULOUS_ATTEMPT;
431 if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
432 game.prop[BOTTLE] = EMPTY_BOTTLE;
433 game.place[WATER] = LOC_NOWHERE;
438 game.prop[DRAGON] = 2;
446 static int eat(token_t verb, token_t obj)
447 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
448 * ok, some things lose appetite, rest are ridiculous. */
450 int spk = actions[verb].message;
451 if (obj == INTRANSITIVE) {
455 spk = THANKS_DELICIOUS;
459 spk = THANKS_DELICIOUS;
461 if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
462 DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
463 OGRE)spk = LOST_APPETITE;
469 static int extinguish(token_t verb, int obj)
470 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
472 int spk = actions[verb].message;
473 if (obj == INTRANSITIVE) {
474 if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
476 if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
477 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
481 game.prop[URN] = game.prop[URN] / 2;
483 } else if (obj == LAMP) {
484 state_change(LAMP, LAMP_DARK);
485 spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
486 } else if (obj == DRAGON || obj == VOLCANO)
492 static int feed(token_t verb, token_t obj)
493 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
494 * mad. Bear, special. */
496 int spk = actions[verb].message;
500 } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) {
501 spk = NOTHING_EDIBLE;
502 if (obj == DRAGON && game.prop[DRAGON] != 0)spk = RIDICULOUS_ATTEMPT;
503 if (obj == TROLL)spk = TROLL_VICES;
504 if (obj == SNAKE && !game.closed && HERE(BIRD)) {
508 } else if (obj == DWARF) {
513 } else if (obj == BEAR) {
514 if (game.prop[BEAR] == UNTAMED_BEAR)
515 spk = NOTHING_EDIBLE;
516 if (game.prop[BEAR] == BEAR_DEAD)
517 spk = RIDICULOUS_ATTEMPT;
520 game.prop[BEAR] = SITTING_BEAR;
525 } else if (obj == OGRE) {
535 int fill(token_t verb, token_t obj)
536 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
540 int spk = actions[verb].message;
542 spk = ARENT_CARRYING;
543 if (LIQLOC(game.loc) == 0)spk = FILL_INVALID;
544 if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
548 rspeak(SHATTER_VASE);
550 game.fixed[VASE] = -1;
551 return (discard(verb, obj, true));
552 } else if (obj == URN) {
554 if (game.prop[URN] != 0) {
560 if (k == 0 || !HERE(BOTTLE)) {
564 game.place[k] = LOC_NOWHERE;
565 game.prop[BOTTLE] = EMPTY_BOTTLE;
566 if (k == OIL)game.prop[URN] = 1;
567 spk = WATER_URN + game.prop[URN];
570 } else if (obj != 0 && obj != BOTTLE) {
573 } else if (obj == 0 && !HERE(BOTTLE))
576 if (LIQLOC(game.loc) == 0)
578 if (HERE(URN) && game.prop[URN] != 0)
582 if (spk == BOTTLED_WATER) {
583 /* FIXME: Arithmetic on property values */
584 game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
587 game.place[k] = CARRIED;
595 static int find(token_t verb, token_t obj)
596 /* Find. Might be carrying it, or it might be here. Else give caveat. */
598 int spk = actions[verb].message;
600 (LIQUID() == obj && AT(BOTTLE)) ||
601 obj == LIQLOC(game.loc) ||
602 (obj == DWARF && atdwrf(game.loc) > 0))
604 if (game.closed)spk = NEEDED_NEARBY;
605 if (TOTING(obj))spk = ALREADY_CARRYING;
610 static int fly(token_t verb, token_t obj)
611 /* Fly. Snide remarks unless hovering rug is here. */
613 int spk = actions[verb].message;
614 if (obj == INTRANSITIVE) {
615 if (game.prop[RUG] != 2)spk = RUG_NOTHING2;
616 if (!HERE(RUG))spk = FLAP_ARMS;
617 if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
629 if (game.prop[RUG] != 2) {
633 game.oldlc2 = game.oldloc;
634 game.oldloc = game.loc;
635 game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
637 if (game.prop[SAPPH] >= 0)
643 static int inven(void)
644 /* Inventory. If object, treat same as find. Else report on current burden. */
647 for (int i = 1; i <= NOBJECTS; i++) {
648 if (i == BEAR || !TOTING(i))
653 pspeak(i, touch, -1);
663 static int light(token_t verb, token_t obj)
664 /* Light. Applicable only to lamp and urn. */
666 int spk = actions[verb].message;
667 if (obj == INTRANSITIVE) {
668 if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
670 if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
671 if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
675 if (game.prop[URN] == 0) {
688 if (game.limit < 0) {
692 state_change(LAMP, LAMP_BRIGHT);
700 static int listen(void)
701 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
704 int spk = ALL_SILENT;
705 k = locations[game.loc].sound;
708 if (locations[game.loc].loud)
713 for (int i = 1; i <= NOBJECTS; i++) {
714 if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
716 int mi = game.prop[i];
718 mi += 3 * game.blooded;
719 long packed_zzword = token_to_packed(game.zzword);
720 pspeak(i, hear, mi, packed_zzword);
722 /* FIXME: Magic number, sensitive to bird state logic */
723 if (i == BIRD && game.prop[i] == 5)
730 static int lock(token_t verb, token_t obj)
731 /* Lock, unlock, no object given. Assume various things if present. */
733 int spk = actions[verb].message;
734 if (obj == INTRANSITIVE) {
735 spk = NOTHING_LOCKED;
736 if (HERE(CLAM))obj = CLAM;
737 if (HERE(OYSTER))obj = OYSTER;
738 if (AT(DOOR))obj = DOOR;
739 if (AT(GRATE))obj = GRATE;
740 if (obj != 0 && HERE(CHAIN)) return GO_UNKNOWN;
741 if (HERE(CHAIN))obj = CHAIN;
742 if (obj == 0 || obj == INTRANSITIVE) {
748 /* Lock, unlock object. Special stuff for opening clam/oyster
750 if (obj == CLAM || obj == OYSTER)
751 return bivalve(verb, obj);
752 if (obj == DOOR)spk = RUSTY_DOOR;
753 if (obj == DOOR && game.prop[DOOR] == 1)spk = OK_MAN;
754 if (obj == CAGE)spk = NO_LOCK;
755 if (obj == KEYS)spk = CANNOT_UNLOCK;
756 if (obj == GRATE || obj == CHAIN) {
763 if (!game.panic)game.clock2 = PANICTIME;
766 state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
775 static int pour(token_t verb, token_t obj)
776 /* Pour. If no object, or object is bottle, assume contents of bottle.
777 * special tests for pouring water or oil on plant or rusty door. */
779 int spk = actions[verb].message;
780 if (obj == BOTTLE || obj == 0)obj = LIQUID();
781 if (obj == 0) return GO_UNKNOWN;
787 if (obj != OIL && obj != WATER) {
791 if (HERE(URN) && game.prop[URN] == 0)
792 return fill(verb, URN);
793 game.prop[BOTTLE] = EMPTY_BOTTLE;
794 game.place[obj] = LOC_NOWHERE;
796 if (!(AT(PLANT) || AT(DOOR))) {
801 spk = SHAKING_LEAVES;
806 pspeak(PLANT, look, game.prop[PLANT] + 3);
807 game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
808 game.prop[PLANT2] = game.prop[PLANT];
812 if (obj == OIL)game.prop[DOOR] = 1;
813 spk = RUSTED_HINGES + game.prop[DOOR];
819 static int quit(void)
820 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
822 if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
827 static int read(struct command_t command)
828 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
830 if (command.obj == INTRANSITIVE) {
832 for (int i = 1; i <= NOBJECTS; i++) {
833 if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
834 command.obj = command.obj * NOBJECTS + i;
836 if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
840 if (DARK(game.loc)) {
841 rspeak(NO_SEE, command.wd1, command.wd1x);
842 } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
843 game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
844 } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
845 rspeak(actions[command.verb].message);
847 pspeak(command.obj, study, game.prop[command.obj]);
851 static int reservoir(void)
852 /* Z'ZZZ (word gets recomputed at startup; different each game). */
854 if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
855 rspeak(NOTHING_HAPPENS);
858 pspeak(RESER, look, game.prop[RESER] + 1);
859 game.prop[RESER] = 1 - game.prop[RESER];
863 game.oldlc2 = game.loc;
871 static int rub(token_t verb, token_t obj)
872 /* Rub. Yields various snide remarks except for lit urn. */
874 int spk = actions[verb].message;
876 spk = PECULIAR_NOTHING;
877 if (obj == URN && game.prop[URN] == 2) {
879 drop(AMBER, game.loc);
880 game.prop[AMBER] = 1;
882 drop(CAVITY, game.loc);
889 static int say(struct command_t *command)
890 /* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
892 long a = command->wd1, b = command->wd1x;
893 if (command->wd2 > 0) {
896 command->wd1 = command->wd2;
898 //int wd = vocab(command->wd1, -1);
900 packed_to_token(command->wd1, word1);
901 int wd = (int) get_vocab_id(word1);
902 /* FIXME: Magic numbers */
903 if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) {
904 /* FIXME: scribbles on the interpreter's command block */
905 wordclear(&command->wd2);
908 rspeak(OKEY_DOKEY, a, b);
912 static int throw_support(long spk)
919 static int throw (struct command_t *command)
920 /* Throw. Same as discard unless axe. Then same as attack except
921 * ignore bird, and if dwarf is present then one might be killed.
922 * (Only way to do so!) Axe also special for dragon, bear, and
923 * troll. Treasures special for troll. */
925 int spk = actions[command->verb].message;
926 if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))command->obj = ROD2;
927 if (!TOTING(command->obj)) {
931 if (objects[command->obj].is_treasure && AT(TROLL)) {
932 spk = TROLL_SATISFIED;
933 /* Snarf a treasure for the troll. */
934 drop(command->obj, 0);
936 move(TROLL + NOBJECTS, 0);
937 drop(TROLL2, objects[TROLL].plac);
938 drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
943 if (command->obj == FOOD && HERE(BEAR)) {
944 /* But throwing food is another story. */
946 return (feed(command->verb, command->obj));
948 if (command->obj != AXE)
949 return (discard(command->verb, command->obj, false));
951 int i = atdwrf(game.loc);
953 if (AT(DRAGON) && game.prop[DRAGON] == 0)
954 return throw_support(DRAGON_SCALES);
956 return throw_support(TROLL_RETURNS);
958 return throw_support(OGRE_DODGE);
959 else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
960 /* This'll teach him to throw the axe at the bear! */
962 game.fixed[AXE] = -1;
969 return (attack(command));
972 if (randrange(NDWARVES + 1) < game.dflag) {
973 return throw_support(DWARF_DODGES);
975 game.dseen[i] = false;
977 return throw_support((++game.dkill == 1)
978 ? DWARF_SMOKE : KILLED_DWARF);
983 static int wake(token_t verb, token_t obj)
984 /* Wake. Only use is to disturb the dwarves. */
986 if (obj != DWARF || !game.closed) {
987 rspeak(actions[verb].message);
995 static int wave(token_t verb, token_t obj)
996 /* Wave. No effect unless waving rod at fissure or at bird. */
998 int spk = actions[verb].message;
999 if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))spk = ARENT_CARRYING;
1002 (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
1006 /* FIXME: Arithemetic on proprty values */
1008 spk = FREE_FLY + MOD(game.prop[BIRD], 2);
1009 if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
1010 drop(JADE, game.loc);
1011 game.prop[JADE] = 0;
1019 return GO_DWARFWAKE;
1021 if (game.closng || !AT(FISSURE)) {
1025 if (HERE(BIRD))rspeak(spk);
1026 game.prop[FISSURE] = 1 - game.prop[FISSURE];
1027 pspeak(FISSURE, look, 2 - game.prop[FISSURE]);
1032 int action(struct command_t *command)
1033 /* Analyse a verb. Remember what it was, go back for object if second word
1034 * unless verb is "say", which snarfs arbitrary second word.
1037 token_t spk = actions[command->verb].message;
1039 if (command->part == unknown) {
1040 /* Analyse an object word. See if the thing is here, whether
1041 * we've got a verb yet, and so on. Object must be here
1042 * unless verb is "find" or "invent(ory)" (and no new verb
1043 * yet to be analysed). Water and oil are also funny, since
1044 * they are never actually dropped at any location, but might
1045 * be here inside the bottle or urn or as a feature of the
1047 if (HERE(command->obj))
1049 else if (command->obj == GRATE) {
1050 if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
1051 command->obj = DPRSSN;
1052 if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
1053 game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
1054 command->obj = ENTRNC;
1055 } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
1057 else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
1059 else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) {
1062 } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != 0) {
1063 command->obj = PLANT2;
1065 } else if (command->obj == KNIFE && game.knfloc == game.loc) {
1067 spk = KNIVES_VANISH;
1070 } else if (command->obj == ROD && HERE(ROD2)) {
1071 command->obj = ROD2;
1073 } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0)
1076 rspeak(NO_SEE, command->wd1, command->wd1x);
1080 if (command->wd2 > 0)
1082 if (command->verb != 0)
1083 command->part = transitive;
1086 switch (command->part) {
1088 if (command->wd2 > 0 && command->verb != SAY)
1090 if (command->verb == SAY)command->obj = command->wd2;
1091 if (command->obj == 0 || command->obj == INTRANSITIVE) {
1092 /* Analyse an intransitive verb (ie, no object given yet). */
1093 switch (command->verb) {
1095 return vcarry(command->verb, INTRANSITIVE);
1101 return lock(command->verb, INTRANSITIVE);
1104 return (GO_CLEAROBJ);
1107 return lock(command->verb, INTRANSITIVE);
1109 return light(command->verb, INTRANSITIVE);
1111 return extinguish(command->verb, INTRANSITIVE);
1121 return attack(command);
1123 return pour(command->verb, command->obj);
1125 return eat(command->verb, INTRANSITIVE);
1127 return drink(command->verb, command->obj);
1141 return fill(command->verb, command->obj);
1149 return bigwords(command->wd1);
1153 command->obj = INTRANSITIVE;
1154 return read(*command);
1164 return fly(command->verb, INTRANSITIVE);
1170 BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1175 /* Analyse a transitive verb. */
1176 switch (command->verb) {
1178 return vcarry(command->verb, command->obj);
1180 return discard(command->verb, command->obj, false);
1182 return say(command);
1184 return lock(command->verb, command->obj);
1187 return (GO_CLEAROBJ);
1190 return lock(command->verb, command->obj);
1192 return light(command->verb, command->obj);
1194 return extinguish(command->verb, command->obj);
1196 return wave(command->verb, command->obj);
1206 return attack(command);
1208 return pour(command->verb, command->obj);
1210 return eat(command->verb, command->obj);
1212 return drink(command->verb, command->obj);
1214 return rub(command->verb, command->obj);
1216 return throw(command);
1222 return find(command->verb, command->obj);
1224 return find(command->verb, command->obj);
1226 return feed(command->verb, command->obj);
1228 return fill(command->verb, command->obj);
1245 return read(*command);
1247 return vbreak(command->verb, command->obj);
1249 return wake(command->verb, command->obj);
1259 return fly(command->verb, command->obj);
1267 BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
1270 /* Unknown verb, couldn't deduce object - might need hint */
1271 rspeak(WHAT_DO, command->wd1, command->wd1x);
1272 return GO_CHECKHINT;
1274 BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE