Source:NetHack 3.1.0/monst.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to monst.h from the source code of NetHack 3.1.0. To link to a particular line, write [[NetHack 3.1.0/monst.h#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1.    /*	SCCS Id: @(#)monst.h	3.1	92/10/18	*/
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.    #ifdef MUSE
9.    /* The weapon_check flag is used two ways:
10.    * 1) When calling mon_wield_item, is 2 or 3 depending on what is desired.
11.    * 2) Between calls to mon_wield_item, is 0 or 1 depending on whether or not
12.    *    the weapon is known by the monster to be cursed (so it shouldn't bother
13.    *    trying for another weapon).
14.    * I originally planned to also use 0 if the monster already had its best
15.    * weapon, to avoid the overhead of a call to mon_wield_item, but it turns out
16.    * that there are enough situations which might make a monster change its
17.    * weapon that this is impractical.
18.    */
19.   #define NO_WEAPON_WANTED 0
20.   #define NEED_WEAPON 1
21.   #define NEED_RANGED_WEAPON 2
22.   #define NEED_HTH_WEAPON 3
23.   #define NEED_PICK_AXE 4
24.   #endif
25.   
26.   #ifndef ALIGN_H
27.   #include "align.h"
28.   #endif
29.   
30.   struct monst {
31.   	struct monst *nmon;
32.   	struct permonst *data;
33.   	unsigned m_id;
34.   	short mnum;		/* permanent monster index number */
35.   	uchar m_lev;		/* adjusted difficulty level of monster */
36.   	aligntyp malign;	/* alignment of this monster, relative to the
37.   				   player (positive = good to kill) */
38.   	xchar mx, my;
39.   	xchar mux, muy;		/* where the monster thinks you are */
40.   #define MTSZ	4
41.   	coord mtrack[MTSZ];	/* monster track */
42.   	int mhp, mhpmax;
43.   	unsigned mappearance;	/* for undetected mimics and the wiz */
44.   	uchar	 m_ap_type;	/* what mappearance is describing: */
45.   #define M_AP_NOTHING	0	/* mappearance is unused -- monster appears
46.   				   as itself */
47.   #define M_AP_FURNITURE	1	/* stairs, a door, an altar, etc. */
48.   #define M_AP_OBJECT	2	/* an object */
49.   #define M_AP_MONSTER	3	/* a monster */
50.   
51.   	schar mtame;		/* level of tameness, implies peaceful */
52.   	int mspec_used;		/* monster's special ability attack timeout */
53.   
54.   	Bitfield(female,1);	/* is female */
55.   	Bitfield(minvis,1);	/* invisible */
56.   	Bitfield(cham,1);	/* shape-changer */
57.   	Bitfield(mundetected,1);	/* not seen in present hiding place */
58.   				/* implies one of M1_CONCEAL or M1_HIDE,
59.   				 * but not mimic (that is, snake, spider,
60.   				 * trapper, piercer)
61.   				 */
62.   	Bitfield(mcan,1);	/* has been cancelled */
63.   	Bitfield(mspeed,2);
64.   	/* free bit! */
65.   
66.   	Bitfield(mflee,1);	/* fleeing */
67.   	Bitfield(mfleetim,7);	/* timeout for mflee */
68.   
69.   	Bitfield(mcansee,1);	/* cansee 1, temp.blinded 0, blind 0 */
70.   	Bitfield(mblinded,7);	/* cansee 0, temp.blinded n, blind 0 */
71.   
72.   	Bitfield(mcanmove,1);	/* paralysis, similar to mblinded */
73.   	Bitfield(mfrozen,7);
74.   
75.   	Bitfield(msleep,1);	/* sleeping */
76.   	Bitfield(mstun,1);	/* stunned (off balance) */
77.   	Bitfield(mconf,1);	/* confused */
78.   	Bitfield(mpeaceful,1);	/* does not attack unprovoked */
79.   	Bitfield(mtrapped,1);	/* trapped in a pit or bear trap */
80.   	Bitfield(mleashed,1);	/* monster is on a leash */
81.   	Bitfield(isshk,1);	/* is shopkeeper */
82.   	Bitfield(isminion,1);	/* is a minion */
83.   
84.   	Bitfield(isgd,1);	/* is guard */
85.   	Bitfield(ispriest,1);	/* is a priest */
86.   	Bitfield(iswiz,1);	/* is the Wizard of Yendor */
87.   	Bitfield(wormno,5);	/* at most 31 worms on any level */
88.   #define MAX_NUM_WORMS	32	/* should be 2^(wormno bitfield size) */
89.   
90.   	long mstrategy;		/* for monsters with mflag3: current strategy */
91.   	long mtrapseen;		/* bitmap of traps we've been trapped in */
92.   	long mlstmv;		/* prevent two moves at once */
93.   	long mgold;
94.   	struct obj *minvent;
95.   #ifdef MUSE
96.   	struct obj *mw;
97.   	long misc_worn_check;
98.   	xchar weapon_check;
99.   #endif
100.  	uchar mnamelth;		/* length of name (following mxlth) */
101.  	short mxlth;		/* length of following data */
102.  	/* in order to prevent alignment problems mextra should
103.  	   be (or follow) a long int */
104.  	int meating;		/* monster is eating timeout */
105.  	long mextra[1];	/* monster dependent info */
106.  };
107.  
108.  /*
109.   * Note that mextra[] may correspond to any of a number of structures, which
110.   * are indicated by some of the other fields.
111.   *	isgd	 ->	struct egd
112.   *	ispriest ->	struct epri
113.   *	isshk	 ->	struct eshk
114.   *	isminion ->	struct emin
115.   *			(struct epri for roaming priests and angels, which is
116.   *			 compatible with emin for polymorph purposes)
117.   *	mtame	 ->	struct edog
118.   *			(struct epri for guardian angels, which do not eat
119.   *			 or do other doggy things)
120.   * Since at most one structure can be indicated in this manner, it is not
121.   * possible to tame any creatures using the other structures (the only
122.   * exception being the guardian angels which are tame on creation).
123.   */
124.  
125.  #define newmonst(xl) (struct monst *)alloc((unsigned)(xl) + sizeof(struct monst))
126.  #define dealloc_monst(mon) free((genericptr_t)(mon))
127.  
128.  /* these are in mspeed */
129.  #define MSLOW 1		/* slow monster */
130.  #define MFAST 2		/* speeded monster */
131.  
132.  #define NAME(mtmp)	(((char *)(mtmp)->mextra) + (mtmp)->mxlth)
133.  
134.  #define MON_WEP(mon)	((mon)->mw)
135.  #define MON_NOWEP(mon)	((mon)->mw = (struct obj *)0)
136.  
137.  #endif /* MONST_H */