1 /* SCCS Id: @(#)hack.h 3.4 2001/04/12 */ 2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3 /* NetHack may be freely redistributed. See license for details. */ 4 5 #ifndef HACK_H 6 #define HACK_H 7 8 #ifndef CONFIG_H 9 #include "config.h" 10 #endif 11 12 /* For debugging beta code. */ 13 #ifdef BETA 14 #define Dpline pline 15 #endif 16 17 #define TELL 1 18 #define NOTELL 0 19 #define ON 1 20 #define OFF 0 21 #define BOLT_LIM 8 /* from this distance ranged attacks will be made */ 22 #define MAX_CARR_CAP 1000 /* so that boulders can be heavier */ 23 #define DUMMY { 0 } 24 25 /* symbolic names for capacity levels */ 26 #define UNENCUMBERED 0 27 #define SLT_ENCUMBER 1 /* Burdened */ 28 #define MOD_ENCUMBER 2 /* Stressed */ 29 #define HVY_ENCUMBER 3 /* Strained */ 30 #define EXT_ENCUMBER 4 /* Overtaxed */ 31 #define OVERLOADED 5 /* Overloaded */ 32 33 /* Macros for how a rumor was delivered in outrumor() */ 34 #define BY_ORACLE 0 35 #define BY_COOKIE 1 36 #define BY_PAPER 2 37 #define BY_OTHER 9 38 39 #ifdef STEED 40 /* Macros for why you are no longer riding */ 41 #define DISMOUNT_GENERIC 0 42 #define DISMOUNT_FELL 1 43 #define DISMOUNT_THROWN 2 44 #define DISMOUNT_POLY 3 45 #define DISMOUNT_ENGULFED 4 46 #define DISMOUNT_BONES 5 47 #define DISMOUNT_BYCHOICE 6 48 #define DISMOUNT_VANISHED 7 49 #endif 50 51 /* Special returns from mapglyph() */ 52 #define MG_CORPSE 0x01 53 #define MG_INVIS 0x02 54 #define MG_DETECT 0x04 55 #define MG_PET 0x08 56 #define MG_RIDDEN 0x10 57 #define MG_INVERSE 0x20 /* use inverse video */ 58 59 /* sellobj_state() states */ 60 #define SELL_NORMAL (0) 61 #define SELL_DELIBERATE (1) 62 #define SELL_DONTSELL (2) 63 64 /* 65 * This is the way the game ends. If these are rearranged, the arrays 66 * in end.c and topten.c will need to be changed. Some parts of the 67 * code assume that PANIC separates the deaths from the non-deaths. 68 */ 69 #define DIED 0 70 #define CHOKING 1 71 #define POISONING 2 72 #define STARVING 3 73 #define DROWNING 4 74 #define BURNING 5 75 #define DISSOLVED 6 76 #define CRUSHING 7 77 #define STONING 8 78 #define TURNED_SLIME 9 79 #ifdef WEBB_DISINT 80 # define GENOCIDED 10 81 # define DISINTEGRATED 11 82 # define MAX_SURVIVABLE_DEATH 11 83 # define PANICKED 12 84 # define TRICKED 13 85 # define QUIT 14 86 # define ESCAPED 15 87 #ifdef ASTRAL_ESCAPE 88 #define DEFIED 16 89 #define ASCENDED 17 90 #endif 91 #endif 92 93 #include "align.h" 94 #include "dungeon.h" 95 #include "monsym.h" 96 #include "mkroom.h" 97 #include "objclass.h" 98 #include "youprop.h" 99 #include "wintype.h" 100 #include "decl.h" 101 #include "timeout.h" 102 103 NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */ 104 105 /* types of calls to bhit() */ 106 #define ZAPPED_WAND 0 107 #define THROWN_WEAPON 1 108 #define KICKED_WEAPON 2 109 #define FLASHED_LIGHT 3 110 #define INVIS_BEAM 4 111 112 #include "trap.h" 113 #include "flag.h" 114 #include "rm.h" 115 #include "vision.h" 116 #include "display.h" 117 #include "engrave.h" 118 #include "rect.h" 119 #include "region.h" 120 121 #ifdef USE_TRAMPOLI /* This doesn't belong here, but we have little choice */ 122 #undef NDECL 123 #define NDECL(f) f() 124 #endif 125 126 #include "extern.h" 127 #include "winprocs.h" 128 129 #ifdef USE_TRAMPOLI 130 #include "wintty.h" 131 #undef WINTTY_H 132 #include "trampoli.h" 133 #undef EXTERN_H 134 #include "extern.h" 135 #endif /* USE_TRAMPOLI */ 136 137 #define NO_SPELL 0 138 139 /* flags to control makemon() */ 140 #define NO_MM_FLAGS 0x00 /* use this rather than plain 0 */ 141 #define NO_MINVENT 0x01 /* suppress minvent when creating mon */ 142 #define MM_NOWAIT 0x02 /* don't set STRAT_WAITMASK flags */ 143 #define MM_EDOG 0x04 /* add edog structure */ 144 #define MM_EMIN 0x08 /* add emin structure */ 145 #define MM_ANGRY 0x10 /* monster is created angry */ 146 #define MM_NONAME 0x20 /* monster is not christened */ 147 #define MM_NOCOUNTBIRTH 0x40 /* don't increment born counter (for revival) */ 148 #define MM_IGNOREWATER 0x80 /* ignore water when positioning */ 149 #define MM_ADJACENTOK 0x100 /* it is acceptable to use adjacent coordinates */ 150 151 /* special mhpmax value when loading bones monster to flag as extinct or genocided */ 152 #define DEFUNCT_MONSTER (-100) 153 154 /* flags for special ggetobj status returns */ 155 #define ALL_FINISHED 0x01 /* called routine already finished the job */ 156 157 /* flags to control query_objlist() */ 158 #define BY_NEXTHERE 0x1 /* follow objlist by nexthere field */ 159 #define AUTOSELECT_SINGLE 0x2 /* if only 1 object, don't ask */ 160 #define USE_INVLET 0x4 /* use object's invlet */ 161 #define INVORDER_SORT 0x8 /* sort objects by packorder */ 162 #define SIGNAL_NOMENU 0x10 /* return -1 rather than 0 if none allowed */ 163 #define FEEL_COCKATRICE 0x20 /* engage cockatrice checks and react */ 164 165 /* Flags to control query_category() */ 166 /* BY_NEXTHERE used by query_category() too, so skip 0x01 */ 167 #define UNPAID_TYPES 0x02 168 #define GOLD_TYPES 0x04 169 #define WORN_TYPES 0x08 170 #define ALL_TYPES 0x10 171 #define BILLED_TYPES 0x20 172 #define CHOOSE_ALL 0x40 173 #define BUC_BLESSED 0x80 174 #define BUC_CURSED 0x100 175 #define BUC_UNCURSED 0x200 176 #define BUC_UNKNOWN 0x400 177 #define BUC_ALLBKNOWN (BUC_BLESSED|BUC_CURSED|BUC_UNCURSED) 178 #define UNIDENTIFIED_TYPES 0x800 179 #define ALL_TYPES_SELECTED -2 180 181 /* Flags to control find_mid() */ 182 #define FM_FMON 0x01 /* search the fmon chain */ 183 #define FM_MIGRATE 0x02 /* search the migrating monster chain */ 184 #define FM_MYDOGS 0x04 /* search mydogs */ 185 #define FM_EVERYWHERE (FM_FMON | FM_MIGRATE | FM_MYDOGS) 186 187 /* Flags to control pick_[race,role,gend,align] routines in role.c */ 188 #define PICK_RANDOM 0 189 #define PICK_RIGID 1 190 191 /* Flags to control dotrap() in trap.c */ 192 #define NOWEBMSG 0x01 /* suppress stumble into web message */ 193 #define FORCEBUNGLE 0x02 /* adjustments appropriate for bungling */ 194 #define RECURSIVETRAP 0x04 /* trap changed into another type this same turn */ 195 196 /* Flags to control test_move in hack.c */ 197 #define DO_MOVE 0 /* really doing the move */ 198 #define TEST_MOVE 1 /* test a normal move (move there next) */ 199 #define TEST_TRAV 2 /* test a future travel location */ 200 #define TEST_TRAP 3 /* check if a future travel location is a trap */ 201 202 /*** some utility macros ***/ 203 #define yn(query) yn_function(query,ynchars, 'n') 204 #define ynq(query) yn_function(query,ynqchars, 'q') 205 #define ynaq(query) yn_function(query,ynaqchars, 'y') 206 #define nyaq(query) yn_function(query,ynaqchars, 'n') 207 #define nyNaq(query) yn_function(query,ynNaqchars, 'n') 208 #define ynNaq(query) yn_function(query,ynNaqchars, 'y') 209 210 /* Macros for scatter */ 211 #define VIS_EFFECTS 0x01 /* display visual effects */ 212 #define MAY_HITMON 0x02 /* objects may hit monsters */ 213 #define MAY_HITYOU 0x04 /* objects may hit you */ 214 #define MAY_HIT (MAY_HITMON|MAY_HITYOU) 215 #define MAY_DESTROY 0x08 /* objects may be destroyed at random */ 216 #define MAY_FRACTURE 0x10 /* boulders & statues may fracture */ 217 218 /* Macros for launching objects */ 219 #define ROLL 0x01 /* the object is rolling */ 220 #define FLING 0x02 /* the object is flying thru the air */ 221 #define LAUNCH_UNSEEN 0x40 /* hero neither caused nor saw it */ 222 #define LAUNCH_KNOWN 0x80 /* the hero caused this by explicit action */ 223 224 /* Macros for explosion types */ 225 #define EXPL_DARK 0 226 #define EXPL_NOXIOUS 1 227 #define EXPL_MUDDY 2 228 #define EXPL_WET 3 229 #define EXPL_MAGICAL 4 230 #define EXPL_FIERY 5 231 #define EXPL_FROSTY 6 232 #define EXPL_MAX 7 233 234 /* Macros for messages referring to hands, eyes, feet, etc... */ 235 #define ARM 0 236 #define EYE 1 237 #define FACE 2 238 #define FINGER 3 239 #define FINGERTIP 4 240 #define FOOT 5 241 #define HAND 6 242 #define HANDED 7 243 #define HEAD 8 244 #define LEG 9 245 #define LIGHT_HEADED 10 246 #define NECK 11 247 #define SPINE 12 248 #define TOE 13 249 #define HAIR 14 250 #define BLOOD 15 251 #define LUNG 16 252 #define NOSE 17 253 #define STOMACH 18 254 255 /* Flags to control menus */ 256 #define MENUTYPELEN sizeof("traditional ") 257 #define MENU_TRADITIONAL 0 258 #define MENU_COMBINATION 1 259 #define MENU_PARTIAL 2 260 #define MENU_FULL 3 261 262 #define MENU_SELECTED TRUE 263 #define MENU_UNSELECTED FALSE 264 265 #define MENU_DEFCNT 1 266 267 /* 268 * Option flags 269 * Each higher number includes the characteristics of the numbers 270 * below it. 271 */ 272 #define SET_IN_FILE 0 /* config file option only */ 273 #define SET_VIA_PROG 1 /* may be set via extern program, not seen in game */ 274 #define DISP_IN_GAME 2 /* may be set via extern program, displayed in game */ 275 #define SET_IN_GAME 3 /* may be set via extern program or set in the game */ 276 277 #define FEATURE_NOTICE_VER(major,minor,patch) (((unsigned long)major << 24) | \ 278 ((unsigned long)minor << 16) | \ 279 ((unsigned long)patch << 8) | \ 280 ((unsigned long)0)) 281 282 #define FEATURE_NOTICE_VER_MAJ (flags.suppress_alert >> 24) 283 #define FEATURE_NOTICE_VER_MIN (((unsigned long)(0x0000000000FF0000L & flags.suppress_alert)) >> 16) 284 #define FEATURE_NOTICE_VER_PATCH (((unsigned long)(0x000000000000FF00L & flags.suppress_alert)) >> 8) 285 286 #ifndef max 287 #define max(a,b) ((a) > (b) ? (a) : (b)) 288 #endif 289 #ifndef min 290 #define min(x,y) ((x) < (y) ? (x) : (y)) 291 #endif 292 #define plur(x) (((x) == 1) ? "" : "s") 293 294 #define ARM_BONUS(obj) (objects[(obj)->otyp].a_ac + (obj)->spe \ 295 /* extra AC point for racial armor */ \ 296 + (is_racial_armor(obj) ? 1 : 0) \ 297 - min((int)greatest_erosion(obj),objects[(obj)->otyp].a_ac)) 298 299 #define makeknown(x) discover_object((x),TRUE,TRUE) 300 #define distu(xx,yy) dist2((int)(xx),(int)(yy),(int)u.ux,(int)u.uy) 301 #define onlineu(xx,yy) online2((int)(xx),(int)(yy),(int)u.ux,(int)u.uy) 302 303 #define rn1(x,y) (rn2(x)+(y)) 304 305 /* negative armor class is randomly weakened to prevent invulnerability */ 306 #define AC_VALUE(AC) ((AC) >= 0 ? (AC) : -rnd(-(AC))) 307 308 #if defined(MICRO) && !defined(__DJGPP__) 309 #define getuid() 1 310 #define getlogin() ((char *)0) 311 #endif /* MICRO */ 312 313 #if defined(OVERLAY)&&(defined(OVL0)||defined(OVL1)||defined(OVL2)||defined(OVL3)||defined(OVLB)) 314 # define USE_OVLx 315 # define STATIC_DCL extern 316 # define STATIC_OVL 317 # ifdef OVLB 318 # define STATIC_VAR 319 # else 320 # define STATIC_VAR extern 321 # endif 322 323 #else /* !OVERLAY || (!OVL0 && !OVL1 && !OVL2 && !OVL3 && !OVLB) */ 324 # define STATIC_DCL static 325 # define STATIC_OVL static 326 # define STATIC_VAR static 327 328 /* If not compiling an overlay, compile everything. */ 329 # define OVL0 /* highest priority */ 330 # define OVL1 331 # define OVL2 332 # define OVL3 /* lowest specified priority */ 333 # define OVLB /* the base overlay segment */ 334 #endif /* OVERLAY && (OVL0 || OVL1 || OVL2 || OVL3 || OVLB) */ 335 336 /* Macro for a few items that are only static if we're not overlaid.... */ 337 #if defined(USE_TRAMPOLI) || defined(USE_OVLx) 338 # define STATIC_PTR 339 #else 340 # define STATIC_PTR static 341 #endif 342 343 /* The function argument to qsort() requires a particular 344 * calling convention under WINCE which is not the default 345 * in that environment. 346 */ 347 #if defined(WIN_CE) 348 # define CFDECLSPEC __cdecl 349 #else 350 # define CFDECLSPEC 351 #endif 352 353 #endif /* HACK_H */ 354