Source:NetHack 3.6.1/include/monst.h

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

Below is the full text to monst.h from the source code of NetHack 3.6.1. To link to a particular line, write [[Source:NetHack 3.6.1/include/monst.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	monst.h	$NHDT-Date: 1461028522 2016/04/19 01:15:22 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.24 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /*-Copyright (c) Robert Patrick Rankin, 2016. */
  4.  /* NetHack may be freely redistributed.  See license for details. */
  5.  
  6.  #ifndef MONST_H
  7.  #define MONST_H
  8.  
  9.  #ifndef MEXTRA_H
  10.  #include "mextra.h"
  11.  #endif
  12.  
  13.  /* The weapon_check flag is used two ways:
  14.   * 1) When calling mon_wield_item, is 2-6 depending on what is desired.
  15.   * 2) Between calls to mon_wield_item, is 0 or 1 depending on whether or not
  16.   *    the weapon is known by the monster to be cursed (so it shouldn't bother
  17.   *    trying for another weapon).
  18.   * I originally planned to also use 0 if the monster already had its best
  19.   * weapon, to avoid the overhead of a call to mon_wield_item, but it turns out
  20.   * that there are enough situations which might make a monster change its
  21.   * weapon that this is impractical.  --KAA
  22.   */
  23.  enum wpn_chk_flags {
  24.      NO_WEAPON_WANTED = 0,
  25.      NEED_WEAPON,
  26.      NEED_RANGED_WEAPON,
  27.      NEED_HTH_WEAPON,
  28.      NEED_PICK_AXE,
  29.      NEED_AXE,
  30.      NEED_PICK_OR_AXE
  31.  };
  32.  
  33.  /* The following flags are used for the second argument to display_minventory
  34.   * in invent.c:
  35.   *
  36.   * PICK_NONE, PICK_ONE, PICK_ANY (wintype.h)  0, 1, 2
  37.   * MINV_NOLET  If set, don't display inventory letters on monster's inventory.
  38.   * MINV_ALL    If set, display all items in monster's inventory, otherwise
  39.   *	       just display wielded weapons and worn items.
  40.   */
  41.  #define MINV_PICKMASK 0x03 /* 1|2 */
  42.  #define MINV_NOLET    0x04
  43.  #define MINV_ALL      0x08
  44.  
  45.  enum m_ap_types {
  46.      M_AP_NOTHING = 0, /* mappearance unused--monster appears as itself */
  47.      M_AP_FURNITURE,   /* stairs, a door, an altar, etc. */
  48.      M_AP_OBJECT,      /* an object */
  49.      M_AP_MONSTER      /* a monster */
  50.  };
  51.  
  52.  struct monst {
  53.      struct monst *nmon;
  54.      struct permonst *data;
  55.      unsigned m_id;
  56.      short mnum;           /* permanent monster index number */
  57.      short cham;           /* if shapeshifter, orig mons[] idx goes here */
  58.      short movement;       /* movement points (derived from permonst definition
  59.                               and added effects */
  60.      uchar m_lev;          /* adjusted difficulty level of monster */
  61.      aligntyp malign;      /* alignment of this monster, relative to the
  62.                               player (positive = good to kill) */
  63.      xchar mx, my;
  64.      xchar mux, muy;       /* where the monster thinks you are */
  65.  #define MTSZ 4
  66.      coord mtrack[MTSZ];   /* monster track */
  67.      int mhp, mhpmax;
  68.      unsigned mappearance; /* for undetected mimics and the wiz */
  69.      uchar m_ap_type;      /* what mappearance is describing, m_ap_types */
  70.  
  71.      schar mtame;                /* level of tameness, implies peaceful */
  72.      unsigned short mintrinsics; /* low 8 correspond to mresists */
  73.      int mspec_used;             /* monster's special ability attack timeout */
  74.  
  75.      Bitfield(female, 1);      /* is female */
  76.      Bitfield(minvis, 1);      /* currently invisible */
  77.      Bitfield(invis_blkd, 1);  /* invisibility blocked */
  78.      Bitfield(perminvis, 1);   /* intrinsic minvis value */
  79.      Bitfield(mcan, 1);        /* has been cancelled */
  80.      Bitfield(mburied, 1);     /* has been buried */
  81.      Bitfield(mundetected, 1); /* not seen in present hiding place;
  82.                                 * implies one of M1_CONCEAL or M1_HIDE,
  83.                                 * but not mimic (that is, snake, spider,
  84.                                 * trapper, piercer, eel)
  85.                                 */
  86.      Bitfield(mcansee, 1);   /* cansee 1, temp.blinded 0, blind 0 */
  87.  
  88.      Bitfield(mspeed, 2);    /* current speed */
  89.      Bitfield(permspeed, 2); /* intrinsic mspeed value */
  90.      Bitfield(mrevived, 1);  /* has been revived from the dead */
  91.      Bitfield(mcloned, 1);   /* has been cloned from another */
  92.      Bitfield(mavenge, 1);   /* did something to deserve retaliation */
  93.      Bitfield(mflee, 1);     /* fleeing */
  94.  
  95.      Bitfield(mfleetim, 7);  /* timeout for mflee */
  96.      Bitfield(msleeping, 1); /* asleep until woken */
  97.  
  98.      Bitfield(mblinded, 7);  /* cansee 0, temp.blinded n, blind 0 */
  99.      Bitfield(mstun, 1);     /* stunned (off balance) */
  100.  
  101.      Bitfield(mfrozen, 7);
  102.      Bitfield(mcanmove, 1);  /* paralysis, similar to mblinded */
  103.  
  104.      Bitfield(mconf, 1);     /* confused */
  105.      Bitfield(mpeaceful, 1); /* does not attack unprovoked */
  106.      Bitfield(mtrapped, 1);  /* trapped in a pit, web or bear trap */
  107.      Bitfield(mleashed, 1);  /* monster is on a leash */
  108.      Bitfield(isshk, 1);     /* is shopkeeper */
  109.      Bitfield(isminion, 1);  /* is a minion */
  110.      Bitfield(isgd, 1);      /* is guard */
  111.      Bitfield(ispriest, 1);  /* is an aligned priest or high priest */
  112.  
  113.      Bitfield(iswiz, 1);     /* is the Wizard of Yendor */
  114.      Bitfield(wormno, 5);    /* at most 31 worms on any level */
  115.      /* 2 free bits */
  116.  
  117.  #define MAX_NUM_WORMS 32    /* should be 2^(wormno bitfield size) */
  118.  
  119.      unsigned long mstrategy; /* for monsters with mflag3: current strategy */
  120.  #ifdef NHSTDC
  121.  #define STRAT_APPEARMSG 0x80000000UL
  122.  #else
  123.  #define STRAT_APPEARMSG 0x80000000L
  124.  #endif
  125.  #define STRAT_ARRIVE    0x40000000L /* just arrived on current level */
  126.  #define STRAT_WAITFORU  0x20000000L
  127.  #define STRAT_CLOSE     0x10000000L
  128.  #define STRAT_WAITMASK  (STRAT_CLOSE | STRAT_WAITFORU)
  129.  #define STRAT_HEAL      0x08000000L
  130.  #define STRAT_GROUND    0x04000000L
  131.  #define STRAT_MONSTR    0x02000000L
  132.  #define STRAT_PLAYER    0x01000000L
  133.  #define STRAT_NONE      0x00000000L
  134.  #define STRAT_STRATMASK 0x0f000000L
  135.  #define STRAT_XMASK     0x00ff0000L
  136.  #define STRAT_YMASK     0x0000ff00L
  137.  #define STRAT_GOAL      0x000000ffL
  138.  #define STRAT_GOALX(s) ((xchar) ((s & STRAT_XMASK) >> 16))
  139.  #define STRAT_GOALY(s) ((xchar) ((s & STRAT_YMASK) >> 8))
  140.  
  141.      long mtrapseen;        /* bitmap of traps we've been trapped in */
  142.      long mlstmv;           /* for catching up with lost time */
  143.      long mspare1;
  144.      struct obj *minvent;   /* mon's inventory */
  145.  
  146.      struct obj *mw;        /* mon's weapon */
  147.      long misc_worn_check;  /* mon's wornmask */
  148.      xchar weapon_check;    /* flag for whether to try switching weapons */
  149.  
  150.      int meating;           /* monster is eating timeout */
  151.      struct mextra *mextra; /* point to mextra struct */
  152.  };
  153.  
  154.  #define newmonst() (struct monst *) alloc(sizeof (struct monst))
  155.  
  156.  /* these are in mspeed */
  157.  #define MSLOW 1 /* slowed monster */
  158.  #define MFAST 2 /* speeded monster */
  159.  
  160.  #define MON_WEP(mon) ((mon)->mw)
  161.  #define MON_NOWEP(mon) ((mon)->mw = (struct obj *) 0)
  162.  
  163.  #define DEADMONSTER(mon) ((mon)->mhp < 1)
  164.  #define is_starting_pet(mon) ((mon)->m_id == context.startingpet_mid)
  165.  #define is_vampshifter(mon)                                      \
  166.      ((mon)->cham == PM_VAMPIRE || (mon)->cham == PM_VAMPIRE_LORD \
  167.       || (mon)->cham == PM_VLAD_THE_IMPALER)
  168.  
  169.  /* mimic appearances that block vision/light */
  170.  #define is_lightblocker_mappear(mon)                       \
  171.      (is_obj_mappear(mon, BOULDER)                          \
  172.       || ((mon)->m_ap_type == M_AP_FURNITURE                \
  173.           && ((mon)->mappearance == S_hcdoor                \
  174.               || (mon)->mappearance == S_vcdoor             \
  175.               || (mon)->mappearance < S_ndoor /* = walls */ \
  176.               || (mon)->mappearance == S_tree)))
  177.  #define is_door_mappear(mon) ((mon)->m_ap_type == M_AP_FURNITURE \
  178.                                && ((mon)->mappearance == S_hcdoor \
  179.                                    || (mon)->mappearance == S_vcdoor))
  180.  #define is_obj_mappear(mon,otyp) ((mon)->m_ap_type == M_AP_OBJECT \
  181.                                    && (mon)->mappearance == (otyp))
  182.  
  183.  #endif /* MONST_H */