1 /* NetHack 3.6 hack.h $NHDT-Date: 1434056948 2015/06/11 21:09:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
17 #define BOLT_LIM 8 /* from this distance ranged attacks will be made */
18 #define MAX_CARR_CAP 1000 /* so that boulders can be heavier */
24 /* symbolic names for capacity levels */
25 #define UNENCUMBERED 0
26 #define SLT_ENCUMBER 1 /* Burdened */
27 #define MOD_ENCUMBER 2 /* Stressed */
28 #define HVY_ENCUMBER 3 /* Strained */
29 #define EXT_ENCUMBER 4 /* Overtaxed */
30 #define OVERLOADED 5 /* Overloaded */
32 /* hunger states - see hu_stat in eat.c */
41 /* Macros for how a rumor was delivered in outrumor() */
47 /* Macros for why you are no longer riding */
48 #define DISMOUNT_GENERIC 0
49 #define DISMOUNT_FELL 1
50 #define DISMOUNT_THROWN 2
51 #define DISMOUNT_POLY 3
52 #define DISMOUNT_ENGULFED 4
53 #define DISMOUNT_BONES 5
54 #define DISMOUNT_BYCHOICE 6
56 /* Special returns from mapglyph() */
57 #define MG_CORPSE 0x01
59 #define MG_DETECT 0x04
61 #define MG_RIDDEN 0x10
62 #define MG_STATUE 0x20
63 #define MG_OBJPILE 0x40 /* more than one stack of objects */
65 /* sellobj_state() states */
66 #define SELL_NORMAL (0)
67 #define SELL_DELIBERATE (1)
68 #define SELL_DONTSELL (2)
70 /* alteration types--keep in synch with costly_alteration(mkobj.c) */
71 #define COST_CANCEL 0 /* standard cancellation */
72 #define COST_DRAIN 1 /* drain life upon an object */
73 #define COST_UNCHRG 2 /* cursed charging */
74 #define COST_UNBLSS 3 /* unbless (devalues holy water) */
75 #define COST_UNCURS 4 /* uncurse (devalues unholy water) */
76 #define COST_DECHNT 5 /* disenchant weapons or armor */
77 #define COST_DEGRD 6 /* removal of rustproofing, dulling via engraving */
78 #define COST_DILUTE 7 /* potion dilution */
79 #define COST_ERASE 8 /* scroll or spellbook blanking */
80 #define COST_BURN 9 /* dipped into flaming oil */
81 #define COST_NUTRLZ 10 /* neutralized via unicorn horn */
82 #define COST_DSTROY 11 /* wand breaking (bill first, useup later) */
83 #define COST_SPLAT 12 /* cream pie to own face (ditto) */
84 #define COST_BITE 13 /* start eating food */
85 #define COST_OPEN 14 /* open tin */
86 #define COST_BRKLCK 15 /* break box/chest's lock */
87 #define COST_RUST 16 /* rust damage */
88 #define COST_ROT 17 /* rotting attack */
89 #define COST_CORRODE 18 /* acid damage */
91 /* bitmask flags for corpse_xname();
92 PFX_THE takes precedence over ARTICLE, NO_PFX takes precedence over both */
93 #define CXN_NORMAL 0 /* no special handling */
94 #define CXN_SINGULAR 1 /* override quantity if greather than 1 */
95 #define CXN_NO_PFX 2 /* suppress "the" from "the Unique Monst */
96 #define CXN_PFX_THE 4 /* prefix with "the " (unless pname) */
97 #define CXN_ARTICLE 8 /* include a/an/the prefix */
98 #define CXN_NOCORPSE 16 /* suppress " corpse" suffix */
101 * This is the way the game ends. If these are rearranged, the arrays
102 * in end.c and topten.c will need to be changed. Some parts of the
103 * code assume that PANIC separates the deaths from the non-deaths.
114 #define TURNED_SLIME 9
126 #include "objclass.h"
133 NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */
135 /* types of calls to bhit() */
136 #define ZAPPED_WAND 0
137 #define THROWN_WEAPON 1
138 #define KICKED_WEAPON 2
139 #define FLASHED_LIGHT 3
142 /* attack mode for hmon() */
143 #define HMON_MELEE 0 /* hand-to-hand */
144 #define HMON_THROWN 1 /* normal ranged (or spitting while poly'd) */
145 #define HMON_KICKED 2 /* alternate ranged */
146 #define HMON_APPLIED 3 /* polearm, treated as ranged */
147 #define HMON_DRAGGED 4 /* attached iron ball, pulled into mon */
149 #define MATCH_WARN_OF_MON(mon) \
150 (Warn_of_mon && ((context.warntype.obj \
151 && (context.warntype.obj & (mon)->data->mflags2)) \
152 || (context.warntype.polyd \
153 && (context.warntype.polyd & (mon)->data->mflags2)) \
154 || (context.warntype.species \
155 && (context.warntype.species == (mon)->data))))
167 #define SYM_OFF_P (0)
168 #define SYM_OFF_O (SYM_OFF_P + MAXPCHARS)
169 #define SYM_OFF_M (SYM_OFF_O + MAXOCLASSES)
170 #define SYM_OFF_W (SYM_OFF_M + MAXMCLASSES)
171 #define SYM_OFF_X (SYM_OFF_W + WARNCOUNT)
172 #define SYM_MAX (SYM_OFF_X + MAXOTHER)
174 #ifdef USE_TRAMPOLI /* This doesn't belong here, but we have little choice \
181 #include "winprocs.h"
187 #include "trampoli.h"
190 #endif /* USE_TRAMPOLI */
192 /* flags to control makemon() */
193 #define NO_MM_FLAGS 0x00000 /* use this rather than plain 0 */
194 #define NO_MINVENT 0x00001 /* suppress minvent when creating mon */
195 #define MM_NOWAIT 0x00002 /* don't set STRAT_WAITMASK flags */
196 #define MM_NOCOUNTBIRTH \
197 0x00004 /* don't increment born counter (for revival) */
198 #define MM_IGNOREWATER 0x00008 /* ignore water when positioning */
199 #define MM_ADJACENTOK \
200 0x00010 /* it is acceptable to use adjacent coordinates */
201 #define MM_ANGRY 0x00020 /* monster is created angry */
202 #define MM_NONAME 0x00040 /* monster is not christened */
203 #define MM_EGD 0x00100 /* add egd structure */
204 #define MM_EPRI 0x00200 /* add epri structure */
205 #define MM_ESHK 0x00400 /* add eshk structure */
206 #define MM_EMIN 0x00800 /* add emin structure */
207 #define MM_EDOG 0x01000 /* add edog structure */
209 /* flags for make_corpse() and mkcorpstat() */
210 #define CORPSTAT_NONE 0x00
211 #define CORPSTAT_INIT 0x01 /* pass init flag to mkcorpstat */
212 #define CORPSTAT_BURIED 0x02 /* bury the corpse or statue */
214 /* flags for decide_to_shift() */
215 #define SHIFT_SEENMSG 0x01 /* put out a message if in sight */
216 #define SHIFT_MSG 0x02 /* always put out a message */
218 /* special mhpmax value when loading bones monster to flag as extinct or
220 #define DEFUNCT_MONSTER (-100)
222 /* macro form of adjustments of physical damage based on Half_physical_damage.
223 * Can be used on-the-fly with the 1st parameter to losehp() if you don't
224 * need to retain the dmg value beyond that call scope.
225 * Take care to ensure it doesn't get used more than once in other instances.
227 #define Maybe_Half_Phys(dmg) \
228 ((Half_physical_damage) ? (((dmg) + 1) / 2) : (dmg))
230 /* flags for special ggetobj status returns */
231 #define ALL_FINISHED 0x01 /* called routine already finished the job */
233 /* flags to control query_objlist() */
234 #define BY_NEXTHERE 0x1 /* follow objlist by nexthere field */
235 #define AUTOSELECT_SINGLE 0x2 /* if only 1 object, don't ask */
236 #define USE_INVLET 0x4 /* use object's invlet */
237 #define INVORDER_SORT 0x8 /* sort objects by packorder */
238 #define SIGNAL_NOMENU 0x10 /* return -1 rather than 0 if none allowed */
239 #define SIGNAL_ESCAPE 0x20 /* return -2 rather than 0 for ESC */
240 #define FEEL_COCKATRICE 0x40 /* engage cockatrice checks and react */
241 #define INCLUDE_HERO 0x80 /* show hero among engulfer's inventory */
243 /* Flags to control query_category() */
244 /* BY_NEXTHERE used by query_category() too, so skip 0x01 */
245 #define UNPAID_TYPES 0x02
246 #define GOLD_TYPES 0x04
247 #define WORN_TYPES 0x08
248 #define ALL_TYPES 0x10
249 #define BILLED_TYPES 0x20
250 #define CHOOSE_ALL 0x40
251 #define BUC_BLESSED 0x80
252 #define BUC_CURSED 0x100
253 #define BUC_UNCURSED 0x200
254 #define BUC_UNKNOWN 0x400
255 #define BUC_ALLBKNOWN (BUC_BLESSED | BUC_CURSED | BUC_UNCURSED)
256 #define ALL_TYPES_SELECTED -2
258 /* Flags to control find_mid() */
259 #define FM_FMON 0x01 /* search the fmon chain */
260 #define FM_MIGRATE 0x02 /* search the migrating monster chain */
261 #define FM_MYDOGS 0x04 /* search mydogs */
262 #define FM_EVERYWHERE (FM_FMON | FM_MIGRATE | FM_MYDOGS)
264 /* Flags to control pick_[race,role,gend,align] routines in role.c */
265 #define PICK_RANDOM 0
268 /* Flags to control dotrap() in trap.c */
269 #define FORCETRAP 0x01 /* triggering not left to chance */
270 #define NOWEBMSG 0x02 /* suppress stumble into web message */
271 #define FORCEBUNGLE 0x04 /* adjustments appropriate for bungling */
272 #define RECURSIVETRAP 0x08 /* trap changed into another type this same turn \
274 #define TOOKPLUNGE 0x10 /* used '>' to enter pit below you */
276 /* Flags to control test_move in hack.c */
277 #define DO_MOVE 0 /* really doing the move */
278 #define TEST_MOVE 1 /* test a normal move (move there next) */
279 #define TEST_TRAV 2 /* test a future travel location */
281 /*** some utility macros ***/
282 #define yn(query) yn_function(query, ynchars, 'n')
283 #define ynq(query) yn_function(query, ynqchars, 'q')
284 #define ynaq(query) yn_function(query, ynaqchars, 'y')
285 #define nyaq(query) yn_function(query, ynaqchars, 'n')
286 #define nyNaq(query) yn_function(query, ynNaqchars, 'n')
287 #define ynNaq(query) yn_function(query, ynNaqchars, 'y')
289 /* Macros for scatter */
290 #define VIS_EFFECTS 0x01 /* display visual effects */
291 #define MAY_HITMON 0x02 /* objects may hit monsters */
292 #define MAY_HITYOU 0x04 /* objects may hit you */
293 #define MAY_HIT (MAY_HITMON | MAY_HITYOU)
294 #define MAY_DESTROY 0x08 /* objects may be destroyed at random */
295 #define MAY_FRACTURE 0x10 /* boulders & statues may fracture */
297 /* Macros for launching objects */
298 #define ROLL 0x01 /* the object is rolling */
299 #define FLING 0x02 /* the object is flying thru the air */
300 #define LAUNCH_UNSEEN 0x40 /* hero neither caused nor saw it */
301 #define LAUNCH_KNOWN 0x80 /* the hero caused this by explicit action */
303 /* Macros for explosion types */
305 #define EXPL_NOXIOUS 1
308 #define EXPL_MAGICAL 4
310 #define EXPL_FROSTY 6
313 /* enlightenment control flags */
314 #define BASICENLIGHTENMENT 1 /* show mundane stuff */
315 #define MAGICENLIGHTENMENT 2 /* show intrinsics and such */
316 #define ENL_GAMEINPROGRESS 0
317 #define ENL_GAMEOVERALIVE 1 /* ascension, escape, quit, trickery */
318 #define ENL_GAMEOVERDEAD 2
320 /* Macros for messages referring to hands, eyes, feet, etc... */
331 #define LIGHT_HEADED 10
341 /* indices for some special tin types */
343 #define HOMEMADE_TIN 1
344 #define SPINACH_TIN (-1)
345 #define RANDOM_TIN (-2)
346 #define HEALTHY_TIN (-3)
348 /* Some misc definitions */
349 #define POTION_OCCUPANT_CHANCE(n) (13 + 2 * (n))
350 #define WAND_BACKFIRE_CHANCE 100
351 #define BALL_IN_MON (u.uswallow && uball && uball->where == OBJ_FREE)
352 #define NODIAG(monnum) ((monnum) == PM_GRID_BUG)
354 /* Flags to control menus */
355 #define MENUTYPELEN sizeof("traditional ")
356 #define MENU_TRADITIONAL 0
357 #define MENU_COMBINATION 1
359 #define MENU_PARTIAL 3
361 #define MENU_SELECTED TRUE
362 #define MENU_UNSELECTED FALSE
366 * Each higher number includes the characteristics of the numbers
369 /* XXX This should be replaced with a bitmap. */
370 #define SET_IN_SYS 0 /* system config file option only */
371 #define SET_IN_FILE 1 /* config file option only */
372 #define SET_VIA_PROG 2 /* may be set via extern program, not seen in game */
373 #define DISP_IN_GAME 3 /* may be set via extern program, displayed in game \
375 #define SET_IN_GAME 4 /* may be set via extern program or set in the game */
376 #define SET__IS_VALUE_VALID(s) ((s < SET_IN_SYS) || (s > SET_IN_GAME))
378 #define FEATURE_NOTICE_VER(major, minor, patch) \
379 (((unsigned long) major << 24) | ((unsigned long) minor << 16) \
380 | ((unsigned long) patch << 8) | ((unsigned long) 0))
382 #define FEATURE_NOTICE_VER_MAJ (flags.suppress_alert >> 24)
383 #define FEATURE_NOTICE_VER_MIN \
384 (((unsigned long) (0x0000000000FF0000L & flags.suppress_alert)) >> 16)
385 #define FEATURE_NOTICE_VER_PATCH \
386 (((unsigned long) (0x000000000000FF00L & flags.suppress_alert)) >> 8)
389 #define max(a, b) ((a) > (b) ? (a) : (b))
392 #define min(x, y) ((x) < (y) ? (x) : (y))
394 #define plur(x) (((x) == 1) ? "" : "s")
396 #define ARM_BONUS(obj) \
397 (objects[(obj)->otyp].a_ac + (obj)->spe \
398 - min((int) greatest_erosion(obj), objects[(obj)->otyp].a_ac))
400 #define makeknown(x) discover_object((x), TRUE, TRUE)
401 #define distu(xx, yy) dist2((int)(xx), (int)(yy), (int) u.ux, (int) u.uy)
402 #define onlineu(xx, yy) online2((int)(xx), (int)(yy), (int) u.ux, (int) u.uy)
404 #define rn1(x, y) (rn2(x) + (y))
406 /* negative armor class is randomly weakened to prevent invulnerability */
407 #define AC_VALUE(AC) ((AC) >= 0 ? (AC) : -rnd(-(AC)))
409 #if defined(MICRO) && !defined(__DJGPP__)
411 #define getlogin() ((char *) 0)
416 #define STATIC_DCL extern
422 #define STATIC_DCL static
423 #define STATIC_OVL static
424 #define STATIC_VAR static
428 /* Macro for a few items that are only static if we're not overlaid.... */
429 #if defined(USE_TRAMPOLI) || defined(USE_OVLx)
432 #define STATIC_PTR static
435 /* The function argument to qsort() requires a particular
436 * calling convention under WINCE which is not the default
437 * in that environment.
440 #define CFDECLSPEC __cdecl
445 #define DEVTEAM_EMAIL "devteam@nethack.org"
446 #define DEVTEAM_URL "http://www.nethack.org"