} 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];
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 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) {
return GO_MOVE;
}
-static int throw(FILE *cmdin, long verb, token_t obj)
+static int throw (FILE *cmdin, long verb, token_t obj)
/* 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
if (obj != AXE)
return (discard(verb, obj, false));
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));
- }
+ 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));
+ }
- 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);
- }
+ 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);
+ }
}
}
#define INVLIMIT 7 /* inverntory limit (# of objects) */
#define INTRANSITIVE -1 /* illegal object number */
#define SPECIALBASE 300 /* base number of special rooms */
+#define GAMELIMIT 330 /* base limit of turns */
+#define NOVICELIMIT 1000 /* limit of turns for novice */
#define WARNTIME 30 /* late game starts at game.limit-this */
#define PANICTIME 15 /* time left after closing */
#define BATTERYLIFE 2500 /* turn limit increment from batteries */
long turns;
long wzdark;
long zzword;
- long abbrev[LOCSIZ+1];
- long atloc[LOCSIZ+1];
- long dseen[NDWARVES+1];
- long dloc[NDWARVES+1];
- long odloc[NDWARVES+1];
- long fixed[NOBJECTS+1];
- long link[NOBJECTS*2 + 1];
- long place[NOBJECTS+1];
- long hinted[HNTSIZ+1];
- long hintlc[HNTSIZ+1];
- long prop[NOBJECTS+1];
+ long abbrev[LOCSIZ + 1];
+ long atloc[LOCSIZ + 1];
+ long dseen[NDWARVES + 1];
+ long dloc[NDWARVES + 1];
+ long odloc[NDWARVES + 1];
+ long fixed[NOBJECTS + 1];
+ long link[NOBJECTS * 2 + 1];
+ long place[NOBJECTS + 1];
+ long hinted[HNTSIZ + 1];
+ long hintlc[HNTSIZ + 1];
+ long prop[NOBJECTS + 1];
};
extern struct game_t game;
extern long LNLENG, LNPOSN, PARMS[];
-extern char rawbuf[LINESIZE], INLINE[LINESIZE+1];
+extern char rawbuf[LINESIZE], INLINE[LINESIZE + 1];
extern const char ascii_to_advent[];
extern const char advent_to_ascii[];
extern FILE *logfp;
extern char* xstrdup(const char*);
extern void packed_to_token(long, char token[]);
extern void speak(const char*);
-extern void PSPEAK(vocab_t,int);
+extern void PSPEAK(vocab_t, int);
extern void RSPEAK(vocab_t);
-extern void SETPRM(long,long,long);
-extern bool GETIN(FILE *,token_t*,token_t*,token_t*,token_t*);
+extern void SETPRM(long, long, long);
+extern bool GETIN(FILE *, token_t*, token_t*, token_t*, token_t*);
extern void echo_input(FILE*, char*, char*);
extern char* get_input(void);
extern bool YES(const char*, const char*, const char*);
-extern long GETTXT(bool,bool,bool);
+extern long GETTXT(bool, bool, bool);
extern token_t MAKEWD(long);
-extern long VOCAB(long,long);
+extern long VOCAB(long, long);
extern void JUGGLE(long);
-extern void MOVE(long,long);
-extern long PUT(long,long,long);
-extern void CARRY(long,long);
-extern void DROP(long,long);
+extern void MOVE(long, long);
+extern long PUT(long, long, long);
+extern void CARRY(long, long);
+extern void DROP(long, long);
extern long ATDWRF(long);
extern long SETBIT(long);
-extern bool TSTBIT(long,int);
-extern long RNDVOC(long,long);
+extern bool TSTBIT(long, int);
+extern long RNDVOC(long, long);
extern bool MAPLIN(FILE *);
extern void DATIME(long*, long*);
* PCT(N) = true N% of the time (N integer from 0 to 100)
* TOTING(OBJ) = true if the OBJ is being carried */
-#define DESTROY(N) MOVE(N, NOWHERE)
+#define DESTROY(N) MOVE(N, LOC_NOWHERE)
#define MOD(N,M) ((N) % (M))
#define TOTING(OBJ) (game.place[OBJ] == CARRIED)
#define AT(OBJ) (game.place[OBJ] == game.loc || game.fixed[OBJ] == game.loc)
#define OUTSID(LOC) ((LOC) <= LOC_GRATE || FOREST(LOC) || (LOC) == PLAC[SAPPH] || (LOC) == LOC_FOOF2 || (LOC) == LOC_FOOF4)
#define INDEEP(LOC) ((LOC) >= LOC_MISTHALL && !OUTSID(LOC) && (LOC) != LOC_FOOF1)
-/* vocabulary items */
+/* vocabulary items */
extern long AMBER, ATTACK, AXE, BACK, BATTERY, BEAR,
- BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
- CLAM, COINS, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
- EMERALD, ENTER, ENTRNC, FIND, FISSURE, FOOD, GRATE, HINT, INVENT,
- JADE, KEYS, KNIFE, LAMP, LOCK, LOOK, MAGAZINE, MESSAG, MIRROR, NUGGET, NUL,
- OGRE, OIL, OYSTER, PANIC, PEARL, PILLOW, PLANT, PLANT2, PYRAMID,
- RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAY, SIGN, SNAKE,
- STEPS, STICK, STREAM, THROW, TRIDENT, TROLL, TROLL2,
- URN, VASE, VEND, VOLCANO, WATER;
+ BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
+ CLAM, COINS, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
+ EMERALD, ENTER, ENTRNC, FIND, FISSURE, FOOD, GRATE, HINT, INVENT,
+ JADE, KEYS, KNIFE, LAMP, LOCK, LOOK, MAGAZINE, MESSAG, MIRROR, NUGGET, NUL,
+ OGRE, OIL, OYSTER, PANIC, PEARL, PILLOW, PLANT, PLANT2, PYRAMID,
+ RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAY, SIGN, SNAKE,
+ STEPS, STICK, STREAM, THROW, TRIDENT, TROLL, TROLL2,
+ URN, VASE, VEND, VOLCANO, WATER;
enum speechpart {unknown, intransitive, transitive};
void initialise(void);
int action(FILE *input, enum speechpart part, long verb, token_t obj);
-/* Phase codes for action returns.
+/* Phase codes for action returns.
* These were at one time FORTRAN line numbers.
* The values don't matter, but perturb their order at your peril.
*/
#define NOARRR 3 /* Pirate doesn't go here unless following player */
#define NOBACK 4 /* Cannot use "back" to move away */
/* Bits past 10 indicate areas of interest to "hint" routines */
-#define HBASE 10 /* Base for location hint bitss */
+#define HBASE 10 /* Base for location hint bits */
#define HCAVE 11 /* Trying to get into cave */
#define HBIRD 12 /* Trying to catch bird */
#define HSNAKE 13 /* Trying to deal with snake */
/* Special object statuses in game.place - can also be a location number (> 0) */
#define CARRIED -1 /* Player is toting it */
-#define NOWHERE 0 /* It's destroyed */
/* hack to ignore GCC Unused Result */
#define IGNORE(r) do{if (r){}}while(0)