OSDN Git Service

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