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