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-type.h"
9 #include "z-quark.h"
10 #include "z-bitflag.h"
11 #include "z-dice.h"
12 #include "obj-properties.h"
13 
14 
15 /*** Game constants ***/
16 
20 enum
21 {
22  #define ELEM(a) ELEM_##a,
23  #include "list-elements.h"
24  #undef ELEM
25 
26  ELEM_MAX
27 };
28 
29 #define ELEM_BASE_MIN ELEM_ACID
30 #define ELEM_BASE_MAX (ELEM_COLD + 1)
31 #define ELEM_HIGH_MIN ELEM_POIS
32 #define ELEM_HIGH_MAX (ELEM_DISEN + 1)
33 
38 enum {
39  #define ORIGIN(a, b, c) ORIGIN_##a,
40  #include "list-origins.h"
41  #undef ORIGIN
42 
43  ORIGIN_MAX
44 };
45 
46 
47 /*** Structures ***/
48 
52 struct effect {
53  struct effect *next;
56  int y;
57  int x;
58  int subtype;
59  int radius;
60  int other;
61  char *msg;
62 };
63 
67 struct chest_trap {
68  struct chest_trap *next;
69  char *name;
70  char *code;
71  int level;
72  struct effect *effect;
73  int pval;
74  bool destroy;
75  bool magic;
76  char *msg;
77  char *msg_death;
78 };
79 
83 struct brand {
84  char *code;
85  char *name;
86  char *verb;
90  int power;
91  struct brand *next;
92 };
93 
97 struct slay {
98  char *code;
99  char *name;
100  char *base;
101  char *melee_verb;
102  char *range_verb;
106  int power;
107  struct slay *next;
108 };
109 
113 struct curse {
114  struct curse *next;
115  char *name;
116  bool *poss;
117  struct object *obj;
118  char *conflict;
119  bitflag conflict_flags[OF_SIZE];
120  char *desc;
121 };
122 
123 enum {
127 };
128 
132 struct element_info {
135 };
136 
140 struct activation {
141  struct activation *next;
142  char *name;
143  int index;
144  bool aim;
145  int power;
146  struct effect *effect;
147  char *message;
148  char *desc;
149 };
150 
151 extern struct activation *activations;
152 
156 struct object_base {
157  char *name;
158 
159  int tval;
160  struct object_base *next;
161 
162  int attr;
163 
166  struct element_info el_info[ELEM_MAX];
167 
171 };
172 
173 extern struct object_base *kb_info;
174 
181 struct object_kind {
182  char *name;
183  char *text;
184 
185  struct object_base *base;
186 
187  struct object_kind *next;
189 
190  int tval;
191  int sval;
193  random_value pval; /* Item extra-parameter */
194 
198  int ac;
200  int dd;
201  int ds;
202  int weight;
204  int cost;
210  struct element_info el_info[ELEM_MAX];
211 
212  bool *brands;
213  bool *slays;
214  int *curses;
217  wchar_t d_char;
220  int alloc_min;
221  int alloc_max;
222  int level;
225  struct effect *effect;
226  int power;
227  char *effect_msg;
234  struct flavor *flavor;
241  bool aware;
242  bool tried;
245  bool everseen;
246 };
247 
248 extern struct object_kind *k_info;
249 extern struct object_kind *unknown_item_kind;
250 extern struct object_kind *unknown_gold_kind;
251 extern struct object_kind *pile_kind;
252 extern struct object_kind *curse_object_kind;
253 
262 struct artifact {
263  char *name;
264  char *text;
265 
267 
268  struct artifact *next;
269 
270  int tval;
271  int sval;
273  int to_h;
274  int to_d;
275  int to_a;
276  int ac;
278  int dd;
279  int ds;
281  int weight;
283  int cost;
288  struct element_info el_info[ELEM_MAX];
289 
290  bool *brands;
291  bool *slays;
292  int *curses;
294  int level;
297  int alloc_min;
298  int alloc_max;
300  bool created;
301  bool seen;
302  bool everseen;
305  char *alt_msg;
306 
308 };
309 
313 extern struct artifact *a_info;
314 
315 
319 struct poss_item {
321  struct poss_item *next;
322 };
323 
327 struct ego_item {
328  struct ego_item *next;
329 
330  char *name;
331  char *text;
332 
334 
335  int cost; /* Ego-item "cost" */
336 
343  struct element_info el_info[ELEM_MAX];
344 
345  bool *brands;
346  bool *slays;
347  int *curses;
349  int rating; /* Level rating boost */
351  int alloc_min;
352  int alloc_max;
355 
356  random_value to_h; /* Extra to-hit bonus */
357  random_value to_d; /* Extra to-dam bonus */
358  random_value to_a; /* Extra to-ac bonus */
359 
360  int min_to_h; /* Minimum to-hit value */
361  int min_to_d; /* Minimum to-dam value */
362  int min_to_a; /* Minimum to-ac value */
363 
364  struct effect *effect;
365  char *effect_msg;
368  bool everseen; /* Do not spoil ignore menus */
369 };
370 
371 /*
372  * The ego-item arrays
373  */
374 extern struct ego_item *e_info;
375 
379 enum {
384 };
385 
386 struct curse_data {
387  int power;
388  int timeout;
389 };
390 
417 struct object {
418  struct object_kind *kind;
419  struct ego_item *ego;
420  struct artifact *artifact;
422  struct object *prev;
423  struct object *next;
424  struct object *known;
428  struct loc grid;
446  struct element_info el_info[ELEM_MAX];
447  bool *brands;
448  bool *slays;
449  struct curse_data *curses;
451  struct effect *effect;
452  char *effect_msg;
468 };
469 
473 static struct object const OBJECT_NULL = {
474  .kind = NULL,
475  .ego = NULL,
476  .artifact = NULL,
477  .prev = NULL,
478  .next = NULL,
479  .known = NULL,
480  .oidx = 0,
481  .grid = { 0, 0 },
482  .tval = 0,
483  .sval = 0,
484  .pval = 0,
485  .weight = 0,
486  .dd = 0,
487  .ds = 0,
488  .ac = 0,
489  .to_a = 0,
490  .to_h = 0,
491  .to_d = 0,
492  .flags = { 0 },
493  .modifiers = { 0 },
494  .el_info = { { 0, 0 } },
495  .brands = NULL,
496  .slays = NULL,
497  .curses = NULL,
498  .effect = NULL,
499  .effect_msg = NULL,
500  .activation = NULL,
501  .time = { 0, 0, 0, 0 },
502  .timeout = 0,
503  .number = 0,
504  .notice = 0,
505  .held_m_idx = 0,
506  .mimicking_m_idx = 0,
507  .origin = 0,
508  .origin_depth = 0,
509  .origin_race = NULL,
510  .note = 0,
511 };
512 
513 struct flavor
514 {
515  char *text;
516  struct flavor *next;
517  unsigned int fidx;
518 
519  byte tval; /* Associated object type */
520  byte sval; /* Associated object sub-type */
521 
522  byte d_attr; /* Default flavor attribute */
523  wchar_t d_char; /* Default flavor character */
524 };
525 
526 extern struct flavor *flavors;
527 
528 
529 typedef bool (*item_tester)(const struct object *);
530 
531 
532 #endif /* !INCLUDED_OBJECT_H */
random_value stack_size
Number to generate.
Definition: object.h:232
uint16_t u16b
Definition: h-basic.h:161
int alloc_max
Lowest normal dungeon level.
Definition: object.h:221
bool(* item_tester)(const struct object *)
Definition: object.h:529
bool * brands
Definition: object.h:290
int rating
Definition: object.h:349
char * message
Definition: object.h:147
int cost
Definition: object.h:335
byte origin_depth
What depth the item was found at.
Definition: object.h:464
int * curses
Array of curse powers.
Definition: object.h:347
Definition: z-dice.c:30
struct flavor * flavor
Special object flavor (or zero)
Definition: object.h:234
u32b eidx
Definition: object.h:333
bool everseen
Definition: object.h:368
definitions and functions for object flags and modifiers
u32b aidx
Definition: object.h:266
Monster "race" information, including racial memories.
Definition: monster.h:307
struct object_kind * k_info
Definition: obj-util.c:47
bitflag notice
Attention paid to the object.
Definition: object.h:458
char * msg_death
Definition: object.h:77
int min_modifiers[OBJ_MOD_MAX]
Definition: object.h:342
struct curse * next
Definition: object.h:114
struct object * next
Next object in a pile.
Definition: object.h:423
struct object_base * next
Definition: object.h:160
struct ego_item * next
Definition: object.h:328
Definition: object.h:513
char * text
Definition: object.h:183
Low-level bit vector manipulation.
int attr
Definition: object.h:162
struct ego_item * e_info
Definition: obj-util.c:49
int alloc_prob
Difficulty level for activation.
Definition: object.h:296
Definition: object.h:380
char * name
Definition: object.h:142
s16b to_a
Plusses to AC.
Definition: object.h:440
byte origin
How this item was found.
Definition: object.h:463
char * alt_msg
Definition: object.h:305
uint32_t u32b
Definition: h-basic.h:164
bool * poss
Definition: object.h:116
Slay type.
Definition: object.h:97
Definition: z-type.h:24
int resist_flag
Definition: object.h:87
bool everseen
Kind has been seen (to despoilify ignore menus)
Definition: object.h:245
struct object_base * base
Definition: object.h:185
s16b held_m_idx
Monster holding us (if any)
Definition: object.h:460
int race_flag
Definition: object.h:103
Information about object kinds, including player knowledge.
Definition: object.h:181
int ds
Base damage sides.
Definition: object.h:279
byte tval
Item type (from kind)
Definition: object.h:430
char * name
Definition: object.h:115
int o_multiplier
Definition: object.h:105
struct activation * activation
Artifact activation.
Definition: object.h:304
char * base
Definition: object.h:100
int power
Definition: object.h:387
byte ds
Number of sides on each damage die.
Definition: object.h:438
char * conflict
Definition: object.h:118
char * desc
Definition: object.h:120
struct object_kind * unknown_item_kind
Initialize objects
Definition: obj-init.c:1521
Structure for possible object kinds for an ego item.
Definition: object.h:319
int dd
Damage dice.
Definition: object.h:200
s16b to_d
Plusses to damage.
Definition: object.h:442
int tval
General artifact type (see TV_ macros)
Definition: object.h:270
int other
Extra parameter to be passed to the handler.
Definition: object.h:60
bool seen
Whether this artifact has been seen this game.
Definition: object.h:301
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:364
random_value to_d
Definition: object.h:357
random_value to_a
Bonus to armor.
Definition: object.h:197
u16b oidx
Item list index, if any.
Definition: object.h:426
Definition: object.h:126
char * msg
Message for deth or whatever.
Definition: object.h:61
Definition: object.h:386
int alloc_max
Minimum depth (can appear earlier)
Definition: object.h:298
struct object_base * kb_info
Definition: obj-util.c:46
int sval
Artifact sub-type.
Definition: object.h:271
struct flavor * flavors
Definition: obj-util.c:50
bool destroy
Definition: object.h:74
Definition: object.h:125
uint8_t byte
Definition: h-basic.h:159
int break_perc
Definition: object.h:168
static const char * kind_flags[]
Definition: obj-init.c:73
Activation structure.
Definition: object.h:140
bool aware
Set if player is aware of the kind's effects.
Definition: object.h:241
int cost
Object base cost.
Definition: object.h:204
bool tried
Set if kind has been tried.
Definition: object.h:242
Information about object types, like rods, wands, etc.
Definition: object.h:156
random_value to_h
Bonus to hit.
Definition: object.h:195
int * curses
Array of curse powers.
Definition: object.h:214
int alloc_min
Highest normal dungeon level.
Definition: object.h:220
s16b ac
Normal AC.
Definition: object.h:439
int ac
Base armor.
Definition: object.h:198
const s16 modifiers[]
Definition: main-nds.c:63
random_value to_d
Bonus to damage.
Definition: object.h:196
bitflag flags
Definition: object.h:134
struct effect * effect
Definition: object.h:146
bool magic
Definition: object.h:75
random_value charge
Number of charges (staves/wands)
Definition: object.h:229
char * code
Definition: object.h:70
char * verb
Definition: object.h:86
char * effect_msg
Definition: object.h:365
Definition: object.h:382
byte ignore
Ignore settings.
Definition: object.h:244
dice_t * dice
Dice expression used in the effect.
Definition: object.h:55
char * melee_verb
Definition: object.h:101
char * effect_msg
Definition: object.h:227
byte d_attr
Default object attribute.
Definition: object.h:216
char * text
Definition: object.h:264
int power
Definition: object.h:106
int alloc_min
Chance of being generated (i.e.
Definition: object.h:297
unsigned int fidx
Definition: object.h:517
int alloc_max
Minimum depth (can appear earlier)
Definition: object.h:352
int multiplier
Definition: object.h:104
Object information, for a specific object.
Definition: object.h:417
int * curses
Array of curse powers.
Definition: object.h:292
s16b res_level
Definition: object.h:133
struct object * prev
Previous object in a pile.
Definition: object.h:422
s16b weight
Item weight.
Definition: object.h:435
int power
Definition: object.h:145
int min_to_a
Definition: object.h:362
char * range_verb
Definition: object.h:102
struct object_kind * unknown_gold_kind
Definition: obj-init.c:1522
struct artifact * artifact
Artifact info of the object, if any.
Definition: object.h:420
int ds
Damage sides.
Definition: object.h:201
int gen_mult_prob
Probability of generating more than one.
Definition: object.h:231
int num_svals
Definition: object.h:170
int pval
Definition: object.h:73
u32b kidx
Definition: object.h:188
int tval
General object type (see TV_ macros)
Definition: object.h:190
struct activation * activation
Artifact activation, if applicable.
Definition: object.h:453
int min_to_h
Definition: object.h:360
bool created
Maximum depth (will NEVER appear deeper)
Definition: object.h:300
char * code
Definition: object.h:98
int ac
Base armor.
Definition: object.h:276
int x
X coordinate or distance.
Definition: object.h:57
s16b mimicking_m_idx
Monster mimicking us (if any)
Definition: object.h:461
struct artifact * a_info
The artifact arrays.
Definition: obj-util.c:48
int level
Definition: object.h:294
byte d_attr
Definition: object.h:522
bool * slays
Definition: object.h:346
struct object_kind * next
Definition: object.h:187
bool * brands
Array of brand structures.
Definition: object.h:447
byte dd
Number of damage dice.
Definition: object.h:437
Represent more complex dice than random_value.
png_uint_32 int flags
Definition: libpng12/png.h:1681
bitflag flags_off[OF_SIZE]
Flags to remove.
Definition: object.h:338
int alloc_prob
Definition: object.h:350
bool * slays
Definition: object.h:291
struct slay * next
Definition: object.h:107
char * text
Definition: object.h:331
byte sval
Item sub-type (from kind)
Definition: object.h:431
int power
Power of the item's effect.
Definition: object.h:226
List of object origins.
int radius
Radius of the effect (if it has one)
Definition: object.h:59
byte bitflag
Definition: z-bitflag.h:27
wchar_t d_char
Default object character.
Definition: object.h:217
int level
Level (difficulty of activation)
Definition: object.h:222
struct activation * next
Definition: object.h:141
struct chest_trap * next
Definition: object.h:68
struct effect * next
Definition: object.h:53
struct object_kind * curse_object_kind
Definition: obj-init.c:1524
random_value time
Recharge time (rods/activation)
Definition: object.h:366
int16_t s16b
Definition: h-basic.h:162
bool * brands
Definition: object.h:345
int y
Y coordinate or distance.
Definition: object.h:56
struct flavor * next
Definition: object.h:516
bool * slays
Array of slay structures.
Definition: object.h:448
int sval
Object sub-type.
Definition: object.h:191
int dd
Base damage dice.
Definition: object.h:278
Element info type.
Definition: object.h:132
random_value to_a
Definition: object.h:358
int to_h
Bonus to hit.
Definition: object.h:273
quark_t note_aware
Also saved in savefile.
Definition: object.h:238
u32b kidx
Definition: object.h:320
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:225
Support various data types.
A struct representing a strategy for making a dice roll.
Definition: z-rand.h:40
char * name
Definition: object.h:263
bool aim
Definition: object.h:144
Save memory by storing strings in a global array, ensuring that each is only allocated once...
int min_to_d
Definition: object.h:361
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:451
int subtype
Projection type, timed effect type, etc.
Definition: object.h:58
Information about ego-items.
Definition: object.h:327
Definition: object.h:56
#define OF_SIZE
Definition: obj-properties.h:121
static struct object const OBJECT_NULL
Null object constant, for safe initialization.
Definition: object.h:473
int alloc_prob
Allocation: commonness.
Definition: object.h:219
struct poss_item * next
Definition: object.h:321
Definition: obj-properties.h:114
Definition: object.h:381
struct object * obj
Definition: object.h:117
int to_a
Bonus to armor.
Definition: object.h:275
random_value to_h
Definition: object.h:356
int weight
Weight, in 1/10lbs.
Definition: object.h:202
struct curse_data * curses
Array of curse powers and timeouts.
Definition: object.h:449
struct poss_item * poss_items
Maximum depth (will NEVER appear deeper)
Definition: object.h:354
char * desc
Definition: object.h:148
char * effect_msg
Message on use.
Definition: object.h:452
random_value pval
Definition: object.h:193
struct object_kind * pile_kind
Definition: obj-init.c:1523
int index
Definition: object.h:143
struct activation * activation
Artifact-like activation.
Definition: object.h:224
struct artifact * next
Definition: object.h:268
int cost
Artifact (pseudo-)worth.
Definition: object.h:283
int tval
Definition: object.h:159
int max_stack
Definition: object.h:169
bool * slays
Definition: object.h:213
wchar_t d_char
Definition: object.h:523
quark_t note_unaware
Autoinscription quark number.
Definition: object.h:239
Curse type.
Definition: object.h:113
s16b pval
Item extra-parameter.
Definition: object.h:433
byte number
Number of items.
Definition: object.h:457
random_value time
Recharge time (rods/activation)
Definition: object.h:454
byte tval
Definition: object.h:519
struct brand * next
Definition: object.h:91
int weight
Weight in 1/10lbs.
Definition: object.h:281
struct activation * activations
Definition: obj-randart.c:45
Effect.
Definition: object.h:52
quark_t note
Inscription index.
Definition: object.h:467
char * name
Definition: object.h:69
bool * brands
Definition: object.h:212
int level
Definition: object.h:71
int o_multiplier
Definition: object.h:89
struct monster_race * origin_race
Monster race that dropped it.
Definition: object.h:465
char * name
Definition: object.h:85
char * text
Definition: object.h:515
#define const
Definition: zconf.h:124
struct ego_item * ego
Ego item info of the object, if any.
Definition: object.h:419
int to_d
Bonus to damage.
Definition: object.h:274
int timeout
Definition: object.h:388
int power
Definition: object.h:90
random_value time
Recharge time (rods/activation)
Definition: object.h:228
struct effect * effect
Definition: object.h:72
struct object * known
Known version of this object.
Definition: object.h:424
s16b to_h
Plusses to hit.
Definition: object.h:441
Definition: object.h:124
s16b timeout
Timeout Counter.
Definition: object.h:455
#define KF_SIZE
Definition: obj-properties.h:141
char * name
Definition: object.h:330
bool everseen
Whether this artifact has ever been seen.
Definition: object.h:302
struct object_kind * kind
Kind of the object.
Definition: object.h:418
int alloc_min
Chance of being generated (i.e.
Definition: object.h:351
char * name
Definition: object.h:99
Brand type.
Definition: object.h:83
Information about artifacts.
Definition: object.h:262
u16b index
The effect index.
Definition: object.h:54
size_t quark_t
Quark type.
Definition: z-quark.h:29
char * name
Definition: object.h:157
char * msg
Definition: object.h:76
random_value time
Recharge time (if appropriate)
Definition: object.h:307
int multiplier
Definition: object.h:88
Chests.
Definition: object.h:67
Definition: object.h:383
char * name
Definition: object.h:182
byte sval
Definition: object.h:520
Write value lines for a set of modifiers.
char * code
Definition: object.h:84