Angband
object.h
Go to the documentation of this file.
1 
5 #ifndef INCLUDED_OBJECT_H
6 #define INCLUDED_OBJECT_H
7 
8 #include "z-rand.h"
9 #include "z-quark.h"
10 #include "z-bitflag.h"
11 #include "z-dice.h"
12 #include "obj-properties.h"
13 #include "effects.h"
14 
15 
16 /*** Game constants ***/
17 
21 enum
22 {
23  #define ELEM(a, b, c, d, e, f, g, col) ELEM_##a,
24  #include "list-elements.h"
25  #undef ELEM
26 
27  ELEM_MAX
28 };
29 
30 #define ELEM_BASE_MIN ELEM_ACID
31 #define ELEM_HIGH_MIN ELEM_POIS
32 #define ELEM_HIGH_MAX ELEM_DISEN
33 
37 enum
38 {
40  #define STAT(a, b, c, d, e, f, g, h) ID_##a,
41  #include "list-stats.h"
42  #undef STAT
43  #define OBJ_MOD(a, b, c, d) ID_##a,
44  #include "list-object-modifiers.h"
45  #undef OBJ_MOD
46  #define ID(a) ID_##a,
47  #include "list-identify-flags.h"
48  #undef ID
49  ID_MAX
50 };
51 
52 #define ID_MOD_MIN ID_STR
53 #define ID_MISC_MIN ID_ARTIFACT
54 
55 #define ID_SIZE FLAG_SIZE(ID_MAX)
56 
57 #define id_has(f, flag) flag_has_dbg(f, ID_SIZE, flag, #f, #flag)
58 #define id_next(f, flag) flag_next(f, ID_SIZE, flag)
59 #define id_is_empty(f) flag_is_empty(f, ID_SIZE)
60 #define id_is_full(f) flag_is_full(f, ID_SIZE)
61 #define id_is_inter(f1, f2) flag_is_inter(f1, f2, ID_SIZE)
62 #define id_is_subset(f1, f2) flag_is_subset(f1, f2, ID_SIZE)
63 #define id_is_equal(f1, f2) flag_is_equal(f1, f2, ID_SIZE)
64 #define id_on(f, flag) flag_on_dbg(f, ID_SIZE, flag, #f, #flag)
65 #define id_off(f, flag) flag_off(f, ID_SIZE, flag)
66 #define id_wipe(f) flag_wipe(f, ID_SIZE)
67 #define id_setall(f) flag_setall(f, ID_SIZE)
68 #define id_negate(f) flag_negate(f, ID_SIZE)
69 #define id_copy(f1, f2) flag_copy(f1, f2, ID_SIZE)
70 #define id_union(f1, f2) flag_union(f1, f2, ID_SIZE)
71 #define id_comp_union(f1, f2) flag_comp_union(f1, f2, ID_SIZE)
72 #define id_inter(f1, f2) flag_inter(f1, f2, ID_SIZE)
73 #define id_diff(f1, f2) flag_diff(f1, f2, ID_SIZE)
74 
75 
80 enum {
81  #define ORIGIN(a, b, c) ORIGIN_##a,
82  #include "list-origins.h"
83  #undef ORIGIN
84 
85  ORIGIN_MAX
86 };
87 
88 
89 /* Values for struct object->marked */
90 enum {
94 };
95 
96 
97 
98 /*** Structures ***/
99 
100 /* Brand type */
101 struct brand {
102  char *name;
103  int element;
105  bool known;
106  struct brand *next;
107 };
108 
109 /* Slay type */
110 struct slay {
111  char *name;
114  bool known;
115  struct slay *next;
116 };
117 
118 enum {
123 };
124 
125 /* Element info type */
126 struct element_info {
129 };
130 
134 struct activation {
135  struct activation *next;
136  char *name;
137  int index;
138  bool aim;
139  int power;
140  struct effect *effect;
141  char *message;
142  char *desc;
143 };
144 
145 extern struct activation *activations;
146 
150 typedef struct object_base
151 {
152  char *name;
153 
154  int tval;
155  struct object_base *next;
156 
157  int attr;
158 
162 
165 } object_base;
166 
167 extern object_base *kb_info;
168 
175 typedef struct object_kind
176 {
177  char *name;
178  char *text;
179 
181 
182  struct object_kind *next;
184 
185  int tval;
186  int sval;
188  random_value pval; /* Item extra-parameter */
189 
193  int ac;
195  int dd;
196  int ds;
197  int weight;
199  int cost;
206 
207  struct brand *brands;
208  struct slay *slays;
209 
211  wchar_t d_char;
214  int alloc_min;
215  int alloc_max;
216  int level;
218  struct effect *effect;
219  int power;
220  char *effect_msg;
227  struct flavor *flavor;
233  bool aware;
234  bool tried;
237  bool everseen;
238 } object_kind;
239 
240 extern object_kind *k_info;
241 
250 typedef struct artifact
251 {
252  char *name;
253  char *text;
254 
256 
257  struct artifact *next;
258 
259  int tval;
260  int sval;
262  int to_h;
263  int to_d;
264  int to_a;
265  int ac;
267  int dd;
268  int ds;
270  int weight;
272  int cost;
278 
279  struct brand *brands;
280  struct slay *slays;
281 
282  int level;
285  int alloc_min;
286  int alloc_max;
288  bool created;
289  bool seen;
290  bool everseen;
293  char *alt_msg;
294 
296 } artifact_type;
297 
301 extern artifact_type *a_info;
302 
303 
310 };
311 
315 typedef struct ego_item
316 {
317  struct ego_item *next;
318 
319  char *name;
320  char *text;
321 
323 
324  int cost; /* Ego-item "cost" */
325 
332 
333  struct brand *brands;
334  struct slay *slays;
335 
336  int level; /* Minimum level */
337  int rarity; /* Object rarity */
338  int rating; /* Level rating boost */
340  int alloc_min;
341  int alloc_max;
344 
345  random_value to_h; /* Extra to-hit bonus */
346  random_value to_d; /* Extra to-dam bonus */
347  random_value to_a; /* Extra to-ac bonus */
348 
349  int min_to_h; /* Minimum to-hit value */
350  int min_to_d; /* Minimum to-dam value */
351  int min_to_a; /* Minimum to-ac value */
352 
353  struct effect *effect;
354  char *effect_msg;
357  bool everseen; /* Do not spoil ignore menus */
358 } ego_item_type;
359 
360 /*
361  * The ego-item arrays
362  */
363 extern ego_item_type *e_info;
364 
365 
366 /*
367  * Object information, for a specific object.
368  *
369  * Note that inscriptions are now handled via the "quark_str()" function
370  * applied to the "note" field, which will return NULL if "note" is zero.
371  *
372  * Each cave grid points to one (or zero) objects via the "obj" field in
373  * its "squares" struct. Each object then points to one (or zero) objects
374  * via the "next" field, and (aside from the first) back via its "prev"
375  * field, forming a doubly linked list, which in game terms represents a
376  * stack of objects in the same grid.
377  *
378  * Each monster points to one (or zero) objects via the "held_obj"
379  * field (see monster.h). Each object then points to one (or zero) objects
380  * and back to previous objects by its own "next" and "prev" fields,
381  * forming a doubly linked list, which in game terms represents the
382  * monster's inventory.
383  *
384  * The "held_m_idx" field is used to indicate which monster, if any,
385  * is holding the object. Objects being held have "ix = 0" and "iy = 0".
386  *
387  * Note that object records are not now copied, but allocated on object
388  * creation and freed on object destruction. These records are handed
389  * around between player and monster inventories and the floor on a fairly
390  * regular basis, and care must be taken when handling such objects.
391  */
392 typedef struct object
393 {
394  struct object_kind *kind;
395  struct ego_item *ego;
397 
398  struct object *prev; /* Previous object in a pile */
399  struct object *next; /* Next object in a pile */
400 
401  byte iy; /* Y-position on map, or zero */
402  byte ix; /* X-position on map, or zero */
403 
404  byte tval; /* Item type (from kind) */
405  byte sval; /* Item sub-type (from kind) */
406 
407  s16b pval; /* Item extra-parameter */
408 
409  s16b weight; /* Item weight */
410 
417 
418  struct brand *brands;
419  struct slay *slays;
420 
421  s16b ac; /* Normal AC */
422  s16b to_a; /* Plusses to AC */
423  s16b to_h; /* Plusses to hit */
424  s16b to_d; /* Plusses to damage */
425 
426  byte dd, ds; /* Damage dice/sides */
427 
428  struct effect *effect;
429  char *effect_msg;
432  s16b timeout; /* Timeout Counter */
433 
434  byte number; /* Number of items */
435  byte marked; /* Object is marked */
436  byte ignore; /* Object is ignored */
437 
438  s16b held_m_idx; /* Monster holding us (if any) */
439  s16b mimicking_m_idx; /* Monster mimicking us (if any) */
440 
441  byte origin; /* How this item was found */
442  byte origin_depth; /* What depth the item was found at */
443  u16b origin_xtra; /* Extra information about origin */
444 
445  quark_t note; /* Inscription index */
446 } object_type;
447 
448 struct flavor
449 {
450  char *text;
451  struct flavor *next;
452  unsigned int fidx;
453 
454  byte tval; /* Associated object type */
455  byte sval; /* Associated object sub-type */
456 
457  byte d_attr; /* Default flavor attribute */
458  wchar_t d_char; /* Default flavor character */
459 };
460 
461 extern struct flavor *flavors;
462 
463 
464 typedef bool (*item_tester)(const struct object *);
465 
466 
467 #endif /* !INCLUDED_OBJECT_H */