Source:NetHack 3.6.0/include/hack.h

From NetHackWiki
(Redirected from Source:Hack.h)
Jump to: navigation, search

Below is the full text to hack.h from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/include/hack.h#line123]], for example.

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.  /* 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. */
  4.  
  5.  #ifndef HACK_H
  6.  #define HACK_H
  7.  
  8.  #ifndef CONFIG_H
  9.  #include "config.h"
  10.  #endif
  11.  #include "lint.h"
  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 \
  20.      {         \
  21.          0     \
  22.      }
  23.  
  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 */
  31.  
  32.  /* hunger states - see hu_stat in eat.c */
  33.  #define SATIATED 0
  34.  #define NOT_HUNGRY 1
  35.  #define HUNGRY 2
  36.  #define WEAK 3
  37.  #define FAINTING 4
  38.  #define FAINTED 5
  39.  #define STARVED 6
  40.  
  41.  /* Macros for how a rumor was delivered in outrumor() */
  42.  #define BY_ORACLE 0
  43.  #define BY_COOKIE 1
  44.  #define BY_PAPER 2
  45.  #define BY_OTHER 9
  46.  
  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
  55.  
  56.  /* Special returns from mapglyph() */
  57.  #define MG_CORPSE 0x01
  58.  #define MG_INVIS 0x02
  59.  #define MG_DETECT 0x04
  60.  #define MG_PET 0x08
  61.  #define MG_RIDDEN 0x10
  62.  #define MG_STATUE 0x20
  63.  #define MG_OBJPILE 0x40  /* more than one stack of objects */
  64.  
  65.  /* sellobj_state() states */
  66.  #define SELL_NORMAL (0)
  67.  #define SELL_DELIBERATE (1)
  68.  #define SELL_DONTSELL (2)
  69.  
  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 */
  90.  
  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 */
  99.  
  100.  /*
  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.
  104.   */
  105.  #define DIED 0
  106.  #define CHOKING 1
  107.  #define POISONING 2
  108.  #define STARVING 3
  109.  #define DROWNING 4
  110.  #define BURNING 5
  111.  #define DISSOLVED 6
  112.  #define CRUSHING 7
  113.  #define STONING 8
  114.  #define TURNED_SLIME 9
  115.  #define GENOCIDED 10
  116.  #define PANICKED 11
  117.  #define TRICKED 12
  118.  #define QUIT 13
  119.  #define ESCAPED 14
  120.  #define ASCENDED 15
  121.  
  122.  #include "align.h"
  123.  #include "dungeon.h"
  124.  #include "monsym.h"
  125.  #include "mkroom.h"
  126.  #include "objclass.h"
  127.  #include "youprop.h"
  128.  #include "wintype.h"
  129.  #include "context.h"
  130.  #include "decl.h"
  131.  #include "timeout.h"
  132.  
  133.  NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */
  134.  
  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
  140.  #define INVIS_BEAM 4
  141.  
  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 */
  148.  
  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))))
  156.  
  157.  #include "trap.h"
  158.  #include "flag.h"
  159.  #include "rm.h"
  160.  #include "vision.h"
  161.  #include "display.h"
  162.  #include "engrave.h"
  163.  #include "rect.h"
  164.  #include "region.h"
  165.  
  166.  /* Symbol offsets */
  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)
  173.  
  174.  #ifdef USE_TRAMPOLI /* This doesn't belong here, but we have little choice \
  175.                         */
  176.  #undef NDECL
  177.  #define NDECL(f) f()
  178.  #endif
  179.  
  180.  #include "extern.h"
  181.  #include "winprocs.h"
  182.  #include "sys.h"
  183.  
  184.  #ifdef USE_TRAMPOLI
  185.  #include "wintty.h"
  186.  #undef WINTTY_H
  187.  #include "trampoli.h"
  188.  #undef EXTERN_H
  189.  #include "extern.h"
  190.  #endif /* USE_TRAMPOLI */
  191.  
  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 */
  208.  
  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 */
  213.  
  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 */
  217.  
  218.  /* special mhpmax value when loading bones monster to flag as extinct or
  219.   * genocided */
  220.  #define DEFUNCT_MONSTER (-100)
  221.  
  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.
  226.   */
  227.  #define Maybe_Half_Phys(dmg) \
  228.      ((Half_physical_damage) ? (((dmg) + 1) / 2) : (dmg))
  229.  
  230.  /* flags for special ggetobj status returns */
  231.  #define ALL_FINISHED 0x01 /* called routine already finished the job */
  232.  
  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 */
  242.  
  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
  257.  
  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)
  263.  
  264.  /* Flags to control pick_[race,role,gend,align] routines in role.c */
  265.  #define PICK_RANDOM 0
  266.  #define PICK_RIGID 1
  267.  
  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 \
  273.                                */
  274.  #define TOOKPLUNGE 0x10    /* used '>' to enter pit below you */
  275.  
  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 */
  280.  
  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')
  288.  
  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 */
  296.  
  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 */
  302.  
  303.  /* Macros for explosion types */
  304.  #define EXPL_DARK 0
  305.  #define EXPL_NOXIOUS 1
  306.  #define EXPL_MUDDY 2
  307.  #define EXPL_WET 3
  308.  #define EXPL_MAGICAL 4
  309.  #define EXPL_FIERY 5
  310.  #define EXPL_FROSTY 6
  311.  #define EXPL_MAX 7
  312.  
  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
  319.  
  320.  /* Macros for messages referring to hands, eyes, feet, etc... */
  321.  #define ARM 0
  322.  #define EYE 1
  323.  #define FACE 2
  324.  #define FINGER 3
  325.  #define FINGERTIP 4
  326.  #define FOOT 5
  327.  #define HAND 6
  328.  #define HANDED 7
  329.  #define HEAD 8
  330.  #define LEG 9
  331.  #define LIGHT_HEADED 10
  332.  #define NECK 11
  333.  #define SPINE 12
  334.  #define TOE 13
  335.  #define HAIR 14
  336.  #define BLOOD 15
  337.  #define LUNG 16
  338.  #define NOSE 17
  339.  #define STOMACH 18
  340.  
  341.  /* indices for some special tin types */
  342.  #define ROTTEN_TIN 0
  343.  #define HOMEMADE_TIN 1
  344.  #define SPINACH_TIN (-1)
  345.  #define RANDOM_TIN (-2)
  346.  #define HEALTHY_TIN (-3)
  347.  
  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)
  353.  
  354.  /* Flags to control menus */
  355.  #define MENUTYPELEN sizeof("traditional ")
  356.  #define MENU_TRADITIONAL 0
  357.  #define MENU_COMBINATION 1
  358.  #define MENU_FULL 2
  359.  #define MENU_PARTIAL 3
  360.  
  361.  #define MENU_SELECTED TRUE
  362.  #define MENU_UNSELECTED FALSE
  363.  
  364.  /*
  365.   * Option flags
  366.   * Each higher number includes the characteristics of the numbers
  367.   * below it.
  368.   */
  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 \
  374.                            */
  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))
  377.  
  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))
  381.  
  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)
  387.  
  388.  #ifndef max
  389.  #define max(a, b) ((a) > (b) ? (a) : (b))
  390.  #endif
  391.  #ifndef min
  392.  #define min(x, y) ((x) < (y) ? (x) : (y))
  393.  #endif
  394.  #define plur(x) (((x) == 1) ? "" : "s")
  395.  
  396.  #define ARM_BONUS(obj)                      \
  397.      (objects[(obj)->otyp].a_ac + (obj)->spe \
  398.       - min((int) greatest_erosion(obj), objects[(obj)->otyp].a_ac))
  399.  
  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)
  403.  
  404.  #define rn1(x, y) (rn2(x) + (y))
  405.  
  406.  /* negative armor class is randomly weakened to prevent invulnerability */
  407.  #define AC_VALUE(AC) ((AC) >= 0 ? (AC) : -rnd(-(AC)))
  408.  
  409.  #if defined(MICRO) && !defined(__DJGPP__)
  410.  #define getuid() 1
  411.  #define getlogin() ((char *) 0)
  412.  #endif /* MICRO */
  413.  
  414.  #if defined(OVERLAY)
  415.  #define USE_OVLx
  416.  #define STATIC_DCL extern
  417.  #define STATIC_OVL
  418.  #define STATIC_VAR
  419.  
  420.  #else /* !OVERLAY */
  421.  
  422.  #define STATIC_DCL static
  423.  #define STATIC_OVL static
  424.  #define STATIC_VAR static
  425.  
  426.  #endif /* OVERLAY */
  427.  
  428.  /* Macro for a few items that are only static if we're not overlaid.... */
  429.  #if defined(USE_TRAMPOLI) || defined(USE_OVLx)
  430.  #define STATIC_PTR
  431.  #else
  432.  #define STATIC_PTR static
  433.  #endif
  434.  
  435.  /* The function argument to qsort() requires a particular
  436.   * calling convention under WINCE which is not the default
  437.   * in that environment.
  438.   */
  439.  #if defined(WIN_CE)
  440.  #define CFDECLSPEC __cdecl
  441.  #else
  442.  #define CFDECLSPEC
  443.  #endif
  444.  
  445.  #define DEVTEAM_EMAIL "devteam@nethack.org"
  446.  #define DEVTEAM_URL "http://www.nethack.org"
  447.  
  448.  #endif /* HACK_H */