X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=blobdiff_plain;f=actions.c;h=16d303f10d60c216b128eca5a17af5ec2e9ee2a7;hp=0f7ece8e6c17ed69a3deeb4196204e65ac099ba1;hb=b729853e7a6c49a7f4dbb54a92913710f5a51a69;hpb=2848494a01db9baccf69c9a592ea5a916af84a8a diff --git a/actions.c b/actions.c index 0f7ece8..16d303f 100644 --- a/actions.c +++ b/actions.c @@ -14,9 +14,9 @@ static int attack(FILE *input, struct command_t *command) { vocab_t verb = command->verb; vocab_t obj = command->obj; - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj == 0 || obj == INTRANSITIVE) { - if (ATDWRF(game.loc) > 0) + if (atdwrf(game.loc) > 0) obj = DWARF; if (HERE(SNAKE))obj = obj * NOBJECTS + SNAKE; if (AT(DRAGON) && game.prop[DRAGON] == 0)obj = obj * NOBJECTS + DRAGON; @@ -42,11 +42,11 @@ static int attack(FILE *input, struct command_t *command) return GO_CLEAROBJ; } DESTROY(BIRD); - game.prop[BIRD] = 0; spk = BIRD_DEAD; } else if (obj == VEND) { - pspeak(VEND, game.prop[VEND] + 2); - game.prop[VEND] = 3 - game.prop[VEND]; + bool blocking = (game.prop[VEND] == VEND_BLOCKS); + game.prop[VEND] = blocking ? VEND_UNBLOCKS : VEND_BLOCKS; + rspeak(blocking ? MACHINE_SWINGOUT : MACHINE_SWINGBACK); return GO_CLEAROBJ; } @@ -58,7 +58,7 @@ static int attack(FILE *input, struct command_t *command) if (obj == DRAGON)spk = ALREADY_DEAD; if (obj == TROLL)spk = ROCKY_TROLL; if (obj == OGRE)spk = OGRE_DODGE; - if (obj == OGRE && ATDWRF(game.loc) > 0) { + if (obj == OGRE && atdwrf(game.loc) > 0) { rspeak(spk); rspeak(KNIFE_THROWN); DESTROY(OGRE); @@ -83,18 +83,18 @@ static int attack(FILE *input, struct command_t *command) GETIN(input, &command->wd1, &command->wd1x, &command->wd2, &command->wd2x); if (command->wd1 != MAKEWD(WORD_YINIT) && command->wd1 != MAKEWD(WORD_YES)) return GO_CHECKFOO; - pspeak(DRAGON, 3); + pspeak(DRAGON, look, 3); game.prop[DRAGON] = 1; game.prop[RUG] = 0; - int k = (PLAC[DRAGON] + FIXD[DRAGON]) / 2; - MOVE(DRAGON + NOBJECTS, -1); - MOVE(RUG + NOBJECTS, 0); - MOVE(DRAGON, k); - MOVE(RUG, k); - DROP(BLOOD, k); + int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2; + move(DRAGON + NOBJECTS, -1); + move(RUG + NOBJECTS, 0); + move(DRAGON, k); + move(RUG, k); + drop(BLOOD, k); for (obj = 1; obj <= NOBJECTS; obj++) { - if (game.place[obj] == PLAC[DRAGON] || game.place[obj] == FIXD[DRAGON]) - MOVE(obj, k); + if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd) + move(obj, k); } game.loc = k; return GO_MOVE; @@ -109,7 +109,7 @@ static int bigwords(token_t foo) * Look up foo in section 3 of vocab to determine which word we've got. Last * word zips the eggs back to the giant room (unless already there). */ { - int k = VOCAB(foo, 3); + int k = vocab(foo, 3); int spk = NOTHING_HAPPENS; if (game.foobar != 1 - k) { if (game.foobar != 0 && game.loc == LOC_GIANTROOM)spk = START_OVER; @@ -122,7 +122,7 @@ static int bigwords(token_t foo) return GO_CLEAROBJ; } game.foobar = 0; - if (game.place[EGGS] == PLAC[EGGS] || (TOTING(EGGS) && game.loc == PLAC[EGGS])) { + if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) { rspeak(spk); return GO_CLEAROBJ; } else { @@ -132,9 +132,9 @@ static int bigwords(token_t foo) game.prop[TROLL] = 1; k = 2; if (HERE(EGGS))k = 1; - if (game.loc == PLAC[EGGS])k = 0; - MOVE(EGGS, PLAC[EGGS]); - pspeak(EGGS, k); + if (game.loc == objects[EGGS].plac)k = 0; + move(EGGS, objects[EGGS].plac); + pspeak(EGGS, look, k); return GO_CLEAROBJ; } } @@ -151,8 +151,8 @@ static int bivalve(token_t verb, token_t obj) if (verb == LOCK)spk = HUH_MAN; if (spk == PEARL_FALLS) { DESTROY(CLAM); - DROP(OYSTER, game.loc); - DROP(PEARL, LOC_CULDESAC); + drop(OYSTER, game.loc); + drop(PEARL, LOC_CULDESAC); } rspeak(spk); return GO_CLEAROBJ; @@ -177,10 +177,10 @@ static void blast(void) static int vbreak(token_t verb, token_t obj) /* Break. Only works for mirror in repository and, of course, the vase. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj == MIRROR)spk = TOO_FAR; if (obj == VASE && game.prop[VASE] == 0) { - if (TOTING(VASE))DROP(VASE, game.loc); + if (TOTING(VASE))drop(VASE, game.loc); game.prop[VASE] = 2; game.fixed[VASE] = -1; spk = BREAK_VASE; @@ -203,7 +203,7 @@ static int brief(void) return GO_CLEAROBJ; } -static int carry(token_t verb, token_t obj) +static int vcarry(token_t verb, token_t obj) /* Carry an object. Special cases for bird and cage (if bird in cage, can't * take one without the other). Liquids also special, since they depend on * status of bottle. Also various side effects, etc. */ @@ -213,7 +213,7 @@ static int carry(token_t verb, token_t obj) /* Carry, no object given yet. OK if only one object present. */ if (game.atloc[game.loc] == 0 || game.link[game.atloc[game.loc]] != 0 || - ATDWRF(game.loc) > 0) + atdwrf(game.loc) > 0) return GO_UNKNOWN; obj = game.atloc[game.loc]; } @@ -259,8 +259,8 @@ static int carry(token_t verb, token_t obj) if (game.holdng >= INVLIMIT) { rspeak(spk); return GO_CLEAROBJ; - } else if (obj == BIRD && game.prop[BIRD] != 1 && -1 - game.prop[BIRD] != 1) { - if (game.prop[BIRD] == 2) { + } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) { + if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) { DESTROY(BIRD); rspeak(BIRD_CRAP); return GO_CLEAROBJ; @@ -271,11 +271,11 @@ static int carry(token_t verb, token_t obj) rspeak(spk); return GO_CLEAROBJ; } - game.prop[BIRD] = 1; + game.prop[BIRD] = BIRD_CAGED; } - if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == 1 || -1 - game.prop[BIRD] == 1)) - CARRY(BIRD + CAGE - obj, game.loc); - CARRY(obj, game.loc); + if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1)) + carry(BIRD + CAGE - obj, game.loc); + carry(obj, game.loc); if (obj == BOTTLE && LIQUID() != 0) game.place[LIQUID()] = CARRIED; if (GSTONE(obj) && game.prop[obj] != 0) { @@ -305,13 +305,13 @@ static int chain(token_t verb) } else { spk = CHAIN_LOCKED; if (game.prop[CHAIN] != 0)spk = ALREADY_LOCKED; - if (game.loc != PLAC[CHAIN])spk = NO_LOCKSITE; + if (game.loc != objects[CHAIN].plac)spk = NO_LOCKSITE; if (spk != CHAIN_LOCKED) { rspeak(spk); return GO_CLEAROBJ; } game.prop[CHAIN] = 2; - if (TOTING(CHAIN))DROP(CHAIN, game.loc); + if (TOTING(CHAIN))drop(CHAIN, game.loc); game.fixed[CHAIN] = -1; } rspeak(spk); @@ -323,7 +323,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it) * bird (might attack snake or dragon) and cage (might contain bird) and vase. * Drop coins at vending machine for extra batteries. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (!just_do_it) { if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj = ROD2; if (!TOTING(obj)) { @@ -350,34 +350,33 @@ static int discard(token_t verb, token_t obj, bool just_do_it) if (spk != RUG_WIGGLES) { int k = 2 - game.prop[RUG]; game.prop[RUG] = k; - if (k == 2) k = PLAC[SAPPH]; - MOVE(RUG + NOBJECTS, k); + if (k == 2) k = objects[SAPPH].plac; + move(RUG + NOBJECTS, k); } } } else if (obj == COINS && HERE(VEND)) { DESTROY(COINS); - DROP(BATTERY, game.loc); - pspeak(BATTERY, FRESH_BATTERIES); + drop(BATTERY, game.loc); + pspeak(BATTERY, look, FRESH_BATTERIES); return GO_CLEAROBJ; } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) { rspeak(BIRD_BURNT); DESTROY(BIRD); - game.prop[BIRD] = 0; return GO_CLEAROBJ; } else if (obj == BEAR && AT(TROLL)) { rspeak(TROLL_SCAMPERS); - MOVE(TROLL, 0); - MOVE(TROLL + NOBJECTS, 0); - MOVE(TROLL2, PLAC[TROLL]); - MOVE(TROLL2 + NOBJECTS, FIXD[TROLL]); - JUGGLE(CHASM); + move(TROLL, 0); + move(TROLL + NOBJECTS, 0); + move(TROLL2, objects[TROLL].plac); + move(TROLL2 + NOBJECTS, objects[TROLL].fixd); + juggle(CHASM); game.prop[TROLL] = 2; - } else if (obj != VASE || game.loc == PLAC[PILLOW]) { + } else if (obj != VASE || game.loc == objects[PILLOW].plac) { rspeak(OK_MAN); } else { game.prop[VASE] = 2; if (AT(PILLOW))game.prop[VASE] = 0; - pspeak(VASE, game.prop[VASE] + 1); + pspeak(VASE, look, game.prop[VASE] + 1); if (game.prop[VASE] != 0)game.fixed[VASE] = -1; } } @@ -385,11 +384,13 @@ static int discard(token_t verb, token_t obj, bool just_do_it) if (k == obj)obj = BOTTLE; if (obj == BOTTLE && k != 0) game.place[k] = LOC_NOWHERE; - if (obj == CAGE && game.prop[BIRD] == 1)DROP(BIRD, game.loc); - DROP(obj, game.loc); + if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) + drop(BIRD, game.loc); + drop(obj, game.loc); if (obj != BIRD) return GO_CLEAROBJ; - game.prop[BIRD] = 0; - if (FOREST(game.loc))game.prop[BIRD] = 2; + game.prop[BIRD] = BIRD_UNCAGED; + if (FOREST(game.loc)) + game.prop[BIRD] = BIRD_FOREST_UNCAGED; return GO_CLEAROBJ; } @@ -397,7 +398,7 @@ static int drink(token_t verb, token_t obj) /* Drink. If no object, assume water and look for it here. If water is in * the bottle, drink that, else must be at a water loc, so drink stream. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE))) return GO_UNKNOWN; if (obj != BLOOD) { @@ -410,7 +411,7 @@ static int drink(token_t verb, token_t obj) } else { DESTROY(BLOOD); game.prop[DRAGON] = 2; - OBJSND[BIRD] = OBJSND[BIRD] + 3; + game.blooded = true; spk = HEAD_BUZZES; } rspeak(spk); @@ -421,7 +422,7 @@ static int eat(token_t verb, token_t obj) /* Eat. Intransitive: assume food if present, else ask what. Transitive: food * ok, some things lose appetite, rest are ridiculous. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj == INTRANSITIVE) { if (!HERE(FOOD)) return GO_UNKNOWN; @@ -443,9 +444,10 @@ static int eat(token_t verb, token_t obj) static int extinguish(token_t verb, int obj) /* Extinguish. Lamp, urn, dragon/volcano (nice try). */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj == INTRANSITIVE) { - if (HERE(LAMP) && game.prop[LAMP] == 1)obj = LAMP; + if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT) + obj = LAMP; if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN; if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN; } @@ -454,7 +456,7 @@ static int extinguish(token_t verb, int obj) game.prop[URN] = game.prop[URN] / 2; spk = URN_DARK; } else if (obj == LAMP) { - game.prop[LAMP] = 0; + game.prop[LAMP] = LAMP_DARK; rspeak(LAMP_OFF); spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE; } else if (obj == DRAGON || obj == VOLCANO) @@ -467,7 +469,7 @@ static int feed(token_t verb, token_t obj) /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him * mad. Bear, special. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj == BIRD) { rspeak(BIRD_PINING); return GO_CLEAROBJ; @@ -477,7 +479,6 @@ static int feed(token_t verb, token_t obj) if (obj == TROLL)spk = TROLL_VICES; if (obj == SNAKE && !game.closed && HERE(BIRD)) { DESTROY(BIRD); - game.prop[BIRD] = 0; spk = BIRD_DEVOURED; } } else if (obj == DWARF) { @@ -510,7 +511,7 @@ int fill(token_t verb, token_t obj) * is nasty.) */ { int k; - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj == VASE) { spk = ARENT_CARRYING; if (LIQLOC(game.loc) == 0)spk = FILL_INVALID; @@ -568,11 +569,11 @@ int fill(token_t verb, token_t obj) static int find(token_t verb, token_t obj) /* Find. Might be carrying it, or it might be here. Else give caveat. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (AT(obj) || (LIQUID() == obj && AT(BOTTLE)) || obj == LIQLOC(game.loc) || - (obj == DWARF && ATDWRF(game.loc) > 0)) + (obj == DWARF && atdwrf(game.loc) > 0)) spk = YOU_HAVEIT; if (game.closed)spk = NEEDED_NEARBY; if (TOTING(obj))spk = ALREADY_CARRYING; @@ -583,7 +584,7 @@ static int find(token_t verb, token_t obj) static int fly(token_t verb, token_t obj) /* Fly. Snide remarks unless hovering rug is here. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj == INTRANSITIVE) { if (game.prop[RUG] != 2)spk = RUG_NOTHING2; if (!HERE(RUG))spk = FLAP_ARMS; @@ -623,7 +624,7 @@ static int inven(void) if (spk == NO_CARRY) rspeak(NOW_HOLDING); game.blklin = false; - pspeak(i, -1); + pspeak(i, touch, -1); game.blklin = true; spk = NO_MESSAGE; } @@ -636,9 +637,10 @@ static int inven(void) static int light(token_t verb, token_t obj) /* Light. Applicable only to lamp and urn. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj == INTRANSITIVE) { - if (HERE(LAMP) && game.prop[LAMP] == 0 && game.limit >= 0)obj = LAMP; + if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) + obj = LAMP; if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN; if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN; } @@ -661,7 +663,7 @@ static int light(token_t verb, token_t obj) rspeak(spk); return GO_CLEAROBJ; } - game.prop[LAMP] = 1; + game.prop[LAMP] = LAMP_BRIGHT; rspeak(LAMP_ON); if (game.wzdark) return GO_TOP; @@ -684,11 +686,15 @@ static int listen(void) spk = NO_MESSAGE; } for (int i = 1; i <= NOBJECTS; i++) { - if (!HERE(i) || OBJSND[i] == 0 || game.prop[i] < 0) + if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0) continue; - pspeak(i, OBJSND[i] + game.prop[i], game.zzword); + int mi = game.prop[i]; + if (i == BIRD) + mi += 3 * game.blooded; + pspeak(i, hear, mi, game.zzword); spk = NO_MESSAGE; - if (i == BIRD && OBJSND[i] + game.prop[i] == 8) + /* FIXME: Magic number, sensitive to bird state logic */ + if (i == BIRD && game.prop[i] == 5) DESTROY(BIRD); } rspeak(spk); @@ -698,7 +704,7 @@ static int listen(void) static int lock(token_t verb, token_t obj) /* Lock, unlock, no object given. Assume various things if present. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj == INTRANSITIVE) { spk = NOTHING_LOCKED; if (HERE(CLAM))obj = CLAM; @@ -731,7 +737,7 @@ static int lock(token_t verb, token_t obj) if (!game.panic)game.clock2 = PANICTIME; game.panic = true; } else { - game.prop[GRATE] = (verb == LOCK) ? 0 : 1; + game.prop[GRATE] = (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN; spk = game.prop[GRATE] ? GRATE_UNLOCKED : GRATE_LOCKED; } } @@ -744,7 +750,7 @@ static int pour(token_t verb, token_t obj) /* Pour. If no object, or object is bottle, assume contents of bottle. * special tests for pouring water or oil on plant or rusty door. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj == BOTTLE || obj == 0)obj = LIQUID(); if (obj == 0) return GO_UNKNOWN; if (!TOTING(obj)) { @@ -771,7 +777,7 @@ static int pour(token_t verb, token_t obj) rspeak(spk); return GO_CLEAROBJ; } - pspeak(PLANT, game.prop[PLANT] + 3); + pspeak(PLANT, look, game.prop[PLANT] + 3); game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3); game.prop[PLANT2] = game.prop[PLANT]; return GO_MOVE; @@ -787,7 +793,7 @@ static int pour(token_t verb, token_t obj) static int quit(void) /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */ { - if (YES(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) + if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) terminate(quitgame); return GO_CLEAROBJ; } @@ -798,7 +804,7 @@ static int read(struct command_t command) if (command.obj == INTRANSITIVE) { command.obj = 0; for (int i = 1; i <= NOBJECTS; i++) { - if (HERE(i) && OBJTXT[i] != 0 && game.prop[i] >= 0) + if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0) command.obj = command.obj * NOBJECTS + i; } if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc)) @@ -807,12 +813,12 @@ static int read(struct command_t command) if (DARK(game.loc)) { rspeak(NO_SEE, command.wd1, command.wd1x); - } else if (OBJTXT[command.obj] == 0 || game.prop[command.obj] < 0) { - rspeak(ACTSPK[command.verb]); - } else if (command.obj == OYSTER && !game.clshnt) { - game.clshnt = YES(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]); + } else if (command.obj == OYSTER && !game.clshnt && game.closed) { + game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]); + } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) { + rspeak(actions[command.verb].message); } else - pspeak(command.obj, OBJTXT[command.obj] + game.prop[command.obj]); + pspeak(command.obj, study, game.prop[command.obj]); return GO_CLEAROBJ; } @@ -823,7 +829,7 @@ static int reservoir(void) rspeak(NOTHING_HAPPENS); return GO_CLEAROBJ; } else { - pspeak(RESER, game.prop[RESER] + 1); + pspeak(RESER, look, game.prop[RESER] + 1); game.prop[RESER] = 1 - game.prop[RESER]; if (AT(RESER)) return GO_CLEAROBJ; @@ -839,15 +845,15 @@ static int reservoir(void) static int rub(token_t verb, token_t obj) /* Rub. Yields various snide remarks except for lit urn. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if (obj != LAMP) spk = PECULIAR_NOTHING; if (obj == URN && game.prop[URN] == 2) { DESTROY(URN); - DROP(AMBER, game.loc); + drop(AMBER, game.loc); game.prop[AMBER] = 1; --game.tally; - DROP(CAVITY, game.loc); + drop(CAVITY, game.loc); spk = URN_GENIES; } rspeak(spk); @@ -863,7 +869,7 @@ static int say(struct command_t *command) b = command->wd2x; command->wd1 = command->wd2; } - int wd = VOCAB(command->wd1, -1); + int wd = vocab(command->wd1, -1); /* FIXME: Magic numbers */ if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) { /* FIXME: scribbles on the interpreter's command block */ @@ -877,7 +883,7 @@ static int say(struct command_t *command) static int throw_support(long spk) { rspeak(spk); - DROP(AXE, game.loc); + drop(AXE, game.loc); return GO_MOVE; } @@ -887,21 +893,21 @@ static int throw (FILE *cmdin, struct command_t *command) * (Only way to do so!) Axe also special for dragon, bear, and * troll. Treasures special for troll. */ { - int spk = ACTSPK[command->verb]; + int spk = actions[command->verb].message; if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))command->obj = ROD2; if (!TOTING(command->obj)) { rspeak(spk); return GO_CLEAROBJ; } - if (command->obj >= MINTRS && command->obj <= MAXTRS && AT(TROLL)) { + if (objects[command->obj].is_treasure && AT(TROLL)) { spk = TROLL_SATISFIED; /* Snarf a treasure for the troll. */ - DROP(command->obj, 0); - MOVE(TROLL, 0); - MOVE(TROLL + NOBJECTS, 0); - DROP(TROLL2, PLAC[TROLL]); - DROP(TROLL2 + NOBJECTS, FIXD[TROLL]); - JUGGLE(CHASM); + drop(command->obj, 0); + move(TROLL, 0); + move(TROLL + NOBJECTS, 0); + drop(TROLL2, objects[TROLL].plac); + drop(TROLL2 + NOBJECTS, objects[TROLL].fixd); + juggle(CHASM); rspeak(spk); return GO_CLEAROBJ; } @@ -913,7 +919,7 @@ static int throw (FILE *cmdin, struct command_t *command) if (command->obj != AXE) return (discard(command->verb, command->obj, false)); else { - int i = ATDWRF(game.loc); + int i = atdwrf(game.loc); if (i <= 0) { if (AT(DRAGON) && game.prop[DRAGON] == 0) return throw_support(DRAGON_SCALES); @@ -923,10 +929,10 @@ static int throw (FILE *cmdin, struct command_t *command) return throw_support(OGRE_DODGE); else if (HERE(BEAR) && game.prop[BEAR] == 0) { /* This'll teach him to throw the axe at the bear! */ - DROP(AXE, game.loc); + drop(AXE, game.loc); game.fixed[AXE] = -1; game.prop[AXE] = 1; - JUGGLE(BEAR); + juggle(BEAR); rspeak(AXE_LOST); return GO_CLEAROBJ; } @@ -949,7 +955,7 @@ static int wake(token_t verb, token_t obj) /* Wake. Only use is to disturb the dwarves. */ { if (obj != DWARF || !game.closed) { - rspeak(ACTSPK[verb]); + rspeak(actions[verb].message); return GO_CLEAROBJ; } else { rspeak(PROD_DWARF); @@ -960,7 +966,7 @@ static int wake(token_t verb, token_t obj) static int wave(token_t verb, token_t obj) /* Wave. No effect unless waving rod at fissure or at bird. */ { - int spk = ACTSPK[verb]; + int spk = actions[verb].message; if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))spk = ARENT_CARRYING; if (obj != ROD || !TOTING(obj) || @@ -968,9 +974,11 @@ static int wave(token_t verb, token_t obj) rspeak(spk); return GO_CLEAROBJ; } - if (HERE(BIRD))spk = FREE_FLY + MOD(game.prop[BIRD], 2); + /* FIXME: Arithemetic on proprty values */ + if (HERE(BIRD)) + spk = FREE_FLY + MOD(game.prop[BIRD], 2); if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) { - DROP(JADE, game.loc); + drop(JADE, game.loc); game.prop[JADE] = 0; --game.tally; spk = NECKLACE_FLY; @@ -987,7 +995,7 @@ static int wave(token_t verb, token_t obj) } if (HERE(BIRD))rspeak(spk); game.prop[FISSURE] = 1 - game.prop[FISSURE]; - pspeak(FISSURE, 2 - game.prop[FISSURE]); + pspeak(FISSURE, look, 2 - game.prop[FISSURE]); return GO_CLEAROBJ; } } @@ -997,7 +1005,7 @@ int action(FILE *input, struct command_t *command) * unless verb is "say", which snarfs arbitrary second word. */ { - token_t spk = ACTSPK[command->verb]; + token_t spk = actions[command->verb].message; if (command->part == unknown) { /* Analyse an object word. See if the thing is here, whether @@ -1015,7 +1023,7 @@ int action(FILE *input, struct command_t *command) if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD || game.loc == LOC_BIRD || game.loc == LOC_PITTOP) command->obj = ENTRNC; - } else if (command->obj == DWARF && ATDWRF(game.loc) > 0) + } else if (command->obj == DWARF && atdwrf(game.loc) > 0) /* FALL THROUGH */; else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc)) /* FALL THROUGH */; @@ -1033,7 +1041,7 @@ int action(FILE *input, struct command_t *command) } else if (command->obj == ROD && HERE(ROD2)) { command->obj = ROD2; /* FALL THROUGH */; - } else if ((command->verb == FIND || command->verb == INVENT) && command->wd2 <= 0) + } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0) /* FALL THROUGH */; else { rspeak(NO_SEE, command->wd1, command->wd1x); @@ -1053,185 +1061,187 @@ int action(FILE *input, struct command_t *command) if (command->verb == SAY)command->obj = command->wd2; if (command->obj == 0 || command->obj == INTRANSITIVE) { /* Analyse an intransitive verb (ie, no object given yet). */ - switch (command->verb - 1) { - case 0: /* CARRY */ - return carry(command->verb, INTRANSITIVE); - case 1: /* DROP */ + switch (command->verb) { + case CARRY: + return vcarry(command->verb, INTRANSITIVE); + case DROP: return GO_UNKNOWN; - case 2: /* SAY */ + case SAY: return GO_UNKNOWN; - case 3: /* UNLOC */ + case UNLOCK: return lock(command->verb, INTRANSITIVE); - case 4: { /* NOTHI */ + case NOTHING: { rspeak(OK_MAN); return (GO_CLEAROBJ); } - case 5: /* LOCK */ + case LOCK: return lock(command->verb, INTRANSITIVE); - case 6: /* LIGHT */ + case LIGHT: return light(command->verb, INTRANSITIVE); - case 7: /* EXTIN */ + case EXTINGUISH: return extinguish(command->verb, INTRANSITIVE); - case 8: /* WAVE */ + case WAVE: return GO_UNKNOWN; - case 9: /* CALM */ + case TAME: return GO_UNKNOWN; - case 10: { /* WALK */ + case GO: { rspeak(spk); return GO_CLEAROBJ; } - case 11: /* ATTAC */ + case ATTACK: return attack(input, command); - case 12: /* POUR */ + case POUR: return pour(command->verb, command->obj); - case 13: /* EAT */ + case EAT: return eat(command->verb, INTRANSITIVE); - case 14: /* DRINK */ + case DRINK: return drink(command->verb, command->obj); - case 15: /* RUB */ + case RUB: return GO_UNKNOWN; - case 16: /* TOSS */ + case THROW: return GO_UNKNOWN; - case 17: /* QUIT */ + case QUIT: return quit(); - case 18: /* FIND */ + case FIND: return GO_UNKNOWN; - case 19: /* INVEN */ + case INVENTORY: return inven(); - case 20: /* FEED */ + case FEED: return GO_UNKNOWN; - case 21: /* FILL */ + case FILL: return fill(command->verb, command->obj); - case 22: /* BLAST */ + case BLAST: blast(); return GO_CLEAROBJ; - case 23: /* SCOR */ + case SCORE: score(scoregame); return GO_CLEAROBJ; - case 24: /* FOO */ + case GIANTWORDS: return bigwords(command->wd1); - case 25: /* BRIEF */ + case BRIEF: return brief(); - case 26: /* READ */ + case READ: command->obj = INTRANSITIVE; return read(*command); - case 27: /* BREAK */ + case BREAK: return GO_UNKNOWN; - case 28: /* WAKE */ + case WAKE: return GO_UNKNOWN; - case 29: /* SUSP */ + case SAVE: return suspend(); - case 30: /* RESU */ + case RESUME: return resume(); - case 31: /* FLY */ + case FLY: return fly(command->verb, INTRANSITIVE); - case 32: /* LISTE */ + case LISTEN: return listen(); - case 33: /* ZZZZ */ + case PART: return reservoir(); + default: + BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE } - BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); } /* FALLTHRU */ case transitive: /* Analyse a transitive verb. */ - switch (command->verb - 1) { - case 0: /* CARRY */ - return carry(command->verb, command->obj); - case 1: /* DROP */ + switch (command->verb) { + case CARRY: + return vcarry(command->verb, command->obj); + case DROP: return discard(command->verb, command->obj, false); - case 2: /* SAY */ + case SAY: return say(command); - case 3: /* UNLOC */ + case UNLOCK: return lock(command->verb, command->obj); - case 4: { /* NOTHI */ + case NOTHING: { rspeak(OK_MAN); return (GO_CLEAROBJ); } - case 5: /* LOCK */ + case LOCK: return lock(command->verb, command->obj); - case 6: /* LIGHT */ + case LIGHT: return light(command->verb, command->obj); - case 7: /* EXTI */ + case EXTINGUISH: return extinguish(command->verb, command->obj); - case 8: /* WAVE */ + case WAVE: return wave(command->verb, command->obj); - case 9: { /* CALM */ + case TAME: { rspeak(spk); return GO_CLEAROBJ; } - case 10: { /* WALK */ + case GO: { rspeak(spk); return GO_CLEAROBJ; } - case 11: /* ATTAC */ + case ATTACK: return attack(input, command); - case 12: /* POUR */ + case POUR: return pour(command->verb, command->obj); - case 13: /* EAT */ + case EAT: return eat(command->verb, command->obj); - case 14: /* DRINK */ + case DRINK: return drink(command->verb, command->obj); - case 15: /* RUB */ + case RUB: return rub(command->verb, command->obj); - case 16: /* TOSS */ + case THROW: return throw(input, command); - case 17: { /* QUIT */ + case QUIT: { rspeak(spk); return GO_CLEAROBJ; } - case 18: /* FIND */ + case FIND: return find(command->verb, command->obj); - case 19: /* INVEN */ + case INVENTORY: return find(command->verb, command->obj); - case 20: /* FEED */ + case FEED: return feed(command->verb, command->obj); - case 21: /* FILL */ + case FILL: return fill(command->verb, command->obj); - case 22: /* BLAST */ + case BLAST: blast(); return GO_CLEAROBJ; - case 23: { /* SCOR */ + case SCORE: { rspeak(spk); return GO_CLEAROBJ; } - case 24: { /* FOO */ + case GIANTWORDS: { rspeak(spk); return GO_CLEAROBJ; } - case 25: { /* BRIEF */ + case BRIEF: { rspeak(spk); return GO_CLEAROBJ; } - case 26: /* READ */ + case READ: return read(*command); - case 27: /* BREAK */ + case BREAK: return vbreak(command->verb, command->obj); - case 28: /* WAKE */ + case WAKE: return wake(command->verb, command->obj); - case 29: { /* SUSP */ + case SAVE: { rspeak(spk); return GO_CLEAROBJ; } - case 30: { /* RESU */ + case RESUME: { rspeak(spk); return GO_CLEAROBJ; } - case 31: /* FLY */ + case FLY: return fly(command->verb, command->obj); - case 32: { /* LISTE */ + case LISTEN: { rspeak(spk); return GO_CLEAROBJ; } - case 33: /* ZZZZ */ + case PART: return reservoir(); - } - BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); + default: + BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE + } case unknown: /* Unknown verb, couldn't deduce object - might need hint */ rspeak(WHAT_DO, command->wd1, command->wd1x); return GO_CHECKHINT; default: - BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); + BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE } }