1 1.16 dholland /* $NetBSD: hack.h,v 1.16 2011/08/06 20:18:26 dholland Exp $ */ 2 1.4 christos 3 1.2 mycroft /* 4 1.9 jsm * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, 5 1.9 jsm * Amsterdam 6 1.9 jsm * All rights reserved. 7 1.9 jsm * 8 1.9 jsm * Redistribution and use in source and binary forms, with or without 9 1.9 jsm * modification, are permitted provided that the following conditions are 10 1.9 jsm * met: 11 1.9 jsm * 12 1.9 jsm * - Redistributions of source code must retain the above copyright notice, 13 1.9 jsm * this list of conditions and the following disclaimer. 14 1.9 jsm * 15 1.9 jsm * - Redistributions in binary form must reproduce the above copyright 16 1.9 jsm * notice, this list of conditions and the following disclaimer in the 17 1.9 jsm * documentation and/or other materials provided with the distribution. 18 1.9 jsm * 19 1.9 jsm * - Neither the name of the Stichting Centrum voor Wiskunde en 20 1.9 jsm * Informatica, nor the names of its contributors may be used to endorse or 21 1.9 jsm * promote products derived from this software without specific prior 22 1.9 jsm * written permission. 23 1.9 jsm * 24 1.9 jsm * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 25 1.9 jsm * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 26 1.9 jsm * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 27 1.9 jsm * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 28 1.9 jsm * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 29 1.9 jsm * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30 1.9 jsm * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 31 1.9 jsm * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 32 1.9 jsm * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 33 1.9 jsm * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 1.9 jsm * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 1.2 mycroft */ 36 1.9 jsm 37 1.9 jsm /* 38 1.9 jsm * Copyright (c) 1982 Jay Fenlason <hack (at) gnu.org> 39 1.9 jsm * All rights reserved. 40 1.9 jsm * 41 1.9 jsm * Redistribution and use in source and binary forms, with or without 42 1.9 jsm * modification, are permitted provided that the following conditions 43 1.9 jsm * are met: 44 1.9 jsm * 1. Redistributions of source code must retain the above copyright 45 1.9 jsm * notice, this list of conditions and the following disclaimer. 46 1.9 jsm * 2. Redistributions in binary form must reproduce the above copyright 47 1.9 jsm * notice, this list of conditions and the following disclaimer in the 48 1.9 jsm * documentation and/or other materials provided with the distribution. 49 1.9 jsm * 3. The name of the author may not be used to endorse or promote products 50 1.9 jsm * derived from this software without specific prior written permission. 51 1.9 jsm * 52 1.9 jsm * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 53 1.9 jsm * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 54 1.9 jsm * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 55 1.9 jsm * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 56 1.9 jsm * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 57 1.9 jsm * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 58 1.9 jsm * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 59 1.9 jsm * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 60 1.9 jsm * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 61 1.9 jsm * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 62 1.9 jsm */ 63 1.9 jsm 64 1.4 christos #ifndef _HACK_H_ 65 1.4 christos #define _HACK_H_ 66 1.1 cgd 67 1.1 cgd #include "config.h" 68 1.5 matt #include <stdlib.h> 69 1.1 cgd #include <string.h> 70 1.14 mrg #include <sys/time.h> 71 1.1 cgd 72 1.1 cgd #define Null(type) ((struct type *) 0) 73 1.1 cgd 74 1.1 cgd #include "def.objclass.h" 75 1.1 cgd 76 1.1 cgd typedef struct { 77 1.1 cgd xchar x,y; 78 1.1 cgd } coord; 79 1.1 cgd 80 1.1 cgd #include "def.monst.h" /* uses coord */ 81 1.1 cgd #include "def.gold.h" 82 1.1 cgd #include "def.trap.h" 83 1.1 cgd #include "def.obj.h" 84 1.1 cgd #include "def.flag.h" 85 1.1 cgd 86 1.1 cgd #define plur(x) (((x) == 1) ? "" : "s") 87 1.1 cgd 88 1.1 cgd #define BUFSZ 256 /* for getlin buffers */ 89 1.1 cgd #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */ 90 1.1 cgd 91 1.1 cgd #include "def.rm.h" 92 1.1 cgd #include "def.permonst.h" 93 1.1 cgd 94 1.16 dholland #define newstring(x) ((char *) alloc(x)) 95 1.1 cgd #include "hack.onames.h" 96 1.1 cgd 97 1.1 cgd #define ON 1 98 1.1 cgd #define OFF 0 99 1.1 cgd 100 1.1 cgd struct prop { 101 1.1 cgd #define TIMEOUT 007777 /* mask */ 102 1.1 cgd #define LEFT_RING W_RINGL /* 010000L */ 103 1.1 cgd #define RIGHT_RING W_RINGR /* 020000L */ 104 1.1 cgd #define INTRINSIC 040000L 105 1.1 cgd #define LEFT_SIDE LEFT_RING 106 1.1 cgd #define RIGHT_SIDE RIGHT_RING 107 1.1 cgd #define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE) 108 1.1 cgd long p_flgs; 109 1.10 jsm void (*p_tofn)(void); /* called after timeout */ 110 1.1 cgd }; 111 1.1 cgd 112 1.1 cgd struct you { 113 1.1 cgd xchar ux, uy; 114 1.1 cgd schar dx, dy, dz; /* direction of move (or zap or ... ) */ 115 1.1 cgd #ifdef QUEST 116 1.1 cgd schar di; /* direction of FF */ 117 1.1 cgd xchar ux0, uy0; /* initial position FF */ 118 1.6 cgd #endif /* QUEST */ 119 1.1 cgd xchar udisx, udisy; /* last display pos */ 120 1.1 cgd char usym; /* usually '@' */ 121 1.1 cgd schar uluck; 122 1.1 cgd #define LUCKMAX 10 /* on moonlit nights 11 */ 123 1.1 cgd #define LUCKMIN (-10) 124 1.1 cgd int last_str_turn:3; /* 0: none, 1: half turn, 2: full turn */ 125 1.1 cgd /* +: turn right, -: turn left */ 126 1.1 cgd unsigned udispl:1; /* @ on display */ 127 1.1 cgd unsigned ulevel:4; /* 1 - 14 */ 128 1.1 cgd #ifdef QUEST 129 1.1 cgd unsigned uhorizon:7; 130 1.6 cgd #endif /* QUEST */ 131 1.1 cgd unsigned utrap:3; /* trap timeout */ 132 1.1 cgd unsigned utraptype:1; /* defined if utrap nonzero */ 133 1.1 cgd #define TT_BEARTRAP 0 134 1.1 cgd #define TT_PIT 1 135 1.1 cgd unsigned uinshop:6; /* used only in shk.c - (roomno+1) of shop */ 136 1.1 cgd 137 1.1 cgd 138 1.1 cgd /* perhaps these #define's should also be generated by makedefs */ 139 1.1 cgd #define TELEPAT LAST_RING /* not a ring */ 140 1.1 cgd #define Telepat u.uprops[TELEPAT].p_flgs 141 1.1 cgd #define FAST (LAST_RING+1) /* not a ring */ 142 1.1 cgd #define Fast u.uprops[FAST].p_flgs 143 1.1 cgd #define CONFUSION (LAST_RING+2) /* not a ring */ 144 1.1 cgd #define Confusion u.uprops[CONFUSION].p_flgs 145 1.1 cgd #define INVIS (LAST_RING+3) /* not a ring */ 146 1.1 cgd #define Invis u.uprops[INVIS].p_flgs 147 1.1 cgd #define Invisible (Invis && !See_invisible) 148 1.1 cgd #define GLIB (LAST_RING+4) /* not a ring */ 149 1.1 cgd #define Glib u.uprops[GLIB].p_flgs 150 1.1 cgd #define PUNISHED (LAST_RING+5) /* not a ring */ 151 1.1 cgd #define Punished u.uprops[PUNISHED].p_flgs 152 1.1 cgd #define SICK (LAST_RING+6) /* not a ring */ 153 1.1 cgd #define Sick u.uprops[SICK].p_flgs 154 1.1 cgd #define BLIND (LAST_RING+7) /* not a ring */ 155 1.1 cgd #define Blind u.uprops[BLIND].p_flgs 156 1.1 cgd #define WOUNDED_LEGS (LAST_RING+8) /* not a ring */ 157 1.1 cgd #define Wounded_legs u.uprops[WOUNDED_LEGS].p_flgs 158 1.1 cgd #define STONED (LAST_RING+9) /* not a ring */ 159 1.1 cgd #define Stoned u.uprops[STONED].p_flgs 160 1.1 cgd #define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */ 161 1.1 cgd unsigned umconf:1; 162 1.8 jsm const char *usick_cause; 163 1.1 cgd struct prop uprops[LAST_RING+10]; 164 1.1 cgd 165 1.1 cgd unsigned uswallow:1; /* set if swallowed by a monster */ 166 1.1 cgd unsigned uswldtim:4; /* time you have been swallowed */ 167 1.1 cgd unsigned uhs:3; /* hunger state - see hack.eat.c */ 168 1.1 cgd schar ustr,ustrmax; 169 1.1 cgd schar udaminc; 170 1.1 cgd schar uac; 171 1.1 cgd int uhp,uhpmax; 172 1.1 cgd long int ugold,ugold0,uexp,urexp; 173 1.1 cgd int uhunger; /* refd only in eat.c and shk.c */ 174 1.1 cgd int uinvault; 175 1.1 cgd struct monst *ustuck; 176 1.1 cgd int nr_killed[CMNUM+2]; /* used for experience bookkeeping */ 177 1.1 cgd }; 178 1.1 cgd 179 1.1 cgd #define DIST(x1,y1,x2,y2) (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2))) 180 1.1 cgd 181 1.1 cgd #define PL_CSIZ 20 /* sizeof pl_character */ 182 1.1 cgd #define MAX_CARR_CAP 120 /* so that boulders can be heavier */ 183 1.1 cgd #define MAXLEVEL 40 184 1.1 cgd #define FAR (COLNO+2) /* position outside screen */ 185 1.4 christos 186 1.4 christos extern boolean in_mklev; 187 1.4 christos extern boolean level_exists[]; 188 1.4 christos extern boolean restoring; 189 1.4 christos extern char *CD; 190 1.8 jsm extern const char *catmore; 191 1.4 christos extern char *hname; 192 1.8 jsm extern const char *const hu_stat[]; /* in eat.c */ 193 1.8 jsm extern const char *nomovemsg; 194 1.8 jsm extern const char *occtxt; 195 1.12 dholland extern const char *save_cm; 196 1.8 jsm extern const char *killer; 197 1.8 jsm extern const char *const traps[]; 198 1.4 christos extern char SAVEF[]; 199 1.4 christos extern char fut_geno[60]; /* idem */ 200 1.4 christos extern char genocided[60]; /* defined in Decl.c */ 201 1.13 dholland extern char lock[PL_NSIZ + 4]; 202 1.11 dholland extern const char mlarge[]; 203 1.4 christos extern char morc; 204 1.11 dholland extern const char nul[]; 205 1.4 christos extern char plname[PL_NSIZ], pl_character[PL_CSIZ]; 206 1.8 jsm extern const char quitchars[]; 207 1.4 christos extern char sdir[]; /* defined in hack.c */ 208 1.8 jsm extern const char shtypes[]; /* = "=/)%?!["; 8 types: 7 specialized, 1 mixed */ 209 1.8 jsm extern const char vowels[]; 210 1.4 christos extern coord bhitpos; /* place where thrown weapon falls to the ground */ 211 1.10 jsm extern int (*afternmv)(void); 212 1.10 jsm extern int (*occupation)(void); 213 1.4 christos extern int CO, LI; /* usually COLNO and ROWNO+2 */ 214 1.4 christos extern int bases[]; 215 1.4 christos extern int doorindex; 216 1.4 christos extern int hackpid; 217 1.4 christos extern int multi; 218 1.4 christos extern int nroom; 219 1.4 christos extern long moves; 220 1.4 christos extern long wailmsg; 221 1.4 christos extern schar xdir[], ydir[]; /* idem */ 222 1.4 christos extern struct monst *mydogs; 223 1.4 christos extern struct monst youmonst; 224 1.4 christos extern struct obj *billobjs; 225 1.4 christos extern struct obj *invent, *uwep, *uarm, *uarm2, *uarmh, *uarms, *uarmg; 226 1.4 christos extern struct obj *uleft, *uright, *fcobj; 227 1.4 christos extern struct obj *uball; /* defined if PUNISHED */ 228 1.4 christos extern struct obj *uchain; /* defined iff PUNISHED */ 229 1.4 christos extern struct obj zeroobj; 230 1.8 jsm extern const struct permonst li_dog, dog, la_dog; 231 1.8 jsm extern const struct permonst pm_eel; 232 1.8 jsm extern const struct permonst pm_ghost; 233 1.8 jsm extern const struct permonst pm_mail_daemon; 234 1.8 jsm extern const struct permonst pm_wizard; 235 1.4 christos #ifndef NOWORM 236 1.4 christos extern long wgrowtime[32]; 237 1.4 christos extern struct wseg *m_atseg; 238 1.4 christos extern struct wseg *wsegs[32], *wheads[32]; 239 1.4 christos #endif 240 1.4 christos extern struct you u; 241 1.4 christos extern xchar curx, cury; /* cursor location on screen */ 242 1.4 christos extern xchar dlevel, maxdlevel; /* dungeon level */ 243 1.4 christos extern xchar seehx,seelx,seehy,seely; /* where to see*/ 244 1.4 christos extern xchar xdnstair, ydnstair, xupstair, yupstair; /* stairs up and down. */ 245 1.4 christos #endif /* _HACK_H_ */ 246