1*5c104910Sdholland /* $NetBSD: header.h,v 1.21 2008/02/03 20:11:05 dholland Exp $ */ 2210cab45Smycroft 361f28255Scgd /* header.h Larn is copyrighted 1986 by Noah Morgan. */ 461f28255Scgd 5be7efc5cSmrg #include <sys/types.h> 6be7efc5cSmrg 761f28255Scgd #define MAXLEVEL 11 861f28255Scgd /* max # levels in the dungeon */ 961f28255Scgd #define MAXVLEVEL 3 1061f28255Scgd /* max # of levels in the temple of the luran */ 1161f28255Scgd #define MAXX 67 1261f28255Scgd #define MAXY 17 1361f28255Scgd 1461f28255Scgd #define SCORESIZE 10 1561f28255Scgd /* this is the number of people on a scoreboard max */ 1661f28255Scgd #define MAXPLEVEL 100 1761f28255Scgd /* maximum player level allowed */ 1861f28255Scgd #define MAXMONST 56 1961f28255Scgd /* maximum # monsters in the dungeon */ 2061f28255Scgd #define SPNUM 38 2109cb1d6fSwiz /* maximum number of spells in existence */ 2261f28255Scgd #define MAXSCROLL 28 2361f28255Scgd /* maximum number of scrolls that are possible */ 2461f28255Scgd #define MAXPOTION 35 2561f28255Scgd /* maximum number of potions that are possible */ 2661f28255Scgd #define TIMELIMIT 30000 2761f28255Scgd /* the maximum number of moves before the game is called */ 2861f28255Scgd #define TAXRATE 1/20 2961f28255Scgd /* the tax rate for the LRS */ 3061f28255Scgd #define MAXOBJ 93 3161f28255Scgd /* the maximum number of objects n < MAXOBJ */ 3261f28255Scgd 3361f28255Scgd /* this is the structure definition of the monster data */ 34a8fba37dSchristos struct monst { 359cc7e274Sdholland const char *name; 3661f28255Scgd char level; 3761f28255Scgd short armorclass; 3861f28255Scgd char damage; 3961f28255Scgd char attack; 4061f28255Scgd char defense; 4161f28255Scgd char genocided; 42a8fba37dSchristos char intelligence; /* monsters intelligence -- used to 43a8fba37dSchristos * choose movement */ 4461f28255Scgd short gold; 4561f28255Scgd short hitpoints; 4661f28255Scgd unsigned long experience; 4761f28255Scgd }; 4861f28255Scgd 4961f28255Scgd /* this is the structure definition for the items in the dnd store */ 50a8fba37dSchristos struct _itm { 5161f28255Scgd short price; 52a8fba37dSchristos u_char obj; 53a8fba37dSchristos u_char arg; 5461f28255Scgd char qty; 5561f28255Scgd }; 5661f28255Scgd 5761f28255Scgd /* this is the structure that holds the entire dungeon specifications */ 58a8fba37dSchristos struct cel { 5961f28255Scgd short hitp; /* monster's hit points */ 6061f28255Scgd char mitem; /* the monster ID */ 6161f28255Scgd char item; /* the object's ID */ 6261f28255Scgd short iarg; /* the object's argument */ 6361f28255Scgd char know; /* have we been here before */ 6461f28255Scgd }; 6561f28255Scgd 6661f28255Scgd /* this is the structure for maintaining & moving the spheres of annihilation */ 67a8fba37dSchristos struct sphere { 6861f28255Scgd struct sphere *p; /* pointer to next structure */ 6961f28255Scgd char x, y, lev; /* location of the sphere */ 7061f28255Scgd char dir; /* direction sphere is going in */ 71365ece4eSthorpej short lifetime; /* duration of the sphere */ 7261f28255Scgd }; 7361f28255Scgd 7461f28255Scgd /* defines for the character attribute array c[] */ 75a8fba37dSchristos #define STRENGTH 0 /* characters physical strength not due to 76a8fba37dSchristos * objects */ 7761f28255Scgd #define INTELLIGENCE 1 7861f28255Scgd #define WISDOM 2 7961f28255Scgd #define CONSTITUTION 3 8061f28255Scgd #define DEXTERITY 4 8161f28255Scgd #define CHARISMA 5 8261f28255Scgd #define HPMAX 6 8361f28255Scgd #define HP 7 8461f28255Scgd #define GOLD 8 8561f28255Scgd #define EXPERIENCE 9 8661f28255Scgd #define LEVEL 10 8761f28255Scgd #define REGEN 11 8861f28255Scgd #define WCLASS 12 8961f28255Scgd #define AC 13 9061f28255Scgd #define BANKACCOUNT 14 9161f28255Scgd #define SPELLMAX 15 9261f28255Scgd #define SPELLS 16 9361f28255Scgd #define ENERGY 17 9461f28255Scgd #define ECOUNTER 18 9561f28255Scgd #define MOREDEFENSES 19 9661f28255Scgd #define WEAR 20 9761f28255Scgd #define PROTECTIONTIME 21 9861f28255Scgd #define WIELD 22 9961f28255Scgd #define AMULET 23 10061f28255Scgd #define REGENCOUNTER 24 10161f28255Scgd #define MOREDAM 25 10261f28255Scgd #define DEXCOUNT 26 10361f28255Scgd #define STRCOUNT 27 10461f28255Scgd #define BLINDCOUNT 28 10561f28255Scgd #define CAVELEVEL 29 10661f28255Scgd #define CONFUSE 30 10761f28255Scgd #define ALTPRO 31 10861f28255Scgd #define HERO 32 10961f28255Scgd #define CHARMCOUNT 33 11061f28255Scgd #define INVISIBILITY 34 11161f28255Scgd #define CANCELLATION 35 11261f28255Scgd #define HASTESELF 36 11361f28255Scgd #define EYEOFLARN 37 11461f28255Scgd #define AGGRAVATE 38 11561f28255Scgd #define GLOBE 39 11661f28255Scgd #define TELEFLAG 40 11761f28255Scgd #define SLAYING 41 11861f28255Scgd #define NEGATESPIRIT 42 11961f28255Scgd #define SCAREMONST 43 12061f28255Scgd #define AWARENESS 44 12161f28255Scgd #define HOLDMONST 45 12261f28255Scgd #define TIMESTOP 46 12361f28255Scgd #define HASTEMONST 47 12461f28255Scgd #define CUBEofUNDEAD 48 12561f28255Scgd #define GIANTSTR 49 12661f28255Scgd #define FIRERESISTANCE 50 12761f28255Scgd #define BESSMANN 51 12861f28255Scgd #define NOTHEFT 52 12961f28255Scgd #define HARDGAME 53 13061f28255Scgd #define CPUTIME 54 13161f28255Scgd #define BYTESIN 55 13261f28255Scgd #define BYTESOUT 56 13361f28255Scgd #define MOVESMADE 57 13461f28255Scgd #define MONSTKILLED 58 13561f28255Scgd #define SPELLSCAST 59 13661f28255Scgd #define LANCEDEATH 60 13761f28255Scgd #define SPIRITPRO 61 13861f28255Scgd #define UNDEADPRO 62 13961f28255Scgd #define SHIELD 63 14061f28255Scgd #define STEALTH 64 14161f28255Scgd #define ITCHING 65 14261f28255Scgd #define LAUGHING 66 14361f28255Scgd #define DRAINSTRENGTH 67 14461f28255Scgd #define CLUMSINESS 68 14561f28255Scgd #define INFEEBLEMENT 69 14661f28255Scgd #define HALFDAM 70 14761f28255Scgd #define SEEINVISIBLE 71 14861f28255Scgd #define FILLROOM 72 14961f28255Scgd #define RANDOMWALK 73 15061f28255Scgd #define SPHCAST 74 /* nz if an active sphere of annihilation */ 15161f28255Scgd #define WTW 75 /* walk through walls */ 152a8fba37dSchristos #define STREXTRA 76 /* character strength due to objects or 153a8fba37dSchristos * enchantments */ 15461f28255Scgd #define TMP 77 /* misc scratch space */ 15561f28255Scgd #define LIFEPROT 78 /* life protection counter */ 15661f28255Scgd 15761f28255Scgd /* defines for the objects in the game */ 15861f28255Scgd 15961f28255Scgd #define OALTAR 1 16061f28255Scgd #define OTHRONE 2 16161f28255Scgd #define OORB 3 16261f28255Scgd #define OPIT 4 16361f28255Scgd #define OSTAIRSUP 5 16461f28255Scgd #define OELEVATORUP 6 16561f28255Scgd #define OFOUNTAIN 7 16661f28255Scgd #define OSTATUE 8 16761f28255Scgd #define OTELEPORTER 9 16861f28255Scgd #define OSCHOOL 10 16961f28255Scgd #define OMIRROR 11 17061f28255Scgd #define ODNDSTORE 12 17161f28255Scgd #define OSTAIRSDOWN 13 17261f28255Scgd #define OELEVATORDOWN 14 17361f28255Scgd #define OBANK2 15 17461f28255Scgd #define OBANK 16 17561f28255Scgd #define ODEADFOUNTAIN 17 17661f28255Scgd #define OMAXGOLD 70 17761f28255Scgd #define OGOLDPILE 18 17861f28255Scgd #define OOPENDOOR 19 17961f28255Scgd #define OCLOSEDDOOR 20 18061f28255Scgd #define OWALL 21 18161f28255Scgd #define OTRAPARROW 66 18261f28255Scgd #define OTRAPARROWIV 67 18361f28255Scgd 18461f28255Scgd #define OLARNEYE 22 18561f28255Scgd 18661f28255Scgd #define OPLATE 23 18761f28255Scgd #define OCHAIN 24 18861f28255Scgd #define OLEATHER 25 18961f28255Scgd #define ORING 60 19061f28255Scgd #define OSTUDLEATHER 61 19161f28255Scgd #define OSPLINT 62 19261f28255Scgd #define OPLATEARMOR 63 19361f28255Scgd #define OSSPLATE 64 19461f28255Scgd #define OSHIELD 68 19561f28255Scgd #define OELVENCHAIN 92 19661f28255Scgd 19761f28255Scgd #define OSWORDofSLASHING 26 19861f28255Scgd #define OHAMMER 27 19961f28255Scgd #define OSWORD 28 20061f28255Scgd #define O2SWORD 29 20161f28255Scgd #define OSPEAR 30 20261f28255Scgd #define ODAGGER 31 20361f28255Scgd #define OBATTLEAXE 57 20461f28255Scgd #define OLONGSWORD 58 20561f28255Scgd #define OFLAIL 59 20661f28255Scgd #define OLANCE 65 20761f28255Scgd #define OVORPAL 90 20861f28255Scgd #define OSLAYER 91 20961f28255Scgd 21061f28255Scgd #define ORINGOFEXTRA 32 21161f28255Scgd #define OREGENRING 33 21261f28255Scgd #define OPROTRING 34 21361f28255Scgd #define OENERGYRING 35 21461f28255Scgd #define ODEXRING 36 21561f28255Scgd #define OSTRRING 37 21661f28255Scgd #define OCLEVERRING 38 21761f28255Scgd #define ODAMRING 39 21861f28255Scgd 21961f28255Scgd #define OBELT 40 22061f28255Scgd 22161f28255Scgd #define OSCROLL 41 22261f28255Scgd #define OPOTION 42 22361f28255Scgd #define OBOOK 43 22461f28255Scgd #define OCHEST 44 22561f28255Scgd #define OAMULET 45 22661f28255Scgd 22761f28255Scgd #define OORBOFDRAGON 46 22861f28255Scgd #define OSPIRITSCARAB 47 22961f28255Scgd #define OCUBEofUNDEAD 48 23061f28255Scgd #define ONOTHEFT 49 23161f28255Scgd 23261f28255Scgd #define ODIAMOND 50 23361f28255Scgd #define ORUBY 51 23461f28255Scgd #define OEMERALD 52 23561f28255Scgd #define OSAPPHIRE 53 23661f28255Scgd 23761f28255Scgd #define OENTRANCE 54 23861f28255Scgd #define OVOLDOWN 55 23961f28255Scgd #define OVOLUP 56 24061f28255Scgd #define OHOME 69 24161f28255Scgd 24261f28255Scgd #define OKGOLD 71 24361f28255Scgd #define ODGOLD 72 24461f28255Scgd #define OIVDARTRAP 73 24561f28255Scgd #define ODARTRAP 74 24661f28255Scgd #define OTRAPDOOR 75 24761f28255Scgd #define OIVTRAPDOOR 76 24861f28255Scgd #define OTRADEPOST 77 24961f28255Scgd #define OIVTELETRAP 78 25061f28255Scgd #define ODEADTHRONE 79 25161f28255Scgd #define OANNIHILATION 80 /* sphere of annihilation */ 25261f28255Scgd #define OTHRONE2 81 25361f28255Scgd #define OLRS 82 /* Larn Revenue Service */ 25461f28255Scgd #define OCOOKIE 83 25561f28255Scgd #define OURN 84 25661f28255Scgd #define OBRASSLAMP 85 25761f28255Scgd #define OHANDofFEAR 86 /* hand of fear */ 25861f28255Scgd #define OSPHTAILSMAN 87 /* tailsman of the sphere */ 25961f28255Scgd #define OWWAND 88 /* wand of wonder */ 26061f28255Scgd #define OPSTAFF 89 /* staff of power */ 26161f28255Scgd /* used up to 92 */ 26261f28255Scgd 26361f28255Scgd /* defines for the monsters as objects */ 26461f28255Scgd 26561f28255Scgd #define BAT 1 26661f28255Scgd #define GNOME 2 26761f28255Scgd #define HOBGOBLIN 3 26861f28255Scgd #define JACKAL 4 26961f28255Scgd #define KOBOLD 5 27061f28255Scgd #define ORC 6 27161f28255Scgd #define SNAKE 7 27261f28255Scgd #define CENTIPEDE 8 27361f28255Scgd #define JACULI 9 27461f28255Scgd #define TROGLODYTE 10 27561f28255Scgd #define ANT 11 27661f28255Scgd #define EYE 12 27761f28255Scgd #define LEPRECHAUN 13 27861f28255Scgd #define NYMPH 14 27961f28255Scgd #define QUASIT 15 28061f28255Scgd #define RUSTMONSTER 16 28161f28255Scgd #define ZOMBIE 17 28261f28255Scgd #define ASSASSINBUG 18 28361f28255Scgd #define BUGBEAR 19 28461f28255Scgd #define HELLHOUND 20 28561f28255Scgd #define ICELIZARD 21 28661f28255Scgd #define CENTAUR 22 28761f28255Scgd #define TROLL 23 28861f28255Scgd #define YETI 24 28961f28255Scgd #define WHITEDRAGON 25 29061f28255Scgd #define ELF 26 29161f28255Scgd #define CUBE 27 29261f28255Scgd #define METAMORPH 28 29361f28255Scgd #define VORTEX 29 29461f28255Scgd #define ZILLER 30 29561f28255Scgd #define VIOLETFUNGI 31 29661f28255Scgd #define WRAITH 32 29761f28255Scgd #define FORVALAKA 33 29861f28255Scgd #define LAMANOBE 34 29961f28255Scgd #define OSEQUIP 35 30061f28255Scgd #define ROTHE 36 30161f28255Scgd #define XORN 37 30261f28255Scgd #define VAMPIRE 38 30361f28255Scgd #define INVISIBLESTALKER 39 30461f28255Scgd #define POLTERGEIST 40 30561f28255Scgd #define DISENCHANTRESS 41 30661f28255Scgd #define SHAMBLINGMOUND 42 30761f28255Scgd #define YELLOWMOLD 43 30861f28255Scgd #define UMBERHULK 44 30961f28255Scgd #define GNOMEKING 45 31061f28255Scgd #define MIMIC 46 31161f28255Scgd #define WATERLORD 47 31261f28255Scgd #define BRONZEDRAGON 48 31361f28255Scgd #define GREENDRAGON 49 31461f28255Scgd #define PURPLEWORM 50 31561f28255Scgd #define XVART 51 31661f28255Scgd #define SPIRITNAGA 52 31761f28255Scgd #define SILVERDRAGON 53 31861f28255Scgd #define PLATINUMDRAGON 54 31961f28255Scgd #define GREENURCHIN 55 32061f28255Scgd #define REDDRAGON 56 32161f28255Scgd #define DEMONLORD 57 32261f28255Scgd #define DEMONPRINCE 64 32361f28255Scgd 324c5275d9cSagc #ifndef NULL 32561f28255Scgd #define NULL 0 326c5275d9cSagc #endif 32761f28255Scgd #define BUFBIG 4096 /* size of the output buffer */ 32861f28255Scgd #define MAXIBUF 4096 /* size of the input buffer */ 32961f28255Scgd #define LOGNAMESIZE 40 /* max size of the players name */ 33061f28255Scgd #define PSNAMESIZE 40 /* max size of the process name */ 33161f28255Scgd 33261f28255Scgd #ifndef NODEFS 33361f28255Scgd extern char VERSION, SUBVERSION; 334ef066a15Sdholland extern u_char beenhere[], boldon, cheat, ckpflag; 3359cc7e274Sdholland extern const char *class[]; 3369cc7e274Sdholland extern u_char course[]; 337a8fba37dSchristos extern char diagfile[], helpfile[], ckpfile[], larnlevels[], 338a0d324eaSchristos playerids[], optsfile[1024], psname[], savefilename[], 339a8fba37dSchristos scorefile[]; 340*5c104910Sdholland extern u_char *inbuffer; 341a8fba37dSchristos extern u_char item[MAXX][MAXY], iven[], know[MAXX][MAXY]; 3429cc7e274Sdholland extern const char *levelname[]; 3439cc7e274Sdholland extern char logfile[], loginname[], logname[], lastmonst[]; 344a8fba37dSchristos extern u_char *lpbuf, *lpend; 345a8fba37dSchristos extern u_char *lpnt, moved[MAXX][MAXY], mitem[MAXX][MAXY], monstlevel[]; 346a8fba37dSchristos extern char monstnamelist[], objnamelist[]; 347a8fba37dSchristos extern u_char nch[], ndgg[], nlpts[], nomove, nosignal, nowelcome; 348a8fba37dSchristos extern u_char nplt[], nsw[]; 3499cc7e274Sdholland extern const char *objectname[]; 3509cc7e274Sdholland extern const char *potionhide[], *potionname[]; 3519cc7e274Sdholland extern const char *spelcode[], *spelname[], *spelmes[]; 3529cc7e274Sdholland extern char aborted[], spelweird[MAXMONST + 8][SPNUM]; 353a8fba37dSchristos extern u_char potprob[]; 354a8fba37dSchristos extern u_char predostuff, restorflag, scprob[]; 355a8fba37dSchristos extern u_char screen[MAXX][MAXY], sex; 3569cc7e274Sdholland extern const char *speldescript[]; 3579cc7e274Sdholland extern const char *scrollhide[], *scrollname[]; 358a8fba37dSchristos extern u_char spelknow[]; 359*5c104910Sdholland extern u_char splev[], stealth[MAXX][MAXY], wizard; 36061f28255Scgd extern short diroffx[], diroffy[], hitflag, hit2flag, hit3flag, hitp[MAXX][MAXY]; 361a8fba37dSchristos extern short iarg[MAXX][MAXY], ivenarg[], lasthx, lasthy, lastnum, lastpx, 362a8fba37dSchristos lastpy; 363365ece4eSthorpej extern short nobeep, oldx, oldy, playerx, playery, level; 364b6e0b3d3Sdholland extern int enable_scroll, srcount, yrepcount, userid, wisid, 3659cc7e274Sdholland io_outfd, io_infd; 366511d1e00Sdholland extern gid_t gid, egid; 367c356cad8Sthorpej extern long outstanding_taxes, skill[], gltime, c[], cbak[]; 368c356cad8Sthorpej extern time_t initialtime; 36961f28255Scgd extern unsigned long randx; 37061f28255Scgd extern struct cel *cell; 37161f28255Scgd extern struct monst monster[]; 37261f28255Scgd extern struct sphere *spheres; 37361f28255Scgd extern struct _itm itm[]; 374ef066a15Sdholland extern int rmst, lasttime; 37561f28255Scgd 37661f28255Scgd /* macro to create scroll #'s with probability of occurrence */ 37761f28255Scgd #define newscroll() (scprob[rund(81)]) 37861f28255Scgd /* macro to return a potion # created with probability of occurrence */ 37961f28255Scgd #define newpotion() (potprob[rund(41)]) 38061f28255Scgd /* macro to return the + points on created leather armor */ 38161f28255Scgd #define newleather() (nlpts[rund(c[HARDGAME]?13:15)]) 38261f28255Scgd /* macro to return the + points on chain armor */ 38361f28255Scgd #define newchain() (nch[rund(10)]) 38461f28255Scgd /* macro to return + points on plate armor */ 38561f28255Scgd #define newplate() (nplt[rund(c[HARDGAME]?4:12)]) 38661f28255Scgd /* macro to return + points on new daggers */ 38761f28255Scgd #define newdagger() (ndgg[rund(13)]) 38861f28255Scgd /* macro to return + points on new swords */ 38961f28255Scgd #define newsword() (nsw[rund(c[HARDGAME]?6:13)]) 39061f28255Scgd /* macro to destroy object at present location */ 39161f28255Scgd #define forget() (item[playerx][playery]=know[playerx][playery]=0) 39261f28255Scgd /* macro to wipe out a monster at a location */ 39361f28255Scgd #define disappear(x,y) (mitem[x][y]=know[x][y]=0) 39461f28255Scgd 39561f28255Scgd #ifdef VT100 39661f28255Scgd /* macro to turn on bold display for the terminal */ 39761f28255Scgd #define setbold() (lprcat(boldon?"\33[1m":"\33[7m")) 39861f28255Scgd /* macro to turn off bold display for the terminal */ 39961f28255Scgd #define resetbold() (lprcat("\33[m")) 40061f28255Scgd /* macro to setup the scrolling region for the terminal */ 40161f28255Scgd #define setscroll() (lprcat("\33[20;24r")) 40261f28255Scgd /* macro to clear the scrolling region for the terminal */ 40361f28255Scgd #define resetscroll() (lprcat("\33[;24r")) 40461f28255Scgd /* macro to clear the screen and home the cursor */ 40561f28255Scgd #define clear() (lprcat("\33[2J\33[f"), cbak[SPELLS]= -50) 40661f28255Scgd #define cltoeoln() lprcat("\33[K") 407a8fba37dSchristos #else /* VT100 */ 40861f28255Scgd /* defines below are for use in the termcap mode only */ 40961f28255Scgd #define ST_START 1 41061f28255Scgd #define ST_END 2 41161f28255Scgd #define BOLD 3 41261f28255Scgd #define END_BOLD 4 41361f28255Scgd #define CLEAR 5 41461f28255Scgd #define CL_LINE 6 41561f28255Scgd #define CL_DOWN 14 41661f28255Scgd #define CURSOR 15 41761f28255Scgd /* macro to turn on bold display for the terminal */ 41861f28255Scgd #define setbold() (*lpnt++ = ST_START) 41961f28255Scgd /* macro to turn off bold display for the terminal */ 42061f28255Scgd #define resetbold() (*lpnt++ = ST_END) 42161f28255Scgd /* macro to setup the scrolling region for the terminal */ 42261f28255Scgd #define setscroll() enable_scroll=1 42361f28255Scgd /* macro to clear the scrolling region for the terminal */ 42461f28255Scgd #define resetscroll() enable_scroll=0 42561f28255Scgd /* macro to clear the screen and home the cursor */ 42661f28255Scgd #define clear() (*lpnt++ =CLEAR, cbak[SPELLS]= -50) 42761f28255Scgd /* macro to clear to end of line */ 42861f28255Scgd #define cltoeoln() (*lpnt++ = CL_LINE) 429a8fba37dSchristos #endif /* VT100 */ 43061f28255Scgd 43161f28255Scgd /* macro to output one byte to the output buffer */ 43261f28255Scgd #define lprc(ch) ((lpnt>=lpend)?(*lpnt++ =(ch), lflush()):(*lpnt++ =(ch))) 43361f28255Scgd 43461f28255Scgd /* macro to seed the random number generator */ 4351a3bb884Sperry #define seedrand(x) (randx=x) 43661f28255Scgd #ifdef MACRORND 43761f28255Scgd /* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */ 43861f28255Scgd #define rnd(x) ((((randx=randx*1103515245+12345)>>7)%(x))+1) 43961f28255Scgd #define rund(x) ((((randx=randx*1103515245+12345)>>7)%(x)) ) 440a8fba37dSchristos #endif /* MACRORND */ 44161f28255Scgd /* macros for miscellaneous data conversion */ 44261f28255Scgd #define min(x,y) (((x)>(y))?(y):(x)) 44361f28255Scgd #define max(x,y) (((x)>(y))?(x):(y)) 444a8fba37dSchristos #endif /* NODEFS */ 445