-/* Limit visibility of ugly globals. Eventually these should go away. */
-extern long WD1, WD1X, WD2, WD2X;
+static int fill(token_t, token_t);
-/*
- * Action handlers. Eventually we'll do lookup through a method table
- * that calls these.
- */
-
-static int fill(token_t verb, token_t);
-
-static int attack(FILE *input, long verb, token_t obj)
+static int attack(FILE *input, struct command_t *command)
/* Attack. Assume target if unambiguous. "Throw" also links here.
* Attackable objects fall into two categories: enemies (snake,
* dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
* enemies, or no enemies but 2 others. */
{
/* Attack. Assume target if unambiguous. "Throw" also links here.
* Attackable objects fall into two categories: enemies (snake,
* dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
* enemies, or no enemies but 2 others. */
{
- 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);
if (obj == TROLL)spk = ROCKY_TROLL;
if (obj == OGRE)spk = OGRE_DODGE;
if (obj == OGRE && ATDWRF(game.loc) > 0) {
if (obj == TROLL)spk = ROCKY_TROLL;
if (obj == OGRE)spk = OGRE_DODGE;
if (obj == OGRE && ATDWRF(game.loc) > 0) {
* Set game.prop to dead, move dragon to central loc (still
* fixed), move rug there (not fixed), and move him there,
* too. Then do a null motion to get new description. */
* Set game.prop to dead, move dragon to central loc (still
* fixed), move rug there (not fixed), and move him there,
* too. Then do a null motion to get new description. */
- RSPEAK(BARE_HANDS_QUERY);
- GETIN(input, &WD1, &WD1X, &WD2, &WD2X);
- if (WD1 != MAKEWD(25) && WD1 != MAKEWD(250519))
+ rspeak(BARE_HANDS_QUERY);
+ GETIN(input, &command->wd1, &command->wd1x, &command->wd2, &command->wd2x);
+ if (command->wd1 != MAKEWD(WORD_YINIT) && command->wd1 != MAKEWD(WORD_YES))
* word zips the eggs back to the giant room (unless already there). */
{
int k = VOCAB(foo, 3);
int spk = NOTHING_HAPPENS;
if (game.foobar != 1 - k) {
* word zips the eggs back to the giant room (unless already there). */
{
int k = VOCAB(foo, 3);
int spk = NOTHING_HAPPENS;
if (game.foobar != 1 - k) {
/* Blast. No effect unless you've got dynamite, which is a neat trick! */
{
if (game.prop[ROD2] < 0 || !game.closed)
/* Blast. No effect unless you've got dynamite, which is a neat trick! */
{
if (game.prop[ROD2] < 0 || !game.closed)
else {
game.bonus = VICTORY_MESSAGE;
if (game.loc == LOC_NE)
game.bonus = DEFEAT_MESSAGE;
if (HERE(ROD2))
game.bonus = SPLATTER_MESSAGE;
else {
game.bonus = VICTORY_MESSAGE;
if (game.loc == LOC_NE)
game.bonus = DEFEAT_MESSAGE;
if (HERE(ROD2))
game.bonus = SPLATTER_MESSAGE;
- } 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) {
return GO_CLEAROBJ;
}
if (!TOTING(CAGE))spk = CANNOT_CARRY;
if (TOTING(ROD))spk = BIRD_EVADES;
if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
return GO_CLEAROBJ;
}
if (!TOTING(CAGE))spk = CANNOT_CARRY;
if (TOTING(ROD))spk = BIRD_EVADES;
if (spk == CANNOT_CARRY || spk == BIRD_EVADES) {
CARRY(BIRD + CAGE - obj, game.loc);
CARRY(obj, game.loc);
if (obj == BOTTLE && LIQUID() != 0)
CARRY(BIRD + CAGE - obj, game.loc);
CARRY(obj, game.loc);
if (obj == BOTTLE && LIQUID() != 0)
if (game.prop[BEAR] == 0)spk = BEAR_BLOCKS;
if (game.prop[CHAIN] == 0)spk = ALREADY_UNLOCKED;
if (spk != CHAIN_UNLOCKED) {
if (game.prop[BEAR] == 0)spk = BEAR_BLOCKS;
if (game.prop[CHAIN] == 0)spk = ALREADY_UNLOCKED;
if (spk != CHAIN_UNLOCKED) {
if (game.prop[CHAIN] != 0)spk = ALREADY_LOCKED;
if (game.loc != PLAC[CHAIN])spk = NO_LOCKSITE;
if (spk != CHAIN_LOCKED) {
if (game.prop[CHAIN] != 0)spk = ALREADY_LOCKED;
if (game.loc != PLAC[CHAIN])spk = NO_LOCKSITE;
if (spk != CHAIN_LOCKED) {
if (game.closed) return GO_DWARFWAKE;
DESTROY(SNAKE);
/* Set game.prop for use by travel options */
game.prop[SNAKE] = 1;
} else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != 0)) {
if (game.closed) return GO_DWARFWAKE;
DESTROY(SNAKE);
/* Set game.prop for use by travel options */
game.prop[SNAKE] = 1;
} else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != 0)) {
MOVE(TROLL, 0);
MOVE(TROLL + NOBJECTS, 0);
MOVE(TROLL2, PLAC[TROLL]);
MOVE(TROLL, 0);
MOVE(TROLL + NOBJECTS, 0);
MOVE(TROLL2, PLAC[TROLL]);
if (k == obj)obj = BOTTLE;
if (obj == BOTTLE && k != 0)
game.place[k] = LOC_NOWHERE;
if (k == obj)obj = BOTTLE;
if (obj == BOTTLE && k != 0)
game.place[k] = LOC_NOWHERE;
if (obj != BLOOD) {
if (obj != 0 && obj != WATER)spk = RIDICULOUS_ATTEMPT;
if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
if (obj != BLOOD) {
if (obj != 0 && obj != WATER)spk = RIDICULOUS_ATTEMPT;
if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
}
if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
}
game.prop[VASE] = 2;
game.fixed[VASE] = -1;
return (discard(verb, obj, true));
} else if (obj == URN) {
spk = FULL_URN;
if (game.prop[URN] != 0) {
game.prop[VASE] = 2;
game.fixed[VASE] = -1;
return (discard(verb, obj, true));
} else if (obj == URN) {
spk = FULL_URN;
if (game.prop[URN] != 0) {
if (game.prop[RUG] != 2)spk = RUG_NOTHING2;
if (!HERE(RUG))spk = FLAP_ARMS;
if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
if (game.prop[RUG] != 2)spk = RUG_NOTHING2;
if (!HERE(RUG))spk = FLAP_ARMS;
if (spk == RUG_NOTHING2 || spk == FLAP_ARMS) {
if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
}
if (obj == URN) {
if (game.prop[URN] == 0) {
if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
}
if (obj == URN) {
if (game.prop[URN] == 0) {
- PSPEAK(i, OBJSND[i] + game.prop[i]);
+ int mi = game.prop[i];
+ if (i == BIRD)
+ mi += 3 * game.blooded;
+ pspeak(i, hear, mi, game.zzword);
if (obj != 0 && HERE(CHAIN)) return GO_UNKNOWN;
if (HERE(CHAIN))obj = CHAIN;
if (obj == 0 || obj == INTRANSITIVE) {
if (obj != 0 && HERE(CHAIN)) return GO_UNKNOWN;
if (HERE(CHAIN))obj = CHAIN;
if (obj == 0 || obj == INTRANSITIVE) {
game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
game.prop[PLANT2] = game.prop[PLANT];
return GO_MOVE;
game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
game.prop[PLANT2] = game.prop[PLANT];
return GO_MOVE;
- if (HERE(i) && OBJTXT[i] != 0 && game.prop[i] >= 0)
- obj = obj * NOBJECTS + i;
+ if (HERE(i) && object_descriptions[i].texts[0] != NULL && game.prop[i] >= 0)
+ command.obj = command.obj * NOBJECTS + i;
- SETPRM(1, WD1, WD1X);
- RSPEAK(NO_SEE);
- return GO_CLEAROBJ;
- }
- if (OBJTXT[obj] == 0 || game.prop[obj] < 0) {
- RSPEAK(ACTSPK[verb]);
- return GO_CLEAROBJ;
- }
- if (obj == OYSTER && !game.clshnt) {
+ rspeak(NO_SEE, command.wd1, command.wd1x);
+ } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
game.clshnt = YES(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
game.clshnt = YES(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
- return GO_CLEAROBJ;
- }
- PSPEAK(obj, OBJTXT[obj] + game.prop[obj]);
+ } else if (object_descriptions[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
+ rspeak(ACTSPK[command.verb]);
+ } else
+ pspeak(command.obj, study, game.prop[command.obj]);
/* Z'ZZZ (word gets recomputed at startup; different each game). */
{
if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
/* Z'ZZZ (word gets recomputed at startup; different each game). */
{
if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) {
- /* FIXME: ugly use of globals */
- SETPRM(1, WD2, WD2X);
- if (WD2 <= 0)
- SETPRM(1, WD1, WD1X);
- if (WD2 > 0)
- WD1 = WD2;
- int wd = VOCAB(WD1, -1);
+ long a = command->wd1, b = command->wd1x;
+ if (command->wd2 > 0) {
+ a = command->wd2;
+ b = command->wd2x;
+ command->wd1 = command->wd2;
+ }
+ int wd = VOCAB(command->wd1, -1);
/* Throw. Same as discard unless axe. Then same as attack except
* ignore bird, and if dwarf is present then one might be killed.
* (Only way to do so!) Axe also special for dragon, bear, and
* troll. Treasures special for troll. */
{
/* Throw. Same as discard unless axe. Then same as attack except
* ignore bird, and if dwarf is present then one might be killed.
* (Only way to do so!) Axe also special for dragon, bear, and
* troll. Treasures special for troll. */
{
- int spk = ACTSPK[verb];
- if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj = ROD2;
- if (!TOTING(obj)) {
- RSPEAK(spk);
+ int spk = ACTSPK[command->verb];
+ if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))command->obj = ROD2;
+ if (!TOTING(command->obj)) {
+ rspeak(spk);
MOVE(TROLL, 0);
MOVE(TROLL + NOBJECTS, 0);
DROP(TROLL2, PLAC[TROLL]);
DROP(TROLL2 + NOBJECTS, FIXD[TROLL]);
JUGGLE(CHASM);
MOVE(TROLL, 0);
MOVE(TROLL + NOBJECTS, 0);
DROP(TROLL2, PLAC[TROLL]);
DROP(TROLL2 + NOBJECTS, FIXD[TROLL]);
JUGGLE(CHASM);
- if (obj != AXE)
- return (discard(verb, obj, false));
+ if (command->obj != AXE)
+ return (discard(command->verb, command->obj, false));
/* Analyse a verb. Remember what it was, go back for object if second word
* unless verb is "say", which snarfs arbitrary second word.
*/
{
/* Analyse a verb. Remember what it was, go back for object if second word
* unless verb is "say", which snarfs arbitrary second word.
*/
{
/* Analyse an object word. See if the thing is here, whether
* we've got a verb yet, and so on. Object must be here
* unless verb is "find" or "invent(ory)" (and no new verb
/* Analyse an object word. See if the thing is here, whether
* we've got a verb yet, and so on. Object must be here
* unless verb is "find" or "invent(ory)" (and no new verb
* they are never actually dropped at any location, but might
* be here inside the bottle or urn or as a feature of the
* location. */
* they are never actually dropped at any location, but might
* be here inside the bottle or urn or as a feature of the
* location. */
if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
- if (WD2 > 0 && verb != SAY) return (2800);
- if (verb == SAY)obj = WD2;
- if (obj == 0 || obj == INTRANSITIVE) {
+ if (command->wd2 > 0 && command->verb != SAY)
+ return GO_WORD2;
+ if (command->verb == SAY)command->obj = command->wd2;
+ if (command->obj == 0 || command->obj == INTRANSITIVE) {
BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
case unknown:
/* Unknown verb, couldn't deduce object - might need hint */
BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
case unknown:
/* Unknown verb, couldn't deduce object - might need hint */