Source:NetHack 3.4.3/include/hack.h

From NetHackWiki
Jump to: navigation, search

Below is the full text to include/hack.h from NetHack 3.4.3. To link to a particular line, write [[hack.h#line123]], for example.

  1. /*	SCCS Id: @(#)hack.h	3.4	2001/04/12	*/
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1. #ifndef HACK_H
  2. #define HACK_H
  3.  
  4. #ifndef CONFIG_H
  5. #include "config.h"
  6. #endif
  7.  
  8. /*	For debugging beta code.	*/
  9. #ifdef BETA
  10. #define Dpline	pline
  11. #endif
  12.  
  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 { 0 }
  20.  
  21. /* symbolic names for capacity levels */
  22. #define UNENCUMBERED	0
  23. #define SLT_ENCUMBER	1	/* Burdened */
  24. #define MOD_ENCUMBER	2	/* Stressed */
  25. #define HVY_ENCUMBER	3	/* Strained */
  26. #define EXT_ENCUMBER	4	/* Overtaxed */
  27. #define OVERLOADED	5	/* Overloaded */
  28.  
  29. /* Macros for how a rumor was delivered in outrumor() */
  30. #define BY_ORACLE	0
  31. #define BY_COOKIE	1
  32. #define BY_PAPER	2
  33. #define BY_OTHER	9
  34.  
  35. #ifdef STEED
  36. /* Macros for why you are no longer riding */
  37. #define DISMOUNT_GENERIC	0
  38. #define DISMOUNT_FELL		1
  39. #define DISMOUNT_THROWN		2
  40. #define DISMOUNT_POLY		3
  41. #define DISMOUNT_ENGULFED	4
  42. #define DISMOUNT_BONES		5
  43. #define DISMOUNT_BYCHOICE	6
  44. #endif
  45.  
  46. /* Special returns from mapglyph() */
  47. #define MG_CORPSE	0x01
  48. #define MG_INVIS	0x02
  49. #define MG_DETECT	0x04
  50. #define MG_PET		0x08
  51. #define MG_RIDDEN	0x10
  52.  
  53. /* sellobj_state() states */
  54. #define SELL_NORMAL	(0)
  55. #define SELL_DELIBERATE	(1)
  56. #define SELL_DONTSELL	(2)
  57.  
  58. /*
  59. * This is the way the game ends.  If these are rearranged, the arrays
  60. * in end.c and topten.c will need to be changed.  Some parts of the
  61. * code assume that PANIC separates the deaths from the non-deaths.
  62. */
  63. #define DIED		 0
  64. #define CHOKING		 1
  65. #define POISONING	 2
  66. #define STARVING	 3
  67. #define DROWNING	 4
  68. #define BURNING		 5
  69. #define DISSOLVED	 6
  70. #define CRUSHING	 7
  71. #define STONING		 8
  72. #define TURNED_SLIME	 9
  73. #define GENOCIDED	10
  74. #define PANICKED	11
  75. #define TRICKED		12
  76. #define QUIT		13
  77. #define ESCAPED		14
  78. #define ASCENDED	15
  79.  
  80. #include "align.h"
  81. #include "dungeon.h"
  82. #include "monsym.h"
  83. #include "mkroom.h"
  84. #include "objclass.h"
  85. #include "youprop.h"
  86. #include "wintype.h"
  87. #include "decl.h"
  88. #include "timeout.h"
  89.  
  90. NEARDATA extern coord bhitpos;	/* place where throw or zap hits or stops */
  91.  
  92. /* types of calls to bhit() */
  93. #define ZAPPED_WAND	0
  94. #define THROWN_WEAPON	1
  95. #define KICKED_WEAPON	2
  96. #define FLASHED_LIGHT	3
  97. #define INVIS_BEAM	4
  98.  
  99. #define MATCH_WARN_OF_MON(mon)	 (Warn_of_mon && flags.warntype && \
  100. 		   		 (flags.warntype & (mon)->data->mflags2))
  101.  
  102. #include "trap.h"
  103. #include "flag.h"
  104. #include "rm.h"
  105. #include "vision.h"
  106. #include "display.h"
  107. #include "engrave.h"
  108. #include "rect.h"
  109. #include "region.h"
  110.  
  111. #ifdef USE_TRAMPOLI /* This doesn't belong here, but we have little choice */
  112. #undef NDECL
  113. #define NDECL(f) f()
  114. #endif
  115.  
  116. #include "extern.h"
  117. #include "winprocs.h"
  118.  
  119. #ifdef USE_TRAMPOLI
  120. #include "wintty.h"
  121. #undef WINTTY_H
  122. #include "trampoli.h"
  123. #undef EXTERN_H
  124. #include "extern.h"
  125. #endif /* USE_TRAMPOLI */
  126.  
  127. #define NO_SPELL	0
  128.  
  129. /* flags to control makemon() */
  130. #define NO_MM_FLAGS	  0x00	/* use this rather than plain 0 */
  131. #define NO_MINVENT	  0x01	/* suppress minvent when creating mon */
  132. #define MM_NOWAIT	  0x02	/* don't set STRAT_WAITMASK flags */
  133. #define MM_EDOG		  0x04	/* add edog structure */
  134. #define MM_EMIN		  0x08	/* add emin structure */
  135. #define MM_ANGRY	  0x10  /* monster is created angry */
  136. #define MM_NONAME	  0x20  /* monster is not christened */
  137. #define MM_NOCOUNTBIRTH	  0x40  /* don't increment born counter (for revival) */
  138. #define MM_IGNOREWATER	  0x80	/* ignore water when positioning */
  139. #define MM_ADJACENTOK	  0x100 /* it is acceptable to use adjacent coordinates */
  140.  
  141. /* special mhpmax value when loading bones monster to flag as extinct or genocided */
  142. #define DEFUNCT_MONSTER	(-100)
  143.  
  144. /* flags for special ggetobj status returns */
  145. #define ALL_FINISHED	  0x01  /* called routine already finished the job */
  146.  
  147. /* flags to control query_objlist() */
  148. #define BY_NEXTHERE	  0x1	/* follow objlist by nexthere field */
  149. #define AUTOSELECT_SINGLE 0x2	/* if only 1 object, don't ask */
  150. #define USE_INVLET	  0x4	/* use object's invlet */
  151. #define INVORDER_SORT	  0x8	/* sort objects by packorder */
  152. #define SIGNAL_NOMENU	  0x10	/* return -1 rather than 0 if none allowed */
  153. #define FEEL_COCKATRICE   0x20  /* engage cockatrice checks and react */
  154.  
  155. /* Flags to control query_category() */
  156. /* BY_NEXTHERE used by query_category() too, so skip 0x01 */
  157. #define UNPAID_TYPES 0x02
  158. #define GOLD_TYPES   0x04
  159. #define WORN_TYPES   0x08
  160. #define ALL_TYPES    0x10
  161. #define BILLED_TYPES 0x20
  162. #define CHOOSE_ALL   0x40
  163. #define BUC_BLESSED  0x80
  164. #define BUC_CURSED   0x100
  165. #define BUC_UNCURSED 0x200
  166. #define BUC_UNKNOWN  0x400
  167. #define BUC_ALLBKNOWN (BUC_BLESSED|BUC_CURSED|BUC_UNCURSED)
  168. #define ALL_TYPES_SELECTED -2
  169.  
  170. /* Flags to control find_mid() */
  171. #define FM_FMON	       0x01	/* search the fmon chain */
  172. #define FM_MIGRATE     0x02	/* search the migrating monster chain */
  173. #define FM_MYDOGS      0x04	/* search mydogs */
  174. #define FM_EVERYWHERE  (FM_FMON | FM_MIGRATE | FM_MYDOGS)
  175.  
  176. /* Flags to control pick_[race,role,gend,align] routines in role.c */
  177. #define PICK_RANDOM	0
  178. #define PICK_RIGID	1
  179.  
  180. /* Flags to control dotrap() in trap.c */
  181. #define NOWEBMSG	0x01	/* suppress stumble into web message */
  182. #define FORCEBUNGLE	0x02	/* adjustments appropriate for bungling */
  183. #define RECURSIVETRAP	0x04	/* trap changed into another type this same turn */
  184.  
  185. /* Flags to control test_move in hack.c */
  186. #define DO_MOVE		0	/* really doing the move */
  187. #define TEST_MOVE	1	/* test a normal move (move there next) */
  188. #define TEST_TRAV	2	/* test a future travel location */
  189.  
  190. /*** some utility macros ***/
  191. #define yn(query) yn_function(query,ynchars, 'n')
  192. #define ynq(query) yn_function(query,ynqchars, 'q')
  193. #define ynaq(query) yn_function(query,ynaqchars, 'y')
  194. #define nyaq(query) yn_function(query,ynaqchars, 'n')
  195. #define nyNaq(query) yn_function(query,ynNaqchars, 'n')
  196. #define ynNaq(query) yn_function(query,ynNaqchars, 'y')
  197.  
  198. /* Macros for scatter */
  199. #define VIS_EFFECTS	0x01	/* display visual effects */
  200. #define MAY_HITMON	0x02	/* objects may hit monsters */
  201. #define MAY_HITYOU	0x04	/* objects may hit you */
  202. #define MAY_HIT		(MAY_HITMON|MAY_HITYOU)
  203. #define MAY_DESTROY	0x08	/* objects may be destroyed at random */
  204. #define MAY_FRACTURE	0x10	/* boulders & statues may fracture */
  205.  
  206. /* Macros for launching objects */
  207. #define ROLL		0x01	/* the object is rolling */
  208. #define FLING		0x02	/* the object is flying thru the air */
  209. #define LAUNCH_UNSEEN	0x40	/* hero neither caused nor saw it */
  210. #define LAUNCH_KNOWN	0x80	/* the hero caused this by explicit action */
  211.  
  212. /* Macros for explosion types */
  213. #define EXPL_DARK	0
  214. #define EXPL_NOXIOUS	1
  215. #define EXPL_MUDDY	2
  216. #define EXPL_WET	3
  217. #define EXPL_MAGICAL	4
  218. #define EXPL_FIERY	5
  219. #define EXPL_FROSTY	6
  220. #define EXPL_MAX	7
  221.  
  222. /* Macros for messages referring to hands, eyes, feet, etc... */
  223. #define ARM 0
  224. #define EYE 1
  225. #define FACE 2
  226. #define FINGER 3
  227. #define FINGERTIP 4
  228. #define FOOT 5
  229. #define HAND 6
  230. #define HANDED 7
  231. #define HEAD 8
  232. #define LEG 9
  233. #define LIGHT_HEADED 10
  234. #define NECK 11
  235. #define SPINE 12
  236. #define TOE 13
  237. #define HAIR 14
  238. #define BLOOD 15
  239. #define LUNG 16
  240. #define NOSE 17
  241. #define STOMACH 18
  242.  
  243. /* Flags to control menus */
  244. #define MENUTYPELEN sizeof("traditional ")
  245. #define MENU_TRADITIONAL 0
  246. #define MENU_COMBINATION 1
  247. #define MENU_PARTIAL	 2
  248. #define MENU_FULL	 3
  249.  
  250. #define MENU_SELECTED	TRUE
  251. #define MENU_UNSELECTED FALSE
  252.  
  253. /*
  254. * Option flags
  255. * Each higher number includes the characteristics of the numbers
  256. * below it.
  257. */
  258. #define SET_IN_FILE	0 /* config file option only */
  259. #define SET_VIA_PROG	1 /* may be set via extern program, not seen in game */
  260. #define DISP_IN_GAME	2 /* may be set via extern program, displayed in game */
  261. #define SET_IN_GAME	3 /* may be set via extern program or set in the game */
  262.  
  263. #define FEATURE_NOTICE_VER(major,minor,patch) (((unsigned long)major << 24) | \
  264. 	((unsigned long)minor << 16) | \
  265. 	((unsigned long)patch << 8) | \
  266. 	((unsigned long)0))
  267.  
  268. #define FEATURE_NOTICE_VER_MAJ	  (flags.suppress_alert >> 24)
  269. #define FEATURE_NOTICE_VER_MIN	  (((unsigned long)(0x0000000000FF0000L & flags.suppress_alert)) >> 16)
  270. #define FEATURE_NOTICE_VER_PATCH  (((unsigned long)(0x000000000000FF00L & flags.suppress_alert)) >>  8)
  271.  
  272. #ifndef max
  273. #define max(a,b) ((a) > (b) ? (a) : (b))
  274. #endif
  275. #ifndef min
  276. #define min(x,y) ((x) < (y) ? (x) : (y))
  277. #endif
  278. #define plur(x) (((x) == 1) ? "" : "s")
  279.  
  280. #define ARM_BONUS(obj)	(objects[(obj)->otyp].a_ac + (obj)->spe \
  281. 			 - min((int)greatest_erosion(obj),objects[(obj)->otyp].a_ac))
  282.  
  283. #define makeknown(x)	discover_object((x),TRUE,TRUE)
  284. #define distu(xx,yy)	dist2((int)(xx),(int)(yy),(int)u.ux,(int)u.uy)
  285. #define onlineu(xx,yy)	online2((int)(xx),(int)(yy),(int)u.ux,(int)u.uy)
  286.  
  287. #define rn1(x,y)	(rn2(x)+(y))
  288.  
  289. /* negative armor class is randomly weakened to prevent invulnerability */
  290. #define AC_VALUE(AC)	((AC) >= 0 ? (AC) : -rnd(-(AC)))
  291.  
  292. #if defined(MICRO) && !defined(__DJGPP__)
  293. #define getuid() 1
  294. #define getlogin() ((char *)0)
  295. #endif /* MICRO */
  296.  
  297. #if defined(OVERLAY)&&(defined(OVL0)||defined(OVL1)||defined(OVL2)||defined(OVL3)||defined(OVLB))
  298. # define USE_OVLx
  299. # define STATIC_DCL extern
  300. # define STATIC_OVL
  301. # ifdef OVLB
  302. #  define STATIC_VAR
  303. # else
  304. #  define STATIC_VAR extern
  305. # endif
  306.  
  307. #else	/* !OVERLAY || (!OVL0 && !OVL1 && !OVL2 && !OVL3 && !OVLB) */
  308. # define STATIC_DCL static
  309. # define STATIC_OVL static
  310. # define STATIC_VAR static
  311.  
  312. /* If not compiling an overlay, compile everything. */
  313. # define OVL0	/* highest priority */
  314. # define OVL1
  315. # define OVL2
  316. # define OVL3	/* lowest specified priority */
  317. # define OVLB	/* the base overlay segment */
  318. #endif	/* OVERLAY && (OVL0 || OVL1 || OVL2 || OVL3 || OVLB) */
  319.  
  320. /* Macro for a few items that are only static if we're not overlaid.... */
  321. #if defined(USE_TRAMPOLI) || defined(USE_OVLx)
  322. # define STATIC_PTR
  323. #else
  324. # define STATIC_PTR static
  325. #endif
  326.  
  327. /* The function argument to qsort() requires a particular
  328. * calling convention under WINCE which is not the default
  329. * in that environment.
  330. */
  331. #if defined(WIN_CE)
  332. # define CFDECLSPEC __cdecl
  333. #else
  334. # define CFDECLSPEC
  335. #endif
  336.  
  337. #endif /* HACK_H */