header.h revision 1.13 1 1.13 christos /* $NetBSD: header.h,v 1.13 2001/02/05 00:57:33 christos Exp $ */
2 1.3 mycroft
3 1.11 christos /* header.h Larn is copyrighted 1986 by Noah Morgan. */
4 1.1 cgd
5 1.8 mrg #include <sys/types.h>
6 1.8 mrg
7 1.1 cgd #define MAXLEVEL 11
8 1.11 christos /* max # levels in the dungeon */
9 1.1 cgd #define MAXVLEVEL 3
10 1.11 christos /* max # of levels in the temple of the luran */
11 1.1 cgd #define MAXX 67
12 1.1 cgd #define MAXY 17
13 1.1 cgd
14 1.1 cgd #define SCORESIZE 10
15 1.11 christos /* this is the number of people on a scoreboard max */
16 1.1 cgd #define MAXPLEVEL 100
17 1.11 christos /* maximum player level allowed */
18 1.1 cgd #define MAXMONST 56
19 1.11 christos /* maximum # monsters in the dungeon */
20 1.1 cgd #define SPNUM 38
21 1.11 christos /* maximum number of spells in existance */
22 1.1 cgd #define MAXSCROLL 28
23 1.11 christos /* maximum number of scrolls that are possible */
24 1.1 cgd #define MAXPOTION 35
25 1.11 christos /* maximum number of potions that are possible */
26 1.1 cgd #define TIMELIMIT 30000
27 1.11 christos /* the maximum number of moves before the game is called */
28 1.1 cgd #define TAXRATE 1/20
29 1.11 christos /* the tax rate for the LRS */
30 1.1 cgd #define MAXOBJ 93
31 1.11 christos /* the maximum number of objects n < MAXOBJ */
32 1.1 cgd
33 1.11 christos /* this is the structure definition of the monster data */
34 1.11 christos struct monst {
35 1.11 christos char *name;
36 1.11 christos char level;
37 1.11 christos short armorclass;
38 1.11 christos char damage;
39 1.11 christos char attack;
40 1.11 christos char defense;
41 1.11 christos char genocided;
42 1.11 christos char intelligence; /* monsters intelligence -- used to
43 1.11 christos * choose movement */
44 1.11 christos short gold;
45 1.11 christos short hitpoints;
46 1.11 christos unsigned long experience;
47 1.11 christos };
48 1.11 christos
49 1.11 christos /* this is the structure definition for the items in the dnd store */
50 1.11 christos struct _itm {
51 1.11 christos short price;
52 1.11 christos u_char obj;
53 1.11 christos u_char arg;
54 1.11 christos char qty;
55 1.11 christos };
56 1.11 christos
57 1.11 christos /* this is the structure that holds the entire dungeon specifications */
58 1.11 christos struct cel {
59 1.11 christos short hitp; /* monster's hit points */
60 1.11 christos char mitem; /* the monster ID */
61 1.11 christos char item; /* the object's ID */
62 1.11 christos short iarg; /* the object's argument */
63 1.11 christos char know; /* have we been here before */
64 1.11 christos };
65 1.1 cgd
66 1.1 cgd /* this is the structure for maintaining & moving the spheres of annihilation */
67 1.11 christos struct sphere {
68 1.11 christos struct sphere *p; /* pointer to next structure */
69 1.11 christos char x, y, lev; /* location of the sphere */
70 1.11 christos char dir; /* direction sphere is going in */
71 1.11 christos short lifetime; /* duration of the sphere */
72 1.11 christos };
73 1.11 christos
74 1.11 christos /* defines for the character attribute array c[] */
75 1.11 christos #define STRENGTH 0 /* characters physical strength not due to
76 1.11 christos * objects */
77 1.1 cgd #define INTELLIGENCE 1
78 1.1 cgd #define WISDOM 2
79 1.1 cgd #define CONSTITUTION 3
80 1.1 cgd #define DEXTERITY 4
81 1.1 cgd #define CHARISMA 5
82 1.1 cgd #define HPMAX 6
83 1.1 cgd #define HP 7
84 1.1 cgd #define GOLD 8
85 1.1 cgd #define EXPERIENCE 9
86 1.1 cgd #define LEVEL 10
87 1.1 cgd #define REGEN 11
88 1.1 cgd #define WCLASS 12
89 1.1 cgd #define AC 13
90 1.1 cgd #define BANKACCOUNT 14
91 1.1 cgd #define SPELLMAX 15
92 1.1 cgd #define SPELLS 16
93 1.1 cgd #define ENERGY 17
94 1.1 cgd #define ECOUNTER 18
95 1.1 cgd #define MOREDEFENSES 19
96 1.1 cgd #define WEAR 20
97 1.1 cgd #define PROTECTIONTIME 21
98 1.1 cgd #define WIELD 22
99 1.1 cgd #define AMULET 23
100 1.1 cgd #define REGENCOUNTER 24
101 1.1 cgd #define MOREDAM 25
102 1.1 cgd #define DEXCOUNT 26
103 1.1 cgd #define STRCOUNT 27
104 1.1 cgd #define BLINDCOUNT 28
105 1.1 cgd #define CAVELEVEL 29
106 1.1 cgd #define CONFUSE 30
107 1.1 cgd #define ALTPRO 31
108 1.1 cgd #define HERO 32
109 1.1 cgd #define CHARMCOUNT 33
110 1.1 cgd #define INVISIBILITY 34
111 1.1 cgd #define CANCELLATION 35
112 1.1 cgd #define HASTESELF 36
113 1.1 cgd #define EYEOFLARN 37
114 1.1 cgd #define AGGRAVATE 38
115 1.1 cgd #define GLOBE 39
116 1.1 cgd #define TELEFLAG 40
117 1.1 cgd #define SLAYING 41
118 1.1 cgd #define NEGATESPIRIT 42
119 1.1 cgd #define SCAREMONST 43
120 1.1 cgd #define AWARENESS 44
121 1.1 cgd #define HOLDMONST 45
122 1.1 cgd #define TIMESTOP 46
123 1.1 cgd #define HASTEMONST 47
124 1.1 cgd #define CUBEofUNDEAD 48
125 1.1 cgd #define GIANTSTR 49
126 1.1 cgd #define FIRERESISTANCE 50
127 1.1 cgd #define BESSMANN 51
128 1.1 cgd #define NOTHEFT 52
129 1.1 cgd #define HARDGAME 53
130 1.1 cgd #define CPUTIME 54
131 1.1 cgd #define BYTESIN 55
132 1.1 cgd #define BYTESOUT 56
133 1.1 cgd #define MOVESMADE 57
134 1.1 cgd #define MONSTKILLED 58
135 1.1 cgd #define SPELLSCAST 59
136 1.1 cgd #define LANCEDEATH 60
137 1.1 cgd #define SPIRITPRO 61
138 1.1 cgd #define UNDEADPRO 62
139 1.1 cgd #define SHIELD 63
140 1.1 cgd #define STEALTH 64
141 1.1 cgd #define ITCHING 65
142 1.1 cgd #define LAUGHING 66
143 1.1 cgd #define DRAINSTRENGTH 67
144 1.1 cgd #define CLUMSINESS 68
145 1.1 cgd #define INFEEBLEMENT 69
146 1.1 cgd #define HALFDAM 70
147 1.1 cgd #define SEEINVISIBLE 71
148 1.1 cgd #define FILLROOM 72
149 1.1 cgd #define RANDOMWALK 73
150 1.11 christos #define SPHCAST 74 /* nz if an active sphere of annihilation */
151 1.11 christos #define WTW 75 /* walk through walls */
152 1.11 christos #define STREXTRA 76 /* character strength due to objects or
153 1.11 christos * enchantments */
154 1.11 christos #define TMP 77 /* misc scratch space */
155 1.11 christos #define LIFEPROT 78 /* life protection counter */
156 1.1 cgd
157 1.11 christos /* defines for the objects in the game */
158 1.1 cgd
159 1.1 cgd #define OALTAR 1
160 1.1 cgd #define OTHRONE 2
161 1.1 cgd #define OORB 3
162 1.1 cgd #define OPIT 4
163 1.1 cgd #define OSTAIRSUP 5
164 1.1 cgd #define OELEVATORUP 6
165 1.1 cgd #define OFOUNTAIN 7
166 1.1 cgd #define OSTATUE 8
167 1.1 cgd #define OTELEPORTER 9
168 1.1 cgd #define OSCHOOL 10
169 1.1 cgd #define OMIRROR 11
170 1.1 cgd #define ODNDSTORE 12
171 1.1 cgd #define OSTAIRSDOWN 13
172 1.1 cgd #define OELEVATORDOWN 14
173 1.1 cgd #define OBANK2 15
174 1.1 cgd #define OBANK 16
175 1.1 cgd #define ODEADFOUNTAIN 17
176 1.1 cgd #define OMAXGOLD 70
177 1.1 cgd #define OGOLDPILE 18
178 1.1 cgd #define OOPENDOOR 19
179 1.1 cgd #define OCLOSEDDOOR 20
180 1.1 cgd #define OWALL 21
181 1.1 cgd #define OTRAPARROW 66
182 1.1 cgd #define OTRAPARROWIV 67
183 1.1 cgd
184 1.1 cgd #define OLARNEYE 22
185 1.1 cgd
186 1.1 cgd #define OPLATE 23
187 1.1 cgd #define OCHAIN 24
188 1.1 cgd #define OLEATHER 25
189 1.1 cgd #define ORING 60
190 1.1 cgd #define OSTUDLEATHER 61
191 1.1 cgd #define OSPLINT 62
192 1.1 cgd #define OPLATEARMOR 63
193 1.1 cgd #define OSSPLATE 64
194 1.1 cgd #define OSHIELD 68
195 1.1 cgd #define OELVENCHAIN 92
196 1.1 cgd
197 1.1 cgd #define OSWORDofSLASHING 26
198 1.1 cgd #define OHAMMER 27
199 1.1 cgd #define OSWORD 28
200 1.1 cgd #define O2SWORD 29
201 1.1 cgd #define OSPEAR 30
202 1.1 cgd #define ODAGGER 31
203 1.1 cgd #define OBATTLEAXE 57
204 1.1 cgd #define OLONGSWORD 58
205 1.1 cgd #define OFLAIL 59
206 1.1 cgd #define OLANCE 65
207 1.1 cgd #define OVORPAL 90
208 1.1 cgd #define OSLAYER 91
209 1.1 cgd
210 1.1 cgd #define ORINGOFEXTRA 32
211 1.1 cgd #define OREGENRING 33
212 1.1 cgd #define OPROTRING 34
213 1.1 cgd #define OENERGYRING 35
214 1.1 cgd #define ODEXRING 36
215 1.1 cgd #define OSTRRING 37
216 1.1 cgd #define OCLEVERRING 38
217 1.1 cgd #define ODAMRING 39
218 1.1 cgd
219 1.1 cgd #define OBELT 40
220 1.1 cgd
221 1.1 cgd #define OSCROLL 41
222 1.1 cgd #define OPOTION 42
223 1.1 cgd #define OBOOK 43
224 1.11 christos #define OCHEST 44
225 1.1 cgd #define OAMULET 45
226 1.1 cgd
227 1.1 cgd #define OORBOFDRAGON 46
228 1.1 cgd #define OSPIRITSCARAB 47
229 1.1 cgd #define OCUBEofUNDEAD 48
230 1.1 cgd #define ONOTHEFT 49
231 1.1 cgd
232 1.1 cgd #define ODIAMOND 50
233 1.1 cgd #define ORUBY 51
234 1.1 cgd #define OEMERALD 52
235 1.1 cgd #define OSAPPHIRE 53
236 1.1 cgd
237 1.1 cgd #define OENTRANCE 54
238 1.1 cgd #define OVOLDOWN 55
239 1.1 cgd #define OVOLUP 56
240 1.1 cgd #define OHOME 69
241 1.1 cgd
242 1.1 cgd #define OKGOLD 71
243 1.1 cgd #define ODGOLD 72
244 1.1 cgd #define OIVDARTRAP 73
245 1.1 cgd #define ODARTRAP 74
246 1.1 cgd #define OTRAPDOOR 75
247 1.1 cgd #define OIVTRAPDOOR 76
248 1.1 cgd #define OTRADEPOST 77
249 1.1 cgd #define OIVTELETRAP 78
250 1.1 cgd #define ODEADTHRONE 79
251 1.11 christos #define OANNIHILATION 80 /* sphere of annihilation */
252 1.1 cgd #define OTHRONE2 81
253 1.11 christos #define OLRS 82 /* Larn Revenue Service */
254 1.1 cgd #define OCOOKIE 83
255 1.1 cgd #define OURN 84
256 1.1 cgd #define OBRASSLAMP 85
257 1.1 cgd #define OHANDofFEAR 86 /* hand of fear */
258 1.1 cgd #define OSPHTAILSMAN 87 /* tailsman of the sphere */
259 1.11 christos #define OWWAND 88 /* wand of wonder */
260 1.11 christos #define OPSTAFF 89 /* staff of power */
261 1.1 cgd /* used up to 92 */
262 1.1 cgd
263 1.11 christos /* defines for the monsters as objects */
264 1.1 cgd
265 1.11 christos #define BAT 1
266 1.11 christos #define GNOME 2
267 1.11 christos #define HOBGOBLIN 3
268 1.11 christos #define JACKAL 4
269 1.11 christos #define KOBOLD 5
270 1.11 christos #define ORC 6
271 1.1 cgd #define SNAKE 7
272 1.1 cgd #define CENTIPEDE 8
273 1.11 christos #define JACULI 9
274 1.11 christos #define TROGLODYTE 10
275 1.11 christos #define ANT 11
276 1.11 christos #define EYE 12
277 1.1 cgd #define LEPRECHAUN 13
278 1.11 christos #define NYMPH 14
279 1.11 christos #define QUASIT 15
280 1.11 christos #define RUSTMONSTER 16
281 1.11 christos #define ZOMBIE 17
282 1.11 christos #define ASSASSINBUG 18
283 1.11 christos #define BUGBEAR 19
284 1.11 christos #define HELLHOUND 20
285 1.11 christos #define ICELIZARD 21
286 1.11 christos #define CENTAUR 22
287 1.11 christos #define TROLL 23
288 1.11 christos #define YETI 24
289 1.11 christos #define WHITEDRAGON 25
290 1.11 christos #define ELF 26
291 1.11 christos #define CUBE 27
292 1.11 christos #define METAMORPH 28
293 1.11 christos #define VORTEX 29
294 1.11 christos #define ZILLER 30
295 1.11 christos #define VIOLETFUNGI 31
296 1.11 christos #define WRAITH 32
297 1.11 christos #define FORVALAKA 33
298 1.11 christos #define LAMANOBE 34
299 1.11 christos #define OSEQUIP 35
300 1.11 christos #define ROTHE 36
301 1.11 christos #define XORN 37
302 1.11 christos #define VAMPIRE 38
303 1.11 christos #define INVISIBLESTALKER 39
304 1.11 christos #define POLTERGEIST 40
305 1.11 christos #define DISENCHANTRESS 41
306 1.11 christos #define SHAMBLINGMOUND 42
307 1.1 cgd #define YELLOWMOLD 43
308 1.1 cgd #define UMBERHULK 44
309 1.1 cgd #define GNOMEKING 45
310 1.1 cgd #define MIMIC 46
311 1.1 cgd #define WATERLORD 47
312 1.1 cgd #define BRONZEDRAGON 48
313 1.1 cgd #define GREENDRAGON 49
314 1.1 cgd #define PURPLEWORM 50
315 1.1 cgd #define XVART 51
316 1.1 cgd #define SPIRITNAGA 52
317 1.1 cgd #define SILVERDRAGON 53
318 1.1 cgd #define PLATINUMDRAGON 54
319 1.1 cgd #define GREENURCHIN 55
320 1.1 cgd #define REDDRAGON 56
321 1.1 cgd #define DEMONLORD 57
322 1.1 cgd #define DEMONPRINCE 64
323 1.1 cgd
324 1.1 cgd #define NULL 0
325 1.11 christos #define BUFBIG 4096 /* size of the output buffer */
326 1.11 christos #define MAXIBUF 4096 /* size of the input buffer */
327 1.11 christos #define LOGNAMESIZE 40 /* max size of the players name */
328 1.11 christos #define PSNAMESIZE 40 /* max size of the process name */
329 1.1 cgd
330 1.1 cgd #ifndef NODEFS
331 1.11 christos extern char VERSION, SUBVERSION;
332 1.11 christos extern u_char alpha[], beenhere[], boldon, cheat, ckpflag;
333 1.11 christos extern u_char *class[], course[];
334 1.11 christos extern char diagfile[], helpfile[], ckpfile[], larnlevels[],
335 1.13 christos playerids[], optsfile[1024], psname[], savefilename[],
336 1.11 christos scorefile[];
337 1.11 christos extern u_char *inbuffer, is_alpha[], is_digit[];
338 1.11 christos extern u_char item[MAXX][MAXY], iven[], know[MAXX][MAXY];
339 1.11 christos extern char *levelname[], logfile[], loginname[], logname[],
340 1.11 christos lastmonst[];
341 1.11 christos extern u_char *lpbuf, *lpend;
342 1.11 christos extern u_char *lpnt, moved[MAXX][MAXY], mitem[MAXX][MAXY], monstlevel[];
343 1.11 christos extern char monstnamelist[], objnamelist[];
344 1.11 christos extern u_char nch[], ndgg[], nlpts[], nomove, nosignal, nowelcome;
345 1.11 christos extern u_char nplt[], nsw[];
346 1.11 christos extern char *objectname[], *potionhide[], *potionname[],
347 1.11 christos *spelcode[], *spelname[], *spelmes[], aborted[],
348 1.11 christos spelweird[MAXMONST + 8][SPNUM];
349 1.11 christos extern u_char potprob[];
350 1.11 christos extern u_char predostuff, restorflag, scprob[];
351 1.11 christos extern u_char screen[MAXX][MAXY], sex;
352 1.11 christos extern char *speldescript[], *scrollhide[], *scrollname[];
353 1.11 christos extern u_char spelknow[];
354 1.11 christos extern u_char splev[], stealth[MAXX][MAXY], to_lower[], to_upper[], wizard;
355 1.11 christos extern short diroffx[], diroffy[], hitflag, hit2flag, hit3flag, hitp[MAXX][MAXY];
356 1.11 christos extern short iarg[MAXX][MAXY], ivenarg[], lasthx, lasthy, lastnum, lastpx,
357 1.11 christos lastpy;
358 1.11 christos extern short nobeep, oldx, oldy, playerx, playery, level;
359 1.11 christos extern int dayplay, enable_scroll, srcount, yrepcount, userid, wisid,
360 1.11 christos lfd, fd;
361 1.11 christos extern uid_t uid, euid;
362 1.12 thorpej extern long outstanding_taxes, skill[], gltime, c[], cbak[];
363 1.12 thorpej extern time_t initialtime;
364 1.1 cgd extern unsigned long randx;
365 1.1 cgd extern struct cel *cell;
366 1.1 cgd extern struct monst monster[];
367 1.1 cgd extern struct sphere *spheres;
368 1.1 cgd extern struct _itm itm[];
369 1.11 christos extern int rmst, maxitm, lasttime;
370 1.1 cgd
371 1.11 christos /* macro to create scroll #'s with probability of occurrence */
372 1.1 cgd #define newscroll() (scprob[rund(81)])
373 1.11 christos /* macro to return a potion # created with probability of occurrence */
374 1.1 cgd #define newpotion() (potprob[rund(41)])
375 1.11 christos /* macro to return the + points on created leather armor */
376 1.1 cgd #define newleather() (nlpts[rund(c[HARDGAME]?13:15)])
377 1.11 christos /* macro to return the + points on chain armor */
378 1.1 cgd #define newchain() (nch[rund(10)])
379 1.11 christos /* macro to return + points on plate armor */
380 1.1 cgd #define newplate() (nplt[rund(c[HARDGAME]?4:12)])
381 1.11 christos /* macro to return + points on new daggers */
382 1.1 cgd #define newdagger() (ndgg[rund(13)])
383 1.11 christos /* macro to return + points on new swords */
384 1.1 cgd #define newsword() (nsw[rund(c[HARDGAME]?6:13)])
385 1.11 christos /* macro to destroy object at present location */
386 1.1 cgd #define forget() (item[playerx][playery]=know[playerx][playery]=0)
387 1.11 christos /* macro to wipe out a monster at a location */
388 1.1 cgd #define disappear(x,y) (mitem[x][y]=know[x][y]=0)
389 1.1 cgd
390 1.1 cgd #ifdef VT100
391 1.11 christos /* macro to turn on bold display for the terminal */
392 1.1 cgd #define setbold() (lprcat(boldon?"\33[1m":"\33[7m"))
393 1.11 christos /* macro to turn off bold display for the terminal */
394 1.1 cgd #define resetbold() (lprcat("\33[m"))
395 1.11 christos /* macro to setup the scrolling region for the terminal */
396 1.1 cgd #define setscroll() (lprcat("\33[20;24r"))
397 1.11 christos /* macro to clear the scrolling region for the terminal */
398 1.1 cgd #define resetscroll() (lprcat("\33[;24r"))
399 1.11 christos /* macro to clear the screen and home the cursor */
400 1.1 cgd #define clear() (lprcat("\33[2J\33[f"), cbak[SPELLS]= -50)
401 1.1 cgd #define cltoeoln() lprcat("\33[K")
402 1.11 christos #else /* VT100 */
403 1.11 christos /* defines below are for use in the termcap mode only */
404 1.1 cgd #define ST_START 1
405 1.1 cgd #define ST_END 2
406 1.1 cgd #define BOLD 3
407 1.1 cgd #define END_BOLD 4
408 1.1 cgd #define CLEAR 5
409 1.1 cgd #define CL_LINE 6
410 1.1 cgd #define CL_DOWN 14
411 1.1 cgd #define CURSOR 15
412 1.11 christos /* macro to turn on bold display for the terminal */
413 1.1 cgd #define setbold() (*lpnt++ = ST_START)
414 1.11 christos /* macro to turn off bold display for the terminal */
415 1.1 cgd #define resetbold() (*lpnt++ = ST_END)
416 1.11 christos /* macro to setup the scrolling region for the terminal */
417 1.1 cgd #define setscroll() enable_scroll=1
418 1.11 christos /* macro to clear the scrolling region for the terminal */
419 1.1 cgd #define resetscroll() enable_scroll=0
420 1.11 christos /* macro to clear the screen and home the cursor */
421 1.1 cgd #define clear() (*lpnt++ =CLEAR, cbak[SPELLS]= -50)
422 1.11 christos /* macro to clear to end of line */
423 1.1 cgd #define cltoeoln() (*lpnt++ = CL_LINE)
424 1.11 christos #endif /* VT100 */
425 1.1 cgd
426 1.11 christos /* macro to output one byte to the output buffer */
427 1.1 cgd #define lprc(ch) ((lpnt>=lpend)?(*lpnt++ =(ch), lflush()):(*lpnt++ =(ch)))
428 1.1 cgd
429 1.11 christos /* macro to seed the random number generator */
430 1.1 cgd #define srand(x) (randx=x)
431 1.1 cgd #ifdef MACRORND
432 1.11 christos /* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */
433 1.1 cgd #define rnd(x) ((((randx=randx*1103515245+12345)>>7)%(x))+1)
434 1.1 cgd #define rund(x) ((((randx=randx*1103515245+12345)>>7)%(x)) )
435 1.11 christos #endif /* MACRORND */
436 1.11 christos /* macros for miscellaneous data conversion */
437 1.1 cgd #define min(x,y) (((x)>(y))?(y):(x))
438 1.1 cgd #define max(x,y) (((x)>(y))?(x):(y))
439 1.1 cgd #define isalpha(x) (is_alpha[x])
440 1.1 cgd #define isdigit(x) (is_digit[x])
441 1.1 cgd #define tolower(x) (to_lower[x])
442 1.1 cgd #define toupper(x) (to_upper[x])
443 1.1 cgd #define lcc(x) (to_lower[x])
444 1.1 cgd #define ucc(x) (to_upper[x])
445 1.11 christos #endif /* NODEFS */
446