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 
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 params[3];
57 };
58 
62 struct brand {
63  char *code;
64  char *name;
65  char *verb;
66  int element;
69  int power;
70  struct brand *next;
71 };
72 
76 struct slay {
77  char *code;
78  char *name;
79  char *base;
80  char *melee_verb;
81  char *range_verb;
82  int race_flag;
84  int power;
85  struct slay *next;
86 };
87 
91 struct curse {
92  struct curse *next;
93  char *name;
94  bool *poss;
95  struct object *obj;
96  char *conflict;
97  char *desc;
98 };
99 
100 enum {
104 };
105 
109 struct element_info {
112 };
113 
117 struct activation {
118  struct activation *next;
119  char *name;
120  int index;
121  bool aim;
122  int power;
123  struct effect *effect;
124  char *message;
125  char *desc;
126 };
127 
128 extern struct activation *activations;
129 
133 struct object_base {
134  char *name;
135 
136  int tval;
137  struct object_base *next;
138 
139  int attr;
140 
144 
148 };
149 
150 extern struct object_base *kb_info;
151 
158 struct object_kind {
159  char *name;
160  char *text;
161 
162  struct object_base *base;
163 
164  struct object_kind *next;
166 
167  int tval;
168  int sval;
170  random_value pval; /* Item extra-parameter */
171 
175  int ac;
177  int dd;
178  int ds;
179  int weight;
181  int cost;
188 
189  bool *brands;
190  bool *slays;
191  int *curses;
194  wchar_t d_char;
197  int alloc_min;
198  int alloc_max;
199  int level;
202  struct effect *effect;
203  int power;
204  char *effect_msg;
211  struct flavor *flavor;
218  bool aware;
219  bool tried;
222  bool everseen;
223 };
224 
225 extern struct object_kind *k_info;
226 extern struct object_kind *unknown_item_kind;
227 extern struct object_kind *unknown_gold_kind;
228 extern struct object_kind *pile_kind;
229 extern struct object_kind *curse_object_kind;
230 
239 struct artifact {
240  char *name;
241  char *text;
242 
244 
245  struct artifact *next;
246 
247  int tval;
248  int sval;
250  int to_h;
251  int to_d;
252  int to_a;
253  int ac;
255  int dd;
256  int ds;
258  int weight;
260  int cost;
266 
267  bool *brands;
268  bool *slays;
269  int *curses;
271  int level;
274  int alloc_min;
275  int alloc_max;
277  bool created;
278  bool seen;
279  bool everseen;
282  char *alt_msg;
283 
285 };
286 
290 extern struct artifact *a_info;
291 
292 
296 struct poss_item {
298  struct poss_item *next;
299 };
300 
304 struct ego_item {
305  struct ego_item *next;
306 
307  char *name;
308  char *text;
309 
311 
312  int cost; /* Ego-item "cost" */
313 
321 
322  bool *brands;
323  bool *slays;
324  int *curses;
326  int rating; /* Level rating boost */
328  int alloc_min;
329  int alloc_max;
332 
333  random_value to_h; /* Extra to-hit bonus */
334  random_value to_d; /* Extra to-dam bonus */
335  random_value to_a; /* Extra to-ac bonus */
336 
337  int min_to_h; /* Minimum to-hit value */
338  int min_to_d; /* Minimum to-dam value */
339  int min_to_a; /* Minimum to-ac value */
340 
341  struct effect *effect;
342  char *effect_msg;
345  bool everseen; /* Do not spoil ignore menus */
346 };
347 
348 /*
349  * The ego-item arrays
350  */
351 extern struct ego_item *e_info;
352 
356 enum {
361 };
362 
363 struct curse_data {
364  int power;
365  int timeout;
366 };
367 
394 struct object {
395  struct object_kind *kind;
396  struct ego_item *ego;
397  struct artifact *artifact;
399  struct object *prev;
400  struct object *next;
401  struct object *known;
425  bool *brands;
426  bool *slays;
427  struct curse_data *curses;
429  struct effect *effect;
430  char *effect_msg;
446 };
447 
451 static struct object const OBJECT_NULL = {
452  .kind = NULL,
453  .ego = NULL,
454  .artifact = NULL,
455  .prev = NULL,
456  .next = NULL,
457  .known = NULL,
458  .oidx = 0,
459  .iy = 0,
460  .ix = 0,
461  .tval = 0,
462  .sval = 0,
463  .pval = 0,
464  .weight = 0,
465  .dd = 0,
466  .ds = 0,
467  .ac = 0,
468  .to_a = 0,
469  .to_h = 0,
470  .to_d = 0,
471  .flags = { 0 },
472  .modifiers = { 0 },
473  .el_info = { { 0, 0 } },
474  .brands = NULL,
475  .slays = NULL,
476  .curses = NULL,
477  .effect = NULL,
478  .effect_msg = NULL,
479  .activation = NULL,
480  .time = { 0, 0, 0, 0 },
481  .timeout = 0,
482  .number = 0,
483  .notice = 0,
484  .held_m_idx = 0,
485  .mimicking_m_idx = 0,
486  .origin = 0,
487  .origin_depth = 0,
488  .origin_race = NULL,
489  .note = 0,
490 };
491 
492 struct flavor
493 {
494  char *text;
495  struct flavor *next;
496  unsigned int fidx;
497 
498  byte tval; /* Associated object type */
499  byte sval; /* Associated object sub-type */
500 
501  byte d_attr; /* Default flavor attribute */
502  wchar_t d_char; /* Default flavor character */
503 };
504 
505 extern struct flavor *flavors;
506 
507 
508 typedef bool (*item_tester)(const struct object *);
509 
510 
511 #endif /* !INCLUDED_OBJECT_H */
random_value stack_size
Number to generate.
Definition: object.h:209
uint16_t u16b
Definition: h-basic.h:169
int alloc_max
Lowest normal dungeon level.
Definition: object.h:198
bool * brands
Definition: object.h:267
int rating
Definition: object.h:326
char * message
Definition: object.h:124
int cost
Definition: object.h:312
byte origin_depth
What depth the item was found at.
Definition: object.h:442
int * curses
Array of curse powers.
Definition: object.h:324
Definition: z-dice.c:30
struct flavor * flavor
Special object flavor (or zero)
Definition: object.h:211
u32b eidx
Definition: object.h:310
bool everseen
Definition: object.h:345
definitions and functions for object flags and modifiers
u32b aidx
Definition: object.h:243
Monster "race" information, including racial memories.
Definition: monster.h:266
struct object_kind * k_info
Definition: obj-util.c:47
bitflag notice
Attention paid to the object.
Definition: object.h:436
int min_modifiers[OBJ_MOD_MAX]
Definition: object.h:319
struct curse * next
Definition: object.h:92
struct object * next
Next object in a pile.
Definition: object.h:400
struct object_base * next
Definition: object.h:137
struct ego_item * next
Definition: object.h:305
Definition: object.h:492
char * text
Definition: object.h:160
Low-level bit vector manipulation.
bitflag kind_flags[KF_SIZE]
Kind flags.
Definition: object.h:184
Definition: object.h:103
int attr
Definition: object.h:139
struct ego_item * e_info
Definition: obj-util.c:49
int alloc_prob
Difficulty level for activation.
Definition: object.h:273
char * name
Definition: object.h:119
s16b to_a
Plusses to AC.
Definition: object.h:418
byte origin
How this item was found.
Definition: object.h:441
char * alt_msg
Definition: object.h:282
uint32_t u32b
Definition: h-basic.h:172
int params[3]
Extra parameters to be passed to the handler.
Definition: object.h:56
bool * poss
Definition: object.h:94
Slay type.
Definition: object.h:76
int resist_flag
Definition: object.h:67
bool everseen
Kind has been seen (to despoilify ignore menus)
Definition: object.h:222
struct object_base * base
Definition: object.h:162
s16b held_m_idx
Monster holding us (if any)
Definition: object.h:438
int race_flag
Definition: object.h:82
Information about object kinds, including player knowledge.
Definition: object.h:158
int ds
Base damage sides.
Definition: object.h:256
byte tval
Item type (from kind)
Definition: object.h:408
char * name
Definition: object.h:93
struct activation * activation
Artifact activation.
Definition: object.h:281
char * base
Definition: object.h:79
int power
Definition: object.h:364
byte ds
Number of sides on each damage die.
Definition: object.h:416
char * conflict
Definition: object.h:96
char * desc
Definition: object.h:97
struct object_kind * unknown_item_kind
Initialize objects
Definition: obj-init.c:1485
int element
Definition: object.h:66
Structure for possible object kinds for an ego item.
Definition: object.h:296
int dd
Damage dice.
Definition: object.h:177
s16b to_d
Plusses to damage.
Definition: object.h:420
int tval
General artifact type (see TV_ macros)
Definition: object.h:247
bool seen
Whether this artifact has been seen this game.
Definition: object.h:278
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:341
random_value to_d
Definition: object.h:334
random_value to_a
Bonus to armor.
Definition: object.h:174
u16b oidx
Item list index, if any.
Definition: object.h:403
Definition: object.h:363
bitflag kind_flags[KF_SIZE]
Kind flags.
Definition: object.h:316
int alloc_max
Minimum depth (can appear earlier)
Definition: object.h:275
struct object_base * kb_info
Definition: obj-util.c:46
int sval
Artifact sub-type.
Definition: object.h:248
struct flavor * flavors
Definition: obj-util.c:50
uint8_t byte
Definition: h-basic.h:167
bitflag kind_flags[KF_SIZE]
Kind flags.
Definition: object.h:142
int break_perc
Definition: object.h:145
struct element_info el_info[ELEM_MAX]
Definition: object.h:187
Activation structure.
Definition: object.h:117
bool aware
Set if player is aware of the kind's effects.
Definition: object.h:218
int cost
Object base cost.
Definition: object.h:181
bool tried
Set if kind has been tried.
Definition: object.h:219
Information about object types, like rods, wands, etc.
Definition: object.h:133
random_value to_h
Bonus to hit.
Definition: object.h:172
int * curses
Array of curse powers.
Definition: object.h:191
int alloc_min
Highest normal dungeon level.
Definition: object.h:197
s16b ac
Normal AC.
Definition: object.h:417
bool(* item_tester)(const struct object *)
Definition: object.h:508
int ac
Base armor.
Definition: object.h:175
s16b modifiers[OBJ_MOD_MAX]
Object modifiers.
Definition: object.h:423
random_value to_d
Bonus to damage.
Definition: object.h:173
Definition: object.h:102
bitflag flags
Definition: object.h:111
struct effect * effect
Definition: object.h:123
random_value charge
Number of charges (staves/wands)
Definition: object.h:206
bitflag flags[OF_SIZE]
Object flags.
Definition: object.h:422
char * verb
Definition: object.h:65
char * effect_msg
Definition: object.h:342
byte ignore
Ignore settings.
Definition: object.h:221
dice_t * dice
Dice expression used in the effect.
Definition: object.h:55
char * melee_verb
Definition: object.h:80
char * effect_msg
Definition: object.h:204
byte d_attr
Default object attribute.
Definition: object.h:193
char * text
Definition: object.h:241
int power
Definition: object.h:84
int alloc_min
Chance of being generated (i.e.
Definition: object.h:274
unsigned int fidx
Definition: object.h:496
int alloc_max
Minimum depth (can appear earlier)
Definition: object.h:329
int multiplier
Definition: object.h:83
Object information, for a specific object.
Definition: object.h:394
int * curses
Array of curse powers.
Definition: object.h:269
s16b res_level
Definition: object.h:110
struct object * prev
Previous object in a pile.
Definition: object.h:399
s16b weight
Item weight.
Definition: object.h:413
int power
Definition: object.h:122
int min_to_a
Definition: object.h:339
char * range_verb
Definition: object.h:81
struct object_kind * unknown_gold_kind
Definition: obj-init.c:1486
struct artifact * artifact
Artifact info of the object, if any.
Definition: object.h:397
int ds
Damage sides.
Definition: object.h:178
int gen_mult_prob
Probability of generating more than one.
Definition: object.h:208
int num_svals
Definition: object.h:147
u32b kidx
Definition: object.h:165
int tval
General object type (see TV_ macros)
Definition: object.h:167
struct activation * activation
Artifact activation, if applicable.
Definition: object.h:431
bitflag flags[OF_SIZE]
Definition: object.h:141
int min_to_h
Definition: object.h:337
bool created
Maximum depth (will NEVER appear deeper)
Definition: object.h:277
int modifiers[OBJ_MOD_MAX]
Definition: object.h:264
char * code
Definition: object.h:77
int ac
Base armor.
Definition: object.h:253
struct element_info el_info[ELEM_MAX]
Definition: object.h:143
s16b mimicking_m_idx
Monster mimicking us (if any)
Definition: object.h:439
struct artifact * a_info
The artifact arrays.
Definition: obj-util.c:48
Definition: object.h:357
int level
Definition: object.h:271
byte d_attr
Definition: object.h:501
bool * slays
Definition: object.h:323
struct element_info el_info[ELEM_MAX]
Object element info.
Definition: object.h:424
struct object_kind * next
Definition: object.h:164
bitflag flags[OF_SIZE]
Flags.
Definition: object.h:262
Definition: object.h:101
bool * brands
Array of brand structures.
Definition: object.h:425
byte dd
Number of damage dice.
Definition: object.h:415
Represent more complex dice than random_value.
bitflag flags[OF_SIZE]
Flags.
Definition: object.h:314
bitflag flags_off[OF_SIZE]
Flags to remove.
Definition: object.h:315
int alloc_prob
Definition: object.h:327
Definition: object.h:359
bool * slays
Definition: object.h:268
struct slay * next
Definition: object.h:85
char * text
Definition: object.h:308
byte sval
Item sub-type (from kind)
Definition: object.h:409
int power
Power of the item's effect.
Definition: object.h:203
List of object origins.
byte bitflag
Definition: z-bitflag.h:27
bitflag flags[OF_SIZE]
Flags.
Definition: object.h:183
wchar_t d_char
Default object character.
Definition: object.h:194
Definition: object.h:56
int level
Level (difficulty of activation)
Definition: object.h:199
struct activation * next
Definition: object.h:118
struct effect * next
Definition: object.h:53
struct object_kind * curse_object_kind
Definition: obj-init.c:1488
random_value time
Recharge time (rods/activation)
Definition: object.h:343
int16_t s16b
Definition: h-basic.h:170
bool * brands
Definition: object.h:322
struct flavor * next
Definition: object.h:495
bool * slays
Array of slay structures.
Definition: object.h:426
int sval
Object sub-type.
Definition: object.h:168
int dd
Base damage dice.
Definition: object.h:255
Element info type.
Definition: object.h:109
random_value to_a
Definition: object.h:335
int to_h
Bonus to hit.
Definition: object.h:250
quark_t note_aware
Also saved in savefile.
Definition: object.h:215
u32b kidx
Definition: object.h:297
byte iy
Y-position on map, or zero.
Definition: object.h:405
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:202
A struct representing a strategy for making a dice roll.
Definition: z-rand.h:40
char * name
Definition: object.h:240
random_value modifiers[OBJ_MOD_MAX]
Definition: object.h:186
bool aim
Definition: object.h:121
Save memory by storing strings in a global array, ensuring that each is only allocated once...
int min_to_d
Definition: object.h:338
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:429
Information about ego-items.
Definition: object.h:304
#define OF_SIZE
Definition: obj-properties.h:120
static struct object const OBJECT_NULL
Null object constant, for safe initialization.
Definition: object.h:451
int alloc_prob
Allocation: commonness.
Definition: object.h:196
struct poss_item * next
Definition: object.h:298
Definition: obj-properties.h:112
struct object * obj
Definition: object.h:95
int to_a
Bonus to armor.
Definition: object.h:252
random_value to_h
Definition: object.h:333
int weight
Weight, in 1/10lbs.
Definition: object.h:179
struct curse_data * curses
Array of curse powers and timeouts.
Definition: object.h:427
struct poss_item * poss_items
Maximum depth (will NEVER appear deeper)
Definition: object.h:331
char * desc
Definition: object.h:125
char * effect_msg
Message on use.
Definition: object.h:430
random_value pval
Definition: object.h:170
struct object_kind * pile_kind
Definition: obj-init.c:1487
int index
Definition: object.h:120
struct activation * activation
Artifact-like activation.
Definition: object.h:201
struct artifact * next
Definition: object.h:245
int cost
Artifact (pseudo-)worth.
Definition: object.h:260
int tval
Definition: object.h:136
int max_stack
Definition: object.h:146
bool * slays
Definition: object.h:190
wchar_t d_char
Definition: object.h:502
quark_t note_unaware
Autoinscription quark number.
Definition: object.h:216
Curse type.
Definition: object.h:91
s16b pval
Item extra-parameter.
Definition: object.h:411
byte number
Number of items.
Definition: object.h:435
random_value time
Recharge time (rods/activation)
Definition: object.h:432
byte tval
Definition: object.h:498
struct brand * next
Definition: object.h:70
int weight
Weight in 1/10lbs.
Definition: object.h:258
Definition: object.h:360
struct activation * activations
Definition: obj-randart.c:45
Effect.
Definition: object.h:52
quark_t note
Inscription index.
Definition: object.h:445
byte ix
X-position on map, or zero.
Definition: object.h:406
bool * brands
Definition: object.h:189
struct monster_race * origin_race
Monster race that dropped it.
Definition: object.h:443
char * name
Definition: object.h:64
char * text
Definition: object.h:494
random_value modifiers[OBJ_MOD_MAX]
Definition: object.h:318
#define const
Definition: zconf.h:124
struct ego_item * ego
Ego item info of the object, if any.
Definition: object.h:396
int to_d
Bonus to damage.
Definition: object.h:251
int timeout
Definition: object.h:365
int power
Definition: object.h:69
random_value time
Recharge time (rods/activation)
Definition: object.h:205
struct object * known
Known version of this object.
Definition: object.h:401
s16b to_h
Plusses to hit.
Definition: object.h:419
s16b timeout
Timeout Counter.
Definition: object.h:433
#define KF_SIZE
Definition: obj-properties.h:140
char * name
Definition: object.h:307
bool everseen
Whether this artifact has ever been seen.
Definition: object.h:279
struct object_kind * kind
Kind of the object.
Definition: object.h:395
struct element_info el_info[ELEM_MAX]
Definition: object.h:320
NULL
Definition: list-summon-types.h:18
int alloc_min
Chance of being generated (i.e.
Definition: object.h:328
char * name
Definition: object.h:78
struct element_info el_info[ELEM_MAX]
Definition: object.h:265
Brand type.
Definition: object.h:62
Information about artifacts.
Definition: object.h:239
u16b index
The effect index.
Definition: object.h:54
size_t quark_t
Quark type.
Definition: z-quark.h:29
Definition: object.h:358
char * name
Definition: object.h:134
random_value time
Recharge time (if appropriate)
Definition: object.h:284
int multiplier
Definition: object.h:68
char * name
Definition: object.h:159
byte sval
Definition: object.h:499
Write value lines for a set of modifiers.
char * code
Definition: object.h:63
A Random Number Generator for Angband.