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