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