Install dma(8) config files with mode 640 as root:mail to prevent ``normal''
[dragonfly/netmp.git] / games / larn / header.h
bloba94ae4786dc35f296b2faa812a44c0a18ad0e33c
1 /* header.h Larn is copyrighted 1986 by Noah Morgan. */
2 /* $DragonFly: src/games/larn/header.h,v 1.5 2006/08/26 17:05:05 pavalos Exp $ */
4 #include <fcntl.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <termcap.h>
9 #include <time.h>
10 #include <unistd.h>
12 #define MAXLEVEL 11
13 /* max # levels in the dungeon */
14 #define MAXVLEVEL 3
15 /* max # of levels in the temple of the luran */
16 #define MAXX 67
17 #define MAXY 17
19 #define SCORESIZE 10
20 /* this is the number of people on a scoreboard max */
21 #define MAXPLEVEL 100
22 /* maximum player level allowed */
23 #define MAXMONST 56
24 /* maximum # monsters in the dungeon */
25 #define SPNUM 38
26 /* maximum number of spells in existance */
27 #define MAXSCROLL 28
28 /* maximum number of scrolls that are possible */
29 #define MAXPOTION 35
30 /* maximum number of potions that are possible */
31 #define TIMELIMIT 30000
32 /* the maximum number of moves before the game is called */
33 #define TAXRATE 1/20
34 /* the tax rate for the LRS */
35 #define MAXOBJ 93
36 /* the maximum number of objects n < MAXOBJ */
38 /* this is the structure definition of the monster data */
39 struct monst
41 const char *name;
42 char level;
43 short armorclass;
44 char damage;
45 char attack;
46 char defense;
47 char genocided;
48 char intelligence; /* monsters intelligence -- used to choose movement */
49 short gold;
50 short hitpoints;
51 unsigned long experience;
54 /* this is the structure definition for the items in the dnd store */
55 struct _itm
57 short price;
58 short obj;
59 short arg;
60 short qty;
63 /* this is the structure that holds the entire dungeon specifications */
64 struct cel
66 short hitp; /* monster's hit points */
67 char mitem; /* the monster ID */
68 char item; /* the object's ID */
69 short iarg; /* the object's argument */
70 char know; /* have we been here before*/
73 /* this is the structure for maintaining & moving the spheres of annihilation */
74 struct sphere
76 struct sphere *p; /* pointer to next structure */
77 char x,y,lev; /* location of the sphere */
78 char dir; /* direction sphere is going in */
79 char lifetime; /* duration of the sphere */
82 /* defines for the character attribute array c[] */
83 #define STRENGTH 0 /* characters physical strength not due to objects */
84 #define INTELLIGENCE 1
85 #define WISDOM 2
86 #define CONSTITUTION 3
87 #define DEXTERITY 4
88 #define CHARISMA 5
89 #define HPMAX 6
90 #define HP 7
91 #define GOLD 8
92 #define EXPERIENCE 9
93 #define LEVEL 10
94 #define REGEN 11
95 #define WCLASS 12
96 #define AC 13
97 #define BANKACCOUNT 14
98 #define SPELLMAX 15
99 #define SPELLS 16
100 #define ENERGY 17
101 #define ECOUNTER 18
102 #define MOREDEFENSES 19
103 #define WEAR 20
104 #define PROTECTIONTIME 21
105 #define WIELD 22
106 #define AMULET 23
107 #define REGENCOUNTER 24
108 #define MOREDAM 25
109 #define DEXCOUNT 26
110 #define STRCOUNT 27
111 #define BLINDCOUNT 28
112 #define CAVELEVEL 29
113 #define CONFUSE 30
114 #define ALTPRO 31
115 #define HERO 32
116 #define CHARMCOUNT 33
117 #define INVISIBILITY 34
118 #define CANCELLATION 35
119 #define HASTESELF 36
120 #define EYEOFLARN 37
121 #define AGGRAVATE 38
122 #define GLOBE 39
123 #define TELEFLAG 40
124 #define SLAYING 41
125 #define NEGATESPIRIT 42
126 #define SCAREMONST 43
127 #define AWARENESS 44
128 #define HOLDMONST 45
129 #define TIMESTOP 46
130 #define HASTEMONST 47
131 #define CUBEofUNDEAD 48
132 #define GIANTSTR 49
133 #define FIRERESISTANCE 50
134 #define BESSMANN 51
135 #define NOTHEFT 52
136 #define HARDGAME 53
137 #define CPUTIME 54
138 #define BYTESIN 55
139 #define BYTESOUT 56
140 #define MOVESMADE 57
141 #define MONSTKILLED 58
142 #define SPELLSCAST 59
143 #define LANCEDEATH 60
144 #define SPIRITPRO 61
145 #define UNDEADPRO 62
146 #define SHIELD 63
147 #define STEALTH 64
148 #define ITCHING 65
149 #define LAUGHING 66
150 #define DRAINSTRENGTH 67
151 #define CLUMSINESS 68
152 #define INFEEBLEMENT 69
153 #define HALFDAM 70
154 #define SEEINVISIBLE 71
155 #define FILLROOM 72
156 #define RANDOMWALK 73
157 #define SPHCAST 74 /* nz if an active sphere of annihilation */
158 #define WTW 75 /* walk through walls */
159 #define STREXTRA 76 /* character strength due to objects or enchantments */
160 #define TMP 77 /* misc scratch space */
161 #define LIFEPROT 78 /* life protection counter */
163 /* defines for the objects in the game */
165 #define OALTAR 1
166 #define OTHRONE 2
167 #define OORB 3
168 #define OPIT 4
169 #define OSTAIRSUP 5
170 #define OELEVATORUP 6
171 #define OFOUNTAIN 7
172 #define OSTATUE 8
173 #define OTELEPORTER 9
174 #define OSCHOOL 10
175 #define OMIRROR 11
176 #define ODNDSTORE 12
177 #define OSTAIRSDOWN 13
178 #define OELEVATORDOWN 14
179 #define OBANK2 15
180 #define OBANK 16
181 #define ODEADFOUNTAIN 17
182 #define OMAXGOLD 70
183 #define OGOLDPILE 18
184 #define OOPENDOOR 19
185 #define OCLOSEDDOOR 20
186 #define OWALL 21
187 #define OTRAPARROW 66
188 #define OTRAPARROWIV 67
190 #define OLARNEYE 22
192 #define OPLATE 23
193 #define OCHAIN 24
194 #define OLEATHER 25
195 #define ORING 60
196 #define OSTUDLEATHER 61
197 #define OSPLINT 62
198 #define OPLATEARMOR 63
199 #define OSSPLATE 64
200 #define OSHIELD 68
201 #define OELVENCHAIN 92
203 #define OSWORDofSLASHING 26
204 #define OHAMMER 27
205 #define OSWORD 28
206 #define O2SWORD 29
207 #define OSPEAR 30
208 #define ODAGGER 31
209 #define OBATTLEAXE 57
210 #define OLONGSWORD 58
211 #define OFLAIL 59
212 #define OLANCE 65
213 #define OVORPAL 90
214 #define OSLAYER 91
216 #define ORINGOFEXTRA 32
217 #define OREGENRING 33
218 #define OPROTRING 34
219 #define OENERGYRING 35
220 #define ODEXRING 36
221 #define OSTRRING 37
222 #define OCLEVERRING 38
223 #define ODAMRING 39
225 #define OBELT 40
227 #define OSCROLL 41
228 #define OPOTION 42
229 #define OBOOK 43
230 #define OCHEST 44
231 #define OAMULET 45
233 #define OORBOFDRAGON 46
234 #define OSPIRITSCARAB 47
235 #define OCUBEofUNDEAD 48
236 #define ONOTHEFT 49
238 #define ODIAMOND 50
239 #define ORUBY 51
240 #define OEMERALD 52
241 #define OSAPPHIRE 53
243 #define OENTRANCE 54
244 #define OVOLDOWN 55
245 #define OVOLUP 56
246 #define OHOME 69
248 #define OKGOLD 71
249 #define ODGOLD 72
250 #define OIVDARTRAP 73
251 #define ODARTRAP 74
252 #define OTRAPDOOR 75
253 #define OIVTRAPDOOR 76
254 #define OTRADEPOST 77
255 #define OIVTELETRAP 78
256 #define ODEADTHRONE 79
257 #define OANNIHILATION 80 /* sphere of annihilation */
258 #define OTHRONE2 81
259 #define OLRS 82 /* Larn Revenue Service */
260 #define OCOOKIE 83
261 #define OURN 84
262 #define OBRASSLAMP 85
263 #define OHANDofFEAR 86 /* hand of fear */
264 #define OSPHTAILSMAN 87 /* tailsman of the sphere */
265 #define OWWAND 88 /* wand of wonder */
266 #define OPSTAFF 89 /* staff of power */
267 /* used up to 92 */
269 /* defines for the monsters as objects */
271 #define BAT 1
272 #define GNOME 2
273 #define HOBGOBLIN 3
274 #define JACKAL 4
275 #define KOBOLD 5
276 #define ORC 6
277 #define SNAKE 7
278 #define CENTIPEDE 8
279 #define JACULI 9
280 #define TROGLODYTE 10
281 #define ANT 11
282 #define EYE 12
283 #define LEPRECHAUN 13
284 #define NYMPH 14
285 #define QUASIT 15
286 #define RUSTMONSTER 16
287 #define ZOMBIE 17
288 #define ASSASSINBUG 18
289 #define BUGBEAR 19
290 #define HELLHOUND 20
291 #define ICELIZARD 21
292 #define CENTAUR 22
293 #define TROLL 23
294 #define YETI 24
295 #define WHITEDRAGON 25
296 #define ELF 26
297 #define CUBE 27
298 #define METAMORPH 28
299 #define VORTEX 29
300 #define ZILLER 30
301 #define VIOLETFUNGI 31
302 #define WRAITH 32
303 #define FORVALAKA 33
304 #define LAMANOBE 34
305 #define OSEQUIP 35
306 #define ROTHE 36
307 #define XORN 37
308 #define VAMPIRE 38
309 #define INVISIBLESTALKER 39
310 #define POLTERGEIST 40
311 #define DISENCHANTRESS 41
312 #define SHAMBLINGMOUND 42
313 #define YELLOWMOLD 43
314 #define UMBERHULK 44
315 #define GNOMEKING 45
316 #define MIMIC 46
317 #define WATERLORD 47
318 #define BRONZEDRAGON 48
319 #define GREENDRAGON 49
320 #define PURPLEWORM 50
321 #define XVART 51
322 #define SPIRITNAGA 52
323 #define SILVERDRAGON 53
324 #define PLATINUMDRAGON 54
325 #define GREENURCHIN 55
326 #define REDDRAGON 56
327 #define DEMONLORD 57
328 #define DEMONPRINCE 64
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 */
335 #ifndef NODEFS
336 extern char VERSION,SUBVERSION;
337 extern char aborted[],alpha[],beenhere[],boldon,cheat,ckpfile[],ckpflag;
338 extern char *class[],course[],diagfile[],fortfile[],helpfile[];
339 extern char *inbuffer,is_alpha[],is_digit[];
340 extern char item[MAXX][MAXY],iven[],know[MAXX][MAXY],larnlevels[],lastmonst[];
341 extern char level,*levelname[],logfile[],loginname[],logname[],*lpbuf,*lpend;
342 extern char *lpnt,moved[MAXX][MAXY],mitem[MAXX][MAXY],monstlevel[];
343 extern char monstnamelist[],nch[],ndgg[],nlpts[],nomove,nosignal,nowelcome;
344 extern char nplt[],nsw[],*objectname[];
345 extern char objnamelist[],optsfile[],playerids[],potprob[];
346 extern char predostuff,psname[],restorflag,savefilename[],scorefile[],scprob[];
347 extern char screen[MAXX][MAXY],sex,*spelcode[],*speldescript[];
348 extern char spelknow[],*spelname[],*spelmes[],spelweird[MAXMONST+8][SPNUM];
349 extern char splev[],stealth[MAXX][MAXY],to_lower[],to_upper[],wizard;
350 extern short diroffx[],diroffy[],hitflag,hit2flag,hit3flag,hitp[MAXX][MAXY];
351 extern short iarg[MAXX][MAXY],ivenarg[],lasthx,lasthy,lastnum,lastpx,lastpy;
352 extern short nobeep,oldx,oldy,playerx,playery;
353 extern int dayplay,enable_scroll,srcount,yrepcount,userid,wisid,lfd,fd;
354 extern time_t initialtime;
355 extern long outstanding_taxes,skill[],gtime,c[],cbak[];
356 extern struct cel *cell;
357 extern struct monst monster[];
358 extern struct sphere *spheres;
359 extern struct _itm itm_[];
360 extern const char *potionhide[],*potionname[],*scrollhide[],*scrollname[];
362 /* bill.c */
363 void mailbill(void);
365 /* create.c */
366 void makeplayer(void);
367 void newcavelevel(int);
368 void eat(int, int);
369 int fillmonst(char);
371 /* diag.c */
372 #ifdef EXTRA
373 int diag(void);
374 #endif
375 int savegame(char *);
376 void restoregame(char *);
378 /* display.c */
379 void bottomline(void);
380 void bottomhp(void);
381 void bottomspell(void);
382 void bottomdo(void);
383 void bot_linex(void);
384 void bottomgold(void);
385 void draws(int, int, int, int);
386 void drawscreen(void);
387 void showcell(int, int);
388 void show1cell(int, int);
389 void showplayer(void);
390 int moveplayer(int);
391 void seemagic(int);
393 /* fortune.c */
394 const char *fortune(void);
396 /* global.c */
397 void raiselevel(void);
398 void loselevel(void);
399 void raiseexperience(long);
400 void loseexperience(long);
401 void losehp(int);
402 void losemhp(int);
403 void raisehp(int);
404 void raisemhp(int);
405 void raisemspells(int);
406 void losemspells(int);
407 int makemonst(int);
408 void positionplayer(void);
409 void recalc(void);
410 void quit(void);
411 void more(void);
412 int take(int, int);
413 int drop_object(int);
414 void enchantarmor(void);
415 void enchweapon(void);
416 int pocketfull(void);
417 int nearbymonst(void);
418 int stealsomething(void);
419 int emptyhanded(void);
420 void creategem(void);
421 void adjustcvalues(int, int);
422 int getpassword(void);
423 int getyn(void);
424 int packweight(void);
425 #ifndef MACRORND
426 int rnd(int);
427 int rund(int);
428 #endif
430 /* help.c */
431 void help(void);
432 void welcome(void);
434 /* io.c */
435 void setupvt100(void);
436 void clearvt100(void);
437 char getchr(void);
438 void scbr(void);
439 void sncbr(void);
440 void newgame(void);
441 void lprintf(const char *, ...);
442 void lprint(long);
443 void lwrite(char *, int);
444 long lgetc(void);
445 long lrint_x(void);
446 void lrfill(char *, int);
447 char *lgetw(void);
448 char *lgetl(void);
449 int lcreat(char *);
450 int lopen(char *);
451 int lappend(char *);
452 void lrclose(void);
453 void lwclose(void);
454 void lprcat(const char *);
455 void cursor(int, int);
456 void cursors(void);
457 #ifndef VT100
458 void init_term(void);
459 #endif
460 void cl_line(int, int);
461 void cl_up(int, int);
462 void cl_dn(int, int);
463 void standout(const char *);
464 void set_score_output(void);
465 void lflush(void);
466 #ifndef VT100
467 char *tmcapcnv(char *, char *);
468 #endif
469 void beep(void);
471 /* main.c */
472 void qshowstr(void);
473 void show3(int);
474 void parse2(void);
475 unsigned long readnum(long);
477 /* monster.c */
478 void createmonster(int);
479 void createitem(int, int);
480 void cast(void);
481 void godirect(int, int, const char *, int, char);
482 int vxy(int *, int *);
483 void hitmonster(int, int);
484 int hitm(int, int, int);
485 void hitplayer(int, int);
486 void dropgold(int);
487 void something(int);
488 int newobject(int, int *);
489 void checkloss(int);
490 long annihilate(void);
491 long newsphere(int, int, int, int);
492 long rmsphere(int, int);
494 /* moreobj.c */
495 void oaltar(void);
496 void othrone(int);
497 void odeadthrone(void);
498 void ochest(void);
499 void ofountain(void);
501 /* movem.c */
502 void movemonst(void);
504 /* nap.c */
505 void nap(int);
507 /* object.c */
508 void lookforobject(void);
509 void oteleport(int);
510 void quaffpotion(int);
511 void larn_adjtime(long);
512 void read_scroll(int);
513 void readbook(int);
514 void iopts(void);
515 void ignore(void);
517 /* regen.c */
518 void regen(void);
520 /* savelev.c */
521 void savelevel(void);
522 void getlevel(void);
524 /* scores.c */
525 int makeboard(void);
526 int hashewon(void);
527 long paytaxes(long);
528 void showscores(void);
529 void showallscores(void);
530 void died(int);
531 void diedlog(void);
532 #ifndef UIDSCORE
533 int getplid(char *);
534 #endif
536 /* signal.c */
537 void sigsetup(void);
539 /* store.c */
540 void dndstore(void);
541 void oschool(void);
542 void obank(void);
543 void obank2(void);
544 void ointerest(void);
545 void otradepost(void);
546 void olrs(void);
548 /* tok.c */
549 int yylex(void);
550 void flushall(void);
551 void sethard(int);
552 void readopts(void);
554 /* macro to create scroll #'s with probability of occurrence */
555 #define newscroll() (scprob[rund(81)])
556 /* macro to return a potion # created with probability of occurrence */
557 #define newpotion() (potprob[rund(41)])
558 /* macro to return the + points on created leather armor */
559 #define newleather() (nlpts[rund(c[HARDGAME]?13:15)])
560 /* macro to return the + points on chain armor */
561 #define newchain() (nch[rund(10)])
562 /* macro to return + points on plate armor */
563 #define newplate() (nplt[rund(c[HARDGAME]?4:12)])
564 /* macro to return + points on new daggers */
565 #define newdagger() (ndgg[rund(13)])
566 /* macro to return + points on new swords */
567 #define newsword() (nsw[rund(c[HARDGAME]?6:13)])
568 /* macro to destroy object at present location */
569 #define forget() (item[playerx][playery]=know[playerx][playery]=0)
570 /* macro to wipe out a monster at a location */
571 #define disappear(x,y) (mitem[x][y]=know[x][y]=0)
573 #ifdef VT100
574 /* macro to turn on bold display for the terminal */
575 #define setbold() (lprcat(boldon?"\33[1m":"\33[7m"))
576 /* macro to turn off bold display for the terminal */
577 #define resetbold() (lprcat("\33[m"))
578 /* macro to setup the scrolling region for the terminal */
579 #define setscroll() (lprcat("\33[20;24r"))
580 /* macro to clear the scrolling region for the terminal */
581 #define resetscroll() (lprcat("\33[;24r"))
582 /* macro to clear the screen and home the cursor */
583 #define clear() (lprcat("\33[2J\33[f"), cbak[SPELLS]= -50)
584 #define cltoeoln() lprcat("\33[K")
585 #else /* VT100 */
586 /* defines below are for use in the termcap mode only */
587 #define ST_START 1
588 #define ST_END 2
589 #define BOLD 3
590 #define END_BOLD 4
591 #define CLEAR 5
592 #define CL_LINE 6
593 #define CL_DOWN 14
594 #define CURSOR 15
595 /* macro to turn on bold display for the terminal */
596 #define setbold() (*lpnt++ = ST_START)
597 /* macro to turn off bold display for the terminal */
598 #define resetbold() (*lpnt++ = ST_END)
599 /* macro to setup the scrolling region for the terminal */
600 #define setscroll() enable_scroll=1
601 /* macro to clear the scrolling region for the terminal */
602 #define resetscroll() enable_scroll=0
603 /* macro to clear the screen and home the cursor */
604 #define clear() (*lpnt++ =CLEAR, cbak[SPELLS]= -50)
605 /* macro to clear to end of line */
606 #define cltoeoln() (*lpnt++ = CL_LINE)
607 #endif /* VT100 */
609 /* macro to output one byte to the output buffer */
610 #define lprc(ch) ((lpnt>=lpend)?(*lpnt++ =(ch), lflush()):(*lpnt++ =(ch)))
612 #ifdef MACRORND
613 extern unsigned long randx;
614 /* macro to seed the random number generator */
615 #define srand(x) (randx=x)
616 /* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */
617 #define rnd(x) ((((randx=randx*1103515245+12345)>>7)%(x))+1)
618 #define rund(x) ((((randx=randx*1103515245+12345)>>7)%(x)) )
619 #endif /* MACRORND */
620 /* macros for miscellaneous data conversion */
621 #define min(x,y) (((x)>(y))?(y):(x))
622 #define max(x,y) (((x)>(y))?(x):(y))
623 #define isalpha(x) (is_alpha[x])
624 #define isdigit(x) (is_digit[x])
625 #define tolower(x) (to_lower[x])
626 #define toupper(x) (to_upper[x])
627 #define lcc(x) (to_lower[x])
628 #define ucc(x) (to_upper[x])
629 #endif /* NODEFS */