1 /* NetHack 3.6 monst.h $NHDT-Date: 1432512777 2015/05/25 00:12:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.20 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
8 /* The weapon_check flag is used two ways:
9 * 1) When calling mon_wield_item, is 2-6 depending on what is desired.
10 * 2) Between calls to mon_wield_item, is 0 or 1 depending on whether or not
11 * the weapon is known by the monster to be cursed (so it shouldn't bother
12 * trying for another weapon).
13 * I originally planned to also use 0 if the monster already had its best
14 * weapon, to avoid the overhead of a call to mon_wield_item, but it turns out
15 * that there are enough situations which might make a monster change its
16 * weapon that this is impractical. --KAA
18 #define NO_WEAPON_WANTED 0
20 #define NEED_RANGED_WEAPON 2
21 #define NEED_HTH_WEAPON 3
22 #define NEED_PICK_AXE 4
24 #define NEED_PICK_OR_AXE 6
26 /* The following flags are used for the second argument to display_minventory
29 * MINV_NOLET If set, don't display inventory letters on monster's inventory.
30 * MINV_ALL If set, display all items in monster's inventory, otherwise
31 * just display wielded weapons and worn items.
33 #define MINV_NOLET 0x01
42 struct permonst *data;
44 short mnum; /* permanent monster index number */
45 short cham; /* if shapeshifter, orig mons[] idx goes here */
46 short movement; /* movement points (derived from permonst definition and
48 uchar m_lev; /* adjusted difficulty level of monster */
49 aligntyp malign; /* alignment of this monster, relative to the
50 player (positive = good to kill) */
52 xchar mux, muy; /* where the monster thinks you are */
54 coord mtrack[MTSZ]; /* monster track */
56 unsigned mappearance; /* for undetected mimics and the wiz */
57 uchar m_ap_type; /* what mappearance is describing: */
58 #define M_AP_NOTHING \
59 0 /* mappearance is unused -- monster appears \
61 #define M_AP_FURNITURE 1 /* stairs, a door, an altar, etc. */
62 #define M_AP_OBJECT 2 /* an object */
63 #define M_AP_MONSTER 3 /* a monster */
65 schar mtame; /* level of tameness, implies peaceful */
66 unsigned short mintrinsics; /* low 8 correspond to mresists */
67 int mspec_used; /* monster's special ability attack timeout */
69 Bitfield(female, 1); /* is female */
70 Bitfield(minvis, 1); /* currently invisible */
71 Bitfield(invis_blkd, 1); /* invisibility blocked */
72 Bitfield(perminvis, 1); /* intrinsic minvis value */
73 Bitfield(mcan, 1); /* has been cancelled */
74 Bitfield(mburied, 1); /* has been buried */
75 Bitfield(mundetected, 1); /* not seen in present hiding place */
76 /* implies one of M1_CONCEAL or M1_HIDE,
77 * but not mimic (that is, snake, spider,
78 * trapper, piercer, eel)
80 Bitfield(mcansee, 1); /* cansee 1, temp.blinded 0, blind 0 */
82 Bitfield(mspeed, 2); /* current speed */
83 Bitfield(permspeed, 2); /* intrinsic mspeed value */
84 Bitfield(mrevived, 1); /* has been revived from the dead */
85 Bitfield(mcloned, 1); /* has been cloned from another */
86 Bitfield(mavenge, 1); /* did something to deserve retaliation */
87 Bitfield(mflee, 1); /* fleeing */
89 Bitfield(mfleetim, 7); /* timeout for mflee */
90 Bitfield(msleeping, 1); /* asleep until woken */
92 Bitfield(mblinded, 7); /* cansee 0, temp.blinded n, blind 0 */
93 Bitfield(mstun, 1); /* stunned (off balance) */
96 Bitfield(mcanmove, 1); /* paralysis, similar to mblinded */
98 Bitfield(mconf, 1); /* confused */
99 Bitfield(mpeaceful, 1); /* does not attack unprovoked */
100 Bitfield(mtrapped, 1); /* trapped in a pit, web or bear trap */
101 Bitfield(mleashed, 1); /* monster is on a leash */
102 Bitfield(isshk, 1); /* is shopkeeper */
103 Bitfield(isminion, 1); /* is a minion */
104 Bitfield(isgd, 1); /* is guard */
105 Bitfield(ispriest, 1); /* is a priest */
107 Bitfield(iswiz, 1); /* is the Wizard of Yendor */
108 Bitfield(wormno, 5); /* at most 31 worms on any level */
111 #define MAX_NUM_WORMS 32 /* should be 2^(wormno bitfield size) */
113 unsigned long mstrategy; /* for monsters with mflag3: current strategy */
115 #define STRAT_APPEARMSG 0x80000000UL
117 #define STRAT_APPEARMSG 0x80000000L
119 #define STRAT_ARRIVE 0x40000000L /* just arrived on current level */
120 #define STRAT_WAITFORU 0x20000000L
121 #define STRAT_CLOSE 0x10000000L
122 #define STRAT_WAITMASK (STRAT_CLOSE | STRAT_WAITFORU)
123 #define STRAT_HEAL 0x08000000L
124 #define STRAT_GROUND 0x04000000L
125 #define STRAT_MONSTR 0x02000000L
126 #define STRAT_PLAYER 0x01000000L
127 #define STRAT_NONE 0x00000000L
128 #define STRAT_STRATMASK 0x0f000000L
129 #define STRAT_XMASK 0x00ff0000L
130 #define STRAT_YMASK 0x0000ff00L
131 #define STRAT_GOAL 0x000000ffL
132 #define STRAT_GOALX(s) ((xchar)((s & STRAT_XMASK) >> 16))
133 #define STRAT_GOALY(s) ((xchar)((s & STRAT_YMASK) >> 8))
135 long mtrapseen; /* bitmap of traps we've been trapped in */
136 long mlstmv; /* for catching up with lost time */
141 long misc_worn_check;
144 int meating; /* monster is eating timeout */
145 struct mextra *mextra; /* point to mextra struct */
148 #define newmonst() (struct monst *) alloc(sizeof(struct monst))
150 /* these are in mspeed */
151 #define MSLOW 1 /* slow monster */
152 #define MFAST 2 /* speeded monster */
154 #define MON_WEP(mon) ((mon)->mw)
155 #define MON_NOWEP(mon) ((mon)->mw = (struct obj *) 0)
157 #define DEADMONSTER(mon) ((mon)->mhp < 1)
158 #define is_starting_pet(mon) ((mon)->m_id == context.startingpet_mid)
159 #define is_vampshifter(mon) \
160 ((mon)->cham == PM_VAMPIRE || (mon)->cham == PM_VAMPIRE_LORD \
161 || (mon)->cham == PM_VLAD_THE_IMPALER)
162 #define is_door_mappear(mon) ((mon)->m_ap_type == M_AP_FURNITURE \
163 && ((mon)->mappearance == S_hcdoor || (mon)->mappearance == S_vcdoor))
164 #define is_obj_mappear(mon,otyp) ((mon)->m_ap_type == M_AP_OBJECT \
165 && (mon)->mappearance == (otyp))