Fandom

Wikihack

Source:SLASH'EM 0.0.7E7F2/obj.h

2,034pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Below is the full text to obj.h from the source code of SLASH'EM 0.0.7E7F2. To link to a particular line, write [[SLASH'EM 0.0.7E7F2/obj.h#line123]], for example.

The latest source code for vanilla NetHack is at Source code.


The NetHack General Public License applies to screenshots, source code and other content from NetHack.
1.    /*	SCCS Id: @(#)obj.h	3.4	2002/01/07	*/
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 <sys/types.h> */
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_id;
26.   	xchar ox,oy;
27.   	short otyp;		/* object class number */
28.   #ifdef UNPOLYPILE
29.   	short oldtyp;	/* WAC for unpolymorph */
30.   #endif
31.   	unsigned owt;
32.   	long quan;		/* number of items */
33.   
34.   	schar spe;		/* quality of weapon, armor or ring (+ or -)
35.   				   number of charges for wand ( >= -1 )
36.   				   marks your eggs, spinach tins
37.   				   royal coffers for a court ( == 2)
38.   				   tells which fruit a fruit is
39.   				   special for uball and amulet
40.   				   historic and gender for statues */
41.   #define STATUE_HISTORIC 0x01
42.   #define STATUE_MALE     0x02
43.   #define STATUE_FEMALE   0x04
44.   	char	oclass;		/* object class */
45.   	char	invlet;		/* designation in inventory */
46.   	char	oartifact;	/* artifact array index */
47.   	schar 	altmode; 	/* alternate modes - eg. SMG, double Lightsaber */
48.   				/* WP_MODEs are in decreasing speed */
49.   #define WP_MODE_AUTO	0	/* Max firing speed */
50.   #define WP_MODE_BURST	1	/* 1/3 of max rate */
51.   #define WP_MODE_SINGLE 	2	/* Single shot */
52.   
53.   	xchar where;		/* where the object thinks it is */
54.   #define OBJ_FREE	0		/* object not attached to anything */
55.   #define OBJ_FLOOR	1		/* object on floor */
56.   #define OBJ_CONTAINED	2		/* object in a container */
57.   #define OBJ_INVENT	3		/* object in the hero's inventory */
58.   #define OBJ_MINVENT	4		/* object in a monster inventory */
59.   #define OBJ_MIGRATING	5		/* object sent off to another level */
60.   #define OBJ_BURIED	6		/* object buried */
61.   #define OBJ_ONBILL	7		/* object on shk bill */
62.   #define NOBJ_STATES	8
63.   	xchar timed;		/* # of fuses (timers) attached to this obj */
64.   
65.   	Bitfield(cursed,1);
66.   	Bitfield(blessed,1);
67.   	Bitfield(unpaid,1);	/* on some bill */
68.   	Bitfield(no_charge,1);	/* if shk shouldn't charge for this */
69.   	Bitfield(known,1);	/* exact nature known */
70.   	Bitfield(dknown,1);	/* color or text known */
71.   	Bitfield(bknown,1);	/* blessing or curse known */
72.   	Bitfield(rknown,1);	/* rustproof or not known */
73.   
74.   	Bitfield(oeroded,2);	/* rusted/burnt weapon/armor */
75.   	Bitfield(oeroded2,2);	/* corroded/rotted weapon/armor */
76.   #define greatest_erosion(otmp) (int)((otmp)->oeroded > (otmp)->oeroded2 ? (otmp)->oeroded : (otmp)->oeroded2)
77.   #define MAX_ERODE 3
78.   #define orotten oeroded		/* rotten food */
79.   #define odiluted oeroded	/* diluted potions */
80.   #define norevive oeroded2
81.   	Bitfield(oerodeproof,1); /* erodeproof weapon/armor */
82.   	Bitfield(olocked,1);	/* object is locked */
83.   #define oarmed olocked
84.   #define odrained olocked	/* drained corpse */
85.   	Bitfield(obroken,1);	/* lock has been broken */
86.   	Bitfield(otrapped,1);	/* container is trapped */
87.   				/* or accidental tripped rolling boulder trap */
88.   #define opoisoned otrapped	/* object (weapon) is coated with poison */
89.   
90.   	Bitfield(recharged,3);	/* number of times it's been recharged */
91.   	Bitfield(lamplit,1);	/* a light-source -- can be lit */
92.   #ifdef INVISIBLE_OBJECTS
93.   	Bitfield(oinvis,1);	/* invisible */
94.   #endif
95.   	Bitfield(greased,1);	/* covered with grease */
96.   	Bitfield(oattached,2);	/* obj struct has special attachment */
97.   #define OATTACHED_NOTHING 0
98.   #define OATTACHED_MONST   1	/* monst struct in oextra */
99.   #define OATTACHED_M_ID    2	/* monst id in oextra */
100.  #define OATTACHED_UNUSED3 3
101.  	Bitfield(in_use,1);	/* for magic items before useup items */
102.  	Bitfield(bypass,1);	/* mark this as an object to be skipped by bhito() */
103.  
104.  	Bitfield(yours,1);	/* obj is yours (eg. thrown by you) */
105.  	Bitfield(was_thrown,1); /* thrown by the hero since last picked up */
106.  	/* ? free bits */
107.  
108.  	int	corpsenm;	/* type of corpse is mons[corpsenm] */
109.  #define leashmon  corpsenm	/* gets m_id of attached pet */
110.  #define spestudied corpsenm	/* # of times a spellbook has been studied */
111.  #define fromsink  corpsenm	/* a potion from a sink */
112.  	unsigned oeaten;	/* nutrition left in food, if partly eaten */
113.  	long age;		/* creation date */
114.  
115.  	uchar onamelth;		/* length of name (following oxlth) */
116.  	short oxlth;		/* length of following data */
117.  	/* in order to prevent alignment problems oextra should
118.  	   be (or follow) a long int */
119.  	long owornmask;
120.  	long oextra[1];		/* used for name of ordinary objects - length
121.  				   is flexible; amount for tmp gold objects */
122.  };
123.  
124.  #define newobj(xl)	(struct obj *)alloc((unsigned)(xl) + sizeof(struct obj))
125.  #define ONAME(otmp)	(((char *)(otmp)->oextra) + (otmp)->oxlth)
126.  
127.  /* All objects */
128.  #ifdef UNPOLYPILE
129.  #define is_hazy(otmp)	((otmp)->oldtyp != STRANGE_OBJECT)
130.  #endif
131.  /* [ALI] None of the objects listed here can be picked up by normal monsters.
132.   * If any such objects need to be marked as indestructible then consideration
133.   * will need to be given to what happens when such a monster disappears
134.   * carrying the object.
135.   */
136.  #define evades_destruction(otmp) ( \
137.  			(otmp)->otyp == AMULET_OF_YENDOR || \
138.  			(otmp)->otyp == CANDELABRUM_OF_INVOCATION || \
139.  			(otmp)->otyp == BELL_OF_OPENING || \
140.  			(otmp)->otyp == SPE_BOOK_OF_THE_DEAD || \
141.  			(otmp)->oartifact == ART_KEY_OF_LAW || \
142.  			(otmp)->oartifact == ART_KEY_OF_NEUTRALITY || \
143.  			(otmp)->oartifact == ART_KEY_OF_CHAOS)
144.  #ifdef INVISIBLE_OBJECTS
145.  #define always_visible(otmp) ( \
146.  			(otmp)->otyp == MUMMY_WRAPPING || \
147.  			(otmp)->oclass == COIN_CLASS)
148.  #endif
149.  
150.  /* Weapons and weapon-tools */
151.  /* KMH -- now based on skill categories.  Formerly:
152.   *	#define is_sword(otmp)	(otmp->oclass == WEAPON_CLASS && \
153.   *			 objects[otmp->otyp].oc_wepcat == WEP_SWORD)
154.   *	#define is_blade(otmp)	(otmp->oclass == WEAPON_CLASS && \
155.   *			 (objects[otmp->otyp].oc_wepcat == WEP_BLADE || \
156.   *			  objects[otmp->otyp].oc_wepcat == WEP_SWORD))
157.   *	#define is_weptool(o)	((o)->oclass == TOOL_CLASS && \
158.   *			 objects[(o)->otyp].oc_weptool)
159.   *	#define is_multigen(otyp) (otyp <= SHURIKEN)
160.   *	#define is_poisonable(otyp) (otyp <= BEC_DE_CORBIN)
161.   */
162.  
163.  #define is_sword(otmp)	((otmp)->oclass == WEAPON_CLASS && \
164.  			 objects[(otmp)->otyp].oc_skill >= P_SHORT_SWORD && \
165.  			 objects[(otmp)->otyp].oc_skill <= P_SABER)
166.  #define is_blade(otmp)	((otmp)->oclass == WEAPON_CLASS && \
167.  			 objects[(otmp)->otyp].oc_skill >= P_DAGGER && \
168.  			 objects[(otmp)->otyp].oc_skill <= P_SABER)
169.  #define is_pole(otmp)	(((otmp)->oclass == WEAPON_CLASS || \
170.  			(otmp)->oclass == TOOL_CLASS) && \
171.  			 (objects[(otmp)->otyp].oc_skill == P_POLEARMS || \
172.  			 objects[(otmp)->otyp].oc_skill == P_LANCE))
173.  #define is_spear(otmp)	((otmp)->oclass == WEAPON_CLASS && \
174.  			 objects[(otmp)->otyp].oc_skill >= P_SPEAR && \
175.  			 objects[(otmp)->otyp].oc_skill <= P_JAVELIN)
176.  #define is_axe(otmp)	((otmp)->oclass == WEAPON_CLASS && \
177.  			 objects[(otmp)->otyp].oc_skill == P_AXE)
178.  #define is_launcher(otmp)	((otmp)->oclass == WEAPON_CLASS && \
179.  			 objects[(otmp)->otyp].oc_skill >= P_BOW && \
180.  			 objects[(otmp)->otyp].oc_skill <= P_CROSSBOW)
181.  #define is_ammo(otmp)	(((otmp)->oclass == WEAPON_CLASS || \
182.  			 (otmp)->oclass == GEM_CLASS) && \
183.  			 objects[(otmp)->otyp].oc_skill >= -P_CROSSBOW && \
184.  			 objects[(otmp)->otyp].oc_skill <= -P_BOW)
185.  #define is_missile(otmp)	(((otmp)->oclass == WEAPON_CLASS || \
186.  			 (otmp)->oclass == TOOL_CLASS) && \
187.  			 objects[(otmp)->otyp].oc_skill >= -P_BOOMERANG && \
188.  			 objects[(otmp)->otyp].oc_skill <= -P_DART)
189.  #define is_grenade(otmp)	(is_ammo(otmp) && \
190.  			 	 objects[(otmp)->otyp].w_ammotyp == WP_GRENADE)
191.  #define is_multigen(otmp)	((otmp)->oclass == WEAPON_CLASS && \
192.  			 objects[(otmp)->otyp].oc_skill >= -P_SHURIKEN && \
193.  			 objects[(otmp)->otyp].oc_skill <= -P_BOW)
194.  #ifdef FIREARMS
195.  #define is_unpoisonable_firearm_ammo(otmp)	\
196.  			 (is_bullet(otmp) || (otmp)->otyp == STICK_OF_DYNAMITE)
197.  #else
198.  #define is_unpoisonable_firearm_ammo(otmp)	0
199.  #endif
200.  #define is_poisonable(otmp)	((otmp)->oclass == WEAPON_CLASS && \
201.  			 (objects[(otmp)->otyp].oc_skill <= P_SABER || \
202.  			 (objects[(otmp)->otyp].oc_skill >= P_POLEARMS && \
203.  			 objects[(otmp)->otyp].oc_skill <= P_LANCE)) && \
204.  			 !is_unpoisonable_firearm_ammo(otmp))
205.  #define uslinging()	(uwep && objects[uwep->otyp].oc_skill == P_SLING)
206.  #define is_weptool(o)	((o)->oclass == TOOL_CLASS && \
207.  			 objects[(o)->otyp].oc_skill != P_NONE)
208.  #define is_pick(otmp)	(((otmp)->oclass == WEAPON_CLASS || \
209.  			 (otmp)->oclass == TOOL_CLASS) && \
210.  			 objects[(otmp)->otyp].oc_skill == P_PICK_AXE)
211.  #define ammo_and_launcher(otmp,ltmp) \
212.  			(is_ammo(otmp) && (ltmp) && \
213.  			objects[(otmp)->otyp].oc_skill == -objects[(ltmp)->otyp].oc_skill && \
214.  			  objects[(otmp)->otyp].w_ammotyp == objects[(ltmp)->otyp].w_ammotyp)
215.  #define bimanual(otmp)	(((otmp)->oclass == WEAPON_CLASS || \
216.  			  (otmp)->oclass == TOOL_CLASS) && \
217.  			 objects[(otmp)->otyp].oc_bimanual)
218.  
219.  #ifdef LIGHTSABERS
220.  #define is_lightsaber(otmp) (objects[(otmp)->otyp].oc_skill == P_LIGHTSABER)
221.  #endif
222.  
223.  #ifdef FIREARMS
224.  #define is_firearm(otmp) \
225.  			((otmp)->oclass == WEAPON_CLASS && \
226.  			 objects[(otmp)->otyp].oc_skill == P_FIREARM)
227.  #define is_bullet(otmp)	((otmp)->oclass == WEAPON_CLASS && \
228.  			 objects[(otmp)->otyp].oc_skill == -P_FIREARM)
229.  #endif
230.  
231.  /* Armor */
232.  #define is_shield(otmp) ((otmp)->oclass == ARMOR_CLASS && \
233.  			 objects[(otmp)->otyp].oc_armcat == ARM_SHIELD)
234.  #define is_helmet(otmp) ((otmp)->oclass == ARMOR_CLASS && \
235.  			 objects[(otmp)->otyp].oc_armcat == ARM_HELM)
236.  #define is_boots(otmp)	((otmp)->oclass == ARMOR_CLASS && \
237.  			 objects[(otmp)->otyp].oc_armcat == ARM_BOOTS)
238.  #define is_gloves(otmp) ((otmp)->oclass == ARMOR_CLASS && \
239.  			 objects[(otmp)->otyp].oc_armcat == ARM_GLOVES)
240.  #define is_cloak(otmp)	((otmp)->oclass == ARMOR_CLASS && \
241.  			 objects[(otmp)->otyp].oc_armcat == ARM_CLOAK)
242.  #define is_shirt(otmp)	((otmp)->oclass == ARMOR_CLASS && \
243.  			 objects[(otmp)->otyp].oc_armcat == ARM_SHIRT)
244.  #define is_suit(otmp)	((otmp)->oclass == ARMOR_CLASS && \
245.  			 objects[(otmp)->otyp].oc_armcat == ARM_SUIT)
246.  #define is_elven_armor(otmp)	((otmp)->otyp == ELVEN_LEATHER_HELM\
247.  				|| (otmp)->otyp == ELVEN_MITHRIL_COAT\
248.  				|| (otmp)->otyp == ELVEN_CLOAK\
249.  				|| (otmp)->otyp == ELVEN_SHIELD\
250.  				|| (otmp)->otyp == ELVEN_BOOTS)
251.  #define is_orcish_armor(otmp)	((otmp)->otyp == ORCISH_HELM\
252.  				|| (otmp)->otyp == ORCISH_CHAIN_MAIL\
253.  				|| (otmp)->otyp == ORCISH_RING_MAIL\
254.  				|| (otmp)->otyp == ORCISH_CLOAK\
255.  				|| (otmp)->otyp == URUK_HAI_SHIELD\
256.  				|| (otmp)->otyp == ORCISH_SHIELD)
257.  #define is_dwarvish_armor(otmp)	((otmp)->otyp == DWARVISH_IRON_HELM\
258.  				|| (otmp)->otyp == DWARVISH_MITHRIL_COAT\
259.  				|| (otmp)->otyp == DWARVISH_CLOAK\
260.  				|| (otmp)->otyp == DWARVISH_ROUNDSHIELD)
261.  #define is_gnomish_armor(otmp)	(FALSE)
262.  
263.  				
264.  /* Eggs and other food */
265.  #define MAX_EGG_HATCH_TIME 200	/* longest an egg can remain unhatched */
266.  #define stale_egg(egg)	((monstermoves - (egg)->age) > (2*MAX_EGG_HATCH_TIME))
267.  #define ofood(o) ((o)->otyp == CORPSE || (o)->otyp == EGG || (o)->otyp == TIN)
268.  #define polyfodder(obj)	(ofood(obj) && (obj)->corpsenm == PM_CHAMELEON)
269.  #define mlevelgain(obj) (ofood(obj) && (obj)->corpsenm == PM_WRAITH)
270.  #define mhealup(obj)	(ofood(obj) && (obj)->corpsenm == PM_NURSE)
271.  #define drainlevel(corpse) (mons[(corpse)->corpsenm].cnutrit*4/5)
272.  
273.  /* Containers */
274.  #define carried(o)	((o)->where == OBJ_INVENT)
275.  #define mcarried(o)	((o)->where == OBJ_MINVENT)
276.  #define Has_contents(o) (/* (Is_container(o) || (o)->otyp == STATUE) && */ \
277.  			 (o)->cobj != (struct obj *)0)
278.  #define Is_container(o) ((o)->otyp == MEDICAL_KIT || \
279.  			 (o)->otyp >= LARGE_BOX && (o)->otyp <= BAG_OF_TRICKS)
280.  #define Is_box(otmp)	((otmp)->otyp == LARGE_BOX || (otmp)->otyp == CHEST)
281.  #ifdef WALLET_O_P
282.  #define Is_mbag(otmp)	((otmp)->otyp == BAG_OF_HOLDING || \
283.                           ((otmp)->oartifact && \
284.                            (otmp)->oartifact == ART_WALLET_OF_PERSEUS) || \
285.    			             (otmp)->otyp == BAG_OF_TRICKS)
286.  #else
287.  #define Is_mbag(otmp)	((otmp)->otyp == BAG_OF_HOLDING || \
288.    			 (otmp)->otyp == BAG_OF_TRICKS)
289.  #endif
290.  
291.  /* dragon gear */
292.  #define Is_dragon_scales(obj)	((obj)->otyp >= GRAY_DRAGON_SCALES && \
293.  				 (obj)->otyp <= YELLOW_DRAGON_SCALES)
294.  #define Is_dragon_mail(obj)	((obj)->otyp >= GRAY_DRAGON_SCALE_MAIL && \
295.  				 (obj)->otyp <= YELLOW_DRAGON_SCALE_MAIL)
296.  #define Is_dragon_armor(obj)	(Is_dragon_scales(obj) || Is_dragon_mail(obj))
297.  #define Dragon_scales_to_pm(obj) &mons[PM_GRAY_DRAGON + (obj)->otyp \
298.  				       - GRAY_DRAGON_SCALES]
299.  #define Dragon_mail_to_pm(obj)	&mons[PM_GRAY_DRAGON + (obj)->otyp \
300.  				      - GRAY_DRAGON_SCALE_MAIL]
301.  #define Dragon_to_scales(pm)	(GRAY_DRAGON_SCALES + (pm - mons))
302.  
303.  /* Elven gear */
304.  #define is_elven_weapon(otmp)	((otmp)->otyp == ELVEN_ARROW\
305.  				|| (otmp)->otyp == ELVEN_SPEAR\
306.  				|| (otmp)->otyp == ELVEN_DAGGER\
307.  				|| (otmp)->otyp == ELVEN_SHORT_SWORD\
308.  				|| (otmp)->otyp == ELVEN_BROADSWORD\
309.  				|| (otmp)->otyp == ELVEN_BOW)
310.  #define is_elven_obj(otmp)	(is_elven_armor(otmp) || is_elven_weapon(otmp))
311.  
312.  /* Orcish gear */
313.  #define is_orcish_obj(otmp)	(is_orcish_armor(otmp)\
314.  				|| (otmp)->otyp == ORCISH_ARROW\
315.  				|| (otmp)->otyp == ORCISH_SPEAR\
316.  				|| (otmp)->otyp == ORCISH_DAGGER\
317.  				|| (otmp)->otyp == ORCISH_SHORT_SWORD\
318.  				|| (otmp)->otyp == ORCISH_BOW)
319.  
320.  /* Dwarvish gear */
321.  #define is_dwarvish_obj(otmp)	(is_dwarvish_armor(otmp)\
322.  				|| (otmp)->otyp == DWARVISH_SPEAR\
323.  				|| (otmp)->otyp == DWARVISH_SHORT_SWORD\
324.  				|| (otmp)->otyp == DWARVISH_MATTOCK)
325.  
326.  /* Gnomish gear */
327.  #define is_gnomish_obj(otmp)	(is_gnomish_armor(otmp))
328.  
329.  /* Light sources */
330.  #define Is_candle(otmp)	((otmp)->otyp == TALLOW_CANDLE || \
331.  			 (otmp)->otyp == WAX_CANDLE || \
332.  			 (otmp)->otyp == MAGIC_CANDLE)
333.  /* maximum amount of oil in a potion of oil */
334.  #define MAX_OIL_IN_FLASK 400
335.  
336.  /* MAGIC_LAMP intentionally excluded below */
337.  /* age field of this is relative age rather than absolute */
338.  #define age_is_relative(otmp)	((otmp)->otyp == BRASS_LANTERN\
339.  				|| (otmp)->otyp == OIL_LAMP\
340.  				|| (otmp)->otyp == TORCH\
341.  				|| (otmp)->otyp == CANDELABRUM_OF_INVOCATION\
342.  				|| (otmp)->otyp == TALLOW_CANDLE\
343.  				|| (otmp)->otyp == WAX_CANDLE\
344.  				|| (otmp)->otyp == POT_OIL)
345.  /* object can be ignited */
346.  #define ignitable(otmp)	((otmp)->otyp == BRASS_LANTERN\
347.  				|| (otmp)->otyp == OIL_LAMP\
348.  				|| (otmp)->otyp == TORCH\
349.  				|| (otmp)->otyp == CANDELABRUM_OF_INVOCATION\
350.  				|| (otmp)->otyp == TALLOW_CANDLE\
351.  				|| (otmp)->otyp == WAX_CANDLE\
352.  				|| (otmp)->otyp == MAGIC_CANDLE\
353.  				|| (otmp)->otyp == POT_OIL)
354.  
355.  /* special stones */
356.  #define is_graystone(obj)	((obj)->otyp == LUCKSTONE || \
357.  				 (obj)->otyp == LOADSTONE || \
358.  				 (obj)->otyp == FLINT     || \
359.  				 (obj)->otyp == TOUCHSTONE || \
360.  				 (obj)->otyp == HEALTHSTONE || \
361.  				 (obj)->otyp == WHETSTONE)
362.  
363.  /* misc */
364.  #ifdef KOPS
365.  #define is_flimsy(otmp)		(objects[(otmp)->otyp].oc_material <= LEATHER || \
366.  				 (otmp)->otyp == RUBBER_HOSE)
367.  #else
368.  #define is_flimsy(otmp)		(objects[(otmp)->otyp].oc_material <= LEATHER)
369.  #endif
370.  
371.  /* helpers, simple enough to be macros */
372.  #define is_plural(o)	((o)->quan > 1 || \
373.  			 (o)->oartifact == ART_EYES_OF_THE_OVERWORLD)
374.  
375.  /* Flags for get_obj_location(). */
376.  #define CONTAINED_TOO	0x1
377.  #define BURIED_TOO	0x2
378.  
379.  #endif /* OBJ_H */

Also on Fandom

Random Wiki