hack.h

Go to the documentation of this file.
00001 /*      SCCS Id: @(#)hack.h     3.4     2001/04/12      */
00002 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
00003 /* NetHack may be freely redistributed.  See license for details. */
00004 
00005 #ifndef HACK_H
00006 #define HACK_H
00007 
00008 #ifndef CONFIG_H
00009 #include "config.h"
00010 #endif
00011 
00012 /*      For debugging beta code.        */
00013 #ifdef BETA
00014 #define Dpline  pline
00015 #endif
00016 
00017 #define TELL            1
00018 #define NOTELL          0
00019 #define ON              1
00020 #define OFF             0
00021 #define BOLT_LIM        8 /* from this distance ranged attacks will be made */
00022 #define MAX_CARR_CAP    1000    /* so that boulders can be heavier */
00023 #define DUMMY { 0 }
00024 
00025 /* symbolic names for capacity levels */
00026 #define UNENCUMBERED    0
00027 #define SLT_ENCUMBER    1       /* Burdened */
00028 #define MOD_ENCUMBER    2       /* Stressed */
00029 #define HVY_ENCUMBER    3       /* Strained */
00030 #define EXT_ENCUMBER    4       /* Overtaxed */
00031 #define OVERLOADED      5       /* Overloaded */
00032 
00033 /* Macros for how a rumor was delivered in outrumor() */
00034 #define BY_ORACLE       0
00035 #define BY_COOKIE       1
00036 #define BY_PAPER        2
00037 #define BY_OTHER        9
00038 
00039 #ifdef STEED
00040 /* Macros for why you are no longer riding */
00041 #define DISMOUNT_GENERIC        0
00042 #define DISMOUNT_FELL           1
00043 #define DISMOUNT_THROWN         2
00044 #define DISMOUNT_POLY           3
00045 #define DISMOUNT_ENGULFED       4
00046 #define DISMOUNT_BONES          5
00047 #define DISMOUNT_BYCHOICE       6
00048 #endif
00049 
00050 /* Special returns from mapglyph() */
00051 #define MG_CORPSE       0x01
00052 #define MG_INVIS        0x02
00053 #define MG_DETECT       0x04
00054 #define MG_PET          0x08
00055 #define MG_RIDDEN       0x10
00056 #define MG_INVERSE      0x20 /* use inverse video */
00057 
00058 /* sellobj_state() states */
00059 #define SELL_NORMAL     (0)
00060 #define SELL_DELIBERATE (1)
00061 #define SELL_DONTSELL   (2)
00062 
00063 /*
00064  * This is the way the game ends.  If these are rearranged, the arrays
00065  * in end.c and topten.c will need to be changed.  Some parts of the
00066  * code assume that PANIC separates the deaths from the non-deaths.
00067  */
00068 #define DIED             0
00069 #define CHOKING          1
00070 #define POISONING        2
00071 #define STARVING         3
00072 #define DROWNING         4
00073 #define BURNING          5
00074 #define DISSOLVED        6
00075 #define CRUSHING         7
00076 #define STONING          8
00077 #define TURNED_SLIME     9
00078 #ifdef WEBB_DISINT
00079 # define GENOCIDED      10
00080 # define DISINTEGRATED  11
00081 # define MAX_SURVIVABLE_DEATH   11
00082 # define PANICKED       12
00083 # define TRICKED        13
00084 # define QUIT           14
00085 # define ESCAPED        15
00086 #ifdef ASTRAL_ESCAPE
00087 #define DEFIED          16
00088 #define ASCENDED        17
00089 #endif
00090 #endif
00091 
00092 #include "align.h"
00093 #include "dungeon.h"
00094 #include "monsym.h"
00095 #include "mkroom.h"
00096 #include "objclass.h"
00097 #include "youprop.h"
00098 #include "wintype.h"
00099 #include "decl.h"
00100 #include "timeout.h"
00101 
00102 NEARDATA extern coord bhitpos;  /* place where throw or zap hits or stops */
00103 
00104 /* types of calls to bhit() */
00105 #define ZAPPED_WAND     0
00106 #define THROWN_WEAPON   1
00107 #define KICKED_WEAPON   2
00108 #define FLASHED_LIGHT   3
00109 #define INVIS_BEAM      4
00110 
00111 #include "trap.h"
00112 #include "flag.h"
00113 #include "rm.h"
00114 #include "vision.h"
00115 #include "display.h"
00116 #include "engrave.h"
00117 #include "rect.h"
00118 #include "region.h"
00119 
00120 #ifdef USE_TRAMPOLI /* This doesn't belong here, but we have little choice */
00121 #undef NDECL
00122 #define NDECL(f) f()
00123 #endif
00124 
00125 #include "extern.h"
00126 #include "winprocs.h"
00127 
00128 #ifdef USE_TRAMPOLI
00129 #include "wintty.h"
00130 #undef WINTTY_H
00131 #include "trampoli.h"
00132 #undef EXTERN_H
00133 #include "extern.h"
00134 #endif /* USE_TRAMPOLI */
00135 
00136 #define NO_SPELL        0
00137 
00138 /* flags to control makemon() */
00139 #define NO_MM_FLAGS       0x00  /* use this rather than plain 0 */
00140 #define NO_MINVENT        0x01  /* suppress minvent when creating mon */
00141 #define MM_NOWAIT         0x02  /* don't set STRAT_WAITMASK flags */
00142 #define MM_EDOG           0x04  /* add edog structure */
00143 #define MM_EMIN           0x08  /* add emin structure */
00144 #define MM_ANGRY          0x10  /* monster is created angry */
00145 #define MM_NONAME         0x20  /* monster is not christened */
00146 #define MM_NOCOUNTBIRTH   0x40  /* don't increment born counter (for revival) */
00147 #define MM_IGNOREWATER    0x80  /* ignore water when positioning */
00148 #define MM_ADJACENTOK     0x100 /* it is acceptable to use adjacent coordinates */
00149 
00150 /* special mhpmax value when loading bones monster to flag as extinct or genocided */
00151 #define DEFUNCT_MONSTER (-100)
00152 
00153 /* flags for special ggetobj status returns */
00154 #define ALL_FINISHED      0x01  /* called routine already finished the job */
00155 
00156 /* flags to control query_objlist() */
00157 #define BY_NEXTHERE       0x1   /* follow objlist by nexthere field */
00158 #define AUTOSELECT_SINGLE 0x2   /* if only 1 object, don't ask */
00159 #define USE_INVLET        0x4   /* use object's invlet */
00160 #define INVORDER_SORT     0x8   /* sort objects by packorder */
00161 #define SIGNAL_NOMENU     0x10  /* return -1 rather than 0 if none allowed */
00162 #define FEEL_COCKATRICE   0x20  /* engage cockatrice checks and react */
00163 
00164 /* Flags to control query_category() */
00165 /* BY_NEXTHERE used by query_category() too, so skip 0x01 */
00166 #define UNPAID_TYPES 0x02
00167 #define GOLD_TYPES   0x04
00168 #define WORN_TYPES   0x08
00169 #define ALL_TYPES    0x10
00170 #define BILLED_TYPES 0x20
00171 #define CHOOSE_ALL   0x40
00172 #define BUC_BLESSED  0x80
00173 #define BUC_CURSED   0x100
00174 #define BUC_UNCURSED 0x200
00175 #define BUC_UNKNOWN  0x400
00176 #define BUC_ALLBKNOWN (BUC_BLESSED|BUC_CURSED|BUC_UNCURSED)
00177 #define UNIDENTIFIED_TYPES 0x800
00178 #define ALL_TYPES_SELECTED -2
00179 
00180 /* Flags to control find_mid() */
00181 #define FM_FMON        0x01     /* search the fmon chain */
00182 #define FM_MIGRATE     0x02     /* search the migrating monster chain */
00183 #define FM_MYDOGS      0x04     /* search mydogs */
00184 #define FM_EVERYWHERE  (FM_FMON | FM_MIGRATE | FM_MYDOGS)
00185 
00186 /* Flags to control pick_[race,role,gend,align] routines in role.c */
00187 #define PICK_RANDOM     0
00188 #define PICK_RIGID      1
00189 
00190 /* Flags to control dotrap() in trap.c */
00191 #define NOWEBMSG        0x01    /* suppress stumble into web message */
00192 #define FORCEBUNGLE     0x02    /* adjustments appropriate for bungling */
00193 #define RECURSIVETRAP   0x04    /* trap changed into another type this same turn */
00194 
00195 /* Flags to control test_move in hack.c */
00196 #define DO_MOVE         0       /* really doing the move */
00197 #define TEST_MOVE       1       /* test a normal move (move there next) */
00198 #define TEST_TRAV       2       /* test a future travel location */
00199 
00200 /*** some utility macros ***/
00201 #define yn(query) yn_function(query,ynchars, 'n')
00202 #define ynq(query) yn_function(query,ynqchars, 'q')
00203 #define ynaq(query) yn_function(query,ynaqchars, 'y')
00204 #define nyaq(query) yn_function(query,ynaqchars, 'n')
00205 #define nyNaq(query) yn_function(query,ynNaqchars, 'n')
00206 #define ynNaq(query) yn_function(query,ynNaqchars, 'y')
00207 
00208 /* Macros for scatter */
00209 #define VIS_EFFECTS     0x01    /* display visual effects */
00210 #define MAY_HITMON      0x02    /* objects may hit monsters */
00211 #define MAY_HITYOU      0x04    /* objects may hit you */
00212 #define MAY_HIT         (MAY_HITMON|MAY_HITYOU)
00213 #define MAY_DESTROY     0x08    /* objects may be destroyed at random */
00214 #define MAY_FRACTURE    0x10    /* boulders & statues may fracture */
00215 
00216 /* Macros for launching objects */
00217 #define ROLL            0x01    /* the object is rolling */
00218 #define FLING           0x02    /* the object is flying thru the air */
00219 #define LAUNCH_UNSEEN   0x40    /* hero neither caused nor saw it */
00220 #define LAUNCH_KNOWN    0x80    /* the hero caused this by explicit action */
00221 
00222 /* Macros for explosion types */
00223 #define EXPL_DARK       0
00224 #define EXPL_NOXIOUS    1
00225 #define EXPL_MUDDY      2
00226 #define EXPL_WET        3
00227 #define EXPL_MAGICAL    4
00228 #define EXPL_FIERY      5
00229 #define EXPL_FROSTY     6
00230 #define EXPL_MAX        7
00231 
00232 /* Macros for messages referring to hands, eyes, feet, etc... */
00233 #define ARM 0
00234 #define EYE 1
00235 #define FACE 2
00236 #define FINGER 3
00237 #define FINGERTIP 4
00238 #define FOOT 5
00239 #define HAND 6
00240 #define HANDED 7
00241 #define HEAD 8
00242 #define LEG 9
00243 #define LIGHT_HEADED 10
00244 #define NECK 11
00245 #define SPINE 12
00246 #define TOE 13
00247 #define HAIR 14
00248 #define BLOOD 15
00249 #define LUNG 16
00250 #define NOSE 17
00251 #define STOMACH 18
00252 
00253 /* Flags to control menus */
00254 #define MENUTYPELEN sizeof("traditional ")
00255 #define MENU_TRADITIONAL 0
00256 #define MENU_COMBINATION 1
00257 #define MENU_PARTIAL     2
00258 #define MENU_FULL        3
00259 
00260 #define MENU_SELECTED   TRUE
00261 #define MENU_UNSELECTED FALSE
00262 
00263 /*
00264  * Option flags
00265  * Each higher number includes the characteristics of the numbers
00266  * below it.
00267  */
00268 #define SET_IN_FILE     0 /* config file option only */
00269 #define SET_VIA_PROG    1 /* may be set via extern program, not seen in game */
00270 #define DISP_IN_GAME    2 /* may be set via extern program, displayed in game */
00271 #define SET_IN_GAME     3 /* may be set via extern program or set in the game */
00272 
00273 #define FEATURE_NOTICE_VER(major,minor,patch) (((unsigned long)major << 24) | \
00274         ((unsigned long)minor << 16) | \
00275         ((unsigned long)patch << 8) | \
00276         ((unsigned long)0))
00277 
00278 #define FEATURE_NOTICE_VER_MAJ    (flags.suppress_alert >> 24)
00279 #define FEATURE_NOTICE_VER_MIN    (((unsigned long)(0x0000000000FF0000L & flags.suppress_alert)) >> 16)
00280 #define FEATURE_NOTICE_VER_PATCH  (((unsigned long)(0x000000000000FF00L & flags.suppress_alert)) >>  8)
00281 
00282 #ifndef max
00283 #define max(a,b) ((a) > (b) ? (a) : (b))
00284 #endif
00285 #ifndef min
00286 #define min(x,y) ((x) < (y) ? (x) : (y))
00287 #endif
00288 #define plur(x) (((x) == 1) ? "" : "s")
00289 
00290 #define ARM_BONUS(obj)  (objects[(obj)->otyp].a_ac + (obj)->spe \
00291                          - min((int)greatest_erosion(obj),objects[(obj)->otyp].a_ac))
00292 
00293 #define makeknown(x)    discover_object((x),TRUE,TRUE)
00294 #define distu(xx,yy)    dist2((int)(xx),(int)(yy),(int)u.ux,(int)u.uy)
00295 #define onlineu(xx,yy)  online2((int)(xx),(int)(yy),(int)u.ux,(int)u.uy)
00296 
00297 #define rn1(x,y)        (rn2(x)+(y))
00298 
00299 /* negative armor class is randomly weakened to prevent invulnerability */
00300 #define AC_VALUE(AC)    ((AC) >= 0 ? (AC) : -rnd(-(AC)))
00301 
00302 #if defined(MICRO) && !defined(__DJGPP__)
00303 #define getuid() 1
00304 #define getlogin() ((char *)0)
00305 #endif /* MICRO */
00306 
00307 #if defined(OVERLAY)&&(defined(OVL0)||defined(OVL1)||defined(OVL2)||defined(OVL3)||defined(OVLB))
00308 # define USE_OVLx
00309 # define STATIC_DCL extern
00310 # define STATIC_OVL
00311 # ifdef OVLB
00312 #  define STATIC_VAR
00313 # else
00314 #  define STATIC_VAR extern
00315 # endif
00316 
00317 #else   /* !OVERLAY || (!OVL0 && !OVL1 && !OVL2 && !OVL3 && !OVLB) */
00318 # define STATIC_DCL static
00319 # define STATIC_OVL static
00320 # define STATIC_VAR static
00321 
00322 /* If not compiling an overlay, compile everything. */
00323 # define OVL0   /* highest priority */
00324 # define OVL1
00325 # define OVL2
00326 # define OVL3   /* lowest specified priority */
00327 # define OVLB   /* the base overlay segment */
00328 #endif  /* OVERLAY && (OVL0 || OVL1 || OVL2 || OVL3 || OVLB) */
00329 
00330 /* Macro for a few items that are only static if we're not overlaid.... */
00331 #if defined(USE_TRAMPOLI) || defined(USE_OVLx)
00332 # define STATIC_PTR
00333 #else
00334 # define STATIC_PTR static
00335 #endif
00336 
00337 /* The function argument to qsort() requires a particular
00338  * calling convention under WINCE which is not the default
00339  * in that environment.
00340  */
00341 #if defined(WIN_CE)
00342 # define CFDECLSPEC __cdecl
00343 #else
00344 # define CFDECLSPEC
00345 #endif
00346  
00347 #endif /* HACK_H */