1 /* NetHack 3.6 monst.h $NHDT-Date: 1561053561 2019/06/20 17:59:21 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.33 $ */
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 MON_FLOOR 0x00
54 #define MON_OFFMAP 0x01
55 #define MON_DETACH 0x02
56 #define MON_MIGRATING 0x04
57 #define MON_LIMBO 0x08
58 #define MON_BUBBLEMOVE 0x10
59 #define MON_ENDGAME_FREE 0x20
60 #define MON_ENDGAME_MIGR 0x40
61 #define MON_OBLITERATE 0x80
62 #define MSTATE_MASK 0xFF
64 #define M_AP_TYPMASK 0x7
65 #define M_AP_F_DKNOWN 0x8
66 #define U_AP_TYPE (youmonst.m_ap_type & M_AP_TYPMASK)
67 #define U_AP_FLAG (youmonst.m_ap_type & ~M_AP_TYPMASK)
68 #define M_AP_TYPE(m) ((m)->m_ap_type & M_AP_TYPMASK)
69 #define M_AP_FLAG(m) ((m)->m_ap_type & ~M_AP_TYPMASK)
73 struct permonst *data;
75 short mnum; /* permanent monster index number */
76 short cham; /* if shapeshifter, orig mons[] idx goes here */
77 short movement; /* movement points (derived from permonst definition
79 uchar m_lev; /* adjusted difficulty level of monster */
80 aligntyp malign; /* alignment of this monster, relative to the
81 player (positive = good to kill) */
83 xchar mux, muy; /* where the monster thinks you are */
85 coord mtrack[MTSZ]; /* monster track */
87 unsigned mappearance; /* for undetected mimics and the wiz */
88 uchar m_ap_type; /* what mappearance is describing, m_ap_types */
90 schar mtame; /* level of tameness, implies peaceful */
91 unsigned short mextrinsics; /* low 8 correspond to mresists */
92 int mspec_used; /* monster's special ability attack timeout */
94 Bitfield(female, 1); /* is female */
95 Bitfield(minvis, 1); /* currently invisible */
96 Bitfield(invis_blkd, 1); /* invisibility blocked */
97 Bitfield(perminvis, 1); /* intrinsic minvis value */
98 Bitfield(mcan, 1); /* has been cancelled */
99 Bitfield(mburied, 1); /* has been buried */
100 #define mtemplit mburied /* since buried isn't implemented, use bit for
101 * monsters shown by transient light source;
102 * only valid during bhit() execution */
103 Bitfield(mundetected, 1); /* not seen in present hiding place;
104 * implies one of M1_CONCEAL or M1_HIDE,
105 * but not mimic (that is, snake, spider,
106 * trapper, piercer, eel) */
107 Bitfield(mcansee, 1); /* cansee 1, temp.blinded 0, blind 0 */
109 Bitfield(mspeed, 2); /* current speed */
110 Bitfield(permspeed, 2); /* intrinsic mspeed value */
111 Bitfield(mrevived, 1); /* has been revived from the dead */
112 Bitfield(mcloned, 1); /* has been cloned from another */
113 Bitfield(mavenge, 1); /* did something to deserve retaliation */
114 Bitfield(mflee, 1); /* fleeing */
116 Bitfield(mfleetim, 7); /* timeout for mflee */
117 Bitfield(msleeping, 1); /* asleep until woken */
119 Bitfield(mblinded, 7); /* cansee 0, temp.blinded n, blind 0 */
120 Bitfield(mstun, 1); /* stunned (off balance) */
122 Bitfield(mfrozen, 7);
123 Bitfield(mcanmove, 1); /* paralysis, similar to mblinded */
125 Bitfield(mconf, 1); /* confused */
126 Bitfield(mpeaceful, 1); /* does not attack unprovoked */
127 Bitfield(mtrapped, 1); /* trapped in a pit, web or bear trap */
128 Bitfield(mleashed, 1); /* monster is on a leash */
129 Bitfield(isshk, 1); /* is shopkeeper */
130 Bitfield(isminion, 1); /* is a minion */
131 Bitfield(isgd, 1); /* is guard */
132 Bitfield(ispriest, 1); /* is an aligned priest or high priest */
134 Bitfield(iswiz, 1); /* is the Wizard of Yendor */
135 Bitfield(wormno, 5); /* at most 31 worms on any level */
138 #define MAX_NUM_WORMS 32 /* should be 2^(wormno bitfield size) */
140 unsigned long mstrategy; /* for monsters with mflag3: current strategy */
142 #define STRAT_APPEARMSG 0x80000000UL
144 #define STRAT_APPEARMSG 0x80000000L
146 #define STRAT_ARRIVE 0x40000000L /* just arrived on current level */
147 #define STRAT_WAITFORU 0x20000000L
148 #define STRAT_CLOSE 0x10000000L
149 #define STRAT_WAITMASK (STRAT_CLOSE | STRAT_WAITFORU)
150 #define STRAT_HEAL 0x08000000L
151 #define STRAT_GROUND 0x04000000L
152 #define STRAT_MONSTR 0x02000000L
153 #define STRAT_PLAYER 0x01000000L
154 #define STRAT_NONE 0x00000000L
155 #define STRAT_STRATMASK 0x0f000000L
156 #define STRAT_XMASK 0x00ff0000L
157 #define STRAT_YMASK 0x0000ff00L
158 #define STRAT_GOAL 0x000000ffL
159 #define STRAT_GOALX(s) ((xchar) ((s & STRAT_XMASK) >> 16))
160 #define STRAT_GOALY(s) ((xchar) ((s & STRAT_YMASK) >> 8))
162 long mtrapseen; /* bitmap of traps we've been trapped in */
163 long mlstmv; /* for catching up with lost time */
165 #define mstate mspare1 /* only for debug exam right now, not code flow */
166 struct obj *minvent; /* mon's inventory */
167 struct obj *mw; /* mon's weapon */
168 long misc_worn_check; /* mon's wornmask */
169 xchar weapon_check; /* flag for whether to try switching weapons */
171 int meating; /* monster is eating timeout */
172 struct mextra *mextra; /* point to mextra struct */
175 #define newmonst() (struct monst *) alloc(sizeof (struct monst))
177 /* these are in mspeed */
178 #define MSLOW 1 /* slowed monster */
179 #define MFAST 2 /* speeded monster */
181 #define MON_WEP(mon) ((mon)->mw)
182 #define MON_NOWEP(mon) ((mon)->mw = (struct obj *) 0)
184 #define DEADMONSTER(mon) ((mon)->mhp < 1)
185 #define is_starting_pet(mon) ((mon)->m_id == context.startingpet_mid)
186 #define is_vampshifter(mon) \
187 ((mon)->cham == PM_VAMPIRE || (mon)->cham == PM_VAMPIRE_LORD \
188 || (mon)->cham == PM_VLAD_THE_IMPALER)
190 /* mimic appearances that block vision/light */
191 #define is_lightblocker_mappear(mon) \
192 (is_obj_mappear(mon, BOULDER) \
193 || (M_AP_TYPE(mon) == M_AP_FURNITURE \
194 && ((mon)->mappearance == S_hcdoor \
195 || (mon)->mappearance == S_vcdoor \
196 || (mon)->mappearance < S_ndoor /* = walls */ \
197 || (mon)->mappearance == S_tree)))
198 #define is_door_mappear(mon) (M_AP_TYPE(mon) == M_AP_FURNITURE \
199 && ((mon)->mappearance == S_hcdoor \
200 || (mon)->mappearance == S_vcdoor))
201 #define is_obj_mappear(mon,otyp) (M_AP_TYPE(mon) == M_AP_OBJECT \
202 && (mon)->mappearance == (otyp))