Source:NetHack 5.0.0/include/objclass.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to objclass.h from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/include/objclass.h#line12]], for example.

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. /* NetHack 5.0	objclass.h	$NHDT-Date: 1596498553 2020/08/03 23:49:13 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.22 $ */
2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3. /*-Copyright (c) Pasi Kallinen, 2018. */
4. /* NetHack may be freely redistributed.  See license for details. */
5. 
6. #ifndef OBJCLASS_H
7. #define OBJCLASS_H
8. 
9. /* [misnamed] definition of a type of object; many objects are composites
10.    (liquid potion inside glass bottle, metal arrowhead on wooden shaft)
11.    and object definitions only specify one type on a best-fit basis */
12. enum obj_material_types {
13.     NO_MATERIAL =  0,
14.     LIQUID      =  1, /* currently only for venom */
15.     WAX         =  2,
16.     VEGGY       =  3, /* foodstuffs */
17.     FLESH       =  4, /*   ditto    */
18.     PAPER       =  5,
19.     CLOTH       =  6,
20.     LEATHER     =  7,
21.     WOOD        =  8,
22.     BONE        =  9,
23.     DRAGON_HIDE = 10, /* not leather! */
24.     IRON        = 11, /* Fe - includes steel */
25.     METAL       = 12, /* Sn, &c. */
26.     COPPER      = 13, /* Cu - includes brass */
27.     SILVER      = 14, /* Ag */
28.     GOLD        = 15, /* Au */
29.     PLATINUM    = 16, /* Pt */
30.     MITHRIL     = 17,
31.     PLASTIC     = 18,
32.     GLASS       = 19,
33.     GEMSTONE    = 20,
34.     MINERAL     = 21
35. };
36. 
37. enum obj_armor_types {
38.     ARM_SUIT   = 0,
39.     ARM_SHIELD = 1,        /* needed for special wear function */
40.     ARM_HELM   = 2,
41.     ARM_GLOVES = 3,
42.     ARM_BOOTS  = 4,
43.     ARM_CLOAK  = 5,
44.     ARM_SHIRT  = 6
45. };
46. 
47. struct objclass {
48.     short oc_name_idx;              /* index of actual name */
49.     short oc_descr_idx;             /* description when name unknown */
50.     char *oc_uname;                 /* called by user */
51.     Bitfield(oc_name_known, 1);     /* discovered */
52.     Bitfield(oc_merge, 1);          /* merge otherwise equal objects */
53.     Bitfield(oc_uses_known, 1);     /* obj->known affects full description;
54.                                      * otherwise, obj->dknown and obj->bknown
55.                                      * tell all, and obj->known should always
56.                                      * be set for proper merging behavior. */
57.     Bitfield(oc_encountered, 1);    /* hero has observed such an item at least
58.                                        once (perhaps without naming it) */
59.     Bitfield(oc_magic, 1);          /* inherently magical object */
60.     Bitfield(oc_charged, 1);        /* may have +n or (n) charges */
61.     Bitfield(oc_unique, 1);         /* special one-of-a-kind object */
62.     Bitfield(oc_nowish, 1);         /* cannot wish for this object */
63. 
64.     Bitfield(oc_big, 1);
65. #define oc_bimanual oc_big /* for weapons & tools used as weapons */
66. #define oc_bulky oc_big    /* for armor */
67.     Bitfield(oc_tough, 1); /* hard gems/rings */
68. 
69.     Bitfield(oc_spare1, 6);         /* padding to align oc_dir + oc_material;
70.                                      * can be cannibalized for other use;
71.                                      * aka 6 free bits */
72. 
73.     Bitfield(oc_dir, 3);
74.     /* oc_dir: zap style for wands and spells */
75. #define NODIR     1 /* non-directional */
76. #define IMMEDIATE 2 /* directional beam that doesn't ricochet */
77. #define RAY       3 /* beam that does bounce off walls */
78.     /* overloaded oc_dir: strike mode bit mask for weapons and weptools */
79. #define PIERCE    1 /* pointed weapon punctures target */
80. #define SLASH     2 /* sharp weapon cuts target */
81. #define WHACK     4 /* blunt weapon bashes target */
82.     Bitfield(oc_material, 5); /* one of obj_material_types */
83. 
84.     schar oc_subtyp;
85. #define oc_skill oc_subtyp  /* Skills of weapons, spellbooks, tools, gems */
86. #define oc_armcat oc_subtyp /* for armor (enum obj_armor_types) */
87. 
88.     uchar oc_oprop; /* property (invis, &c.) conveyed */
89.     char  oc_class; /* object class (enum obj_class_types) */
90.     schar oc_delay; /* delay when using such an object */
91.     uchar oc_color; /* color of the object */
92. 
93.     short oc_prob;            /* probability, used in mkobj() */
94.     unsigned oc_weight;       /* encumbrance (1 cn = 0.1 lb.) */
95.     short oc_cost;            /* base cost in shops */
96.     /* Check the AD&D rules!  The FIRST is small monster damage. */
97.     /* for weapons, and tools, rocks, and gems useful as weapons */
98.     schar oc_wsdam, oc_wldam; /* max small/large monster damage */
99.     schar oc_oc1, oc_oc2;
100. #define oc_hitbon oc_oc1 /* weapons: "to hit" bonus */
101. 
102. #define a_ac oc_oc1     /* armor class, used in ARM_BONUS in do.c */
103. #define a_can oc_oc2    /* armor: used in mhitu.c */
104. #define oc_level oc_oc2 /* books: spell level */
105. 
106.     unsigned short oc_nutrition; /* food value */
107. 
108.     unsigned long oc_sell_minseen;
109.     unsigned long oc_sell_maxseen;
110.     unsigned long oc_buy_minseen;
111.     unsigned long oc_buy_maxseen;
112. };
113. 
114. struct class_sym {
115.     char sym;
116.     const char *name;
117.     const char *explain;
118. };
119. 
120. struct objdescr {
121.     const char *oc_name;  /* actual name */
122.     const char *oc_descr; /* description when name unknown */
123. };
124. 
125. /*
126.  * All objects have a class. Make sure that all classes have a corresponding
127.  * symbol below.
128.  */
129. 
130. enum objclass_defchars {
131. #define OBJCLASS_DEFCHAR_ENUM
132. #include "defsym.h"
133. #undef OBJCLASS_DEFCHAR_ENUM
134. };
135. 
136. enum objclass_classes {
137.     RANDOM_CLASS =  0, /* used for generating random objects */
138. #define OBJCLASS_CLASS_ENUM
139. #include "defsym.h"
140. #undef OBJCLASS_CLASS_ENUM
141.     MAXOCLASSES
142. };
143. 
144. /* Default characters for object classes */
145. enum objclass_syms {
146. #define OBJCLASS_S_ENUM
147. #include "defsym.h"
148. #undef OBJCLASS_S_ENUM
149. };
150. 
151. /* for mkobj() use ONLY! odd '-SPBOOK_CLASS' is in case of unsigned enums */
152. #define SPBOOK_no_NOVEL (0 - (int) SPBOOK_CLASS)
153. 
154. #define BURNING_OIL (MAXOCLASSES + 1) /* Can be used as input to explode    */
155. #define MON_EXPLODE (MAXOCLASSES + 2) /* Exploding monster (e.g. gas spore) */
156. #define TRAP_EXPLODE (MAXOCLASSES + 3)
157. 
158. #if 0 /* moved to decl.h so that makedefs.c won't see them */
159. extern const struct class_sym
160.         def_oc_syms[MAXOCLASSES];       /* default class symbols */
161. extern uchar oc_syms[MAXOCLASSES];      /* current class symbols */
162. #endif
163. 
164. struct fruit {
165.     char fname[PL_FSIZ];
166.     int fid;
167.     struct fruit *nextf;
168. };
169. #define newfruit() (struct fruit *) alloc(sizeof(struct fruit))
170. #define dealloc_fruit(rind) free((genericptr_t)(rind))
171. 
172. enum objects_nums {
173. #define OBJECTS_ENUM
174. #include "objects.h"
175. #undef OBJECTS_ENUM
176.     NUM_OBJECTS
177. };
178. 
179. enum misc_object_nums {
180.     NUM_REAL_GEMS  = (LAST_REAL_GEM - FIRST_REAL_GEM + 1),
181.     NUM_GLASS_GEMS = (LAST_GLASS_GEM - FIRST_GLASS_GEM + 1),
182.     /* LAST_SPELL is SPE_BLANK_PAPER, guaranteeing that spl_book[] will
183.        have at least one unused slot at end to be used as a terminator */
184.     MAXSPELL       = (LAST_SPELL - FIRST_SPELL + 1),
185. };
186. 
187. extern NEARDATA struct objclass objects[NUM_OBJECTS + 1];
188. extern NEARDATA struct objdescr obj_descr[NUM_OBJECTS + 1];
189. 
190. #define OBJ_NAME(obj) (obj_descr[(obj).oc_name_idx].oc_name)
191. #define OBJ_DESCR(obj) (obj_descr[(obj).oc_descr_idx].oc_descr)
192. 
193. #define is_organic(otmp) (objects[otmp->otyp].oc_material <= WOOD)
194. #define is_metallic(otmp) \
195.     (objects[otmp->otyp].oc_material >= IRON            \
196.      && objects[otmp->otyp].oc_material <= MITHRIL)
197. 
198. /* primary damage: fire/rust/--- */
199. /* is_flammable(otmp), is_rottable(otmp) in mkobj.c */
200. #define is_rustprone(otmp) (objects[otmp->otyp].oc_material == IRON)
201. #define is_crackable(otmp) \
202.     (objects[(otmp)->otyp].oc_material == GLASS         \
203.      && (otmp)->oclass == ARMOR_CLASS) /* erosion_matters() */
204. /* secondary damage: rot/acid/acid */
205. #define is_corrodeable(otmp) \
206.     (objects[otmp->otyp].oc_material == COPPER          \
207.      || objects[otmp->otyp].oc_material == IRON)
208. /* subject to any damage */
209. #define is_damageable(otmp) \
210.     (is_rustprone(otmp) || is_flammable(otmp)           \
211.      || is_rottable(otmp) || is_corrodeable(otmp)       \
212.      || is_crackable(otmp))
213. 
214. #endif /* OBJCLASS_H */