Source:NetHack 3.2.0/obj.h

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

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

1.   /*	SCCS Id: @(#)obj.h	3.2	95/11/09	*/ 2.   /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3.    /* NetHack may be freely redistributed. See license for details. */ 4.     5.    #ifndef OBJ_H 6.   #define OBJ_H 7.    8.    /* #define obj obj_nh	/* uncomment for SCO UNIX, which has a conflicting 9.   			 * typedef for "obj" in  */ 10.   11.   union vptrs { 12.  	    struct obj *v_nexthere;	/* floor location lists */ 13.  	    struct obj *v_ocontainer;	/* point back to container */ 14.  	    struct monst *v_ocarry;	/* point back to carrying monst */ 15.  };  16.    17.   struct obj { 18.  	struct obj *nobj; 19.  	union vptrs v;  20. #define nexthere	v.v_nexthere 21.  #define ocontainer	v.v_ocontainer 22.  #define ocarry		v.v_ocarry 23.   24.   	struct obj *cobj;       /* contents list for containers */ 25.  /*	unsigned o_cwt;		/* container weight capacity */ 26.  	unsigned o_id; 27.  	xchar ox,oy; 28.  	short otyp;		/* object class number */ 29.  	unsigned owt; 30.  	long quan;		/* number of items */ 31.   32.   	schar spe;		/* quality of weapon, armor or ring (+ or -) 33.  				   number of charges for wand ( >= -1 ) 34.  				   marks your eggs, spinach tins 35.  				   indicates statues have spellbooks inside 36.  				   royal coffers for a court ( == 2) 37.  				   tells which fruit a fruit is  38. special for uball and amulet %% BAH */ 39.  	char	oclass;		/* object class */ 40.  	char	invlet;		/* designation in inventory */ 41.  	char	oartifact;	/* artifact array index */ 42.   43.   	xchar where;		/* where the object thinks it is */ 44.  #define OBJ_FREE	0		/* object not attached to anything */ 45.  #define OBJ_FLOOR	1		/* object on floor */ 46.  #define OBJ_CONTAINED	2		/* object in a container */ 47.  #define OBJ_INVENT	3		/* object in the hero's inventory */ 48.  #define OBJ_MINVENT	4		/* object in a monster inventory */ 49.  #define OBJ_MIGRATING   5		/* object sent off to another level */ 50.  #define OBJ_BURIED	6		/* object buried */ 51.  #define OBJ_ONBILL	7		/* object on shk bill */ 52.  #define NOBJ_STATES	8 53.  	xchar timed;		/* # of fuses (timers) attached to this obj */ 54.   55.   	Bitfield(cursed,1); 56.  	Bitfield(blessed,1); 57.  	Bitfield(unpaid,1);	/* on some bill */ 58.  	Bitfield(no_charge,1);	/* if shk shouldn't charge for this */ 59.  	Bitfield(known,1);	/* exact nature known */ 60.  	Bitfield(dknown,1);	/* color or text known */ 61.  	Bitfield(bknown,1);	/* blessing or curse known */ 62.  	Bitfield(rknown,1);	/* rustproof or not known */ 63.   64.   	Bitfield(oeroded,2);	/* rusted/corroded/burnt/rotted weapon/armor */ 65.  #define MAX_ERODE 3 66.  #define orotten oeroded		/* rotten food */ 67.  #define odiluted oeroded	/* diluted potions */ 68.  	Bitfield(oerodeproof,1); /* erodeproof weapon/armor */ 69.  	Bitfield(olocked,1);	/* object is locked */ 70.  #define recharged olocked	/* recharged once */ 71.  	Bitfield(obroken,1);	/* lock has been broken */ 72.  	Bitfield(otrapped,1);	/* container is trapped */ 73.  #define opoisoned otrapped	/* object (weapon) is coated with poison */ 74.  #ifndef NO_SIGNAL 75.  	Bitfield(in_use,1);	/* for magic items before useup items */ 76.  #endif 77.  	Bitfield(lamplit,1);    /* a light-source -- can be lit */ 78.   79.   	Bitfield(oinvis,1);	/* not yet implemented */ 80.  	Bitfield(greased,1);	/* covered with grease */ 81.  	Bitfield(onamelth,6); 82.   83.   	int	corpsenm;	/* type of corpse is mons[corpsenm] */ 84.  #define leashmon  corpsenm	/* gets m_id of attached pet */ 85.  #define spestudied corpsenm	/* how many times a spellbook has been studied */ 86.  	unsigned oeaten;	/* nutrition left in food, if partly eaten */ 87.  	long age;		/* creation date */ 88.  	long owornmask; 89.   90.   /* note that TIMEOUT in you.h is defined as 07777L; no bits for items that 91.   * confer properties may overlap that mask, or timeout.c will happily 92.   * rearrange the bits behind the back of the property code 93.   * shirts, balls, and chains are currently safe 94.   * FROMOUTSIDE and FROMEXPER in you.h are defined as 020000000L and 0400000000L 95.   * respectively. Declarations here should not overlap with those bits either. 96.   */  97.   #define W_BALL	02000L 98.  #define W_CHAIN	04000L 99.  #define W_RINGL	010000L		/* make W_RINGL = RING_LEFT (see uprop) */ 100. #define W_RINGR	020000L 101. #define W_RING	(W_RINGL | W_RINGR) 102. #define W_ARM	040000L 103. #define W_ARMC	0100000L 104. #define W_ARMH	0200000L 105. #define W_ARMS	0400000L 106. #define W_ARMG	01000000L 107. #define W_ARMF	02000000L 108. #define W_AMUL	04000000L 109. #define W_TOOL	010000000L	/* wearing another tool (see uprop) */ 110. #define W_WEP	020000000L 111. #define W_ART	040000000L	/* _carrying_ an artifact, not really worn */ 112. #define W_ARTI	0100000000L	/* an invoked artifact, not really worn */ 113. #ifdef TOURIST 114. #define W_ARMU	01000L 115. #define W_ARMOR	(W_ARM | W_ARMC | W_ARMH | W_ARMS | W_ARMG | W_ARMF | W_ARMU) 116. #else 117. #define W_ARMOR	(W_ARM | W_ARMC | W_ARMH | W_ARMS | W_ARMG | W_ARMF) 118. #endif 119. 	long oextra[1];		/* used for name of ordinary objects - length 120. 				   is flexible; amount for tmp gold objects */ 121. };  122.   123.  #define newobj(xl)	(struct obj *)alloc((unsigned)(xl) + sizeof(struct obj)) 124. #define ONAME(otmp)	((char *)(otmp)->oextra) 125.  126.  #define carried(o)	((o)->where == OBJ_INVENT) 127. #define Has_contents(o) (/* (Is_container(o) || (o)->otyp == STATUE) && */ \  128.  			 (o)->cobj != (struct obj *)0) 129. #define Is_container(o) ((o)->otyp >= LARGE_BOX && (o)->otyp <= BAG_OF_TRICKS) 130. #define Is_box(otmp)	(otmp->otyp == LARGE_BOX || otmp->otyp == CHEST) 131. #define Is_mbag(otmp)	(otmp->otyp == BAG_OF_HOLDING || \  132.  			 otmp->otyp == BAG_OF_TRICKS) 133.  134.  #define is_shield(otmp) (otmp->oclass == ARMOR_CLASS && \  135.  			 objects[otmp->otyp].oc_armcat == ARM_SHIELD) 136. #define is_helmet(otmp) (otmp->oclass == ARMOR_CLASS && \  137.  			 objects[otmp->otyp].oc_armcat == ARM_HELM) 138. #define is_boots(otmp)	(otmp->oclass == ARMOR_CLASS && \  139.  			 objects[otmp->otyp].oc_armcat == ARM_BOOTS) 140. #define is_gloves(otmp) (otmp->oclass == ARMOR_CLASS && \  141.  			 objects[otmp->otyp].oc_armcat == ARM_GLOVES) 142. #define is_cloak(otmp)	(otmp->oclass == ARMOR_CLASS && \  143.  			 objects[otmp->otyp].oc_armcat == ARM_CLOAK) 144. #define is_shirt(otmp)	(otmp->oclass == ARMOR_CLASS && \  145.  			 objects[otmp->otyp].oc_armcat == ARM_SHIRT) 146. #define is_suit(otmp)	(otmp->oclass == ARMOR_CLASS && \  147.  			 objects[otmp->otyp].oc_armcat == ARM_SUIT) 148.  149.  #define is_sword(otmp)	(otmp->oclass == WEAPON_CLASS && \  150.  			 objects[otmp->otyp].oc_wepcat == WEP_SWORD) 151. #define is_blade(otmp)	(otmp->oclass == WEAPON_CLASS && \  152.  			 (objects[otmp->otyp].oc_wepcat == WEP_BLADE || \ 153. 			  objects[otmp->otyp].oc_wepcat == WEP_SWORD)) 154. #define is_weptool(o)	((o)->oclass == TOOL_CLASS && \  155.  			 objects[(o)->otyp].oc_weptool) 156. #define bimanual(otmp)	((otmp->oclass == WEAPON_CLASS || \ 157. 			  otmp->oclass == TOOL_CLASS) && \  158.  			 objects[otmp->otyp].oc_bimanual) 159.  160.  #define Is_candle(otmp)	(otmp->otyp == TALLOW_CANDLE || \  161.  			 otmp->otyp == WAX_CANDLE) 162.  163.  /* Flags for get_obj_location. */ 164.  #define CONTAINED_TOO	0x1 165. #define BURIED_TOO	0x2 166.  167.  /* maximum amount of oil in a potion of oil */ 168. #define MAX_OIL_IN_FLASK 400 169.  170.  /* egg stuff */ 171. #define MAX_EGG_HATCH_TIME 200	/* longest an egg can remain unhatched */ 172. #define stale_egg(egg)	((monstermoves - (egg)->age) > (2*MAX_EGG_HATCH_TIME)) 173.  174.  #define ofood(o) ((o)->otyp == CORPSE || (o)->otyp == EGG || (o)->otyp == TIN) 175. #define polyfodder(obj)	(ofood(obj) && (obj)->corpsenm == PM_CHAMELEON) 176. #define mlevelgain(obj)	(ofood(obj) && (obj)->corpsenm == PM_WRAITH) 177. #define mhealup(obj)	(ofood(obj) && (obj)->corpsenm == PM_NURSE) 178.  179.  #endif /* OBJ_H */