NHDT->ANH, nethack->anethack, nhdat->anhdat
[aNetHack.git] / include / hack.h
blob2b54a99d623b5bafa382789d8f25934fd9a63f61
1 /* aNetHack 0.0.1 hack.h $ANH-Date: 1451683048 2016/01/01 21:17:28 $ $ANH-Branch: master $:$ANH-Revision: 1.68 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* aNetHack may be freely redistributed. See license for details. */
5 #ifndef HACK_H
6 #define HACK_H
8 #ifndef CONFIG_H
9 #include "config.h"
10 #endif
11 #include "lint.h"
13 #define TELL 1
14 #define NOTELL 0
15 #define ON 1
16 #define OFF 0
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 */
19 #define DUMMY \
20 { \
21 0 \
24 /* symbolic names for capacity levels */
25 enum encumbrance_types {
26 UNENCUMBERED = 0,
27 SLT_ENCUMBER, /* Burdened */
28 MOD_ENCUMBER, /* Stressed */
29 HVY_ENCUMBER, /* Strained */
30 EXT_ENCUMBER, /* Overtaxed */
31 OVERLOADED /* Overloaded */
34 /* weight increment of heavy iron ball */
35 #define IRON_BALL_W_INCR 160
37 /* hunger states - see hu_stat in eat.c */
38 enum hunger_state_types {
39 SATIATED = 0,
40 NOT_HUNGRY,
41 HUNGRY,
42 WEAK,
43 FAINTING,
44 FAINTED,
45 STARVED
48 /* Macros for how a rumor was delivered in outrumor() */
49 #define BY_ORACLE 0
50 #define BY_COOKIE 1
51 #define BY_PAPER 2
52 #define BY_OTHER 9
54 /* Macros for why you are no longer riding */
55 enum dismount_types {
56 DISMOUNT_GENERIC = 0,
57 DISMOUNT_FELL,
58 DISMOUNT_THROWN,
59 DISMOUNT_POLY,
60 DISMOUNT_ENGULFED,
61 DISMOUNT_BONES,
62 DISMOUNT_BYCHOICE
65 /* Special returns from mapglyph() */
66 #define MG_CORPSE 0x01
67 #define MG_INVIS 0x02
68 #define MG_DETECT 0x04
69 #define MG_PET 0x08
70 #define MG_RIDDEN 0x10
71 #define MG_STATUE 0x20
72 #define MG_OBJPILE 0x40 /* more than one stack of objects */
73 #define MG_BW_LAVA 0x80 /* 'black & white lava': highlight lava if it
74 can't be distringuished from water by color */
76 /* sellobj_state() states */
77 #define SELL_NORMAL (0)
78 #define SELL_DELIBERATE (1)
79 #define SELL_DONTSELL (2)
81 /* alteration types--keep in synch with costly_alteration(mkobj.c) */
82 enum cost_alteration_types {
83 COST_CANCEL = 0, /* standard cancellation */
84 COST_DRAIN, /* drain life upon an object */
85 COST_UNCHRG, /* cursed charging */
86 COST_UNBLSS, /* unbless (devalues holy water) */
87 COST_UNCURS, /* uncurse (devalues unholy water) */
88 COST_DECHNT, /* disenchant weapons or armor */
89 COST_DEGRD, /* removal of rustproofing, dulling via engraving */
90 COST_DILUTE, /* potion dilution */
91 COST_ERASE, /* scroll or spellbook blanking */
92 COST_BURN, /* dipped into flaming oil */
93 COST_NUTRLZ, /* neutralized via unicorn horn */
94 COST_DSTROY, /* wand breaking (bill first, useup later) */
95 COST_SPLAT, /* cream pie to own face (ditto) */
96 COST_BITE, /* start eating food */
97 COST_OPEN, /* open tin */
98 COST_BRKLCK, /* break box/chest's lock */
99 COST_RUST, /* rust damage */
100 COST_ROT, /* rotting attack */
101 COST_CORRODE /* acid damage */
104 /* bitmask flags for corpse_xname();
105 PFX_THE takes precedence over ARTICLE, NO_PFX takes precedence over both */
106 #define CXN_NORMAL 0 /* no special handling */
107 #define CXN_SINGULAR 1 /* override quantity if greather than 1 */
108 #define CXN_NO_PFX 2 /* suppress "the" from "the Unique Monst */
109 #define CXN_PFX_THE 4 /* prefix with "the " (unless pname) */
110 #define CXN_ARTICLE 8 /* include a/an/the prefix */
111 #define CXN_NOCORPSE 16 /* suppress " corpse" suffix */
113 /* getpos() return values */
114 enum getpos_retval {
115 LOOK_TRADITIONAL = 0, /* '.' -- ask about "more info?" */
116 LOOK_QUICK, /* ',' -- skip "more info?" */
117 LOOK_ONCE, /* ';' -- skip and stop looping */
118 LOOK_VERBOSE /* ':' -- show more info w/o asking */
122 * This is the way the game ends. If these are rearranged, the arrays
123 * in end.c and topten.c will need to be changed. Some parts of the
124 * code assume that PANIC separates the deaths from the non-deaths.
126 enum game_end_types {
127 DIED = 0,
128 CHOKING,
129 POISONING,
130 STARVING,
131 DROWNING,
132 BURNING,
133 DISSOLVED,
134 CRUSHING,
135 STONING,
136 TURNED_SLIME,
137 GENOCIDED,
138 PANICKED,
139 TRICKED,
140 QUIT,
141 ESCAPED,
142 ASCENDED
145 #include "align.h"
146 #include "dungeon.h"
147 #include "monsym.h"
148 #include "mkroom.h"
149 #include "objclass.h"
150 #include "youprop.h"
151 #include "wintype.h"
152 #include "context.h"
153 #include "decl.h"
154 #include "timeout.h"
156 NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */
158 /* types of calls to bhit() */
159 enum bhit_call_types {
160 ZAPPED_WAND = 0,
161 THROWN_WEAPON,
162 KICKED_WEAPON,
163 FLASHED_LIGHT,
164 INVIS_BEAM
167 /* attack mode for hmon() */
168 enum hmon_atkmode_types {
169 HMON_MELEE = 0, /* hand-to-hand */
170 HMON_THROWN, /* normal ranged (or spitting while poly'd) */
171 HMON_KICKED, /* alternate ranged */
172 HMON_APPLIED, /* polearm, treated as ranged */
173 HMON_DRAGGED /* attached iron ball, pulled into mon */
176 #define MATCH_WARN_OF_MON(mon) \
177 (Warn_of_mon && ((context.warntype.obj \
178 && (context.warntype.obj & (mon)->data->mflags2)) \
179 || (context.warntype.polyd \
180 && (context.warntype.polyd & (mon)->data->mflags2)) \
181 || (context.warntype.species \
182 && (context.warntype.species == (mon)->data))))
184 #include "trap.h"
185 #include "flag.h"
186 #include "rm.h"
187 #include "vision.h"
188 #include "display.h"
189 #include "engrave.h"
190 #include "rect.h"
191 #include "region.h"
193 /* Symbol offsets */
194 #define SYM_OFF_P (0)
195 #define SYM_OFF_O (SYM_OFF_P + MAXPCHARS)
196 #define SYM_OFF_M (SYM_OFF_O + MAXOCLASSES)
197 #define SYM_OFF_W (SYM_OFF_M + MAXMCLASSES)
198 #define SYM_OFF_X (SYM_OFF_W + WARNCOUNT)
199 #define SYM_MAX (SYM_OFF_X + MAXOTHER)
201 #ifdef USE_TRAMPOLI /* This doesn't belong here, but we have little choice \
203 #undef NDECL
204 #define NDECL(f) f()
205 #endif
207 #include "extern.h"
208 #include "winprocs.h"
209 #include "sys.h"
211 #ifdef USE_TRAMPOLI
212 #include "wintty.h"
213 #undef WINTTY_H
214 #include "trampoli.h"
215 #undef EXTERN_H
216 #include "extern.h"
217 #endif /* USE_TRAMPOLI */
219 /* flags to control makemon() */
220 #define NO_MM_FLAGS 0x00000 /* use this rather than plain 0 */
221 #define NO_MINVENT 0x00001 /* suppress minvent when creating mon */
222 #define MM_NOWAIT 0x00002 /* don't set STRAT_WAITMASK flags */
223 #define MM_NOCOUNTBIRTH \
224 0x00004 /* don't increment born counter (for revival) */
225 #define MM_IGNOREWATER 0x00008 /* ignore water when positioning */
226 #define MM_ADJACENTOK \
227 0x00010 /* it is acceptable to use adjacent coordinates */
228 #define MM_ANGRY 0x00020 /* monster is created angry */
229 #define MM_NONAME 0x00040 /* monster is not christened */
230 #define MM_EGD 0x00100 /* add egd structure */
231 #define MM_EPRI 0x00200 /* add epri structure */
232 #define MM_ESHK 0x00400 /* add eshk structure */
233 #define MM_EMIN 0x00800 /* add emin structure */
234 #define MM_EDOG 0x01000 /* add edog structure */
236 /* flags for make_corpse() and mkcorpstat() */
237 #define CORPSTAT_NONE 0x00
238 #define CORPSTAT_INIT 0x01 /* pass init flag to mkcorpstat */
239 #define CORPSTAT_BURIED 0x02 /* bury the corpse or statue */
241 /* flags for decide_to_shift() */
242 #define SHIFT_SEENMSG 0x01 /* put out a message if in sight */
243 #define SHIFT_MSG 0x02 /* always put out a message */
245 /* special mhpmax value when loading bones monster to flag as extinct or
246 * genocided */
247 #define DEFUNCT_MONSTER (-100)
249 /* macro form of adjustments of physical damage based on Half_physical_damage.
250 * Can be used on-the-fly with the 1st parameter to losehp() if you don't
251 * need to retain the dmg value beyond that call scope.
252 * Take care to ensure it doesn't get used more than once in other instances.
254 #define Maybe_Half_Phys(dmg) \
255 ((Half_physical_damage) ? (((dmg) + 1) / 2) : (dmg))
257 /* flags for special ggetobj status returns */
258 #define ALL_FINISHED 0x01 /* called routine already finished the job */
260 /* flags to control query_objlist() */
261 #define BY_NEXTHERE 0x1 /* follow objlist by nexthere field */
262 #define AUTOSELECT_SINGLE 0x2 /* if only 1 object, don't ask */
263 #define USE_INVLET 0x4 /* use object's invlet */
264 #define INVORDER_SORT 0x8 /* sort objects by packorder */
265 #define SIGNAL_NOMENU 0x10 /* return -1 rather than 0 if none allowed */
266 #define SIGNAL_ESCAPE 0x20 /* return -2 rather than 0 for ESC */
267 #define FEEL_COCKATRICE 0x40 /* engage cockatrice checks and react */
268 #define INCLUDE_HERO 0x80 /* show hero among engulfer's inventory */
270 /* Flags to control query_category() */
271 /* BY_NEXTHERE used by query_category() too, so skip 0x01 */
272 #define UNPAID_TYPES 0x02
273 #define GOLD_TYPES 0x04
274 #define WORN_TYPES 0x08
275 #define ALL_TYPES 0x10
276 #define BILLED_TYPES 0x20
277 #define CHOOSE_ALL 0x40
278 #define BUC_BLESSED 0x80
279 #define BUC_CURSED 0x100
280 #define BUC_UNCURSED 0x200
281 #define BUC_UNKNOWN 0x400
282 #define BUC_ALLBKNOWN (BUC_BLESSED | BUC_CURSED | BUC_UNCURSED)
283 #define ALL_TYPES_SELECTED -2
285 /* Flags to control find_mid() */
286 #define FM_FMON 0x01 /* search the fmon chain */
287 #define FM_MIGRATE 0x02 /* search the migrating monster chain */
288 #define FM_MYDOGS 0x04 /* search mydogs */
289 #define FM_EVERYWHERE (FM_FMON | FM_MIGRATE | FM_MYDOGS)
291 /* Flags to control pick_[race,role,gend,align] routines in role.c */
292 #define PICK_RANDOM 0
293 #define PICK_RIGID 1
295 /* Flags to control dotrap() in trap.c */
296 #define FORCETRAP 0x01 /* triggering not left to chance */
297 #define NOWEBMSG 0x02 /* suppress stumble into web message */
298 #define FORCEBUNGLE 0x04 /* adjustments appropriate for bungling */
299 #define RECURSIVETRAP 0x08 /* trap changed into another type this same turn */
300 #define TOOKPLUNGE 0x10 /* used '>' to enter pit below you */
301 #define VIASITTING 0x20 /* #sit while at trap location (affects message) */
303 /* Flags to control test_move in hack.c */
304 #define DO_MOVE 0 /* really doing the move */
305 #define TEST_MOVE 1 /* test a normal move (move there next) */
306 #define TEST_TRAV 2 /* test a future travel location */
307 #define TEST_TRAP 3 /* check if a future travel loc is a trap */
309 /*** some utility macros ***/
310 #define yn(query) yn_function(query, ynchars, 'n')
311 #define ynq(query) yn_function(query, ynqchars, 'q')
312 #define ynaq(query) yn_function(query, ynaqchars, 'y')
313 #define nyaq(query) yn_function(query, ynaqchars, 'n')
314 #define nyNaq(query) yn_function(query, ynNaqchars, 'n')
315 #define ynNaq(query) yn_function(query, ynNaqchars, 'y')
317 /* Macros for scatter */
318 #define VIS_EFFECTS 0x01 /* display visual effects */
319 #define MAY_HITMON 0x02 /* objects may hit monsters */
320 #define MAY_HITYOU 0x04 /* objects may hit you */
321 #define MAY_HIT (MAY_HITMON | MAY_HITYOU)
322 #define MAY_DESTROY 0x08 /* objects may be destroyed at random */
323 #define MAY_FRACTURE 0x10 /* boulders & statues may fracture */
325 /* Macros for launching objects */
326 #define ROLL 0x01 /* the object is rolling */
327 #define FLING 0x02 /* the object is flying thru the air */
328 #define LAUNCH_UNSEEN 0x40 /* hero neither caused nor saw it */
329 #define LAUNCH_KNOWN 0x80 /* the hero caused this by explicit action */
331 /* Macros for explosion types */
332 enum explosion_types {
333 EXPL_DARK = 0,
334 EXPL_NOXIOUS,
335 EXPL_MUDDY,
336 EXPL_WET,
337 EXPL_MAGICAL,
338 EXPL_FIERY,
339 EXPL_FROSTY,
340 EXPL_MAX
343 /* enlightenment control flags */
344 #define BASICENLIGHTENMENT 1 /* show mundane stuff */
345 #define MAGICENLIGHTENMENT 2 /* show intrinsics and such */
346 #define ENL_GAMEINPROGRESS 0
347 #define ENL_GAMEOVERALIVE 1 /* ascension, escape, quit, trickery */
348 #define ENL_GAMEOVERDEAD 2
350 /* control flags for sortloot() */
351 #define SORTLOOT_PACK 0x01
352 #define SORTLOOT_INVLET 0x02
353 #define SORTLOOT_LOOT 0x04
355 /* flags for xkilled() [note: meaning of first bit used to be reversed,
356 1 to give message and 0 to suppress] */
357 #define XKILL_GIVEMSG 0
358 #define XKILL_NOMSG 1
359 #define XKILL_NOCORPSE 2
360 #define XKILL_NOCONDUCT 4
362 /* Macros for messages referring to hands, eyes, feet, etc... */
363 enum bodypart_types {
364 ARM = 0,
365 EYE,
366 FACE,
367 FINGER,
368 FINGERTIP,
369 FOOT,
370 HAND,
371 HANDED,
372 HEAD,
373 LEG,
374 LIGHT_HEADED,
375 NECK,
376 SPINE,
377 TOE,
378 HAIR,
379 BLOOD,
380 LUNG,
381 NOSE,
382 STOMACH
385 /* indices for some special tin types */
386 #define ROTTEN_TIN 0
387 #define HOMEMADE_TIN 1
388 #define SPINACH_TIN (-1)
389 #define RANDOM_TIN (-2)
390 #define HEALTHY_TIN (-3)
392 /* Some misc definitions */
393 #define POTION_OCCUPANT_CHANCE(n) (13 + 2 * (n))
394 #define WAND_BACKFIRE_CHANCE 100
395 #define BALL_IN_MON (u.uswallow && uball && uball->where == OBJ_FREE)
396 #define NODIAG(monnum) ((monnum) == PM_GRID_BUG)
398 /* Flags to control menus */
399 #define MENUTYPELEN sizeof("traditional ")
400 #define MENU_TRADITIONAL 0
401 #define MENU_COMBINATION 1
402 #define MENU_FULL 2
403 #define MENU_PARTIAL 3
405 #define MENU_SELECTED TRUE
406 #define MENU_UNSELECTED FALSE
409 * Option flags
410 * Each higher number includes the characteristics of the numbers
411 * below it.
413 /* XXX This should be replaced with a bitmap. */
414 #define SET_IN_SYS 0 /* system config file option only */
415 #define SET_IN_FILE 1 /* config file option only */
416 #define SET_VIA_PROG 2 /* may be set via extern program, not seen in game */
417 #define DISP_IN_GAME 3 /* may be set via extern program, displayed in game \
419 #define SET_IN_GAME 4 /* may be set via extern program or set in the game */
420 #define SET_IN_WIZGAME 5 /* may be set set in the game if wizmode */
421 #define SET__IS_VALUE_VALID(s) ((s < SET_IN_SYS) || (s > SET_IN_WIZGAME))
423 #define FEATURE_NOTICE_VER(major, minor, patch) \
424 (((unsigned long) major << 24) | ((unsigned long) minor << 16) \
425 | ((unsigned long) patch << 8) | ((unsigned long) 0))
427 #define FEATURE_NOTICE_VER_MAJ (flags.suppress_alert >> 24)
428 #define FEATURE_NOTICE_VER_MIN \
429 (((unsigned long) (0x0000000000FF0000L & flags.suppress_alert)) >> 16)
430 #define FEATURE_NOTICE_VER_PATCH \
431 (((unsigned long) (0x000000000000FF00L & flags.suppress_alert)) >> 8)
433 #ifndef max
434 #define max(a, b) ((a) > (b) ? (a) : (b))
435 #endif
436 #ifndef min
437 #define min(x, y) ((x) < (y) ? (x) : (y))
438 #endif
439 #define plur(x) (((x) == 1) ? "" : "s")
441 #define ARM_BONUS(obj) \
442 (objects[(obj)->otyp].a_ac + (obj)->spe \
443 - min((int) greatest_erosion(obj), objects[(obj)->otyp].a_ac))
445 #define makeknown(x) discover_object((x), TRUE, TRUE)
446 #define distu(xx, yy) dist2((int)(xx), (int)(yy), (int) u.ux, (int) u.uy)
447 #define onlineu(xx, yy) online2((int)(xx), (int)(yy), (int) u.ux, (int) u.uy)
449 #define rn1(x, y) (rn2(x) + (y))
451 /* negative armor class is randomly weakened to prevent invulnerability */
452 #define AC_VALUE(AC) ((AC) >= 0 ? (AC) : -rnd(-(AC)))
454 #if defined(MICRO) && !defined(__DJGPP__)
455 #define getuid() 1
456 #define getlogin() ((char *) 0)
457 #endif /* MICRO */
459 #if defined(OVERLAY)
460 #define USE_OVLx
461 #define STATIC_DCL extern
462 #define STATIC_OVL
463 #define STATIC_VAR
465 #else /* !OVERLAY */
467 #define STATIC_DCL static
468 #define STATIC_OVL static
469 #define STATIC_VAR static
471 #endif /* OVERLAY */
473 /* Macro for a few items that are only static if we're not overlaid.... */
474 #if defined(USE_TRAMPOLI) || defined(USE_OVLx)
475 #define STATIC_PTR
476 #else
477 #define STATIC_PTR static
478 #endif
480 /* The function argument to qsort() requires a particular
481 * calling convention under WINCE which is not the default
482 * in that environment.
484 #if defined(WIN_CE)
485 #define CFDECLSPEC __cdecl
486 #else
487 #define CFDECLSPEC
488 #endif
490 #define DEVTEAM_EMAIL "elronnd@slashem.me"
491 #define DEVTEAM_URL "http://repo.or.cz/aNetHack.git"
493 #endif /* HACK_H */