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