00001 /* SCCS Id: @(#)monst.h 3.4 1999/01/04 */ 00002 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 00003 /* NetHack may be freely redistributed. See license for details. */ 00004 00005 #ifndef MONST_H 00006 #define MONST_H 00007 00008 /* The weapon_check flag is used two ways: 00009 * 1) When calling mon_wield_item, is 2-6 depending on what is desired. 00010 * 2) Between calls to mon_wield_item, is 0 or 1 depending on whether or not 00011 * the weapon is known by the monster to be cursed (so it shouldn't bother 00012 * trying for another weapon). 00013 * I originally planned to also use 0 if the monster already had its best 00014 * weapon, to avoid the overhead of a call to mon_wield_item, but it turns out 00015 * that there are enough situations which might make a monster change its 00016 * weapon that this is impractical. --KAA 00017 */ 00018 # define NO_WEAPON_WANTED 0 00019 # define NEED_WEAPON 1 00020 # define NEED_RANGED_WEAPON 2 00021 # define NEED_HTH_WEAPON 3 00022 # define NEED_PICK_AXE 4 00023 # define NEED_AXE 5 00024 # define NEED_PICK_OR_AXE 6 00025 00026 /* The following flags are used for the second argument to display_minventory 00027 * in invent.c: 00028 * 00029 * MINV_NOLET If set, don't display inventory letters on monster's inventory. 00030 * MINV_ALL If set, display all items in monster's inventory, otherwise 00031 * just display wielded weapons and worn items. 00032 */ 00033 #define MINV_NOLET 0x01 00034 #define MINV_ALL 0x02 00035 00036 #ifndef ALIGN_H 00037 #include "align.h" 00038 #endif 00039 00040 struct monst { 00041 struct monst *nmon; 00042 struct permonst *data; 00043 size_t m_id; 00044 short mnum; /* permanent monster index number */ 00045 short movement; /* movement points (derived from permonst definition and added effects */ 00046 uchar m_lev; /* adjusted difficulty level of monster */ 00047 aligntyp malign; /* alignment of this monster, relative to the 00048 player (positive = good to kill) */ 00049 xchar mx, my; 00050 xchar mux, muy; /* where the monster thinks you are */ 00051 #define MTSZ 4 00052 coord mtrack[MTSZ]; /* monster track */ 00053 int mhp, mhpmax; 00054 unsigned mappearance; /* for undetected mimics and the wiz */ 00055 uchar m_ap_type; /* what mappearance is describing: */ 00056 #define M_AP_NOTHING 0 /* mappearance is unused -- monster appears 00057 as itself */ 00058 #define M_AP_FURNITURE 1 /* stairs, a door, an altar, etc. */ 00059 #define M_AP_OBJECT 2 /* an object */ 00060 #define M_AP_MONSTER 3 /* a monster */ 00061 00062 schar mtame; /* level of tameness, implies peaceful */ 00063 unsigned short mintrinsics; /* low 8 correspond to mresists */ 00064 int mspec_used; /* monster's special ability attack timeout */ 00065 00066 Bitfield(female,1); /* is female */ 00067 Bitfield(minvis,1); /* currently invisible */ 00068 Bitfield(invis_blkd,1); /* invisibility blocked */ 00069 Bitfield(perminvis,1); /* intrinsic minvis value */ 00070 Bitfield(cham,3); /* shape-changer */ 00071 /* note: lychanthropes are handled elsewhere */ 00072 #define CHAM_ORDINARY 0 /* not a shapechanger */ 00073 #define CHAM_CHAMELEON 1 /* animal */ 00074 #define CHAM_DOPPELGANGER 2 /* demi-human */ 00075 #define CHAM_SANDESTIN 3 /* demon */ 00076 #define CHAM_MAX_INDX CHAM_SANDESTIN 00077 Bitfield(mundetected,1); /* not seen in present hiding place */ 00078 /* implies one of M1_CONCEAL or M1_HIDE, 00079 * but not mimic (that is, snake, spider, 00080 * trapper, piercer, eel) 00081 */ 00082 00083 Bitfield(mcan,1); /* has been cancelled */ 00084 Bitfield(mburied,1); /* has been buried */ 00085 Bitfield(mspeed,2); /* current speed */ 00086 Bitfield(permspeed,2); /* intrinsic mspeed value */ 00087 Bitfield(mrevived,1); /* has been revived from the dead */ 00088 Bitfield(mavenge,1); /* did something to deserve retaliation */ 00089 00090 Bitfield(mflee,1); /* fleeing */ 00091 Bitfield(mfleetim,7); /* timeout for mflee */ 00092 00093 Bitfield(mcansee,1); /* cansee 1, temp.blinded 0, blind 0 */ 00094 Bitfield(mblinded,7); /* cansee 0, temp.blinded n, blind 0 */ 00095 00096 Bitfield(mcanmove,1); /* paralysis, similar to mblinded */ 00097 Bitfield(mfrozen,7); 00098 00099 Bitfield(msleeping,1); /* asleep until woken */ 00100 Bitfield(mstun,1); /* stunned (off balance) */ 00101 Bitfield(mconf,1); /* confused */ 00102 Bitfield(mpeaceful,1); /* does not attack unprovoked */ 00103 Bitfield(mtrapped,1); /* trapped in a pit, web or bear trap */ 00104 Bitfield(mleashed,1); /* monster is on a leash */ 00105 Bitfield(isshk,1); /* is shopkeeper */ 00106 Bitfield(isminion,1); /* is a minion */ 00107 00108 Bitfield(isgd,1); /* is guard */ 00109 Bitfield(ispriest,1); /* is a priest */ 00110 Bitfield(iswiz,1); /* is the Wizard of Yendor */ 00111 Bitfield(wormno,5); /* at most 31 worms on any level */ 00112 #define MAX_NUM_WORMS 32 /* should be 2^(wormno bitfield size) */ 00113 00114 long mstrategy; /* for monsters with mflag3: current strategy */ 00115 #define STRAT_ARRIVE 0x40000000L /* just arrived on current level */ 00116 #define STRAT_WAITFORU 0x20000000L 00117 #define STRAT_CLOSE 0x10000000L 00118 #define STRAT_WAITMASK 0x30000000L 00119 #define STRAT_HEAL 0x08000000L 00120 #define STRAT_GROUND 0x04000000L 00121 #define STRAT_MONSTR 0x02000000L 00122 #define STRAT_PLAYER 0x01000000L 00123 #define STRAT_NONE 0x00000000L 00124 #define STRAT_STRATMASK 0x0f000000L 00125 #define STRAT_XMASK 0x00ff0000L 00126 #define STRAT_YMASK 0x0000ff00L 00127 #define STRAT_GOAL 0x000000ffL 00128 #define STRAT_GOALX(s) ((xchar)((s & STRAT_XMASK) >> 16)) 00129 #define STRAT_GOALY(s) ((xchar)((s & STRAT_YMASK) >> 8)) 00130 00131 long mtrapseen; /* bitmap of traps we've been trapped in */ 00132 long mlstmv; /* for catching up with lost time */ 00133 #ifndef GOLDOBJ 00134 long mgold; 00135 #endif 00136 struct obj *minvent; 00137 00138 struct obj *mw; 00139 long misc_worn_check; 00140 xchar weapon_check; 00141 00142 #ifdef LIVELOG_BONES_KILLER 00143 char former_rank[25]; /* for bones' ghost rank in the former life */ 00144 #endif 00145 00146 uchar mnamelth; /* length of name (following mxlth) */ 00147 short mxlth; /* length of following data */ 00148 /* in order to prevent alignment problems mextra should 00149 be (or follow) a long int */ 00150 int meating; /* monster is eating timeout */ 00151 long mextra[1]; /* monster dependent info */ 00152 }; 00153 00154 /* 00155 * Note that mextra[] may correspond to any of a number of structures, which 00156 * are indicated by some of the other fields. 00157 * isgd -> struct egd 00158 * ispriest -> struct epri 00159 * isshk -> struct eshk 00160 * isminion -> struct emin 00161 * (struct epri for roaming priests and angels, which is 00162 * compatible with emin for polymorph purposes) 00163 * mtame -> struct edog 00164 * (struct epri for guardian angels, which do not eat 00165 * or do other doggy things) 00166 * Since at most one structure can be indicated in this manner, it is not 00167 * possible to tame any creatures using the other structures (the only 00168 * exception being the guardian angels which are tame on creation). 00169 */ 00170 00171 #define newmonst(xl) (struct monst *)alloc((unsigned)(xl) + sizeof(struct monst)) 00172 #define dealloc_monst(mon) free((genericptr_t)(mon)) 00173 00174 /* these are in mspeed */ 00175 #define MSLOW 1 /* slow monster */ 00176 #define MFAST 2 /* speeded monster */ 00177 00178 #define NAME(mtmp) (((char *)(mtmp)->mextra) + (mtmp)->mxlth) 00179 00180 #define MON_WEP(mon) ((mon)->mw) 00181 #define MON_NOWEP(mon) ((mon)->mw = (struct obj *)0) 00182 00183 #define DEADMONSTER(mon) ((mon)->mhp < 1) 00184 00185 #endif /* MONST_H */