OSDN Git Service

force nhdefkey.dll
[jnethack/source.git] / include / monst.h
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. */
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         = 1,
26     NEED_RANGED_WEAPON  = 2,
27     NEED_HTH_WEAPON     = 3,
28     NEED_PICK_AXE       = 4,
29     NEED_AXE            = 5,
30     NEED_PICK_OR_AXE    = 6
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 /* monster appearance types */
46 enum m_ap_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 */
51 };
52
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)
59
60 struct monst {
61     struct monst *nmon;
62     struct permonst *data;
63     unsigned m_id;
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
67                              and added effects */
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) */
71     xchar mx, my;
72     xchar mux, muy;       /* where the monster thinks you are */
73 #define MTSZ 4
74     coord mtrack[MTSZ];   /* monster track */
75     int mhp, mhpmax;
76     unsigned mappearance; /* for undetected mimics and the wiz */
77     uchar m_ap_type;      /* what mappearance is describing, m_ap_types */
78
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 */
82
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)
93                                */
94     Bitfield(mcansee, 1);   /* cansee 1, temp.blinded 0, blind 0 */
95
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 */
102
103     Bitfield(mfleetim, 7);  /* timeout for mflee */
104     Bitfield(msleeping, 1); /* asleep until woken */
105
106     Bitfield(mblinded, 7);  /* cansee 0, temp.blinded n, blind 0 */
107     Bitfield(mstun, 1);     /* stunned (off balance) */
108
109     Bitfield(mfrozen, 7);
110     Bitfield(mcanmove, 1);  /* paralysis, similar to mblinded */
111
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 */
120
121     Bitfield(iswiz, 1);     /* is the Wizard of Yendor */
122     Bitfield(wormno, 5);    /* at most 31 worms on any level */
123     /* 2 free bits */
124
125 #define MAX_NUM_WORMS 32    /* should be 2^(wormno bitfield size) */
126
127     unsigned long mstrategy; /* for monsters with mflag3: current strategy */
128 #ifdef NHSTDC
129 #define STRAT_APPEARMSG 0x80000000UL
130 #else
131 #define STRAT_APPEARMSG 0x80000000L
132 #endif
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))
148
149     long mtrapseen;        /* bitmap of traps we've been trapped in */
150     long mlstmv;           /* for catching up with lost time */
151     long mspare1;
152     struct obj *minvent;   /* mon's inventory */
153
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 */
157
158     int meating;           /* monster is eating timeout */
159     struct mextra *mextra; /* point to mextra struct */
160 };
161
162 #define newmonst() (struct monst *) alloc(sizeof (struct monst))
163
164 /* these are in mspeed */
165 #define MSLOW 1 /* slowed monster */
166 #define MFAST 2 /* speeded monster */
167
168 #define MON_WEP(mon) ((mon)->mw)
169 #define MON_NOWEP(mon) ((mon)->mw = (struct obj *) 0)
170
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)
176
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))
190
191 #endif /* MONST_H */