1 /* NetHack 3.6 hack.h $NHDT-Date: 1561019041 2019/06/20 08:24:01 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.106 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Pasi Kallinen, 2017. */
4 /* NetHack may be freely redistributed. See license for details. */
18 #define BOLT_LIM 8 /* from this distance ranged attacks will be made */
19 #define MAX_CARR_CAP 1000 /* so that boulders can be heavier */
20 #define DUMMY { 0 } /* array initializer, letting [1..N-1] default */
22 /* symbolic names for capacity levels */
23 enum encumbrance_types {
25 SLT_ENCUMBER = 1, /* Burdened */
26 MOD_ENCUMBER = 2, /* Stressed */
27 HVY_ENCUMBER = 3, /* Strained */
28 EXT_ENCUMBER = 4, /* Overtaxed */
29 OVERLOADED = 5 /* Overloaded */
32 /* weight increment of heavy iron ball */
33 #define IRON_BALL_W_INCR 160
35 /* number of turns it takes for vault guard to show up */
36 #define VAULT_GUARD_TIME 30
38 #define SHOP_DOOR_COST 400L /* cost of a destroyed shop door */
39 #define SHOP_BARS_COST 300L /* cost of iron bars */
40 #define SHOP_HOLE_COST 200L /* cost of making hole/trapdoor */
41 #define SHOP_WALL_COST 200L /* cost of destroying a wall */
42 #define SHOP_WALL_DMG (10L * ACURRSTR) /* damaging a wall */
44 /* hunger states - see hu_stat in eat.c */
45 enum hunger_state_types {
55 /* Macros for how a rumor was delivered in outrumor() */
61 /* Macros for why you are no longer riding */
67 DISMOUNT_ENGULFED = 4,
72 /* mgflags for mapglyph() */
73 #define MG_FLAG_NORMAL 0x00
74 #define MG_FLAG_NOOVERRIDE 0x01
76 /* Special returns from mapglyph() */
77 #define MG_CORPSE 0x01
79 #define MG_DETECT 0x04
81 #define MG_RIDDEN 0x10
82 #define MG_STATUE 0x20
83 #define MG_OBJPILE 0x40 /* more than one stack of objects */
84 #define MG_BW_LAVA 0x80 /* 'black & white lava': highlight lava if it
85 can't be distringuished from water by color */
87 /* sellobj_state() states */
88 #define SELL_NORMAL (0)
89 #define SELL_DELIBERATE (1)
90 #define SELL_DONTSELL (2)
92 /* alteration types--keep in synch with costly_alteration(mkobj.c) */
93 enum cost_alteration_types {
94 COST_CANCEL = 0, /* standard cancellation */
95 COST_DRAIN = 1, /* drain life upon an object */
96 COST_UNCHRG = 2, /* cursed charging */
97 COST_UNBLSS = 3, /* unbless (devalues holy water) */
98 COST_UNCURS = 4, /* uncurse (devalues unholy water) */
99 COST_DECHNT = 5, /* disenchant weapons or armor */
100 COST_DEGRD = 6, /* removal of rustproofing, dulling via engraving */
101 COST_DILUTE = 7, /* potion dilution */
102 COST_ERASE = 8, /* scroll or spellbook blanking */
103 COST_BURN = 9, /* dipped into flaming oil */
104 COST_NUTRLZ = 10, /* neutralized via unicorn horn */
105 COST_DSTROY = 11, /* wand breaking (bill first, useup later) */
106 COST_SPLAT = 12, /* cream pie to own face (ditto) */
107 COST_BITE = 13, /* start eating food */
108 COST_OPEN = 14, /* open tin */
109 COST_BRKLCK = 15, /* break box/chest's lock */
110 COST_RUST = 16, /* rust damage */
111 COST_ROT = 17, /* rotting attack */
112 COST_CORRODE = 18 /* acid damage */
115 /* bitmask flags for corpse_xname();
116 PFX_THE takes precedence over ARTICLE, NO_PFX takes precedence over both */
117 #define CXN_NORMAL 0 /* no special handling */
118 #define CXN_SINGULAR 1 /* override quantity if greather than 1 */
119 #define CXN_NO_PFX 2 /* suppress "the" from "the Unique Monst */
120 #define CXN_PFX_THE 4 /* prefix with "the " (unless pname) */
121 #define CXN_ARTICLE 8 /* include a/an/the prefix */
122 #define CXN_NOCORPSE 16 /* suppress " corpse" suffix */
124 /* getpos() return values */
126 LOOK_TRADITIONAL = 0, /* '.' -- ask about "more info?" */
127 LOOK_QUICK = 1, /* ',' -- skip "more info?" */
128 LOOK_ONCE = 2, /* ';' -- skip and stop looping */
129 LOOK_VERBOSE = 3 /* ':' -- show more info w/o asking */
133 * This is the way the game ends. If these are rearranged, the arrays
134 * in end.c and topten.c will need to be changed. Some parts of the
135 * code assume that PANIC separates the deaths from the non-deaths.
137 enum game_end_types {
156 typedef struct strbuf {
166 #include "objclass.h"
173 NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */
175 /* types of calls to bhit() */
176 enum bhit_call_types {
179 THROWN_TETHERED_WEAPON = 2,
185 /* attack mode for hmon() */
186 enum hmon_atkmode_types {
187 HMON_MELEE = 0, /* hand-to-hand */
188 HMON_THROWN = 1, /* normal ranged (or spitting while poly'd) */
189 HMON_KICKED = 2, /* alternate ranged */
190 HMON_APPLIED = 3, /* polearm, treated as ranged */
191 HMON_DRAGGED = 4 /* attached iron ball, pulled into mon */
194 /* sortloot() return type; needed before extern.h */
195 struct sortloot_item {
197 char *str; /* result of loot_xname(obj) in some cases, otherwise null */
198 int indx; /* signed int, because sortloot()'s qsort comparison routine
199 assumes (a->indx - b->indx) might yield a negative result */
200 xchar orderclass; /* order rather than object class; 0 => not yet init'd */
201 xchar subclass; /* subclass for some classes */
202 xchar disco; /* discovery status */
204 typedef struct sortloot_item Loot;
206 #define MATCH_WARN_OF_MON(mon) \
207 (Warn_of_mon && ((context.warntype.obj \
208 && (context.warntype.obj & (mon)->data->mflags2)) \
209 || (context.warntype.polyd \
210 && (context.warntype.polyd & (mon)->data->mflags2)) \
211 || (context.warntype.species \
212 && (context.warntype.species == (mon)->data))))
224 #define SYM_OFF_P (0)
225 #define SYM_OFF_O (SYM_OFF_P + MAXPCHARS)
226 #define SYM_OFF_M (SYM_OFF_O + MAXOCLASSES)
227 #define SYM_OFF_W (SYM_OFF_M + MAXMCLASSES)
228 #define SYM_OFF_X (SYM_OFF_W + WARNCOUNT)
229 #define SYM_MAX (SYM_OFF_X + MAXOTHER)
231 #ifdef USE_TRAMPOLI /* this doesn't belong here, but we have little choice */
237 #include "winprocs.h"
243 #include "trampoli.h"
246 #endif /* USE_TRAMPOLI */
248 /* flags to control makemon(); goodpos() uses some plus has some of its own */
249 #define NO_MM_FLAGS 0x00000 /* use this rather than plain 0 */
250 #define NO_MINVENT 0x00001 /* suppress minvent when creating mon */
251 #define MM_NOWAIT 0x00002 /* don't set STRAT_WAITMASK flags */
252 #define MM_NOCOUNTBIRTH 0x00004 /* don't increment born count (for revival) */
253 #define MM_IGNOREWATER 0x00008 /* ignore water when positioning */
254 #define MM_ADJACENTOK 0x00010 /* acceptable to use adjacent coordinates */
255 #define MM_ANGRY 0x00020 /* monster is created angry */
256 #define MM_NONAME 0x00040 /* monster is not christened */
257 #define MM_EGD 0x00100 /* add egd structure */
258 #define MM_EPRI 0x00200 /* add epri structure */
259 #define MM_ESHK 0x00400 /* add eshk structure */
260 #define MM_EMIN 0x00800 /* add emin structure */
261 #define MM_EDOG 0x01000 /* add edog structure */
262 #define MM_ASLEEP 0x02000 /* monsters should be generated asleep */
263 #define MM_NOGRP 0x04000 /* suppress creation of monster groups */
264 /* if more MM_ flag masks are added, skip or renumber the GP_ one(s) */
265 #define GP_ALLOW_XY 0x08000 /* [actually used by enexto() to decide whether
266 * to make an extra call to goodpos()] */
268 /* flags for make_corpse() and mkcorpstat() */
269 #define CORPSTAT_NONE 0x00
270 #define CORPSTAT_INIT 0x01 /* pass init flag to mkcorpstat */
271 #define CORPSTAT_BURIED 0x02 /* bury the corpse or statue */
273 /* flags for decide_to_shift() */
274 #define SHIFT_SEENMSG 0x01 /* put out a message if in sight */
275 #define SHIFT_MSG 0x02 /* always put out a message */
277 /* flags for deliver_obj_to_mon */
279 #define DF_RANDOM 0x01
282 /* special mhpmax value when loading bones monster to flag as extinct or
284 #define DEFUNCT_MONSTER (-100)
286 /* macro form of adjustments of physical damage based on Half_physical_damage.
287 * Can be used on-the-fly with the 1st parameter to losehp() if you don't
288 * need to retain the dmg value beyond that call scope.
289 * Take care to ensure it doesn't get used more than once in other instances.
291 #define Maybe_Half_Phys(dmg) \
292 ((Half_physical_damage) ? (((dmg) + 1) / 2) : (dmg))
294 /* flags for special ggetobj status returns */
295 #define ALL_FINISHED 0x01 /* called routine already finished the job */
297 /* flags to control query_objlist() */
298 #define BY_NEXTHERE 0x01 /* follow objlist by nexthere field */
299 #define AUTOSELECT_SINGLE 0x02 /* if only 1 object, don't ask */
300 #define USE_INVLET 0x04 /* use object's invlet */
301 #define INVORDER_SORT 0x08 /* sort objects by packorder */
302 #define SIGNAL_NOMENU 0x10 /* return -1 rather than 0 if none allowed */
303 #define SIGNAL_ESCAPE 0x20 /* return -2 rather than 0 for ESC */
304 #define FEEL_COCKATRICE 0x40 /* engage cockatrice checks and react */
305 #define INCLUDE_HERO 0x80 /* show hero among engulfer's inventory */
307 /* Flags to control query_category() */
308 /* BY_NEXTHERE used by query_category() too, so skip 0x01 */
309 #define UNPAID_TYPES 0x002
310 #define GOLD_TYPES 0x004
311 #define WORN_TYPES 0x008
312 #define ALL_TYPES 0x010
313 #define BILLED_TYPES 0x020
314 #define CHOOSE_ALL 0x040
315 #define BUC_BLESSED 0x080
316 #define BUC_CURSED 0x100
317 #define BUC_UNCURSED 0x200
318 #define BUC_UNKNOWN 0x400
319 #define BUC_ALLBKNOWN (BUC_BLESSED | BUC_CURSED | BUC_UNCURSED)
320 #define BUCX_TYPES (BUC_ALLBKNOWN | BUC_UNKNOWN)
321 #define ALL_TYPES_SELECTED -2
323 /* Flags to control find_mid() */
324 #define FM_FMON 0x01 /* search the fmon chain */
325 #define FM_MIGRATE 0x02 /* search the migrating monster chain */
326 #define FM_MYDOGS 0x04 /* search mydogs */
327 #define FM_EVERYWHERE (FM_FMON | FM_MIGRATE | FM_MYDOGS)
329 /* Flags to control pick_[race,role,gend,align] routines in role.c */
330 #define PICK_RANDOM 0
333 /* Flags to control dotrap() in trap.c */
334 #define FORCETRAP 0x01 /* triggering not left to chance */
335 #define NOWEBMSG 0x02 /* suppress stumble into web message */
336 #define FORCEBUNGLE 0x04 /* adjustments appropriate for bungling */
337 #define RECURSIVETRAP 0x08 /* trap changed into another type this same turn */
338 #define TOOKPLUNGE 0x10 /* used '>' to enter pit below you */
339 #define VIASITTING 0x20 /* #sit while at trap location (affects message) */
340 #define FAILEDUNTRAP 0x40 /* trap activated by failed untrap attempt */
342 /* Flags to control test_move in hack.c */
343 #define DO_MOVE 0 /* really doing the move */
344 #define TEST_MOVE 1 /* test a normal move (move there next) */
345 #define TEST_TRAV 2 /* test a future travel location */
346 #define TEST_TRAP 3 /* check if a future travel loc is a trap */
348 /*** some utility macros ***/
349 #define yn(query) yn_function(query, ynchars, 'n')
350 #define ynq(query) yn_function(query, ynqchars, 'q')
351 #define ynaq(query) yn_function(query, ynaqchars, 'y')
352 #define nyaq(query) yn_function(query, ynaqchars, 'n')
353 #define nyNaq(query) yn_function(query, ynNaqchars, 'n')
354 #define ynNaq(query) yn_function(query, ynNaqchars, 'y')
356 /* Macros for scatter */
357 #define VIS_EFFECTS 0x01 /* display visual effects */
358 #define MAY_HITMON 0x02 /* objects may hit monsters */
359 #define MAY_HITYOU 0x04 /* objects may hit you */
360 #define MAY_HIT (MAY_HITMON | MAY_HITYOU)
361 #define MAY_DESTROY 0x08 /* objects may be destroyed at random */
362 #define MAY_FRACTURE 0x10 /* boulders & statues may fracture */
364 /* Macros for launching objects */
365 #define ROLL 0x01 /* the object is rolling */
366 #define FLING 0x02 /* the object is flying thru the air */
367 #define LAUNCH_UNSEEN 0x40 /* hero neither caused nor saw it */
368 #define LAUNCH_KNOWN 0x80 /* the hero caused this by explicit action */
370 /* Macros for explosion types */
371 enum explosion_types {
382 /* enlightenment control flags */
383 #define BASICENLIGHTENMENT 1 /* show mundane stuff */
384 #define MAGICENLIGHTENMENT 2 /* show intrinsics and such */
385 #define ENL_GAMEINPROGRESS 0
386 #define ENL_GAMEOVERALIVE 1 /* ascension, escape, quit, trickery */
387 #define ENL_GAMEOVERDEAD 2
389 /* control flags for sortloot() */
390 #define SORTLOOT_PACK 0x01
391 #define SORTLOOT_INVLET 0x02
392 #define SORTLOOT_LOOT 0x04
393 #define SORTLOOT_PETRIFY 0x20 /* override filter func for c-trice corpses */
395 /* flags for xkilled() [note: meaning of first bit used to be reversed,
396 1 to give message and 0 to suppress] */
397 #define XKILL_GIVEMSG 0
398 #define XKILL_NOMSG 1
399 #define XKILL_NOCORPSE 2
400 #define XKILL_NOCONDUCT 4
402 /* pline_flags; mask values for custompline()'s first argument */
403 /* #define PLINE_ORDINARY 0 */
404 #define PLINE_NOREPEAT 1
405 #define OVERRIDE_MSGTYPE 2
406 #define SUPPRESS_HISTORY 4
407 #define URGENT_MESSAGE 8
409 /* Macros for messages referring to hands, eyes, feet, etc... */
410 enum bodypart_types {
432 /* indices for some special tin types */
434 #define HOMEMADE_TIN 1
435 #define SPINACH_TIN (-1)
436 #define RANDOM_TIN (-2)
437 #define HEALTHY_TIN (-3)
439 /* Some misc definitions */
440 #define POTION_OCCUPANT_CHANCE(n) (13 + 2 * (n))
441 #define WAND_BACKFIRE_CHANCE 100
442 #define BALL_IN_MON (u.uswallow && uball && uball->where == OBJ_FREE)
443 #define CHAIN_IN_MON (u.uswallow && uchain && uchain->where == OBJ_FREE)
444 #define NODIAG(monnum) ((monnum) == PM_GRID_BUG)
446 /* Flags to control menus */
447 #define MENUTYPELEN sizeof("traditional ")
448 #define MENU_TRADITIONAL 0
449 #define MENU_COMBINATION 1
451 #define MENU_PARTIAL 3
453 #define MENU_SELECTED TRUE
454 #define MENU_UNSELECTED FALSE
458 * Each higher number includes the characteristics of the numbers
461 /* XXX This should be replaced with a bitmap. */
462 #define SET_IN_SYS 0 /* system config file option only */
463 #define SET_IN_FILE 1 /* config file option only */
464 #define SET_VIA_PROG 2 /* may be set via extern program, not seen in game */
465 #define DISP_IN_GAME 3 /* may be set via extern program, displayed in game \
467 #define SET_IN_GAME 4 /* may be set via extern program or set in the game */
468 #define SET_IN_WIZGAME 5 /* may be set set in the game if wizmode */
469 #define SET__IS_VALUE_VALID(s) ((s < SET_IN_SYS) || (s > SET_IN_WIZGAME))
471 #define FEATURE_NOTICE_VER(major, minor, patch) \
472 (((unsigned long) major << 24) | ((unsigned long) minor << 16) \
473 | ((unsigned long) patch << 8) | ((unsigned long) 0))
475 #define FEATURE_NOTICE_VER_MAJ (flags.suppress_alert >> 24)
476 #define FEATURE_NOTICE_VER_MIN \
477 (((unsigned long) (0x0000000000FF0000L & flags.suppress_alert)) >> 16)
478 #define FEATURE_NOTICE_VER_PATCH \
479 (((unsigned long) (0x000000000000FF00L & flags.suppress_alert)) >> 8)
482 #define max(a, b) ((a) > (b) ? (a) : (b))
485 #define min(x, y) ((x) < (y) ? (x) : (y))
487 #define plur(x) (((x) == 1) ? "" : "s")
489 #define ARM_BONUS(obj) \
490 (objects[(obj)->otyp].a_ac + (obj)->spe \
491 - min((int) greatest_erosion(obj), objects[(obj)->otyp].a_ac))
493 #define makeknown(x) discover_object((x), TRUE, TRUE)
494 #define distu(xx, yy) dist2((int)(xx), (int)(yy), (int) u.ux, (int) u.uy)
495 #define onlineu(xx, yy) online2((int)(xx), (int)(yy), (int) u.ux, (int) u.uy)
497 #define rn1(x, y) (rn2(x) + (y))
499 /* negative armor class is randomly weakened to prevent invulnerability */
500 #define AC_VALUE(AC) ((AC) >= 0 ? (AC) : -rnd(-(AC)))
502 #if defined(MICRO) && !defined(__DJGPP__)
504 #define getlogin() ((char *) 0)
509 #define STATIC_DCL extern
515 #define STATIC_DCL static
516 #define STATIC_OVL static
517 #define STATIC_VAR static
521 /* Macro for a few items that are only static if we're not overlaid.... */
522 #if defined(USE_TRAMPOLI) || defined(USE_OVLx)
525 #define STATIC_PTR static
528 /* The function argument to qsort() requires a particular
529 * calling convention under WINCE which is not the default
530 * in that environment.
533 #define CFDECLSPEC __cdecl
538 #define DEVTEAM_EMAIL "devteam@nethack.org"
539 #define DEVTEAM_URL "https://www.nethack.org/"