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 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;
73  int power;
74  struct brand *next;
75 };
76 
80 struct slay {
81  char *code;
82  char *name;
83  char *base;
84  char *melee_verb;
85  char *range_verb;
86  int race_flag;
88  int power;
89  struct slay *next;
90 };
91 
95 struct curse {
96  struct curse *next;
97  char *name;
98  bool *poss;
99  struct object *obj;
100  char *conflict;
101  bitflag conflict_flags[OF_SIZE];
102  char *desc;
103 };
104 
105 enum {
109 };
110 
114 struct element_info {
117 };
118 
122 struct activation {
123  struct activation *next;
124  char *name;
125  int index;
126  bool aim;
127  int power;
128  struct effect *effect;
129  char *message;
130  char *desc;
131 };
132 
133 extern struct activation *activations;
134 
138 struct object_base {
139  char *name;
140 
141  int tval;
142  struct object_base *next;
143 
144  int attr;
145 
148  struct element_info el_info[ELEM_MAX];
149 
153 };
154 
155 extern struct object_base *kb_info;
156 
163 struct object_kind {
164  char *name;
165  char *text;
166 
167  struct object_base *base;
168 
169  struct object_kind *next;
171 
172  int tval;
173  int sval;
175  random_value pval; /* Item extra-parameter */
176 
180  int ac;
182  int dd;
183  int ds;
184  int weight;
186  int cost;
192  struct element_info el_info[ELEM_MAX];
193 
194  bool *brands;
195  bool *slays;
196  int *curses;
199  wchar_t d_char;
202  int alloc_min;
203  int alloc_max;
204  int level;
207  struct effect *effect;
208  int power;
209  char *effect_msg;
216  struct flavor *flavor;
223  bool aware;
224  bool tried;
227  bool everseen;
228 };
229 
230 extern struct object_kind *k_info;
231 extern struct object_kind *unknown_item_kind;
232 extern struct object_kind *unknown_gold_kind;
233 extern struct object_kind *pile_kind;
234 extern struct object_kind *curse_object_kind;
235 
244 struct artifact {
245  char *name;
246  char *text;
247 
249 
250  struct artifact *next;
251 
252  int tval;
253  int sval;
255  int to_h;
256  int to_d;
257  int to_a;
258  int ac;
260  int dd;
261  int ds;
263  int weight;
265  int cost;
270  struct element_info el_info[ELEM_MAX];
271 
272  bool *brands;
273  bool *slays;
274  int *curses;
276  int level;
279  int alloc_min;
280  int alloc_max;
282  bool created;
283  bool seen;
284  bool everseen;
287  char *alt_msg;
288 
290 };
291 
295 extern struct artifact *a_info;
296 
297 
301 struct poss_item {
303  struct poss_item *next;
304 };
305 
309 struct ego_item {
310  struct ego_item *next;
311 
312  char *name;
313  char *text;
314 
316 
317  int cost; /* Ego-item "cost" */
318 
325  struct element_info el_info[ELEM_MAX];
326 
327  bool *brands;
328  bool *slays;
329  int *curses;
331  int rating; /* Level rating boost */
333  int alloc_min;
334  int alloc_max;
337 
338  random_value to_h; /* Extra to-hit bonus */
339  random_value to_d; /* Extra to-dam bonus */
340  random_value to_a; /* Extra to-ac bonus */
341 
342  int min_to_h; /* Minimum to-hit value */
343  int min_to_d; /* Minimum to-dam value */
344  int min_to_a; /* Minimum to-ac value */
345 
346  struct effect *effect;
347  char *effect_msg;
350  bool everseen; /* Do not spoil ignore menus */
351 };
352 
353 /*
354  * The ego-item arrays
355  */
356 extern struct ego_item *e_info;
357 
361 enum {
366 };
367 
368 struct curse_data {
369  int power;
370  int timeout;
371 };
372 
399 struct object {
400  struct object_kind *kind;
401  struct ego_item *ego;
402  struct artifact *artifact;
404  struct object *prev;
405  struct object *next;
406  struct object *known;
429  struct element_info el_info[ELEM_MAX];
430  bool *brands;
431  bool *slays;
432  struct curse_data *curses;
434  struct effect *effect;
435  char *effect_msg;
451 };
452 
456 static struct object const OBJECT_NULL = {
457  .kind = NULL,
458  .ego = NULL,
459  .artifact = NULL,
460  .prev = NULL,
461  .next = NULL,
462  .known = NULL,
463  .oidx = 0,
464  .iy = 0,
465  .ix = 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:214
uint16_t u16b
Definition: h-basic.h:169
int alloc_max
Lowest normal dungeon level.
Definition: object.h:203
bool(* item_tester)(const struct object *)
Definition: object.h:513
bool * brands
Definition: object.h:272
int rating
Definition: object.h:331
char * message
Definition: object.h:129
int cost
Definition: object.h:317
byte origin_depth
What depth the item was found at.
Definition: object.h:447
int * curses
Array of curse powers.
Definition: object.h:329
Definition: z-dice.c:30
struct flavor * flavor
Special object flavor (or zero)
Definition: object.h:216
u32b eidx
Definition: object.h:315
bool everseen
Definition: object.h:350
definitions and functions for object flags and modifiers
u32b aidx
Definition: object.h:248
Monster "race" information, including racial memories.
Definition: monster.h:267
struct object_kind * k_info
Definition: obj-util.c:47
bitflag notice
Attention paid to the object.
Definition: object.h:441
int min_modifiers[OBJ_MOD_MAX]
Definition: object.h:324
struct curse * next
Definition: object.h:96
struct object * next
Next object in a pile.
Definition: object.h:405
struct object_base * next
Definition: object.h:142
struct ego_item * next
Definition: object.h:310
Definition: object.h:497
char * text
Definition: object.h:165
Low-level bit vector manipulation.
Definition: object.h:108
int attr
Definition: object.h:144
struct ego_item * e_info
Definition: obj-util.c:49
int alloc_prob
Difficulty level for activation.
Definition: object.h:278
char * name
Definition: object.h:124
s16b to_a
Plusses to AC.
Definition: object.h:423
byte origin
How this item was found.
Definition: object.h:446
char * alt_msg
Definition: object.h:287
uint32_t u32b
Definition: h-basic.h:172
bool * poss
Definition: object.h:98
Slay type.
Definition: object.h:80
int resist_flag
Definition: object.h:71
bool everseen
Kind has been seen (to despoilify ignore menus)
Definition: object.h:227
struct object_base * base
Definition: object.h:167
s16b held_m_idx
Monster holding us (if any)
Definition: object.h:443
int race_flag
Definition: object.h:86
Information about object kinds, including player knowledge.
Definition: object.h:163
int ds
Base damage sides.
Definition: object.h:261
byte tval
Item type (from kind)
Definition: object.h:413
char * name
Definition: object.h:97
struct activation * activation
Artifact activation.
Definition: object.h:286
char * base
Definition: object.h:83
int power
Definition: object.h:369
byte ds
Number of sides on each damage die.
Definition: object.h:421
char * conflict
Definition: object.h:100
char * desc
Definition: object.h:102
struct object_kind * unknown_item_kind
Initialize objects
Definition: obj-init.c:1495
Structure for possible object kinds for an ego item.
Definition: object.h:301
int dd
Damage dice.
Definition: object.h:182
s16b to_d
Plusses to damage.
Definition: object.h:425
int tval
General artifact type (see TV_ macros)
Definition: object.h:252
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:283
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:346
random_value to_d
Definition: object.h:339
random_value to_a
Bonus to armor.
Definition: object.h:179
u16b oidx
Item list index, if any.
Definition: object.h:408
char * msg
Message for deth or whatever.
Definition: object.h:61
Definition: object.h:368
int alloc_max
Minimum depth (can appear earlier)
Definition: object.h:280
struct object_base * kb_info
Definition: obj-util.c:46
int sval
Artifact sub-type.
Definition: object.h:253
struct flavor * flavors
Definition: obj-util.c:50
uint8_t byte
Definition: h-basic.h:167
int break_perc
Definition: object.h:150
static const char * kind_flags[]
Definition: obj-init.c:73
Activation structure.
Definition: object.h:122
bool aware
Set if player is aware of the kind's effects.
Definition: object.h:223
int cost
Object base cost.
Definition: object.h:186
bool tried
Set if kind has been tried.
Definition: object.h:224
Information about object types, like rods, wands, etc.
Definition: object.h:138
random_value to_h
Bonus to hit.
Definition: object.h:177
int * curses
Array of curse powers.
Definition: object.h:196
int alloc_min
Highest normal dungeon level.
Definition: object.h:202
s16b ac
Normal AC.
Definition: object.h:422
int ac
Base armor.
Definition: object.h:180
const s16 modifiers[]
Definition: main-nds.c:61
random_value to_d
Bonus to damage.
Definition: object.h:178
Definition: object.h:107
bitflag flags
Definition: object.h:116
struct effect * effect
Definition: object.h:128
random_value charge
Number of charges (staves/wands)
Definition: object.h:211
char * verb
Definition: object.h:70
char * effect_msg
Definition: object.h:347
byte ignore
Ignore settings.
Definition: object.h:226
dice_t * dice
Dice expression used in the effect.
Definition: object.h:55
char * melee_verb
Definition: object.h:84
char * effect_msg
Definition: object.h:209
byte d_attr
Default object attribute.
Definition: object.h:198
char * text
Definition: object.h:246
int power
Definition: object.h:88
int alloc_min
Chance of being generated (i.e.
Definition: object.h:279
unsigned int fidx
Definition: object.h:501
int alloc_max
Minimum depth (can appear earlier)
Definition: object.h:334
int multiplier
Definition: object.h:87
Object information, for a specific object.
Definition: object.h:399
int * curses
Array of curse powers.
Definition: object.h:274
s16b res_level
Definition: object.h:115
struct object * prev
Previous object in a pile.
Definition: object.h:404
s16b weight
Item weight.
Definition: object.h:418
int power
Definition: object.h:127
int min_to_a
Definition: object.h:344
char * range_verb
Definition: object.h:85
struct object_kind * unknown_gold_kind
Definition: obj-init.c:1496
struct artifact * artifact
Artifact info of the object, if any.
Definition: object.h:402
int ds
Damage sides.
Definition: object.h:183
int gen_mult_prob
Probability of generating more than one.
Definition: object.h:213
int num_svals
Definition: object.h:152
u32b kidx
Definition: object.h:170
int tval
General object type (see TV_ macros)
Definition: object.h:172
struct activation * activation
Artifact activation, if applicable.
Definition: object.h:436
int min_to_h
Definition: object.h:342
bool created
Maximum depth (will NEVER appear deeper)
Definition: object.h:282
char * code
Definition: object.h:81
int ac
Base armor.
Definition: object.h:258
int x
X coordinate or distance.
Definition: object.h:57
s16b mimicking_m_idx
Monster mimicking us (if any)
Definition: object.h:444
struct artifact * a_info
The artifact arrays.
Definition: obj-util.c:48
Definition: object.h:362
int level
Definition: object.h:276
byte d_attr
Definition: object.h:506
bool * slays
Definition: object.h:328
struct object_kind * next
Definition: object.h:169
Definition: object.h:106
bool * brands
Array of brand structures.
Definition: object.h:430
byte dd
Number of damage dice.
Definition: object.h:420
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:320
int alloc_prob
Definition: object.h:332
Definition: object.h:364
bool * slays
Definition: object.h:273
struct slay * next
Definition: object.h:89
char * text
Definition: object.h:313
byte sval
Item sub-type (from kind)
Definition: object.h:414
int power
Power of the item's effect.
Definition: object.h:208
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:199
Definition: object.h:56
int level
Level (difficulty of activation)
Definition: object.h:204
struct activation * next
Definition: object.h:123
struct effect * next
Definition: object.h:53
struct object_kind * curse_object_kind
Definition: obj-init.c:1498
random_value time
Recharge time (rods/activation)
Definition: object.h:348
int16_t s16b
Definition: h-basic.h:170
bool * brands
Definition: object.h:327
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:431
int sval
Object sub-type.
Definition: object.h:173
int dd
Base damage dice.
Definition: object.h:260
Element info type.
Definition: object.h:114
random_value to_a
Definition: object.h:340
int to_h
Bonus to hit.
Definition: object.h:255
quark_t note_aware
Also saved in savefile.
Definition: object.h:220
u32b kidx
Definition: object.h:302
byte iy
Y-position on map, or zero.
Definition: object.h:410
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:207
A struct representing a strategy for making a dice roll.
Definition: z-rand.h:40
char * name
Definition: object.h:245
bool aim
Definition: object.h:126
Save memory by storing strings in a global array, ensuring that each is only allocated once...
int min_to_d
Definition: object.h:343
struct effect * effect
Effect this item produces (effects.c)
Definition: object.h:434
int subtype
Projection type, timed effect type, etc.
Definition: object.h:58
Information about ego-items.
Definition: object.h:309
#define OF_SIZE
Definition: obj-properties.h:120
static struct object const OBJECT_NULL
Null object constant, for safe initialization.
Definition: object.h:456
int alloc_prob
Allocation: commonness.
Definition: object.h:201
struct poss_item * next
Definition: object.h:303
Definition: obj-properties.h:114
struct object * obj
Definition: object.h:99
int to_a
Bonus to armor.
Definition: object.h:257
random_value to_h
Definition: object.h:338
int weight
Weight, in 1/10lbs.
Definition: object.h:184
struct curse_data * curses
Array of curse powers and timeouts.
Definition: object.h:432
struct poss_item * poss_items
Maximum depth (will NEVER appear deeper)
Definition: object.h:336
char * desc
Definition: object.h:130
char * effect_msg
Message on use.
Definition: object.h:435
random_value pval
Definition: object.h:175
struct object_kind * pile_kind
Definition: obj-init.c:1497
int index
Definition: object.h:125
struct activation * activation
Artifact-like activation.
Definition: object.h:206
struct artifact * next
Definition: object.h:250
int cost
Artifact (pseudo-)worth.
Definition: object.h:265
int tval
Definition: object.h:141
int max_stack
Definition: object.h:151
bool * slays
Definition: object.h:195
wchar_t d_char
Definition: object.h:507
quark_t note_unaware
Autoinscription quark number.
Definition: object.h:221
Curse type.
Definition: object.h:95
s16b pval
Item extra-parameter.
Definition: object.h:416
byte number
Number of items.
Definition: object.h:440
random_value time
Recharge time (rods/activation)
Definition: object.h:437
byte tval
Definition: object.h:503
struct brand * next
Definition: object.h:74
int weight
Weight in 1/10lbs.
Definition: object.h:263
Definition: object.h:365
struct activation * activations
Definition: obj-randart.c:45
Effect.
Definition: object.h:52
quark_t note
Inscription index.
Definition: object.h:450
byte ix
X-position on map, or zero.
Definition: object.h:411
bool * brands
Definition: object.h:194
struct monster_race * origin_race
Monster race that dropped it.
Definition: object.h:448
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:401
int to_d
Bonus to damage.
Definition: object.h:256
int timeout
Definition: object.h:370
int power
Definition: object.h:73
random_value time
Recharge time (rods/activation)
Definition: object.h:210
struct object * known
Known version of this object.
Definition: object.h:406
s16b to_h
Plusses to hit.
Definition: object.h:424
s16b timeout
Timeout Counter.
Definition: object.h:438
#define KF_SIZE
Definition: obj-properties.h:140
char * name
Definition: object.h:312
bool everseen
Whether this artifact has ever been seen.
Definition: object.h:284
struct object_kind * kind
Kind of the object.
Definition: object.h:400
int alloc_min
Chance of being generated (i.e.
Definition: object.h:333
char * name
Definition: object.h:82
Brand type.
Definition: object.h:67
Information about artifacts.
Definition: object.h:244
u16b index
The effect index.
Definition: object.h:54
size_t quark_t
Quark type.
Definition: z-quark.h:29
Definition: object.h:363
char * name
Definition: object.h:139
random_value time
Recharge time (if appropriate)
Definition: object.h:289
int multiplier
Definition: object.h:72
char * name
Definition: object.h:164
byte sval
Definition: object.h:504
Write value lines for a set of modifiers.
char * code
Definition: object.h:68
A Random Number Generator for Angband.