Angband
monster.h
Go to the documentation of this file.
1 
19 #ifndef MONSTER_MONSTER_H
20 #define MONSTER_MONSTER_H
21 
22 #include "h-basic.h"
23 #include "z-bitflag.h"
24 #include "z-rand.h"
25 #include "cave.h"
26 #include "target.h"
27 #include "mon-timed.h"
28 #include "mon-blows.h"
29 
30 /*** Monster flags ***/
31 
35 enum
36 {
37  #define MFLAG(a, b) MFLAG_##a,
38  #include "list-mon-temp-flags.h"
39  #undef MFLAG
40  MFLAG_MAX
41 };
42 
43 
48  RFT_NONE = 0, /* placeholder flag */
49  RFT_OBV, /* an obvious property */
50  RFT_DISP, /* for display purposes */
51  RFT_GEN, /* related to generation */
52  RFT_NOTE, /* especially noteworthy for lore */
53  RFT_BEHAV, /* behaviour-related */
54  RFT_DROP, /* drop details */
55  RFT_DET, /* detection properties */
56  RFT_ALTER, /* environment shaping */
57  RFT_RACE_N, /* types of monster (noun) */
58  RFT_RACE_A, /* types of monster (adjective) */
59  RFT_VULN, /* vulnerabilities with no corresponding resistance */
60  RFT_VULN_I, /* vulnerabilities with a corresponding resistance */
61  RFT_RES, /* elemental resistances */
62  RFT_PROT, /* immunity from status effects */
63 
65 };
66 
67 #define MFLAG_SIZE FLAG_SIZE(MFLAG_MAX)
68 
69 #define mflag_has(f, flag) flag_has_dbg(f, MFLAG_SIZE, flag, #f, #flag)
70 #define mflag_next(f, flag) flag_next(f, MFLAG_SIZE, flag)
71 #define mflag_is_empty(f) flag_is_empty(f, MFLAG_SIZE)
72 #define mflag_is_full(f) flag_is_full(f, MFLAG_SIZE)
73 #define mflag_is_inter(f1, f2) flag_is_inter(f1, f2, MFLAG_SIZE)
74 #define mflag_is_subset(f1, f2) flag_is_subset(f1, f2, MFLAG_SIZE)
75 #define mflag_is_equal(f1, f2) flag_is_equal(f1, f2, MFLAG_SIZE)
76 #define mflag_on(f, flag) flag_on_dbg(f, MFLAG_SIZE, flag, #f, #flag)
77 #define mflag_off(f, flag) flag_off(f, MFLAG_SIZE, flag)
78 #define mflag_wipe(f) flag_wipe(f, MFLAG_SIZE)
79 #define mflag_setall(f) flag_setall(f, MFLAG_SIZE)
80 #define mflag_negate(f) flag_negate(f, MFLAG_SIZE)
81 #define mflag_copy(f1, f2) flag_copy(f1, f2, MFLAG_SIZE)
82 #define mflag_union(f1, f2) flag_union(f1, f2, MFLAG_SIZE)
83 #define mflag_inter(f1, f2) flag_inter(f1, f2, MFLAG_SIZE)
84 #define mflag_diff(f1, f2) flag_diff(f1, f2, MFLAG_SIZE)
85 
89 enum
90 {
91  #define RF(a, b, c) RF_##a,
92  #include "list-mon-race-flags.h"
93  #undef RF
94  RF_MAX
95 };
96 
97 #define RF_SIZE FLAG_SIZE(RF_MAX)
98 
99 #define rf_has(f, flag) flag_has_dbg(f, RF_SIZE, flag, #f, #flag)
100 #define rf_next(f, flag) flag_next(f, RF_SIZE, flag)
101 #define rf_count(f) flag_count(f, RF_SIZE)
102 #define rf_is_empty(f) flag_is_empty(f, RF_SIZE)
103 #define rf_is_full(f) flag_is_full(f, RF_SIZE)
104 #define rf_is_inter(f1, f2) flag_is_inter(f1, f2, RF_SIZE)
105 #define rf_is_subset(f1, f2) flag_is_subset(f1, f2, RF_SIZE)
106 #define rf_is_equal(f1, f2) flag_is_equal(f1, f2, RF_SIZE)
107 #define rf_on(f, flag) flag_on_dbg(f, RF_SIZE, flag, #f, #flag)
108 #define rf_off(f, flag) flag_off(f, RF_SIZE, flag)
109 #define rf_wipe(f) flag_wipe(f, RF_SIZE)
110 #define rf_setall(f) flag_setall(f, RF_SIZE)
111 #define rf_negate(f) flag_negate(f, RF_SIZE)
112 #define rf_copy(f1, f2) flag_copy(f1, f2, RF_SIZE)
113 #define rf_union(f1, f2) flag_union(f1, f2, RF_SIZE)
114 #define rf_comp_union(f1, f2) flag_comp_union(f1, f2, RF_SIZE)
115 #define rf_inter(f1, f2) flag_inter(f1, f2, RF_SIZE)
116 #define rf_diff(f1, f2) flag_diff(f1, f2, RF_SIZE)
117 
118 
122 enum
123 {
124  #define RSF(a, b) RSF_##a,
125  #include "list-mon-spells.h"
126  #undef RSF
127 };
128 
129 #define RSF_SIZE FLAG_SIZE(RSF_MAX)
130 
131 
137 struct monster_flag {
138  u16b index; /* the RF_ index */
139  u16b type; /* RFT_ category */
140  const char *desc; /* lore description */
141 };
142 
146 struct monster_blow {
147  struct monster_blow *next; /* Unused after parsing */
148 
149  struct blow_method *method; /* Method */
150  struct blow_effect *effect; /* Effect */
151  random_value dice; /* Damage dice */
152  int times_seen; /* Sightings of the blow (lore only) */
153 };
154 
158 struct monster_pain {
159  const char *messages[7];
160  int pain_idx;
161 
163 };
164 
165 
171 
172  int power; /* Spell power at which this level starts */
173  char *lore_desc; /* Description of the attack used in lore text */
174  byte lore_attr; /* Color of the attack used in lore text */
175  byte lore_attr_resist; /* Color used in lore text when resisted */
176  byte lore_attr_immune; /* Color used in lore text when resisted strongly */
177  char *message; /* Description of the attack */
178  char *blind_message; /* Description of the attack if unseen */
179  char *miss_message; /* Description of a missed attack */
180  char *save_message; /* Message on passing saving throw, if any */
181 };
182 
188 
189  u16b index; /* Numerical index (RSF_FOO) */
190  int msgt; /* Flag for message colouring */
191  int hit; /* To-hit level for the attack */
192  struct effect *effect; /* Effect(s) of the spell */
193  struct monster_spell_level *level; /* Spell power dependent details */
194 };
195 
196 
200 struct monster_base {
202 
203  char *name; /* Name for recognition in code */
204  char *text; /* In-game name */
205 
206  bitflag flags[RF_SIZE]; /* Flags */
207  bitflag spell_flags[RSF_SIZE]; /* Spell flags */
208 
209  wchar_t d_char; /* Default monster character */
210 
211  struct monster_pain *pain; /* Pain messages */
212 };
213 
214 
218 struct monster_drop {
220  struct object_kind *kind;
221  unsigned int tval;
222  unsigned int percent_chance;
223  unsigned int min;
224  unsigned int max;
225 };
226 
233 };
234 
240  char *name;
243  unsigned int percent_chance;
244  unsigned int number_dice;
245  unsigned int number_side;
246 };
247 
255  unsigned int percent_chance;
256  unsigned int number_dice;
257  unsigned int number_side;
258 };
259 
264  int index;
266 };
267 
272 };
273 
279  struct object_kind *kind;
280 };
281 
287  char *name;
290 };
291 
307 struct monster_race {
309 
310  unsigned int ridx;
311 
312  char *name;
313  char *text;
314  char *plural; /* Optional pluralized name */
315 
317 
318  int avg_hp; /* Average HP for this creature */
319 
320  int ac; /* Armour Class */
321 
322  int sleep; /* Inactive counter (base) */
323  int hearing; /* Monster sense of hearing (1-100, standard 20) */
324  int smell; /* Monster sense of smell (0-50, standard 20) */
325  int speed; /* Speed (normally 110) */
326  int light; /* Light intensity */
327 
328  int mexp; /* Exp value for kill */
329 
330  int freq_innate; /* Innate spell frequency */
331  int freq_spell; /* Other spell frequency */
332  int spell_power; /* Power of spells */
333 
334  bitflag flags[RF_SIZE]; /* Flags */
335  bitflag spell_flags[RSF_SIZE]; /* Spell flags */
336 
337  struct monster_blow *blow; /* Melee blows */
338 
339  int level; /* Level of creature */
340  int rarity; /* Rarity of creature */
341 
342  byte d_attr; /* Default monster attribute */
343  wchar_t d_char; /* Default monster character */
344 
345  byte max_num; /* Maximum population allowed per level */
346  int cur_num; /* Monster population on current level */
347 
349 
351 
353 
355 
358 };
359 
360 
369 struct monster {
370  struct monster_race *race; /* Monster's (current) race */
371  struct monster_race *original_race; /* Changed monster's original race */
372  int midx;
373 
374  struct loc grid; /* Location on map */
375 
376  s16b hp; /* Current Hit points */
377  s16b maxhp; /* Max Hit points */
378 
379  s16b m_timed[MON_TMD_MAX]; /* Timed monster status effects */
380 
381  byte mspeed; /* Monster "speed" */
382  byte energy; /* Monster "energy" */
383 
384  byte cdis; /* Current dis from player */
385 
386  bitflag mflag[MFLAG_SIZE]; /* Temporary monster flags */
387 
388  struct object *mimicked_obj; /* Object this monster is mimicking */
389  struct object *held_obj; /* Object being held (if any) */
390 
391  byte attr; /* attr last used for drawing monster */
392 
393  struct player_state known_pstate; /* Known player state */
394 
395  struct target target; /* Monster target */
396 
397  struct monster_group_info group_info[GROUP_MAX];/* Monster group details */
398  struct heatmap heatmap; /* Monster location heatmap */
399 
400  byte min_range; /* What is the closest we want to be? */
401  byte best_range; /* How close do we want to be? */
402 };
403 
406 extern struct monster_pain *pain_messages;
407 extern struct monster_spell *monster_spells;
408 extern struct monster_base *rb_info;
409 extern struct monster_race *r_info;
410 extern const struct monster_race *ref_race;
411 
412 #endif /* !MONSTER_MONSTER_H */
uint16_t u16b
Definition: h-basic.h:169
struct object * mimicked_obj
Definition: monster.h:388
Monster pain messages.
Definition: monster.h:158
char * blind_message
Definition: monster.h:178
Definition: monster.h:57
char * plural
Definition: monster.h:314
struct monster_race * race
Definition: monster.h:288
Definition: cave.h:167
Definition: monster.h:53
unsigned int max
Definition: monster.h:224
char * name
Definition: monster.h:287
Specified monster drops.
Definition: monster.h:218
char * name
Definition: monster.h:203
Monster "race" information, including racial memories.
Definition: monster.h:307
Definition: monster.h:50
Low-level bit vector manipulation.
monster_flag_type
The monster flag types.
Definition: monster.h:47
char * name
Definition: monster.h:312
char * lore_desc
Definition: monster.h:173
Monster information, for a specific monster.
Definition: monster.h:369
Definition: mon-blows.h:31
random_value dice
Definition: monster.h:151
Definition: monster.h:56
Different shapes a monster can take.
Definition: monster.h:285
Definition: z-type.h:24
struct monster_spell_level * level
Definition: monster.h:193
struct monster_spell * next
Definition: monster.h:187
monster_group_type
Definition: monster.h:268
Information about object kinds, including player knowledge.
Definition: object.h:163
Definition: monster.h:64
Definition: monster.h:52
Structures and functions for monster timed effects.
Definition: monster.h:51
struct monster_spell_level * next
Definition: monster.h:170
byte min_range
Definition: monster.h:400
struct monster_base * rb_info
Definition: mon-init.c:41
unsigned int percent_chance
Definition: monster.h:243
struct object_kind * kind
Definition: monster.h:220
unsigned int number_side
Definition: monster.h:245
Definition: monster.h:60
struct monster_drop * drops
Definition: monster.h:348
int spell_power
Definition: monster.h:332
struct monster_shape * shapes
Definition: monster.h:356
int num_shapes
Definition: monster.h:357
uint8_t byte
Definition: h-basic.h:167
#define RSF_SIZE
Definition: monster.h:129
const char * desc
Definition: monster.h:140
unsigned int number_dice
Definition: monster.h:244
List of monster spell flags.
struct monster_base * base
Definition: monster.h:289
byte d_attr
Definition: monster.h:342
struct monster_drop * next
Definition: monster.h:219
Definition: monster.h:61
struct monster_race * race
Definition: monster.h:241
Monster spell types.
Definition: monster.h:186
Monster friends (specific monster)
Definition: monster.h:238
struct monster_blow * next
Definition: monster.h:147
Definition: monster.h:230
All the variable state that changes when you put on/take off equipment.
Definition: player.h:385
int level
Definition: monster.h:339
Object information, for a specific object.
Definition: object.h:399
struct monster_mimic * next
Definition: monster.h:278
Monster spell levels.
Definition: monster.h:169
Definition: mon-blows.h:72
struct object * held_obj
Definition: monster.h:389
int freq_innate
Definition: monster.h:330
#define MFLAG_SIZE
Definition: monster.h:67
char * miss_message
Definition: monster.h:179
The lowest level header.
u16b type
Definition: monster.h:139
wchar_t d_char
Definition: monster.h:209
Monster group info.
Definition: monster.h:263
int sleep
Definition: monster.h:322
byte cdis
Definition: monster.h:384
byte max_num
Definition: monster.h:345
struct monster_base * base
Definition: monster.h:316
struct monster_base * next
Definition: monster.h:201
Definition: monster.h:49
s16b hp
Definition: monster.h:376
struct monster_race * r_info
Definition: mon-init.c:42
struct monster_race * original_race
Definition: monster.h:371
struct monster_pain * next
Definition: monster.h:162
Base monster type.
Definition: monster.h:200
int speed
Definition: monster.h:325
struct blow_effect * effect
Definition: monster.h:150
png_uint_32 int flags
Definition: libpng12/png.h:1681
int rarity
Definition: monster.h:340
struct monster_race * next
Definition: monster.h:308
char * name
Definition: monster.h:240
struct effect * effect
Definition: monster.h:192
int avg_hp
Definition: monster.h:318
Definition: monster.h:228
byte attr
Definition: monster.h:391
byte bitflag
Definition: z-bitflag.h:27
unsigned int number_dice
Definition: monster.h:256
int power
Definition: monster.h:172
byte best_range
Definition: monster.h:401
int16_t s16b
Definition: h-basic.h:170
char * text
Definition: monster.h:204
char * save_message
Definition: monster.h:180
char * message
Definition: monster.h:177
Structures.
Definition: monster.h:137
A struct representing a strategy for making a dice roll.
Definition: z-rand.h:40
unsigned int percent_chance
Definition: monster.h:222
struct monster_friends * next
Definition: monster.h:239
char * text
Definition: monster.h:313
int freq_spell
Definition: monster.h:331
u16b index
Definition: monster.h:138
int hearing
Definition: monster.h:323
int smell
Definition: monster.h:324
Definition: monster.h:54
struct monster_shape * next
Definition: monster.h:286
struct monster_friends * friends
Definition: monster.h:350
s16b maxhp
Definition: monster.h:377
struct monster_base * base
Definition: monster.h:253
unsigned int percent_chance
Definition: monster.h:255
Definition: monster.h:186
bitflag spell_flags[RSF_SIZE]
Definition: monster.h:207
Matters relating to the current dungeon level.
int pain_idx
Definition: monster.h:160
static msgqueue_t * messages
Definition: message.c:52
Definition: monster.h:59
Definition: monster.h:229
struct monster_friends_base * next
Definition: monster.h:252
Definition: monster.h:58
struct object_kind * kind
Definition: monster.h:279
int ac
Definition: monster.h:320
byte energy
Definition: monster.h:382
unsigned int min
Definition: monster.h:223
Targetting code.
struct monster_spell * monster_spells
Definition: mon-init.c:40
struct monster_mimic * mimic_kinds
Definition: monster.h:354
unsigned int ridx
Definition: monster.h:310
byte lore_attr_immune
Definition: monster.h:176
struct blow_method * method
Definition: monster.h:149
Effect.
Definition: object.h:52
monster race flags
byte lore_attr
Definition: monster.h:174
struct monster_blow * blow
Definition: monster.h:337
int hit
Definition: monster.h:191
int index
Definition: monster.h:264
Definition: monster.h:62
Definition: monster.h:55
int msgt
Definition: monster.h:190
Definition: monster.h:57
int times_seen
Definition: monster.h:152
struct monster_friends_base * friends_base
Definition: monster.h:352
Definition: monster.h:48
int cur_num
Definition: monster.h:346
byte mspeed
Definition: monster.h:381
Definition: monster.h:270
struct monster_pain * pain_messages
Variables.
Definition: mon-init.c:39
unsigned int number_side
Definition: monster.h:257
const struct monster_race * ref_race
Definition: mon-init.c:43
How monsters mimic.
Definition: monster.h:277
struct monster_race * race
Definition: monster.h:370
Definition: monster.h:269
int light
Definition: monster.h:326
struct monster_pain * pain
Definition: monster.h:211
monster_group_role
Definition: monster.h:227
Definition: monster.h:271
wchar_t d_char
Definition: monster.h:343
Temporary monster flags.
Definition: monster.h:232
byte lore_attr_resist
Definition: monster.h:175
Definition: monster.h:231
#define RF_SIZE
Definition: monster.h:97
Definition: target.h:39
Monster friends (general type)
Definition: monster.h:251
Monster blows.
Definition: monster.h:146
u16b index
Definition: monster.h:189
unsigned int tval
Definition: monster.h:221
int mexp
Definition: monster.h:328
Functions for managing monster melee.
int midx
Definition: monster.h:372
A Random Number Generator for Angband.