1 /* SCCS Id: @(#)monst.h 3.4 1999/01/04 */ 2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3 /* NetHack may be freely redistributed. See license for details. */ 4 5 #ifndef MONST_H 6 #define MONST_H 7 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 17 */ 18 # define NO_WEAPON_WANTED 0 19 # define NEED_WEAPON 1 20 # define NEED_RANGED_WEAPON 2 21 # define NEED_HTH_WEAPON 3 22 # define NEED_PICK_AXE 4 23 # define NEED_AXE 5 24 # define NEED_PICK_OR_AXE 6 25 26 /* The following flags are used for the second argument to display_minventory 27 * in invent.c: 28 * 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. 32 */ 33 #define MINV_NOLET 0x01 34 #define MINV_ALL 0x02 35 36 #ifndef ALIGN_H 37 #include "align.h" 38 #endif 39 40 struct monst { 41 struct monst *nmon; 42 struct permonst *data; 43 size_t m_id; 44 short mnum; /* permanent monster index number */ 45 short movement; /* movement points (derived from permonst definition and added effects */ 46 uchar m_lev; /* adjusted difficulty level of monster */ 47 aligntyp malign; /* alignment of this monster, relative to the 48 player (positive = good to kill) */ 49 xchar mx, my; 50 xchar mux, muy; /* where the monster thinks you are */ 51 #define MTSZ 4 52 coord mtrack[MTSZ]; /* monster track */ 53 int mhp, mhpmax; 54 unsigned mappearance; /* for undetected mimics and the wiz */ 55 uchar m_ap_type; /* what mappearance is describing: */ 56 #define M_AP_NOTHING 0 /* mappearance is unused -- monster appears 57 as itself */ 58 #define M_AP_FURNITURE 1 /* stairs, a door, an altar, etc. */ 59 #define M_AP_OBJECT 2 /* an object */ 60 #define M_AP_MONSTER 3 /* a monster */ 61 62 schar mtame; /* level of tameness, implies peaceful */ 63 unsigned short mintrinsics; /* low 8 correspond to mresists */ 64 int mspec_used; /* monster's special ability attack timeout */ 65 66 int mtrapped; /* trapped in a pit, web or bear trap */ 67 int mfeetfrozen; /* monster's feet are frozen so it can't 68 move (0 = not frozen) */ 69 70 Bitfield(female,1); /* is female */ 71 Bitfield(minvis,1); /* currently invisible */ 72 Bitfield(invis_blkd,1); /* invisibility blocked */ 73 Bitfield(perminvis,1); /* intrinsic minvis value */ 74 Bitfield(cham,3); /* shape-changer */ 75 /* note: lychanthropes are handled elsewhere */ 76 #define CHAM_ORDINARY 0 /* not a shapechanger */ 77 #define CHAM_CHAMELEON 1 /* animal */ 78 #define CHAM_DOPPELGANGER 2 /* demi-human */ 79 #define CHAM_SANDESTIN 3 /* demon */ 80 #define CHAM_MAX_INDX CHAM_SANDESTIN 81 Bitfield(mundetected,1); /* not seen in present hiding place */ 82 /* implies one of M1_CONCEAL or M1_HIDE, 83 * but not mimic (that is, snake, spider, 84 * trapper, piercer, eel) 85 */ 86 87 Bitfield(mcan,1); /* has been cancelled */ 88 Bitfield(mburied,1); /* has been buried */ 89 Bitfield(mspeed,2); /* current speed */ 90 Bitfield(permspeed,2); /* intrinsic mspeed value */ 91 Bitfield(mrevived,1); /* has been revived from the dead */ 92 Bitfield(mavenge,1); /* did something to deserve retaliation */ 93 94 Bitfield(mflee,1); /* fleeing */ 95 Bitfield(mfleetim,7); /* timeout for mflee */ 96 97 Bitfield(mcansee,1); /* cansee 1, temp.blinded 0, blind 0 */ 98 Bitfield(mblinded,7); /* cansee 0, temp.blinded n, blind 0 */ 99 100 Bitfield(mcanmove,1); /* paralysis, similar to mblinded */ 101 Bitfield(mfrozen,7); 102 103 Bitfield(msleeping,1); /* asleep until woken */ 104 Bitfield(mstun,1); /* stunned (off balance) */ 105 Bitfield(mconf,1); /* confused */ 106 Bitfield(mpeaceful,1); /* does not attack unprovoked */ 107 Bitfield(mleashed,1); /* monster is on a leash */ 108 Bitfield(isshk,1); /* is shopkeeper */ 109 Bitfield(isminion,1); /* is a minion */ 110 111 Bitfield(isgd,1); /* is guard */ 112 Bitfield(ispriest,1); /* is a priest */ 113 Bitfield(iswiz,1); /* is the Wizard of Yendor */ 114 Bitfield(wormno,5); /* at most 31 worms on any level */ 115 #define MAX_NUM_WORMS 32 /* should be 2^(wormno bitfield size) */ 116 117 long mstrategy; /* for monsters with mflag3: current strategy */ 118 #define STRAT_ARRIVE 0x40000000L /* just arrived on current level */ 119 #define STRAT_WAITFORU 0x20000000L 120 #define STRAT_CLOSE 0x10000000L 121 #define STRAT_WAITMASK 0x30000000L 122 #define STRAT_HEAL 0x08000000L 123 #define STRAT_GROUND 0x04000000L 124 #define STRAT_MONSTR 0x02000000L 125 #define STRAT_PLAYER 0x01000000L 126 #define STRAT_NONE 0x00000000L 127 #define STRAT_STRATMASK 0x0f000000L 128 #define STRAT_XMASK 0x00ff0000L 129 #define STRAT_YMASK 0x0000ff00L 130 #define STRAT_GOAL 0x000000ffL 131 #define STRAT_GOALX(s) ((xchar)((s & STRAT_XMASK) >> 16)) 132 #define STRAT_GOALY(s) ((xchar)((s & STRAT_YMASK) >> 8)) 133 134 long mtrapseen; /* bitmap of traps we've been trapped in */ 135 long mlstmv; /* for catching up with lost time */ 136 #ifndef GOLDOBJ 137 long mgold; 138 #endif 139 struct obj *minvent; 140 141 struct obj *mw; 142 long misc_worn_check; 143 xchar weapon_check; 144 145 long mgrlastattack; /* turn when a grouper last attacked. 146 at certain points, the attackers decide 147 to get back to attacking all at once. */ 148 149 150 #ifdef LIVELOG_BONES_KILLER 151 char former_rank[25]; /* for bones' ghost rank in the former life */ 152 #endif 153 154 uchar mnamelth; /* length of name (following mxlth) */ 155 short mxlth; /* length of following data */ 156 /* in order to prevent alignment problems mextra should 157 be (or follow) a long int */ 158 int meating; /* monster is eating timeout */ 159 long mextra[1]; /* monster dependent info */ 160 }; 161 162 /* 163 * Note that mextra[] may correspond to any of a number of structures, which 164 * are indicated by some of the other fields. 165 * isgd -> struct egd 166 * ispriest -> struct epri 167 * isshk -> struct eshk 168 * isminion -> struct emin 169 * (struct epri for roaming priests and angels, which is 170 * compatible with emin for polymorph purposes) 171 * mtame -> struct edog 172 * (struct epri for guardian angels, which do not eat 173 * or do other doggy things) 174 * Since at most one structure can be indicated in this manner, it is not 175 * possible to tame any creatures using the other structures (the only 176 * exception being the guardian angels which are tame on creation). 177 */ 178 179 #define newmonst(xl) (struct monst *)alloc((unsigned)(xl) + sizeof(struct monst)) 180 #define dealloc_monst(mon) free((genericptr_t)(mon)) 181 182 /* these are in mspeed */ 183 #define MSLOW 1 /* slow monster */ 184 #define MFAST 2 /* speeded monster */ 185 186 #define NAME(mtmp) (((char *)(mtmp)->mextra) + (mtmp)->mxlth) 187 188 #define MON_WEP(mon) ((mon)->mw) 189 #define MON_NOWEP(mon) ((mon)->mw = (struct obj *)0) 190 191 #define DEADMONSTER(mon) ((mon)->mhp < 1) 192 193 /* Returns true if monster is trapped in place but can still attack. 194 * (mon evaluated twice) */ 195 #define IS_TRAPPED(mon) ((mon)->mtrapped || (mon)->mfeetfrozen) 196 197 #endif /* MONST_H */ 198