dumplog's saved_plines[]
[aNetHack.git] / include / monst.h
blobd918897de7f95c1cccfe62b8b432ee0f794342b5
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 /* NetHack may be freely redistributed. See license for details. */
5 #ifndef MONST_H
6 #define MONST_H
8 #ifndef MEXTRA_H
9 #include "mextra.h"
10 #endif
12 /* The weapon_check flag is used two ways:
13 * 1) When calling mon_wield_item, is 2-6 depending on what is desired.
14 * 2) Between calls to mon_wield_item, is 0 or 1 depending on whether or not
15 * the weapon is known by the monster to be cursed (so it shouldn't bother
16 * trying for another weapon).
17 * I originally planned to also use 0 if the monster already had its best
18 * weapon, to avoid the overhead of a call to mon_wield_item, but it turns out
19 * that there are enough situations which might make a monster change its
20 * weapon that this is impractical. --KAA
22 #define NO_WEAPON_WANTED 0
23 #define NEED_WEAPON 1
24 #define NEED_RANGED_WEAPON 2
25 #define NEED_HTH_WEAPON 3
26 #define NEED_PICK_AXE 4
27 #define NEED_AXE 5
28 #define NEED_PICK_OR_AXE 6
30 /* The following flags are used for the second argument to display_minventory
31 * in invent.c:
33 * PICK_NONE, PICK_ONE, PICK_ANY (wintype.h) 0, 1, 2
34 * MINV_NOLET If set, don't display inventory letters on monster's inventory.
35 * MINV_ALL If set, display all items in monster's inventory, otherwise
36 * just display wielded weapons and worn items.
38 #define MINV_PICKMASK 0x03 /* 1|2 */
39 #define MINV_NOLET 0x04
40 #define MINV_ALL 0x08
42 struct monst {
43 struct monst *nmon;
44 struct permonst *data;
45 unsigned m_id;
46 short mnum; /* permanent monster index number */
47 short cham; /* if shapeshifter, orig mons[] idx goes here */
48 short movement; /* movement points (derived from permonst definition
49 and added effects */
50 uchar m_lev; /* adjusted difficulty level of monster */
51 aligntyp malign; /* alignment of this monster, relative to the
52 player (positive = good to kill) */
53 xchar mx, my;
54 xchar mux, muy; /* where the monster thinks you are */
55 #define MTSZ 4
56 coord mtrack[MTSZ]; /* monster track */
57 int mhp, mhpmax;
58 unsigned mappearance; /* for undetected mimics and the wiz */
59 uchar m_ap_type; /* what mappearance is describing: */
60 #define M_AP_NOTHING 0 /* mappearance unused--monster appears as itself */
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) */
95 Bitfield(mfrozen, 7);
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 an aligned priest or high priest */
107 Bitfield(iswiz, 1); /* is the Wizard of Yendor */
108 Bitfield(wormno, 5); /* at most 31 worms on any level */
109 /* 2 free bits */
111 #define MAX_NUM_WORMS 32 /* should be 2^(wormno bitfield size) */
113 unsigned long mstrategy; /* for monsters with mflag3: current strategy */
114 #ifdef NHSTDC
115 #define STRAT_APPEARMSG 0x80000000UL
116 #else
117 #define STRAT_APPEARMSG 0x80000000L
118 #endif
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 */
137 long mspare1;
138 struct obj *minvent; /* mon's inventory */
140 struct obj *mw; /* mon's weapon */
141 long misc_worn_check; /* mon's wornmask */
142 xchar weapon_check; /* flag for whether to try switching weapons */
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 /* slowed 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)
163 /* mimic appearances that block vision/light */
164 #define is_lightblocker_mappear(mon) \
165 (is_obj_mappear(mon, BOULDER) \
166 || ((mon)->m_ap_type == M_AP_FURNITURE \
167 && ((mon)->mappearance == S_hcdoor \
168 || (mon)->mappearance == S_vcdoor \
169 || (mon)->mappearance < S_ndoor /* = walls */ \
170 || (mon)->mappearance == S_tree)))
171 #define is_door_mappear(mon) ((mon)->m_ap_type == M_AP_FURNITURE \
172 && ((mon)->mappearance == S_hcdoor \
173 || (mon)->mappearance == S_vcdoor))
174 #define is_obj_mappear(mon,otyp) ((mon)->m_ap_type == M_AP_OBJECT \
175 && (mon)->mappearance == (otyp))
177 #endif /* MONST_H */