1 /* NetHack 3.6 monst.h $NHDT-Date: 1550524559 2019/02/18 21:15:59 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.28 $ */
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. */
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
26 NEED_RANGED_WEAPON = 2,
33 /* The following flags are used for the second argument to display_minventory
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.
41 #define MINV_PICKMASK 0x03 /* 1|2 */
42 #define MINV_NOLET 0x04
45 /* monster appearance types */
47 M_AP_NOTHING = 0, /* mappearance unused--monster appears as itself */
48 M_AP_FURNITURE = 1, /* stairs, a door, an altar, etc. */
49 M_AP_OBJECT = 2, /* an object */
50 M_AP_MONSTER = 3 /* a monster; mostly used for cloned Wizard */
53 #define M_AP_TYPMASK 0x7
54 #define M_AP_F_DKNOWN 0x8
55 #define U_AP_TYPE (youmonst.m_ap_type & M_AP_TYPMASK)
56 #define U_AP_FLAG (youmonst.m_ap_type & ~M_AP_TYPMASK)
57 #define M_AP_TYPE(m) ((m)->m_ap_type & M_AP_TYPMASK)
58 #define M_AP_FLAG(m) ((m)->m_ap_type & ~M_AP_TYPMASK)
62 struct permonst *data;
64 short mnum; /* permanent monster index number */
65 short cham; /* if shapeshifter, orig mons[] idx goes here */
66 short movement; /* movement points (derived from permonst definition
68 uchar m_lev; /* adjusted difficulty level of monster */
69 aligntyp malign; /* alignment of this monster, relative to the
70 player (positive = good to kill) */
72 xchar mux, muy; /* where the monster thinks you are */
74 coord mtrack[MTSZ]; /* monster track */
76 unsigned mappearance; /* for undetected mimics and the wiz */
77 uchar m_ap_type; /* what mappearance is describing, m_ap_types */
79 schar mtame; /* level of tameness, implies peaceful */
80 unsigned short mextrinsics; /* low 8 correspond to mresists */
81 int mspec_used; /* monster's special ability attack timeout */
83 Bitfield(female, 1); /* is female */
84 Bitfield(minvis, 1); /* currently invisible */
85 Bitfield(invis_blkd, 1); /* invisibility blocked */
86 Bitfield(perminvis, 1); /* intrinsic minvis value */
87 Bitfield(mcan, 1); /* has been cancelled */
88 Bitfield(mburied, 1); /* has been buried */
89 Bitfield(mundetected, 1); /* not seen in present hiding place;
90 * implies one of M1_CONCEAL or M1_HIDE,
91 * but not mimic (that is, snake, spider,
92 * trapper, piercer, eel)
94 Bitfield(mcansee, 1); /* cansee 1, temp.blinded 0, blind 0 */
96 Bitfield(mspeed, 2); /* current speed */
97 Bitfield(permspeed, 2); /* intrinsic mspeed value */
98 Bitfield(mrevived, 1); /* has been revived from the dead */
99 Bitfield(mcloned, 1); /* has been cloned from another */
100 Bitfield(mavenge, 1); /* did something to deserve retaliation */
101 Bitfield(mflee, 1); /* fleeing */
103 Bitfield(mfleetim, 7); /* timeout for mflee */
104 Bitfield(msleeping, 1); /* asleep until woken */
106 Bitfield(mblinded, 7); /* cansee 0, temp.blinded n, blind 0 */
107 Bitfield(mstun, 1); /* stunned (off balance) */
109 Bitfield(mfrozen, 7);
110 Bitfield(mcanmove, 1); /* paralysis, similar to mblinded */
112 Bitfield(mconf, 1); /* confused */
113 Bitfield(mpeaceful, 1); /* does not attack unprovoked */
114 Bitfield(mtrapped, 1); /* trapped in a pit, web or bear trap */
115 Bitfield(mleashed, 1); /* monster is on a leash */
116 Bitfield(isshk, 1); /* is shopkeeper */
117 Bitfield(isminion, 1); /* is a minion */
118 Bitfield(isgd, 1); /* is guard */
119 Bitfield(ispriest, 1); /* is an aligned priest or high priest */
121 Bitfield(iswiz, 1); /* is the Wizard of Yendor */
122 Bitfield(wormno, 5); /* at most 31 worms on any level */
125 #define MAX_NUM_WORMS 32 /* should be 2^(wormno bitfield size) */
127 unsigned long mstrategy; /* for monsters with mflag3: current strategy */
129 #define STRAT_APPEARMSG 0x80000000UL
131 #define STRAT_APPEARMSG 0x80000000L
133 #define STRAT_ARRIVE 0x40000000L /* just arrived on current level */
134 #define STRAT_WAITFORU 0x20000000L
135 #define STRAT_CLOSE 0x10000000L
136 #define STRAT_WAITMASK (STRAT_CLOSE | STRAT_WAITFORU)
137 #define STRAT_HEAL 0x08000000L
138 #define STRAT_GROUND 0x04000000L
139 #define STRAT_MONSTR 0x02000000L
140 #define STRAT_PLAYER 0x01000000L
141 #define STRAT_NONE 0x00000000L
142 #define STRAT_STRATMASK 0x0f000000L
143 #define STRAT_XMASK 0x00ff0000L
144 #define STRAT_YMASK 0x0000ff00L
145 #define STRAT_GOAL 0x000000ffL
146 #define STRAT_GOALX(s) ((xchar) ((s & STRAT_XMASK) >> 16))
147 #define STRAT_GOALY(s) ((xchar) ((s & STRAT_YMASK) >> 8))
149 long mtrapseen; /* bitmap of traps we've been trapped in */
150 long mlstmv; /* for catching up with lost time */
152 struct obj *minvent; /* mon's inventory */
154 struct obj *mw; /* mon's weapon */
155 long misc_worn_check; /* mon's wornmask */
156 xchar weapon_check; /* flag for whether to try switching weapons */
158 int meating; /* monster is eating timeout */
159 struct mextra *mextra; /* point to mextra struct */
162 #define newmonst() (struct monst *) alloc(sizeof (struct monst))
164 /* these are in mspeed */
165 #define MSLOW 1 /* slowed monster */
166 #define MFAST 2 /* speeded monster */
168 #define MON_WEP(mon) ((mon)->mw)
169 #define MON_NOWEP(mon) ((mon)->mw = (struct obj *) 0)
171 #define DEADMONSTER(mon) ((mon)->mhp < 1)
172 #define is_starting_pet(mon) ((mon)->m_id == context.startingpet_mid)
173 #define is_vampshifter(mon) \
174 ((mon)->cham == PM_VAMPIRE || (mon)->cham == PM_VAMPIRE_LORD \
175 || (mon)->cham == PM_VLAD_THE_IMPALER)
177 /* mimic appearances that block vision/light */
178 #define is_lightblocker_mappear(mon) \
179 (is_obj_mappear(mon, BOULDER) \
180 || (M_AP_TYPE(mon) == M_AP_FURNITURE \
181 && ((mon)->mappearance == S_hcdoor \
182 || (mon)->mappearance == S_vcdoor \
183 || (mon)->mappearance < S_ndoor /* = walls */ \
184 || (mon)->mappearance == S_tree)))
185 #define is_door_mappear(mon) (M_AP_TYPE(mon) == M_AP_FURNITURE \
186 && ((mon)->mappearance == S_hcdoor \
187 || (mon)->mappearance == S_vcdoor))
188 #define is_obj_mappear(mon,otyp) (M_AP_TYPE(mon) == M_AP_OBJECT \
189 && (mon)->mappearance == (otyp))