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  u16b index; /* Numerical index (RSF_FOO) */
173  int msgt; /* Flag for message colouring */
174  char *message; /* Description of the attack */
175  char *blind_message; /* Description of the attack if unseen */
176  char *message_strong; /* Description of the attack (strong version) */
177  char *blind_message_strong;/* Attack description if unseen (strong)*/
178  char *miss_message; /* Description of a missed attack */
179  char *save_message; /* Message on passing saving throw, if any */
180  char *lore_desc; /* Description of the attack used in lore text */
181  char *lore_desc_strong; /* Attack description used in lore text (strong) */
182  byte lore_attr; /* Color of the attack used in lore text */
183  byte lore_attr_resist; /* Color used in lore text when resisted */
184  byte lore_attr_immune; /* Color used in lore text when resisted strongly */
185  int hit; /* To-hit level for the attack */
186  struct effect *effect; /* Effect(s) of the spell */
187  random_value power; /* Relative power of the spell */
188 };
189 
190 
194 struct monster_base {
196 
197  char *name; /* Name for recognition in code */
198  char *text; /* In-game name */
199 
200  bitflag flags[RF_SIZE]; /* Flags */
201  bitflag spell_flags[RSF_SIZE]; /* Spell flags */
202 
203  wchar_t d_char; /* Default monster character */
204 
205  struct monster_pain *pain; /* Pain messages */
206 };
207 
208 
212 struct monster_drop {
214  struct object_kind *kind;
215  unsigned int tval;
216  unsigned int percent_chance;
217  unsigned int min;
218  unsigned int max;
219 };
220 
226  char *name;
228  unsigned int percent_chance;
229  unsigned int number_dice;
230  unsigned int number_side;
231 };
232 
239  unsigned int percent_chance;
240  unsigned int number_dice;
241  unsigned int number_side;
242 };
243 
249  struct object_kind *kind;
250 };
251 
267 struct monster_race {
269 
270  unsigned int ridx;
271 
272  char *name;
273  char *text;
274  char *plural; /* Optional pluralized name */
275 
277 
278  int avg_hp; /* Average HP for this creature */
279 
280  int ac; /* Armour Class */
281 
282  int sleep; /* Inactive counter (base) */
283  int hearing; /* Monster sense of hearing (1-100, standard 20) */
284  int smell; /* Monster sense of smell (0-50, standard 20) */
285  int speed; /* Speed (normally 110) */
286 
287  int mexp; /* Exp value for kill */
288 
289  int freq_innate; /* Innate spell frequency */
290  int freq_spell; /* Other spell frequency */
291  int spell_power; /* Power of spells */
292 
293  bitflag flags[RF_SIZE]; /* Flags */
294  bitflag spell_flags[RSF_SIZE]; /* Spell flags */
295 
296  struct monster_blow *blow; /* Melee blows */
297 
298  int level; /* Level of creature */
299  int rarity; /* Rarity of creature */
300 
301  byte d_attr; /* Default monster attribute */
302  wchar_t d_char; /* Default monster character */
303 
304  byte max_num; /* Maximum population allowed per level */
305  int cur_num; /* Monster population on current level */
306 
308 
310 
312 
314 };
315 
316 
325 struct monster {
327  int midx;
328 
329  byte fy; /* Y location on map */
330  byte fx; /* X location on map */
331 
332  s16b hp; /* Current Hit points */
333  s16b maxhp; /* Max Hit points */
334 
335  s16b m_timed[MON_TMD_MAX]; /* Timed monster status effects */
336 
337  byte mspeed; /* Monster "speed" */
338  byte energy; /* Monster "energy" */
339 
340  byte cdis; /* Current dis from player */
341 
342  bitflag mflag[MFLAG_SIZE]; /* Temporary monster flags */
343 
344  struct object *mimicked_obj; /* Object this monster is mimicking */
345  struct object *held_obj; /* Object being held (if any) */
346 
347  byte attr; /* attr last used for drawing monster */
348 
349  struct player_state known_pstate; /* Known player state */
350 
351  struct target target;
355 };
356 
359 extern s16b num_repro;
360 
361 extern struct monster_pain *pain_messages;
362 extern struct monster_spell *monster_spells;
363 extern struct monster_base *rb_info;
364 extern struct monster_race *r_info;
365 extern const struct monster_race *ref_race;
366 
367 #endif /* !MONSTER_MONSTER_H */
uint16_t u16b
Definition: h-basic.h:169
struct object * mimicked_obj
Definition: monster.h:344
Monster pain messages.
Definition: monster.h:158
Definition: monster.h:56
char * plural
Definition: monster.h:274
Definition: monster.h:53
unsigned int max
Definition: monster.h:218
Specified monster drops.
Definition: monster.h:212
char * name
Definition: monster.h:197
Monster "race" information, including racial memories.
Definition: monster.h:267
Definition: monster.h:50
char * message
Definition: monster.h:174
char * blind_message_strong
Definition: monster.h:177
Low-level bit vector manipulation.
monster_flag_type
The monster flag types.
Definition: monster.h:47
char * name
Definition: monster.h:272
Monster information, for a specific monster.
Definition: monster.h:325
Definition: mon-blows.h:31
random_value dice
Definition: monster.h:151
Definition: monster.h:56
byte lore_attr
Definition: monster.h:182
struct monster_spell * next
Definition: monster.h:170
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.
char * save_message
Definition: monster.h:179
Definition: monster.h:51
byte min_range
What is the closest we want to be? Not saved.
Definition: monster.h:353
struct monster_base * rb_info
Definition: mon-init.c:41
byte fy
Definition: monster.h:329
unsigned int percent_chance
Definition: monster.h:228
struct object_kind * kind
Definition: monster.h:214
unsigned int number_side
Definition: monster.h:230
char * blind_message
Definition: monster.h:175
Definition: monster.h:60
struct monster_drop * drops
Definition: monster.h:307
int spell_power
Definition: monster.h:291
s16b num_repro
Variables.
Definition: mon-make.c:36
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:229
List of monster spell flags.
byte d_attr
Definition: monster.h:301
struct monster_drop * next
Definition: monster.h:213
Definition: monster.h:61
struct monster_race * race
Definition: monster.h:227
Monster spell types.
Definition: monster.h:169
Monster friends (specific monster)
Definition: monster.h:224
struct monster_blow * next
Definition: monster.h:147
All the variable state that changes when you put on/take off equipment.
Definition: player.h:385
int level
Definition: monster.h:298
Object information, for a specific object.
Definition: object.h:399
struct monster_mimic * next
Definition: monster.h:248
Definition: mon-blows.h:72
struct object * held_obj
Definition: monster.h:345
int freq_innate
Definition: monster.h:289
#define MFLAG_SIZE
Definition: monster.h:67
The lowest level header.
u16b type
Definition: monster.h:139
wchar_t d_char
Definition: monster.h:203
int sleep
Definition: monster.h:282
byte cdis
Definition: monster.h:340
byte max_num
Definition: monster.h:304
struct monster_base * base
Definition: monster.h:276
struct monster_base * next
Definition: monster.h:195
Definition: monster.h:49
s16b hp
Definition: monster.h:332
struct monster_race * r_info
Definition: mon-init.c:42
struct monster_pain * next
Definition: monster.h:162
Base monster type.
Definition: monster.h:194
int speed
Definition: monster.h:285
struct blow_effect * effect
Definition: monster.h:150
png_uint_32 int flags
Definition: libpng12/png.h:1681
int rarity
Definition: monster.h:299
struct monster_race * next
Definition: monster.h:268
char * name
Definition: monster.h:226
struct effect * effect
Definition: monster.h:186
int avg_hp
Definition: monster.h:278
byte attr
Definition: monster.h:347
byte bitflag
Definition: z-bitflag.h:27
byte fx
Definition: monster.h:330
unsigned int number_dice
Definition: monster.h:240
char * message_strong
Definition: monster.h:176
byte best_range
How close do we want to be? Not saved.
Definition: monster.h:354
int16_t s16b
Definition: h-basic.h:170
char * text
Definition: monster.h:198
byte lore_attr_immune
Definition: monster.h:184
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:216
struct monster_friends * next
Definition: monster.h:225
char * text
Definition: monster.h:273
int freq_spell
Definition: monster.h:290
u16b index
Definition: monster.h:138
int hearing
Definition: monster.h:283
int smell
Definition: monster.h:284
Definition: monster.h:54
struct monster_friends * friends
Definition: monster.h:309
s16b maxhp
Definition: monster.h:333
struct monster_base * base
Definition: monster.h:238
unsigned int percent_chance
Definition: monster.h:239
Definition: monster.h:183
bitflag spell_flags[RSF_SIZE]
Definition: monster.h:201
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
struct monster_friends_base * next
Definition: monster.h:237
Definition: monster.h:58
struct object_kind * kind
Definition: monster.h:249
int ac
Definition: monster.h:280
byte energy
Definition: monster.h:338
char * miss_message
Definition: monster.h:178
unsigned int min
Definition: monster.h:217
Targetting code.
struct monster_spell * monster_spells
Definition: mon-init.c:40
struct monster_mimic * mimic_kinds
Definition: monster.h:313
unsigned int ridx
Definition: monster.h:270
struct blow_method * method
Definition: monster.h:149
Effect.
Definition: object.h:52
monster race flags
struct monster_blow * blow
Definition: monster.h:296
int hit
Definition: monster.h:185
Definition: monster.h:62
Definition: monster.h:55
byte lore_attr_resist
Definition: monster.h:183
int msgt
Definition: monster.h:173
Definition: monster.h:57
int times_seen
Definition: monster.h:152
struct monster_friends_base * friends_base
Definition: monster.h:311
random_value power
Definition: monster.h:187
Definition: monster.h:48
int cur_num
Definition: monster.h:305
byte mspeed
Definition: monster.h:337
char * lore_desc_strong
Definition: monster.h:181
struct monster_pain * pain_messages
Definition: mon-init.c:39
unsigned int number_side
Definition: monster.h:241
const struct monster_race * ref_race
Definition: mon-init.c:43
How monsters mimic.
Definition: monster.h:247
struct monster_race * race
Definition: monster.h:326
struct monster_pain * pain
Definition: monster.h:205
wchar_t d_char
Definition: monster.h:302
Temporary monster flags.
#define RF_SIZE
Definition: monster.h:97
Definition: target.h:39
Monster friends (general type)
Definition: monster.h:236
Monster blows.
Definition: monster.h:146
u16b index
Definition: monster.h:172
unsigned int tval
Definition: monster.h:215
int mexp
Definition: monster.h:287
Functions for managing monster melee.
int midx
Definition: monster.h:327
char * lore_desc
Definition: monster.h:180
A Random Number Generator for Angband.