Source:NetHack 3.2.0/objclass.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to objclass.h from the source code of NetHack 3.2.0. To link to a particular line, write [[NetHack 3.2.0/objclass.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: @(#)objclass.h	3.2	95/08/13	*/
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    
5.    #ifndef OBJCLASS_H
6.    #define OBJCLASS_H
7.    
8.    /* definition of a class of objects */
9.    
10.   struct objclass {
11.   	short	oc_name_idx;		/* index of actual name */
12.   	short	oc_descr_idx;		/* description when name unknown */
13.   	char *	oc_uname;		/* called by user */
14.   	Bitfield(oc_name_known,1);
15.   	Bitfield(oc_merge,1);	/* merge otherwise equal objects */
16.   	Bitfield(oc_uses_known,1); /* obj->known affects full decription */
17.   				/* otherwise, obj->dknown and obj->bknown */
18.   				/* tell all, and obj->known should always */
19.   				/* be set for proper merging behavior */
20.   	Bitfield(oc_pre_discovered,1);	/* Already known at start of game; */
21.   					/* won't be listed as a discovery. */
22.   	Bitfield(oc_magic,1);	/* inherently magical object */
23.   	Bitfield(oc_charged,1);	/* may have +n or (n) charges */
24.   	Bitfield(oc_unique,1);	/* special one-of-a-kind object */
25.   	Bitfield(oc_nowish,1);	/* cannot wish for this object */
26.   
27.   	Bitfield(oc_big,1);
28.   #define oc_bimanual	oc_big	/* for weapons & tools used as weapons */
29.   #define oc_bulky	oc_big	/* for armor */
30.   	Bitfield(oc_tough,1);	/* hard gems/rings */
31.   
32.   	Bitfield(oc_dir,2);
33.   #define NODIR		1	/* for wands/spells: non-directional */
34.   #define IMMEDIATE	2	/*		     directional */
35.   #define RAY		3	/*		     zap beams */
36.   
37.   #define PIERCE		1	/* for weapons & tools used as weapons */
38.   #define SLASH		2
39.   #define WHACK		0
40.   
41.   	Bitfield(oc_subtyp,3);
42.   #define oc_armcat	oc_subtyp   /* for armor */
43.   #define oc_weptool	oc_subtyp   /* for tools, must be one of below */
44.   #define oc_wepcat	oc_subtyp   /* for weapons, tools, gems */
45.   
46.   #define ARM_SHIELD	1	/* needed for special wear function */
47.   #define ARM_HELM	2
48.   #define ARM_GLOVES	3
49.   #define ARM_BOOTS	4
50.   #define ARM_CLOAK	5
51.   #define ARM_SHIRT	6
52.   #define ARM_SUIT	0
53.   
54.   #define WEP_BOW		1
55.   #define WEP_AMMO	2
56.   #define WEP_MISSILE	3
57.   #define WEP_SPEAR	4	/* not used at present */
58.   #define WEP_POLEARM	5	/* not used at present */
59.   #define WEP_BLADE	6
60.   #define WEP_SWORD	7
61.   
62.   	Bitfield(oc_material,5);
63.   #define LIQUID		1	/* currently only for venom */
64.   #define WAX		2
65.   #define VEGGY		3	/* foodstuffs */
66.   #define FLESH		4	/*   ditto    */
67.   #define PAPER		5
68.   #define CLOTH		6
69.   #define LEATHER		7
70.   #define WOOD		8
71.   #define BONE		9
72.   #define DRAGON_HIDE	10	/* not leather! */
73.   #define IRON		11	/* Fe - includes steel */
74.   #define METAL		12	/* Sn, &c. */
75.   #define COPPER		13	/* Cu - includes brass */
76.   #define SILVER		14	/* Ag */
77.   #define GOLD		15	/* Au */
78.   #define PLATINUM	16	/* Pt */
79.   #define MITHRIL		17
80.   #define PLASTIC		18
81.   #define GLASS		19
82.   #define GEMSTONE	20
83.   #define MINERAL		21
84.   
85.   #define is_organic(otmp)	(objects[otmp->otyp].oc_material <= WOOD)
86.   #define is_metallic(otmp)	(objects[otmp->otyp].oc_material >= IRON && \
87.   				 objects[otmp->otyp].oc_material <= MITHRIL)
88.   #define is_corrodeable(otmp)	(objects[otmp->otyp].oc_material == COPPER)
89.   #define is_rustprone(otmp)	(objects[otmp->otyp].oc_material == IRON)
90.   
91.   	uchar	oc_oprop;		/* property (invis, &c.) conveyed */
92.   	char	oc_class;		/* object class */
93.   	schar	oc_delay;		/* delay when using such an object */
94.   #ifdef TEXTCOLOR
95.   	uchar	oc_color;		/* display color of the object */
96.   #endif /* TEXTCOLOR */
97.   	short	oc_prob;		/* probability, used in mkobj() */
98.   	unsigned short	oc_weight;	/* encumbrance (1 cn = 0.1 lb.) */
99.   	short	oc_cost;		/* base cost in shops */
100.  /* Check the AD&D rules!  The FIRST is small monster damage. */
101.  /* for weapons, and tools, rocks, and gems useful as weapons */
102.  	schar	oc_wsdam, oc_wldam;	/* max small/large monster damage */
103.  	schar	oc_oc1, oc_oc2;
104.  #define oc_hitbon	oc_oc1		/* weapons: "to hit" bonus */
105.  #define w_propellor	oc_oc2		/* weapons: negative value = bow */
106.  #define WP_BOW		1
107.  #define WP_SLING	2
108.  #define WP_CROSSBOW	3
109.  
110.  #define a_ac		oc_oc1	/* armor class, used in ARM_BONUS in do.c */
111.  #define a_can		oc_oc2		/* armor: used in mhitu.c */
112.  #define oc_level	oc_oc2		/* books: spell level */
113.  
114.  	unsigned short	oc_nutrition;	/* food value */
115.  };
116.  
117.  struct objdescr {
118.  	const char *oc_name;		/* actual name */
119.  	const char *oc_descr;		/* description when name unknown */
120.  };
121.  
122.  extern NEARDATA struct objclass objects[];
123.  extern NEARDATA struct objdescr obj_descr[];
124.  
125.  /*
126.   * All objects have a class. Make sure that all classes have a corresponding
127.   * symbol below.
128.   */
129.  #define RANDOM_CLASS	 0	/* used for generating random objects */
130.  #define ILLOBJ_CLASS	 1
131.  #define WEAPON_CLASS	 2
132.  #define ARMOR_CLASS	 3
133.  #define RING_CLASS	 4
134.  #define AMULET_CLASS	 5
135.  #define TOOL_CLASS	 6
136.  #define FOOD_CLASS	 7
137.  #define POTION_CLASS	 8
138.  #define SCROLL_CLASS	 9
139.  #define SPBOOK_CLASS	10	/* actually SPELL-book */
140.  #define WAND_CLASS	11
141.  #define GOLD_CLASS	12
142.  #define GEM_CLASS	13
143.  #define ROCK_CLASS	14
144.  #define BALL_CLASS	15
145.  #define CHAIN_CLASS	16
146.  #define VENOM_CLASS	17
147.  #define MAXOCLASSES     18
148.  
149.  #define ALLOW_COUNT	(MAXOCLASSES+1)	/* Can be used in the object class */
150.  #define ALL_CLASSES	(MAXOCLASSES+2)	/* input to getobj().		   */
151.  #define ALLOW_NONE	(MAXOCLASSES+3)	/*				   */
152.  
153.  #define BURNING_OIL	(MAXOCLASSES+1)	/* Can be used as input to explode. */
154.  
155.  #if 0	/* moved to decl.h so that makedefs.c won't see them */
156.  extern const char def_oc_syms[MAXOCLASSES];	/* default class symbols */
157.  extern uchar oc_syms[MAXOCLASSES];		/* current class symbols */
158.  #endif
159.  
160.  /* Default definitions of all object-symbols (must match classes above). */
161.  
162.  #define ILLOBJ_SYM	']'	/* should be same as S_MIMIC_DEF      */
163.  #define WEAPON_SYM	')'
164.  #define ARMOR_SYM	'['
165.  #define RING_SYM	'='
166.  #define AMULET_SYM	'"'
167.  #define TOOL_SYM	'('
168.  #define FOOD_SYM	'%'
169.  #define POTION_SYM	'!'
170.  #define SCROLL_SYM	'?'
171.  #define SPBOOK_SYM	'+'
172.  #define WAND_SYM	'/'
173.  #define GOLD_SYM	'$'
174.  #define GEM_SYM		'*'
175.  #define ROCK_SYM	'`'
176.  #define BALL_SYM	'0'
177.  #define CHAIN_SYM	'_'
178.  #define VENOM_SYM	'.'
179.  
180.  struct fruit {
181.  	char fname[PL_FSIZ];
182.  	int fid;
183.  	struct fruit *nextf;
184.  };
185.  #define newfruit() (struct fruit *)alloc(sizeof(struct fruit))
186.  #define dealloc_fruit(rind) free((genericptr_t) (rind))
187.  
188.  #define OBJ_NAME(obj)  (obj_descr[(obj).oc_name_idx].oc_name)
189.  #define OBJ_DESCR(obj) (obj_descr[(obj).oc_descr_idx].oc_descr)
190.  #endif /* OBJCLASS_H */