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 
147 };
148 
149 extern struct object_base *kb_info;
150 
157 struct object_kind {
158  char *name;
159  char *text;
160 
161  struct object_base *base;
162 
163  struct object_kind *next;
165 
166  int tval;
167  int sval;
169  random_value pval; /* Item extra-parameter */
170 
174  int ac;
176  int dd;
177  int ds;
178  int weight;
180  int cost;
187 
188  bool *brands;
189  bool *slays;
190  int *curses;
193  wchar_t d_char;
196  int alloc_min;
197  int alloc_max;
198  int level;
201  struct effect *effect;
202  int power;
203  char *effect_msg;
210  struct flavor *flavor;
217  bool aware;
218  bool tried;
221  bool everseen;
222 };
223 
224 extern struct object_kind *k_info;
225 extern struct object_kind *unknown_item_kind;
226 extern struct object_kind *unknown_gold_kind;
227 extern struct object_kind *pile_kind;
228 extern struct object_kind *curse_object_kind;
229 
238 struct artifact {
239  char *name;
240  char *text;
241 
243 
244  struct artifact *next;
245 
246  int tval;
247  int sval;
249  int to_h;
250  int to_d;
251  int to_a;
252  int ac;
254  int dd;
255  int ds;
257  int weight;
259  int cost;
265 
266  bool *brands;
267  bool *slays;
268  int *curses;
270  int level;
273  int alloc_min;
274  int alloc_max;
276  bool created;
277  bool seen;
278  bool everseen;
281  char *alt_msg;
282 
284 };
285 
289 extern struct artifact *a_info;
290 
291 
295 struct poss_item {
297  struct poss_item *next;
298 };
299 
303 struct ego_item {
304  struct ego_item *next;
305 
306  char *name;
307  char *text;
308 
310 
311  int cost; /* Ego-item "cost" */
312 
320 
321  bool *brands;
322  bool *slays;
323  int *curses;
325  int rating; /* Level rating boost */
327  int alloc_min;
328  int alloc_max;
331 
332  random_value to_h; /* Extra to-hit bonus */
333  random_value to_d; /* Extra to-dam bonus */
334  random_value to_a; /* Extra to-ac bonus */
335 
336  int min_to_h; /* Minimum to-hit value */
337  int min_to_d; /* Minimum to-dam value */
338  int min_to_a; /* Minimum to-ac value */
339 
340  struct effect *effect;
341  char *effect_msg;
344  bool everseen; /* Do not spoil ignore menus */
345 };
346 
347 /*
348  * The ego-item arrays
349  */
350 extern struct ego_item *e_info;
351 
355 enum {
360 };
361 
362 struct curse_data {
363  int power;
364  int timeout;
365 };
366 
393 struct object {
394  struct object_kind *kind;
395  struct ego_item *ego;
396  struct artifact *artifact;
398  struct object *prev;
399  struct object *next;
400  struct object *known;
424  bool *brands;
425  bool *slays;
426  struct curse_data *curses;
428  struct effect *effect;
429  char *effect_msg;
445 };
446 
450 static struct object const OBJECT_NULL = {
451  .kind = NULL,
452  .ego = NULL,
453  .artifact = NULL,
454  .prev = NULL,
455  .next = NULL,
456  .known = NULL,
457  .oidx = 0,
458  .iy = 0,
459  .ix = 0,
460  .tval = 0,
461  .sval = 0,
462  .pval = 0,
463  .weight = 0,
464  .dd = 0,
465  .ds = 0,
466  .ac = 0,
467  .to_a = 0,
468  .to_h = 0,
469  .to_d = 0,
470  .flags = { 0 },
471  .modifiers = { 0 },
472  .el_info = { { 0, 0 } },
473  .brands = NULL,
474  .slays = NULL,
475  .curses = NULL,
476  .effect = NULL,
477  .effect_msg = NULL,
478  .activation = NULL,
479  .time = { 0, 0, 0, 0 },
480  .timeout = 0,
481  .number = 0,
482  .notice = 0,
483  .held_m_idx = 0,
484  .mimicking_m_idx = 0,
485  .origin = 0,
486  .origin_depth = 0,
487  .origin_race = NULL,
488  .note = 0,
489 };
490 
491 struct flavor
492 {
493  char *text;
494  struct flavor *next;
495  unsigned int fidx;
496 
497  byte tval; /* Associated object type */
498  byte sval; /* Associated object sub-type */
499 
500  byte d_attr; /* Default flavor attribute */
501  wchar_t d_char; /* Default flavor character */
502 };
503 
504 extern struct flavor *flavors;
505 
506 
507 typedef bool (*item_tester)(const struct object *);
508 
509 
510 #endif /* !INCLUDED_OBJECT_H */
random_value stack_size
Number to generate.
Definition: object.h:208
uint16_t u16b
Definition: h-basic.h:169
int alloc_max
Lowest normal dungeon level.
Definition: object.h:197
bool * brands
Definition: object.h:266
int rating
Definition: object.h:325
char * message
Definition: object.h:124
int cost
Definition: object.h:311
byte origin_depth
What depth the item was found at.
Definition: object.h:441
int * curses
Array of curse powers.
Definition: object.h:323
Definition: z-dice.c:30
struct flavor * flavor
Special object flavor (or zero)
Definition: object.h:210
u32b eidx
Definition: object.h:309
bool everseen
Definition: object.h:344
definitions and functions for object flags and modifiers
u32b aidx
Definition: object.h:242
Monster "race" information, including racial memories.
Definition: monster.h:263
struct object_kind * k_info
Definition: obj-util.c:47
bitflag notice
Attention paid to the object.
Definition: object.h:435
int min_modifiers[OBJ_MOD_MAX]
Definition: object.h:318
struct curse * next
Definition: object.h:92
struct object * next
Next object in a pile.
Definition: object.h:399
struct object_base * next
Definition: object.h:137
struct ego_item * next
Definition: object.h:304
Definition: object.h:491
char * text
Definition: object.h:159
Low-level bit vector manipulation.
bitflag kind_flags[KF_SIZE]
Kind flags.
Definition: object.h:183
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:272
char * name
Definition: object.h:119
s16b to_a
Plusses to AC.
Definition: object.h:417
byte origin
How this item was found.
Definition: object.h:440
char * alt_msg
Definition: object.h:281
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:221
struct object_base * base
Definition: object.h:161
s16b held_m_idx
Monster holding us (if any)
Definition: object.h:437
int race_flag
Definition: object.h:82
Information about object kinds, including player knowledge.
Definition: object.h:157
int ds
Base damage sides.
Definition: object.h:255
byte tval
Item type (from kind)
Definition: object.h:407
char * name
Definition: object.h:93
struct activation * activation
Artifact activation.
Definition: object.h:280
char * base
Definition: object.h:79
int power
Definition: object.h:363
byte ds
Number of sides on each damage die.
Definition: object.h:415
char * conflict
Definition: object.h:96
char * desc
Definition: object.h:97
struct object_kind * unknown_item_kind
Initialize objects
Definition: obj-init.c:1469
int element
Definition: object.h:66
Structure for possible object kinds for an ego item.
Definition: object.h:295
int dd
Damage dice.
Definition: object.h:176
s16b to_d
Plusses to damage.
Definition: object.h:419
int tval
General artifact type (see TV_ macros)
Definition: object.h:246
bool seen
Whether this artifact has been seen this game.
Definition: object.h:277
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:340
random_value to_d
Definition: object.h:333
random_value to_a
Bonus to armor.
Definition: object.h:173
u16b oidx
Item list index, if any.
Definition: object.h:402
Definition: object.h:362
bitflag kind_flags[KF_SIZE]
Kind flags.
Definition: object.h:315
int alloc_max
Minimum depth (can appear earlier)
Definition: object.h:274
struct object_base * kb_info
Definition: obj-util.c:46
int sval
Artifact sub-type.
Definition: object.h:247
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:186
Activation structure.
Definition: object.h:117
bool aware
Set if player is aware of the kind's effects.
Definition: object.h:217
int cost
Object base cost.
Definition: object.h:180
bool tried
Set if kind has been tried.
Definition: object.h:218
Information about object types, like rods, wands, etc.
Definition: object.h:133
random_value to_h
Bonus to hit.
Definition: object.h:171
int * curses
Array of curse powers.
Definition: object.h:190
int alloc_min
Highest normal dungeon level.
Definition: object.h:196
s16b ac
Normal AC.
Definition: object.h:416
bool(* item_tester)(const struct object *)
Definition: object.h:507
int ac
Base armor.
Definition: object.h:174
s16b modifiers[OBJ_MOD_MAX]
Object modifiers.
Definition: object.h:422
random_value to_d
Bonus to damage.
Definition: object.h:172
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:205
bitflag flags[OF_SIZE]
Object flags.
Definition: object.h:421
char * verb
Definition: object.h:65
char * effect_msg
Definition: object.h:341
byte ignore
Ignore settings.
Definition: object.h:220
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:203
byte d_attr
Default object attribute.
Definition: object.h:192
char * text
Definition: object.h:240
int power
Definition: object.h:84
int alloc_min
Chance of being generated (i.e.
Definition: object.h:273
unsigned int fidx
Definition: object.h:495
int alloc_max
Minimum depth (can appear earlier)
Definition: object.h:328
int multiplier
Definition: object.h:83
Object information, for a specific object.
Definition: object.h:393
int * curses
Array of curse powers.
Definition: object.h:268
s16b res_level
Definition: object.h:110
struct object * prev
Previous object in a pile.
Definition: object.h:398
s16b weight
Item weight.
Definition: object.h:412
int power
Definition: object.h:122
int min_to_a
Definition: object.h:338
char * range_verb
Definition: object.h:81
struct object_kind * unknown_gold_kind
Definition: obj-init.c:1470
struct artifact * artifact
Artifact info of the object, if any.
Definition: object.h:396
int ds
Damage sides.
Definition: object.h:177
int gen_mult_prob
Probability of generating more than one.
Definition: object.h:207
int num_svals
Definition: object.h:146
u32b kidx
Definition: object.h:164
int tval
General object type (see TV_ macros)
Definition: object.h:166
struct activation * activation
Artifact activation, if applicable.
Definition: object.h:430
bitflag flags[OF_SIZE]
Definition: object.h:141
int min_to_h
Definition: object.h:336
bool created
Maximum depth (will NEVER appear deeper)
Definition: object.h:276
int modifiers[OBJ_MOD_MAX]
Definition: object.h:263
char * code
Definition: object.h:77
int ac
Base armor.
Definition: object.h:252
struct element_info el_info[ELEM_MAX]
Definition: object.h:143
s16b mimicking_m_idx
Monster mimicking us (if any)
Definition: object.h:438
struct artifact * a_info
The artifact arrays.
Definition: obj-util.c:48
Definition: object.h:356
int level
Definition: object.h:270
byte d_attr
Definition: object.h:500
bool * slays
Definition: object.h:322
struct element_info el_info[ELEM_MAX]
Object element info.
Definition: object.h:423
struct object_kind * next
Definition: object.h:163
bitflag flags[OF_SIZE]
Flags.
Definition: object.h:261
Definition: object.h:101
bool * brands
Array of brand structures.
Definition: object.h:424
byte dd
Number of damage dice.
Definition: object.h:414
Represent more complex dice than random_value.
bitflag flags[OF_SIZE]
Flags.
Definition: object.h:313
bitflag flags_off[OF_SIZE]
Flags to remove.
Definition: object.h:314
int alloc_prob
Definition: object.h:326
Definition: object.h:358
bool * slays
Definition: object.h:267
struct slay * next
Definition: object.h:85
char * text
Definition: object.h:307
byte sval
Item sub-type (from kind)
Definition: object.h:408
int power
Power of the item's effect.
Definition: object.h:202
List of object origins.
byte bitflag
Definition: z-bitflag.h:27
bitflag flags[OF_SIZE]
Flags.
Definition: object.h:182
wchar_t d_char
Default object character.
Definition: object.h:193
Definition: object.h:56
int level
Level (difficulty of activation)
Definition: object.h:198
struct activation * next
Definition: object.h:118
struct effect * next
Definition: object.h:53
struct object_kind * curse_object_kind
Definition: obj-init.c:1472
random_value time
Recharge time (rods/activation)
Definition: object.h:342
int16_t s16b
Definition: h-basic.h:170
bool * brands
Definition: object.h:321
struct flavor * next
Definition: object.h:494
bool * slays
Array of slay structures.
Definition: object.h:425
int sval
Object sub-type.
Definition: object.h:167
int dd
Base damage dice.
Definition: object.h:254
Element info type.
Definition: object.h:109
random_value to_a
Definition: object.h:334
int to_h
Bonus to hit.
Definition: object.h:249
quark_t note_aware
Also saved in savefile.
Definition: object.h:214
u32b kidx
Definition: object.h:296
byte iy
Y-position on map, or zero.
Definition: object.h:404
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:201
A struct representing a strategy for making a dice roll.
Definition: z-rand.h:40
char * name
Definition: object.h:239
random_value modifiers[OBJ_MOD_MAX]
Definition: object.h:185
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:337
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:428
Information about ego-items.
Definition: object.h:303
#define OF_SIZE
Definition: obj-properties.h:120
static struct object const OBJECT_NULL
Null object constant, for safe initialization.
Definition: object.h:450
int alloc_prob
Allocation: commonness.
Definition: object.h:195
struct poss_item * next
Definition: object.h:297
Definition: obj-properties.h:112
struct object * obj
Definition: object.h:95
int to_a
Bonus to armor.
Definition: object.h:251
random_value to_h
Definition: object.h:332
int weight
Weight, in 1/10lbs.
Definition: object.h:178
struct curse_data * curses
Array of curse powers and timeouts.
Definition: object.h:426
struct poss_item * poss_items
Maximum depth (will NEVER appear deeper)
Definition: object.h:330
char * desc
Definition: object.h:125
char * effect_msg
Message on use.
Definition: object.h:429
random_value pval
Definition: object.h:169
struct object_kind * pile_kind
Definition: obj-init.c:1471
int index
Definition: object.h:120
struct activation * activation
Artifact-like activation.
Definition: object.h:200
struct artifact * next
Definition: object.h:244
int cost
Artifact (pseudo-)worth.
Definition: object.h:259
int tval
Definition: object.h:136
bool * slays
Definition: object.h:189
wchar_t d_char
Definition: object.h:501
quark_t note_unaware
Autoinscription quark number.
Definition: object.h:215
Curse type.
Definition: object.h:91
s16b pval
Item extra-parameter.
Definition: object.h:410
byte number
Number of items.
Definition: object.h:434
random_value time
Recharge time (rods/activation)
Definition: object.h:431
byte tval
Definition: object.h:497
struct brand * next
Definition: object.h:70
int weight
Weight in 1/10lbs.
Definition: object.h:257
Definition: object.h:359
struct activation * activations
Definition: obj-randart.c:45
Effect.
Definition: object.h:52
quark_t note
Inscription index.
Definition: object.h:444
byte ix
X-position on map, or zero.
Definition: object.h:405
bool * brands
Definition: object.h:188
struct monster_race * origin_race
Monster race that dropped it.
Definition: object.h:442
char * name
Definition: object.h:64
char * text
Definition: object.h:493
random_value modifiers[OBJ_MOD_MAX]
Definition: object.h:317
#define const
Definition: zconf.h:124
struct ego_item * ego
Ego item info of the object, if any.
Definition: object.h:395
int to_d
Bonus to damage.
Definition: object.h:250
int timeout
Definition: object.h:364
int power
Definition: object.h:69
random_value time
Recharge time (rods/activation)
Definition: object.h:204
struct object * known
Known version of this object.
Definition: object.h:400
s16b to_h
Plusses to hit.
Definition: object.h:418
s16b timeout
Timeout Counter.
Definition: object.h:432
#define KF_SIZE
Definition: obj-properties.h:140
char * name
Definition: object.h:306
bool everseen
Whether this artifact has ever been seen.
Definition: object.h:278
struct object_kind * kind
Kind of the object.
Definition: object.h:394
struct element_info el_info[ELEM_MAX]
Definition: object.h:319
NULL
Definition: list-summon-types.h:18
int alloc_min
Chance of being generated (i.e.
Definition: object.h:327
char * name
Definition: object.h:78
struct element_info el_info[ELEM_MAX]
Definition: object.h:264
Brand type.
Definition: object.h:62
Information about artifacts.
Definition: object.h:238
u16b index
The effect index.
Definition: object.h:54
size_t quark_t
Quark type.
Definition: z-quark.h:29
Definition: object.h:357
char * name
Definition: object.h:134
random_value time
Recharge time (if appropriate)
Definition: object.h:283
int multiplier
Definition: object.h:68
char * name
Definition: object.h:158
byte sval
Definition: object.h:498
Write value lines for a set of modifiers.
char * code
Definition: object.h:63
A Random Number Generator for Angband.