date and time created 85/04/22 15:41:53 by edward
[unix-history] / usr / src / games / battlestar / extern.h
CommitLineData
a7c71d1e 1/* @(#)extern.h 1.2 %G% */
56905c15
EW
2
3#include <sys/signal.h>
4#include <stdio.h>
5
6#define PATH(x) "/usr/games/lib/x"
7#define logfile PATH(battlestar.log)
8
9#define BITS (8 * sizeof (int))
10
11#define OUTSIDE (position > 68 && position < 246 && position != 218)
12#define rnd(x) (rand() % (x))
13#define max(a,b) ((a) < (b) ? (b) : (a))
14#define testbit(array, index) (array[index/BITS] & (1 << (index % BITS)))
15#define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
16#define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
17
18 /* well known rooms */
19#define FINAL 275
20#define GARDEN 197
21#define POOLS 126
22#define DOCK 93
23
24 /* word types */
25#define VERB 0
26#define OBJECT 1
27#define NOUNS 2
28#define PREPS 3
29#define ADJS 4
30#define CONJ 5
31
32 /* words numbers */
33#define KNIFE 0
34#define SWORD 1
35#define LAND 2
36#define WOODSMAN 3
37#define TWO_HANDED 4
38#define CLEAVER 5
39#define BROAD 6
40#define MAIL 7
41#define HELM 8
42#define SHIELD 9
43#define MAID 10
44#define BODY 10
45#define VIPER 11
46#define LAMPON 12
47#define SHOES 13
48#define CYLON 14
49#define PAJAMAS 15
50#define ROBE 16
51#define AMULET 17
52#define MEDALION 18
53#define TALISMAN 19
54#define DEADWOOD 20
55#define MALLET 21
56#define LASER 22
57#define BATHGOD 23
58#define NORMGOD 24
59#define GRENADE 25
60#define CHAIN 26
61#define ROPE 27
62#define LEVIS 28
63#define MACE 29
64#define SHOVEL 30
65#define HALBERD 31
66#define COMPASS 32
67#define CRASH 33
68#define ELF 34
69#define FOOT 35
70#define COINS 36
71#define MATCHES 37
72#define MAN 38
73#define PAPAYAS 39
74#define PINEAPPLE 40
75#define KIWI 41
76#define COCONUTS 42
77#define MANGO 43
78#define RING 44
79#define POTION 45
80#define BRACELET 46
81#define GIRL 47
82#define GIRLTALK 48
83#define DARK 49
84#define TIMER 50
85#define CHAR 53
86#define BOMB 54
87#define DEADGOD 55
88#define DEADTIME 56
89#define DEADNATIVE 57
90#define NATIVE 58
91#define HORSE 59
92#define CAR 60
93#define POT 61
94#define BAR 62
95#define BLOCK 63
96#define NUMOFOBJECTS 64
97 /* non-objects below */
98#define UP 1000
99#define DOWN 1001
100#define AHEAD 1002
101#define BACK 1003
102#define RIGHT 1004
103#define LEFT 1005
104#define TAKE 1006
105#define USE 1007
106#define LOOK 1008
107#define QUIT 1009
108#define NORTH 1010
109#define SOUTH 1011
110#define EAST 1012
111#define WEST 1013
112#define SU 1014
113#define DROP 1015
114#define TAKEOFF 1016
115#define DRAW 1017
116#define PUTON 1018
117#define WEARIT 1019
118#define PUT 1020
119#define INVEN 1021
120#define EVERYTHING 1022
121#define AND 1023
122#define KILL 1024
123#define RAVAGE 1025
124#define UNDRESS 1026
125#define THROW 1027
126#define LAUNCH 1028
127#define LANDIT 1029
128#define LIGHT 1030
129#define FOLLOW 1031
130#define KISS 1032
131#define LOVE 1033
132#define GIVE 1034
133#define SMITE 1035
134#define SHOOT 1036
135#define ON 1037
136#define OFF 1038
137#define TIME 1039
138#define SLEEP 1040
139#define DIG 1041
140#define EAT 1042
141#define SWIM 1043
142#define DRINK 1044
143#define DOOR 1045
144#define SAVE 1046
145#define RIDE 1047
146#define DRIVE 1048
147#define SCORE 1049
148#define BURY 1050
149#define JUMP 1051
a7c71d1e 150#define KICK 1052
56905c15
EW
151
152 /* injuries */
153#define ARM 6 /* broken arm */
154#define RIBS 7 /* broken ribs */
155#define SPINE 9 /* broken back */
156#define SKULL 11 /* fractured skull */
157#define INCISE 10 /* deep incisions */
158#define NECK 12 /* broken NECK */
159#define NUMOFINJURIES 13
160
161 /* notes */
162#define CANTLAUNCH 0
163#define LAUNCHED 1
164#define CANTSEE 2
165#define CANTMOVE 3
166#define JINXED 4
167#define DUG 5
168#define NUMOFNOTES 6
169
170 /* fundamental constants */
171#define NUMOFROOMS 275
172#define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
173#define LINELENGTH 81
174
175#define TODAY 0
176#define TONIGHT 1
177#define CYCLE 100
178
179 /* initial variable values */
a7c71d1e 180#define TANKFULL 250
56905c15
EW
181#define TORPEDOES 10
182#define MAXWEIGHT 60
183#define MAXCUMBER 10
184
185struct room {
186 char *name;
187 int link[8];
188#define north link[0]
189#define south link[1]
190#define east link[2]
191#define west link[3]
192#define up link[4]
193#define access link[5]
194#define down link[6]
195#define flyhere link[7]
196 char *desc;
197 unsigned int objects[NUMOFWORDS];
198};
199struct room dayfile[];
200struct room nightfile[];
201struct room *location;
202
203 /* object characteristics */
204char *objdes[NUMOFOBJECTS];
205char *objsht[NUMOFOBJECTS];
206char *ouch[NUMOFINJURIES];
207int objwt[NUMOFOBJECTS];
208int objcumber[NUMOFOBJECTS];
209
210 /* current input line */
211#define NWORD 20 /* words per line */
212char words[NWORD][15];
213int wordvalue[NWORD];
214int wordtype[NWORD];
215int wordcount, wordnumber;
216
217char *truedirec(), *rate();
218char *getcom(), *getword();
219
220 /* state of the game */
221int time;
222int position;
223int direction;
224int left, right, ahead, back;
225int clock, fuel, torps;
226int carrying, encumber;
227int rythmn;
228int followfight;
229int ate;
230int snooze;
231int meetgirl;
232int followgod;
233int godready;
234int win;
235int wintime;
236int wiz;
237int tempwiz;
238int matchlight, matchcount;
239int loved;
240int pleasure, power, ego;
241int WEIGHT;
242int CUMBER;
243int notes[NUMOFNOTES];
244unsigned int inven[NUMOFWORDS];
245unsigned int wear[NUMOFWORDS];
246char beenthere[NUMOFROOMS+1];
247char injuries[NUMOFINJURIES];
248
249char uname[9];
250
251struct wlist {
252 char *string;
253 int value, article;
254 struct wlist *next;
255};
256#define HASHSIZE 256
257#define HASHMUL 81
258#define HASHMASK (HASHSIZE - 1)
259struct wlist *hashtab[HASHSIZE];
260struct wlist wlist[];
261
262struct objs {
263 short room;
264 short obj;
265};
266struct objs dayobjs[];
267struct objs nightobjs[];