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 brand {
68  char *code;
69  char *name;
70  char *verb;
74  int power;
75  struct brand *next;
76 };
77 
81 struct slay {
82  char *code;
83  char *name;
84  char *base;
85  char *melee_verb;
86  char *range_verb;
87  int race_flag;
90  int power;
91  struct slay *next;
92 };
93 
97 struct curse {
98  struct curse *next;
99  char *name;
100  bool *poss;
101  struct object *obj;
102  char *conflict;
103  bitflag conflict_flags[OF_SIZE];
104  char *desc;
105 };
106 
107 enum {
111 };
112 
116 struct element_info {
119 };
120 
124 struct activation {
125  struct activation *next;
126  char *name;
127  int index;
128  bool aim;
129  int power;
130  struct effect *effect;
131  char *message;
132  char *desc;
133 };
134 
135 extern struct activation *activations;
136 
140 struct object_base {
141  char *name;
142 
143  int tval;
144  struct object_base *next;
145 
146  int attr;
147 
150  struct element_info el_info[ELEM_MAX];
151 
155 };
156 
157 extern struct object_base *kb_info;
158 
165 struct object_kind {
166  char *name;
167  char *text;
168 
169  struct object_base *base;
170 
171  struct object_kind *next;
173 
174  int tval;
175  int sval;
177  random_value pval; /* Item extra-parameter */
178 
182  int ac;
184  int dd;
185  int ds;
186  int weight;
188  int cost;
194  struct element_info el_info[ELEM_MAX];
195 
196  bool *brands;
197  bool *slays;
198  int *curses;
201  wchar_t d_char;
204  int alloc_min;
205  int alloc_max;
206  int level;
209  struct effect *effect;
210  int power;
211  char *effect_msg;
218  struct flavor *flavor;
225  bool aware;
226  bool tried;
229  bool everseen;
230 };
231 
232 extern struct object_kind *k_info;
233 extern struct object_kind *unknown_item_kind;
234 extern struct object_kind *unknown_gold_kind;
235 extern struct object_kind *pile_kind;
236 extern struct object_kind *curse_object_kind;
237 
246 struct artifact {
247  char *name;
248  char *text;
249 
251 
252  struct artifact *next;
253 
254  int tval;
255  int sval;
257  int to_h;
258  int to_d;
259  int to_a;
260  int ac;
262  int dd;
263  int ds;
265  int weight;
267  int cost;
272  struct element_info el_info[ELEM_MAX];
273 
274  bool *brands;
275  bool *slays;
276  int *curses;
278  int level;
281  int alloc_min;
282  int alloc_max;
284  bool created;
285  bool seen;
286  bool everseen;
289  char *alt_msg;
290 
292 };
293 
297 extern struct artifact *a_info;
298 
299 
303 struct poss_item {
305  struct poss_item *next;
306 };
307 
311 struct ego_item {
312  struct ego_item *next;
313 
314  char *name;
315  char *text;
316 
318 
319  int cost; /* Ego-item "cost" */
320 
327  struct element_info el_info[ELEM_MAX];
328 
329  bool *brands;
330  bool *slays;
331  int *curses;
333  int rating; /* Level rating boost */
335  int alloc_min;
336  int alloc_max;
339 
340  random_value to_h; /* Extra to-hit bonus */
341  random_value to_d; /* Extra to-dam bonus */
342  random_value to_a; /* Extra to-ac bonus */
343 
344  int min_to_h; /* Minimum to-hit value */
345  int min_to_d; /* Minimum to-dam value */
346  int min_to_a; /* Minimum to-ac value */
347 
348  struct effect *effect;
349  char *effect_msg;
352  bool everseen; /* Do not spoil ignore menus */
353 };
354 
355 /*
356  * The ego-item arrays
357  */
358 extern struct ego_item *e_info;
359 
363 enum {
368 };
369 
370 struct curse_data {
371  int power;
372  int timeout;
373 };
374 
401 struct object {
402  struct object_kind *kind;
403  struct ego_item *ego;
404  struct artifact *artifact;
406  struct object *prev;
407  struct object *next;
408  struct object *known;
412  struct loc grid;
430  struct element_info el_info[ELEM_MAX];
431  bool *brands;
432  bool *slays;
433  struct curse_data *curses;
435  struct effect *effect;
436  char *effect_msg;
452 };
453 
457 static struct object const OBJECT_NULL = {
458  .kind = NULL,
459  .ego = NULL,
460  .artifact = NULL,
461  .prev = NULL,
462  .next = NULL,
463  .known = NULL,
464  .oidx = 0,
465  .grid = { 0, 0 },
466  .tval = 0,
467  .sval = 0,
468  .pval = 0,
469  .weight = 0,
470  .dd = 0,
471  .ds = 0,
472  .ac = 0,
473  .to_a = 0,
474  .to_h = 0,
475  .to_d = 0,
476  .flags = { 0 },
477  .modifiers = { 0 },
478  .el_info = { { 0, 0 } },
479  .brands = NULL,
480  .slays = NULL,
481  .curses = NULL,
482  .effect = NULL,
483  .effect_msg = NULL,
484  .activation = NULL,
485  .time = { 0, 0, 0, 0 },
486  .timeout = 0,
487  .number = 0,
488  .notice = 0,
489  .held_m_idx = 0,
490  .mimicking_m_idx = 0,
491  .origin = 0,
492  .origin_depth = 0,
493  .origin_race = NULL,
494  .note = 0,
495 };
496 
497 struct flavor
498 {
499  char *text;
500  struct flavor *next;
501  unsigned int fidx;
502 
503  byte tval; /* Associated object type */
504  byte sval; /* Associated object sub-type */
505 
506  byte d_attr; /* Default flavor attribute */
507  wchar_t d_char; /* Default flavor character */
508 };
509 
510 extern struct flavor *flavors;
511 
512 
513 typedef bool (*item_tester)(const struct object *);
514 
515 
516 #endif /* !INCLUDED_OBJECT_H */
random_value stack_size
Number to generate.
Definition: object.h:216
uint16_t u16b
Definition: h-basic.h:169
int alloc_max
Lowest normal dungeon level.
Definition: object.h:205
bool(* item_tester)(const struct object *)
Definition: object.h:513
bool * brands
Definition: object.h:274
int rating
Definition: object.h:333
char * message
Definition: object.h:131
int cost
Definition: object.h:319
byte origin_depth
What depth the item was found at.
Definition: object.h:448
int * curses
Array of curse powers.
Definition: object.h:331
Definition: z-dice.c:30
struct flavor * flavor
Special object flavor (or zero)
Definition: object.h:218
u32b eidx
Definition: object.h:317
bool everseen
Definition: object.h:352
definitions and functions for object flags and modifiers
u32b aidx
Definition: object.h:250
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:442
int min_modifiers[OBJ_MOD_MAX]
Definition: object.h:326
struct curse * next
Definition: object.h:98
struct object * next
Next object in a pile.
Definition: object.h:407
struct object_base * next
Definition: object.h:144
struct ego_item * next
Definition: object.h:312
Definition: object.h:497
char * text
Definition: object.h:167
Low-level bit vector manipulation.
int attr
Definition: object.h:146
struct ego_item * e_info
Definition: obj-util.c:49
int alloc_prob
Difficulty level for activation.
Definition: object.h:280
Definition: object.h:364
char * name
Definition: object.h:126
s16b to_a
Plusses to AC.
Definition: object.h:424
byte origin
How this item was found.
Definition: object.h:447
char * alt_msg
Definition: object.h:289
uint32_t u32b
Definition: h-basic.h:172
bool * poss
Definition: object.h:100
Slay type.
Definition: object.h:81
Definition: z-type.h:24
int resist_flag
Definition: object.h:71
bool everseen
Kind has been seen (to despoilify ignore menus)
Definition: object.h:229
struct object_base * base
Definition: object.h:169
s16b held_m_idx
Monster holding us (if any)
Definition: object.h:444
int race_flag
Definition: object.h:87
Information about object kinds, including player knowledge.
Definition: object.h:165
int ds
Base damage sides.
Definition: object.h:263
byte tval
Item type (from kind)
Definition: object.h:414
char * name
Definition: object.h:99
int o_multiplier
Definition: object.h:89
struct activation * activation
Artifact activation.
Definition: object.h:288
char * base
Definition: object.h:84
int power
Definition: object.h:371
byte ds
Number of sides on each damage die.
Definition: object.h:422
char * conflict
Definition: object.h:102
char * desc
Definition: object.h:104
struct object_kind * unknown_item_kind
Initialize objects
Definition: obj-init.c:1528
Structure for possible object kinds for an ego item.
Definition: object.h:303
int dd
Damage dice.
Definition: object.h:184
s16b to_d
Plusses to damage.
Definition: object.h:426
int tval
General artifact type (see TV_ macros)
Definition: object.h:254
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:285
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:348
random_value to_d
Definition: object.h:341
random_value to_a
Bonus to armor.
Definition: object.h:181
u16b oidx
Item list index, if any.
Definition: object.h:410
Definition: object.h:110
char * msg
Message for deth or whatever.
Definition: object.h:61
Definition: object.h:370
int alloc_max
Minimum depth (can appear earlier)
Definition: object.h:282
struct object_base * kb_info
Definition: obj-util.c:46
int sval
Artifact sub-type.
Definition: object.h:255
struct flavor * flavors
Definition: obj-util.c:50
Definition: object.h:109
uint8_t byte
Definition: h-basic.h:167
int break_perc
Definition: object.h:152
static const char * kind_flags[]
Definition: obj-init.c:73
Activation structure.
Definition: object.h:124
bool aware
Set if player is aware of the kind's effects.
Definition: object.h:225
int cost
Object base cost.
Definition: object.h:188
bool tried
Set if kind has been tried.
Definition: object.h:226
Information about object types, like rods, wands, etc.
Definition: object.h:140
random_value to_h
Bonus to hit.
Definition: object.h:179
int * curses
Array of curse powers.
Definition: object.h:198
int alloc_min
Highest normal dungeon level.
Definition: object.h:204
s16b ac
Normal AC.
Definition: object.h:423
int ac
Base armor.
Definition: object.h:182
const s16 modifiers[]
Definition: main-nds.c:61
random_value to_d
Bonus to damage.
Definition: object.h:180
bitflag flags
Definition: object.h:118
struct effect * effect
Definition: object.h:130
random_value charge
Number of charges (staves/wands)
Definition: object.h:213
char * verb
Definition: object.h:70
char * effect_msg
Definition: object.h:349
Definition: object.h:366
byte ignore
Ignore settings.
Definition: object.h:228
dice_t * dice
Dice expression used in the effect.
Definition: object.h:55
char * melee_verb
Definition: object.h:85
char * effect_msg
Definition: object.h:211
byte d_attr
Default object attribute.
Definition: object.h:200
char * text
Definition: object.h:248
int power
Definition: object.h:90
int alloc_min
Chance of being generated (i.e.
Definition: object.h:281
unsigned int fidx
Definition: object.h:501
int alloc_max
Minimum depth (can appear earlier)
Definition: object.h:336
int multiplier
Definition: object.h:88
Object information, for a specific object.
Definition: object.h:401
int * curses
Array of curse powers.
Definition: object.h:276
s16b res_level
Definition: object.h:117
struct object * prev
Previous object in a pile.
Definition: object.h:406
s16b weight
Item weight.
Definition: object.h:419
int power
Definition: object.h:129
int min_to_a
Definition: object.h:346
char * range_verb
Definition: object.h:86
struct object_kind * unknown_gold_kind
Definition: obj-init.c:1529
struct artifact * artifact
Artifact info of the object, if any.
Definition: object.h:404
int ds
Damage sides.
Definition: object.h:185
int gen_mult_prob
Probability of generating more than one.
Definition: object.h:215
int num_svals
Definition: object.h:154
u32b kidx
Definition: object.h:172
int tval
General object type (see TV_ macros)
Definition: object.h:174
struct activation * activation
Artifact activation, if applicable.
Definition: object.h:437
int min_to_h
Definition: object.h:344
bool created
Maximum depth (will NEVER appear deeper)
Definition: object.h:284
char * code
Definition: object.h:82
int ac
Base armor.
Definition: object.h:260
int x
X coordinate or distance.
Definition: object.h:57
s16b mimicking_m_idx
Monster mimicking us (if any)
Definition: object.h:445
struct artifact * a_info
The artifact arrays.
Definition: obj-util.c:48
int level
Definition: object.h:278
byte d_attr
Definition: object.h:506
bool * slays
Definition: object.h:330
struct object_kind * next
Definition: object.h:171
bool * brands
Array of brand structures.
Definition: object.h:431
byte dd
Number of damage dice.
Definition: object.h:421
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:322
int alloc_prob
Definition: object.h:334
bool * slays
Definition: object.h:275
struct slay * next
Definition: object.h:91
char * text
Definition: object.h:315
byte sval
Item sub-type (from kind)
Definition: object.h:415
int power
Power of the item's effect.
Definition: object.h:210
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:201
int level
Level (difficulty of activation)
Definition: object.h:206
struct activation * next
Definition: object.h:125
struct effect * next
Definition: object.h:53
struct object_kind * curse_object_kind
Definition: obj-init.c:1531
random_value time
Recharge time (rods/activation)
Definition: object.h:350
int16_t s16b
Definition: h-basic.h:170
bool * brands
Definition: object.h:329
int y
Y coordinate or distance.
Definition: object.h:56
struct flavor * next
Definition: object.h:500
bool * slays
Array of slay structures.
Definition: object.h:432
int sval
Object sub-type.
Definition: object.h:175
int dd
Base damage dice.
Definition: object.h:262
Element info type.
Definition: object.h:116
random_value to_a
Definition: object.h:342
int to_h
Bonus to hit.
Definition: object.h:257
quark_t note_aware
Also saved in savefile.
Definition: object.h:222
u32b kidx
Definition: object.h:304
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:209
Support various data types.
A struct representing a strategy for making a dice roll.
Definition: z-rand.h:40
char * name
Definition: object.h:247
bool aim
Definition: object.h:128
Save memory by storing strings in a global array, ensuring that each is only allocated once...
int min_to_d
Definition: object.h:345
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:435
int subtype
Projection type, timed effect type, etc.
Definition: object.h:58
Information about ego-items.
Definition: object.h:311
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:457
int alloc_prob
Allocation: commonness.
Definition: object.h:203
struct poss_item * next
Definition: object.h:305
Definition: obj-properties.h:114
Definition: object.h:365
struct object * obj
Definition: object.h:101
int to_a
Bonus to armor.
Definition: object.h:259
random_value to_h
Definition: object.h:340
int weight
Weight, in 1/10lbs.
Definition: object.h:186
struct curse_data * curses
Array of curse powers and timeouts.
Definition: object.h:433
struct poss_item * poss_items
Maximum depth (will NEVER appear deeper)
Definition: object.h:338
char * desc
Definition: object.h:132
char * effect_msg
Message on use.
Definition: object.h:436
random_value pval
Definition: object.h:177
struct object_kind * pile_kind
Definition: obj-init.c:1530
int index
Definition: object.h:127
struct activation * activation
Artifact-like activation.
Definition: object.h:208
struct artifact * next
Definition: object.h:252
int cost
Artifact (pseudo-)worth.
Definition: object.h:267
int tval
Definition: object.h:143
int max_stack
Definition: object.h:153
bool * slays
Definition: object.h:197
wchar_t d_char
Definition: object.h:507
quark_t note_unaware
Autoinscription quark number.
Definition: object.h:223
Curse type.
Definition: object.h:97
s16b pval
Item extra-parameter.
Definition: object.h:417
byte number
Number of items.
Definition: object.h:441
random_value time
Recharge time (rods/activation)
Definition: object.h:438
byte tval
Definition: object.h:503
struct brand * next
Definition: object.h:75
int weight
Weight in 1/10lbs.
Definition: object.h:265
struct activation * activations
Definition: obj-randart.c:45
Effect.
Definition: object.h:52
quark_t note
Inscription index.
Definition: object.h:451
bool * brands
Definition: object.h:196
int o_multiplier
Definition: object.h:73
struct monster_race * origin_race
Monster race that dropped it.
Definition: object.h:449
char * name
Definition: object.h:69
char * text
Definition: object.h:499
#define const
Definition: zconf.h:124
struct ego_item * ego
Ego item info of the object, if any.
Definition: object.h:403
int to_d
Bonus to damage.
Definition: object.h:258
int timeout
Definition: object.h:372
int power
Definition: object.h:74
random_value time
Recharge time (rods/activation)
Definition: object.h:212
struct object * known
Known version of this object.
Definition: object.h:408
s16b to_h
Plusses to hit.
Definition: object.h:425
Definition: object.h:108
s16b timeout
Timeout Counter.
Definition: object.h:439
#define KF_SIZE
Definition: obj-properties.h:141
char * name
Definition: object.h:314
bool everseen
Whether this artifact has ever been seen.
Definition: object.h:286
struct object_kind * kind
Kind of the object.
Definition: object.h:402
int alloc_min
Chance of being generated (i.e.
Definition: object.h:335
char * name
Definition: object.h:83
Brand type.
Definition: object.h:67
Information about artifacts.
Definition: object.h:246
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:141
random_value time
Recharge time (if appropriate)
Definition: object.h:291
int multiplier
Definition: object.h:72
Definition: object.h:367
char * name
Definition: object.h:166
byte sval
Definition: object.h:504
Write value lines for a set of modifiers.
char * code
Definition: object.h:68