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 "mon-timed.h"
27 #include "mon-blows.h"
28 
29 /*** Monster flags ***/
30 
34 enum
35 {
36  #define MFLAG(a, b) MFLAG_##a,
37  #include "list-mon-temp-flags.h"
38  #undef MFLAG
39  MFLAG_MAX
40 };
41 
42 
47  RFT_NONE = 0, /* placeholder flag */
48  RFT_OBV, /* an obvious property */
49  RFT_DISP, /* for display purposes */
50  RFT_GEN, /* related to generation */
51  RFT_NOTE, /* especially noteworthy for lore */
52  RFT_BEHAV, /* behaviour-related */
53  RFT_DROP, /* drop details */
54  RFT_DET, /* detection properties */
55  RFT_ALTER, /* environment shaping */
56  RFT_RACE_N, /* types of monster (noun) */
57  RFT_RACE_A, /* types of monster (adjective) */
58  RFT_VULN, /* vulnerabilities with no corresponding resistance */
59  RFT_VULN_I, /* vulnerabilities with a corresponding resistance */
60  RFT_RES, /* elemental resistances */
61  RFT_PROT, /* immunity from status effects */
62 
64 };
65 
66 #define MFLAG_SIZE FLAG_SIZE(MFLAG_MAX)
67 
68 #define mflag_has(f, flag) flag_has_dbg(f, MFLAG_SIZE, flag, #f, #flag)
69 #define mflag_next(f, flag) flag_next(f, MFLAG_SIZE, flag)
70 #define mflag_is_empty(f) flag_is_empty(f, MFLAG_SIZE)
71 #define mflag_is_full(f) flag_is_full(f, MFLAG_SIZE)
72 #define mflag_is_inter(f1, f2) flag_is_inter(f1, f2, MFLAG_SIZE)
73 #define mflag_is_subset(f1, f2) flag_is_subset(f1, f2, MFLAG_SIZE)
74 #define mflag_is_equal(f1, f2) flag_is_equal(f1, f2, MFLAG_SIZE)
75 #define mflag_on(f, flag) flag_on_dbg(f, MFLAG_SIZE, flag, #f, #flag)
76 #define mflag_off(f, flag) flag_off(f, MFLAG_SIZE, flag)
77 #define mflag_wipe(f) flag_wipe(f, MFLAG_SIZE)
78 #define mflag_setall(f) flag_setall(f, MFLAG_SIZE)
79 #define mflag_negate(f) flag_negate(f, MFLAG_SIZE)
80 #define mflag_copy(f1, f2) flag_copy(f1, f2, MFLAG_SIZE)
81 #define mflag_union(f1, f2) flag_union(f1, f2, MFLAG_SIZE)
82 #define mflag_inter(f1, f2) flag_inter(f1, f2, MFLAG_SIZE)
83 #define mflag_diff(f1, f2) flag_diff(f1, f2, MFLAG_SIZE)
84 
88 enum
89 {
90  #define RF(a, b, c) RF_##a,
91  #include "list-mon-race-flags.h"
92  #undef RF
93  RF_MAX
94 };
95 
96 #define RF_SIZE FLAG_SIZE(RF_MAX)
97 
98 #define rf_has(f, flag) flag_has_dbg(f, RF_SIZE, flag, #f, #flag)
99 #define rf_next(f, flag) flag_next(f, RF_SIZE, flag)
100 #define rf_count(f) flag_count(f, RF_SIZE)
101 #define rf_is_empty(f) flag_is_empty(f, RF_SIZE)
102 #define rf_is_full(f) flag_is_full(f, RF_SIZE)
103 #define rf_is_inter(f1, f2) flag_is_inter(f1, f2, RF_SIZE)
104 #define rf_is_subset(f1, f2) flag_is_subset(f1, f2, RF_SIZE)
105 #define rf_is_equal(f1, f2) flag_is_equal(f1, f2, RF_SIZE)
106 #define rf_on(f, flag) flag_on_dbg(f, RF_SIZE, flag, #f, #flag)
107 #define rf_off(f, flag) flag_off(f, RF_SIZE, flag)
108 #define rf_wipe(f) flag_wipe(f, RF_SIZE)
109 #define rf_setall(f) flag_setall(f, RF_SIZE)
110 #define rf_negate(f) flag_negate(f, RF_SIZE)
111 #define rf_copy(f1, f2) flag_copy(f1, f2, RF_SIZE)
112 #define rf_union(f1, f2) flag_union(f1, f2, RF_SIZE)
113 #define rf_comp_union(f1, f2) flag_comp_union(f1, f2, RF_SIZE)
114 #define rf_inter(f1, f2) flag_inter(f1, f2, RF_SIZE)
115 #define rf_diff(f1, f2) flag_diff(f1, f2, RF_SIZE)
116 
117 
121 enum
122 {
123  #define RSF(a, b) RSF_##a,
124  #include "list-mon-spells.h"
125  #undef RSF
126 };
127 
128 #define RSF_SIZE FLAG_SIZE(RSF_MAX)
129 
130 
136 struct monster_flag {
137  u16b index; /* the RF_ index */
138  u16b type; /* RFT_ category */
139  const char *desc; /* lore description */
140 };
141 
145 struct monster_blow {
146  struct monster_blow *next; /* Unused after parsing */
147 
148  struct blow_method *method; /* Method */
149  struct blow_effect *effect; /* Effect */
150  random_value dice; /* Damage dice */
151  int times_seen; /* Sightings of the blow (lore only) */
152 };
153 
157 struct monster_pain {
158  const char *messages[7];
159  int pain_idx;
160 
162 };
163 
164 
170 
171  u16b index; /* Numerical index (RSF_FOO) */
172  int msgt; /* Flag for message colouring */
173  char *message; /* Description of the attack */
174  char *blind_message; /* Description of the attack if unseen */
175  char *message_strong; /* Description of the attack (strong version) */
176  char *blind_message_strong;/* Attack description if unseen (strong)*/
177  char *miss_message; /* Description of a missed attack */
178  char *save_message; /* Message on passing saving throw, if any */
179  char *lore_desc; /* Description of the attack used in lore text */
180  char *lore_desc_strong; /* Attack description used in lore text (strong) */
181  byte lore_attr; /* Color of the attack used in lore text */
182  byte lore_attr_resist; /* Color used in lore text when resisted */
183  byte lore_attr_immune; /* Color used in lore text when resisted strongly */
184  int hit; /* To-hit level for the attack */
185  struct effect *effect; /* Effect(s) of the spell */
186  random_value power; /* Relative power of the spell */
187 };
188 
189 
193 struct monster_base {
195 
196  char *name; /* Name for recognition in code */
197  char *text; /* In-game name */
198 
199  bitflag flags[RF_SIZE]; /* Flags */
200  bitflag spell_flags[RSF_SIZE]; /* Spell flags */
201 
202  wchar_t d_char; /* Default monster character */
203 
204  struct monster_pain *pain; /* Pain messages */
205 };
206 
207 
211 struct monster_drop {
213  struct object_kind *kind;
214  unsigned int percent_chance;
215  unsigned int min;
216  unsigned int max;
217 };
218 
224  char *name;
226  unsigned int percent_chance;
227  unsigned int number_dice;
228  unsigned int number_side;
229 };
230 
237  unsigned int percent_chance;
238  unsigned int number_dice;
239  unsigned int number_side;
240 };
241 
247  struct object_kind *kind;
248 };
249 
265 struct monster_race {
267 
268  unsigned int ridx;
269 
270  char *name;
271  char *text;
272  char *plural; /* Optional pluralized name */
273 
275 
276  int avg_hp; /* Average HP for this creature */
277 
278  int ac; /* Armour Class */
279 
280  int sleep; /* Inactive counter (base) */
281  int hearing; /* Monster sense of hearing (1-100, standard 20) */
282  int smell; /* Monster sense of smell (0-50, standard 20) */
283  int speed; /* Speed (normally 110) */
284 
285  int mexp; /* Exp value for kill */
286 
287  int freq_innate; /* Innate spell frequency */
288  int freq_spell; /* Other spell frequency */
289  int spell_power; /* Power of spells */
290 
291  bitflag flags[RF_SIZE]; /* Flags */
292  bitflag spell_flags[RSF_SIZE]; /* Spell flags */
293 
294  struct monster_blow *blow; /* Melee blows */
295 
296  int level; /* Level of creature */
297  int rarity; /* Rarity of creature */
298 
299  byte d_attr; /* Default monster attribute */
300  wchar_t d_char; /* Default monster character */
301 
302  byte max_num; /* Maximum population allowed per level */
303  int cur_num; /* Monster population on current level */
304 
306 
308 
310 
312 };
313 
314 
323 struct monster {
325  int midx;
326 
327  byte fy; /* Y location on map */
328  byte fx; /* X location on map */
329 
330  s16b hp; /* Current Hit points */
331  s16b maxhp; /* Max Hit points */
332 
333  s16b m_timed[MON_TMD_MAX]; /* Timed monster status effects */
334 
335  byte mspeed; /* Monster "speed" */
336  byte energy; /* Monster "energy" */
337 
338  byte cdis; /* Current dis from player */
339 
340  bitflag mflag[MFLAG_SIZE]; /* Temporary monster flags */
341 
342  struct object *mimicked_obj; /* Object this monster is mimicking */
343  struct object *held_obj; /* Object being held (if any) */
344 
345  byte attr; /* attr last used for drawing monster */
346 
347  struct player_state known_pstate; /* Known player state */
348 
351 
354 };
355 
358 extern s16b num_repro;
359 
360 extern struct monster_pain *pain_messages;
361 extern struct monster_spell *monster_spells;
362 extern struct monster_base *rb_info;
363 extern struct monster_race *r_info;
364 extern const struct monster_race *ref_race;
365 
366 #endif /* !MONSTER_MONSTER_H */
uint16_t u16b
Definition: h-basic.h:169
struct object * mimicked_obj
Definition: monster.h:342
Monster pain messages.
Definition: monster.h:157
Definition: monster.h:55
char * plural
Definition: monster.h:272
Definition: monster.h:52
unsigned int max
Definition: monster.h:216
Specified monster drops.
Definition: monster.h:211
char * name
Definition: monster.h:196
Monster "race" information, including racial memories.
Definition: monster.h:265
Definition: monster.h:49
char * message
Definition: monster.h:173
char * blind_message_strong
Definition: monster.h:176
Low-level bit vector manipulation.
monster_flag_type
The monster flag types.
Definition: monster.h:46
char * name
Definition: monster.h:270
Monster information, for a specific monster.
Definition: monster.h:323
Definition: mon-blows.h:26
random_value dice
Definition: monster.h:150
Definition: monster.h:55
bitflag mflag[MFLAG_SIZE]
Definition: monster.h:340
byte lore_attr
Definition: monster.h:181
struct monster_spell * next
Definition: monster.h:169
Information about object kinds, including player knowledge.
Definition: object.h:158
Definition: monster.h:63
Definition: monster.h:51
Structures and functions for monster timed effects.
char * save_message
Definition: monster.h:178
Definition: monster.h:50
byte min_range
What is the closest we want to be? Not saved.
Definition: monster.h:352
struct monster_base * rb_info
Definition: mon-init.c:41
byte fy
Definition: monster.h:327
unsigned int percent_chance
Definition: monster.h:226
struct object_kind * kind
Definition: monster.h:213
unsigned int number_side
Definition: monster.h:228
char * blind_message
Definition: monster.h:174
Definition: monster.h:59
bitflag spell_flags[RSF_SIZE]
Definition: monster.h:292
struct monster_drop * drops
Definition: monster.h:305
int spell_power
Definition: monster.h:289
s16b num_repro
Variables.
Definition: mon-make.c:39
uint8_t byte
Definition: h-basic.h:167
#define RSF_SIZE
Definition: monster.h:128
const char * desc
Definition: monster.h:139
unsigned int number_dice
Definition: monster.h:227
List of monster spell flags.
byte d_attr
Definition: monster.h:299
struct monster_drop * next
Definition: monster.h:212
Definition: monster.h:60
struct monster_race * race
Definition: monster.h:225
Monster spell types.
Definition: monster.h:168
Monster friends (specific monster)
Definition: monster.h:222
s16b m_timed[MON_TMD_MAX]
Definition: monster.h:333
struct monster_blow * next
Definition: monster.h:146
All the variable state that changes when you put on/take off equipment.
Definition: player.h:354
int level
Definition: monster.h:296
bitflag flags[RF_SIZE]
Definition: monster.h:291
Object information, for a specific object.
Definition: object.h:394
struct monster_mimic * next
Definition: monster.h:246
Definition: mon-blows.h:66
struct object * held_obj
Definition: monster.h:343
int freq_innate
Definition: monster.h:287
#define MFLAG_SIZE
Definition: monster.h:66
The lowest level header.
u16b type
Definition: monster.h:138
bitflag flags[RF_SIZE]
Definition: monster.h:199
wchar_t d_char
Definition: monster.h:202
int sleep
Definition: monster.h:280
byte cdis
Definition: monster.h:338
byte max_num
Definition: monster.h:302
struct monster_base * base
Definition: monster.h:274
struct monster_base * next
Definition: monster.h:194
Definition: monster.h:48
s16b hp
Definition: monster.h:330
struct monster_race * r_info
Definition: mon-init.c:42
struct monster_pain * next
Definition: monster.h:161
Base monster type.
Definition: monster.h:193
int speed
Definition: monster.h:283
struct blow_effect * effect
Definition: monster.h:149
int rarity
Definition: monster.h:297
struct monster_race * next
Definition: monster.h:266
char * name
Definition: monster.h:224
struct effect * effect
Definition: monster.h:185
int avg_hp
Definition: monster.h:276
byte attr
Definition: monster.h:345
byte bitflag
Definition: z-bitflag.h:27
byte fx
Definition: monster.h:328
unsigned int number_dice
Definition: monster.h:238
char * message_strong
Definition: monster.h:175
byte best_range
How close do we want to be? Not saved.
Definition: monster.h:353
int16_t s16b
Definition: h-basic.h:170
char * text
Definition: monster.h:197
byte lore_attr_immune
Definition: monster.h:183
struct player_state known_pstate
Definition: monster.h:347
byte ty
Monster target.
Definition: monster.h:349
Structures.
Definition: monster.h:136
A struct representing a strategy for making a dice roll.
Definition: z-rand.h:40
unsigned int percent_chance
Definition: monster.h:214
struct monster_friends * next
Definition: monster.h:223
char * text
Definition: monster.h:271
int freq_spell
Definition: monster.h:288
u16b index
Definition: monster.h:137
int hearing
Definition: monster.h:281
int smell
Definition: monster.h:282
Definition: monster.h:53
const char * messages[7]
Definition: monster.h:158
struct monster_friends * friends
Definition: monster.h:307
s16b maxhp
Definition: monster.h:331
struct monster_base * base
Definition: monster.h:236
unsigned int percent_chance
Definition: monster.h:237
Definition: monster.h:181
bitflag spell_flags[RSF_SIZE]
Definition: monster.h:200
Matters relating to the current dungeon level.
int pain_idx
Definition: monster.h:159
Definition: monster.h:58
struct monster_friends_base * next
Definition: monster.h:235
Definition: monster.h:57
struct object_kind * kind
Definition: monster.h:247
int ac
Definition: monster.h:278
byte energy
Definition: monster.h:336
char * miss_message
Definition: monster.h:177
unsigned int min
Definition: monster.h:215
struct monster_spell * monster_spells
Definition: mon-init.c:40
struct monster_mimic * mimic_kinds
Definition: monster.h:311
unsigned int ridx
Definition: monster.h:268
struct blow_method * method
Definition: monster.h:148
Effect.
Definition: object.h:52
monster race flags
struct monster_blow * blow
Definition: monster.h:294
int hit
Definition: monster.h:184
Definition: monster.h:61
Definition: monster.h:54
byte lore_attr_resist
Definition: monster.h:182
int msgt
Definition: monster.h:172
Definition: monster.h:56
int times_seen
Definition: monster.h:151
struct monster_friends_base * friends_base
Definition: monster.h:309
random_value power
Definition: monster.h:186
Definition: monster.h:47
int cur_num
Definition: monster.h:303
byte mspeed
Definition: monster.h:335
char * lore_desc_strong
Definition: monster.h:180
struct monster_pain * pain_messages
Definition: mon-init.c:39
unsigned int number_side
Definition: monster.h:239
const struct monster_race * ref_race
Definition: mon-init.c:43
How monsters mimic.
Definition: monster.h:245
struct monster_race * race
Definition: monster.h:324
struct monster_pain * pain
Definition: monster.h:204
byte tx
Definition: monster.h:350
wchar_t d_char
Definition: monster.h:300
Temporary monster flags.
#define RF_SIZE
Definition: monster.h:96
Monster friends (general type)
Definition: monster.h:234
Monster blows.
Definition: monster.h:145
u16b index
Definition: monster.h:171
int mexp
Definition: monster.h:285
int midx
Definition: monster.h:325
char * lore_desc
Definition: monster.h:179
A Random Number Generator for Angband.