Add html production for convenience generating the website.
[open-adventure.git] / funcs.h
1 #include <stdbool.h>
2 #include "database.h"
3
4 /*  Statement functions
5  *
6  *  AT(OBJ)     = true if on either side of two-placed object
7  *  CNDBIT(L,N) = true if COND(L) has bit n set (bit 0 is units bit)
8  *  DARK(DUMMY) = true if location "LOC" is dark
9  *  FORCED(LOC) = true if LOC moves without asking for input (COND=2)
10  *  FOREST(LOC)  = true if LOC is part of the forest
11  *  GSTONE(OBJ)  = true if OBJ is a gemstone
12  *  HERE(OBJ)   = true if the OBJ is at "LOC" (or is being carried)
13  *  LIQ(DUMMY)  = object number of liquid in bottle
14  *  LIQLOC(LOC) = object number of liquid (if any) at LOC
15  *  PCT(N)       = true N% of the time (N integer from 0 to 100)
16  *  TOTING(OBJ) = true if the OBJ is being carried */
17
18 #define TOTING(OBJ)     (PLACE[OBJ] == -1)
19 #define AT(OBJ) (PLACE[OBJ] == LOC || FIXED[OBJ] == LOC)
20 #define HERE(OBJ)       (AT(OBJ) || TOTING(OBJ))
21 #define LIQ2(PBOTL)     ((1-(PBOTL))*WATER+((PBOTL)/2)*(WATER+OIL))
22 #define LIQ(DUMMY)      (LIQ2(PROP[BOTTLE]<0 ? -1-PROP[BOTTLE] : PROP[BOTTLE]))
23 #define LIQLOC(LOC)     (LIQ2((MOD(COND[LOC]/2*2,8)-5)*MOD(COND[LOC]/4,2)+1))
24 #define CNDBIT(L,N)     (TSTBIT(COND[L],N))
25 #define FORCED(LOC)     (COND[LOC] == 2)
26 #define DARK(DUMMY)     ((!CNDBIT(LOC,0)) && (PROP[LAMP] == 0 || !HERE(LAMP)))
27 #define PCT(N)  (randrange(100) < (N))
28 #define GSTONE(OBJ)     ((OBJ) == EMRALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH)
29 #define FOREST(LOC)     ((LOC) >= 145 && (LOC) <= 166)
30 #define VOCWRD(LETTRS,SECT)     (VOCAB(MAKEWD(LETTRS),SECT))
31
32 /*  The following two functions were added to fix a bug (CLOCK1 decremented
33  *  while in forest).  They should probably be replaced by using another
34  *  "cond" bit.  For now, however, a quick fix...  OUTSID(LOC) is true if
35  *  LOC is outside, INDEEP(LOC) is true if LOC is "deep" in the cave (hall
36  *  of mists or deeper).  Note special kludges for "Foof!" locs. */
37
38 #define OUTSID(LOC)     ((LOC) <= 8 || FOREST(LOC) || (LOC) == PLAC[SAPPH] || (LOC) == 180 || (LOC) == 182)
39 #define INDEEP(LOC)     ((LOC) >= 15 && !OUTSID(LOC) && (LOC) != 179)
40
41 extern int carry(void), discard(bool), attack(FILE *), throw(FILE *), feed(void), fill(void);
42 void score(long);
43
44
45
46