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