#include "newdb.h"
/* Limit visibility of ugly globals. Eventually these should go away. */
-extern long WD1, WD1X, WD2, WD2X;
+extern token_t WD1, WD1X, WD2, WD2X;
-/*
- * Action handlers. Eventually we'll do lookup through a method table
- * that calls these.
- */
-
-static int fill(token_t verb, token_t);
+static int fill(token_t, token_t);
-static int attack(FILE *input, long verb, token_t obj)
+static int attack(FILE *input, token_t verb, token_t obj)
/* 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
* 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))
+ if (WD1 != MAKEWD(WORD_YINIT) && WD1 != MAKEWD(WORD_YES))
return GO_CHECKFOO;
PSPEAK(DRAGON, 3);
game.prop[DRAGON] = 1;
return GO_CLEAROBJ;
}
-static int bigwords(long foo)
+static int bigwords(token_t foo)
/* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
* Look up WD1 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). */
} else {
/* Bring back troll if we steal the eggs back from him before
* crossing. */
- if (game.place[EGGS] == 0 && game.place[TROLL] == 0 && game.prop[TROLL] == 0)
+ if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == 0)
game.prop[TROLL] = 1;
k = 2;
if (HERE(EGGS))k = 1;
int k = LIQUID();
if (k == obj)obj = BOTTLE;
if (obj == BOTTLE && k != 0)
- game.place[k] = NOWHERE;
+ game.place[k] = LOC_NOWHERE;
if (obj == CAGE && game.prop[BIRD] == 1)DROP(BIRD, game.loc);
DROP(obj, game.loc);
if (obj != BIRD) return GO_CLEAROBJ;
if (obj != 0 && obj != WATER)spk = RIDICULOUS_ATTEMPT;
if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
game.prop[BOTTLE] = 1;
- game.place[WATER] = NOWHERE;
+ game.place[WATER] = LOC_NOWHERE;
spk = BOTTLE_EMPTY;
}
} else {
RSPEAK(spk);
return GO_CLEAROBJ;
}
- game.place[k] = NOWHERE;
+ game.place[k] = LOC_NOWHERE;
game.prop[BOTTLE] = 1;
if (k == OIL)game.prop[URN] = 1;
spk = WATER_URN + game.prop[URN];
obj == LIQLOC(game.loc) ||
(obj == DWARF && ATDWRF(game.loc) > 0))
spk = YOU_HAVEIT;
- if (game.closed)spk = NEEDED_NEreplace;
+ if (game.closed)spk = NEEDED_NEARBY;
if (TOTING(obj))spk = ALREADY_CARRYING;
RSPEAK(spk);
return GO_CLEAROBJ;
if (HERE(URN) && game.prop[URN] == 0)
return fill(verb, URN);
game.prop[BOTTLE] = 1;
- game.place[obj] = NOWHERE;
+ game.place[obj] = LOC_NOWHERE;
spk = GROUND_WET;
if (!(AT(PLANT) || AT(DOOR))) {
RSPEAK(spk);
static int quit(void)
/* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
{
- if (YES(REALLY_QUIT, OK_MAN, OK_MAN))
+ if (YES(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
terminate(quitgame);
return GO_CLEAROBJ;
}
static int read(token_t verb, token_t obj)
/* Read. Print stuff based on objtxt. Oyster (?) is special case. */
{
- int spk = ACTSPK[verb];
if (obj == INTRANSITIVE) {
obj = 0;
for (int i = 1; i <= NOBJECTS; i++) {
return GO_CLEAROBJ;
}
if (OBJTXT[obj] == 0 || game.prop[obj] < 0) {
- RSPEAK(spk);
+ RSPEAK(ACTSPK[verb]);
return GO_CLEAROBJ;
}
if (obj == OYSTER && !game.clshnt) {
- game.clshnt = YES(CLUE_QUERY, WAYOUT_CLUE, 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]);
}
if (obj != AXE)
return (discard(verb, obj, false));
- int i = ATDWRF(game.loc);
- if (i <= 0) {
- if (AT(DRAGON) && game.prop[DRAGON] == 0)
- return throw_support(DRAGON_SCALES);
- if (AT(TROLL))
- return throw_support(TROLL_RETURNS);
- else if (AT(OGRE))
- 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);
- game.fixed[AXE] = -1;
- game.prop[AXE] = 1;
- JUGGLE(BEAR);
- RSPEAK(AXE_LOST);
- return GO_CLEAROBJ;
+ else {
+ int i = ATDWRF(game.loc);
+ if (i <= 0) {
+ if (AT(DRAGON) && game.prop[DRAGON] == 0)
+ return throw_support(DRAGON_SCALES);
+ if (AT(TROLL))
+ return throw_support(TROLL_RETURNS);
+ else if (AT(OGRE))
+ 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);
+ game.fixed[AXE] = -1;
+ game.prop[AXE] = 1;
+ JUGGLE(BEAR);
+ RSPEAK(AXE_LOST);
+ return GO_CLEAROBJ;
+ }
+ return (attack(cmdin, verb, 0));
}
- return (attack(cmdin, verb, 0));
- }
- if (randrange(NDWARVES + 1) < game.dflag) {
- return throw_support(DWARF_DODGES);
+ if (randrange(NDWARVES + 1) < game.dflag) {
+ return throw_support(DWARF_DODGES);
+ } else {
+ game.dseen[i] = false;
+ game.dloc[i] = 0;
+ return throw_support((++game.dkill == 1)
+ ? DWARF_SMOKE : KILLED_DWARF);
+ }
}
- game.dseen[i] = false;
- game.dloc[i] = 0;
- return throw_support((++game.dkill == 1) ? DWARF_SMOKE : KILLED_DWARF);
}
static int wake(token_t verb, token_t obj)
}
}
-int action(FILE *input, enum speechpart part, long verb, token_t obj)
+int action(FILE *input, enum speechpart part, token_t verb, token_t obj)
/* Analyse a verb. Remember what it was, go back for object if second word
* unless verb is "say", which snarfs arbitrary second word.
*/
switch (part) {
case intransitive:
- if (WD2 > 0 && verb != SAY) return (2800);
+ if (WD2 > 0 && verb != SAY)
+ return GO_WORD2;
if (verb == SAY)obj = WD2;
if (obj == 0 || obj == INTRANSITIVE) {
/* Analyse an intransitive verb (ie, no object given yet). */