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 *miss_message; /* Description of a missed attack */
176  char *save_message; /* Message on passing saving throw, if any */
177  char *lore_desc; /* Description of the attack used in lore text */
178  byte lore_attr; /* Color of the attack used in lore text */
179  byte lore_attr_resist; /* Color used in lore text when resisted */
180  byte lore_attr_immune; /* Color used in lore text when resisted strongly */
181  int hit; /* To-hit level for the attack */
182  struct effect *effect; /* Effect(s) of the spell */
183  random_value power; /* Relative power of the spell */
184 };
185 
186 
190 struct monster_base {
192 
193  char *name; /* Name for recognition in code */
194  char *text; /* In-game name */
195 
196  bitflag flags[RF_SIZE]; /* Flags */
197  bitflag spell_flags[RSF_SIZE]; /* Spell flags */
198 
199  wchar_t d_char; /* Default monster character */
200 
201  struct monster_pain *pain; /* Pain messages */
202 };
203 
204 
208 struct monster_drop {
210  struct object_kind *kind;
212  unsigned int percent_chance;
213  unsigned int min;
214  unsigned int max;
215 };
216 
222  char *name;
224  unsigned int percent_chance;
225  unsigned int number_dice;
226  unsigned int number_side;
227 };
228 
235  unsigned int percent_chance;
236  unsigned int number_dice;
237  unsigned int number_side;
238 };
239 
245  struct object_kind *kind;
246 };
247 
263 struct monster_race {
265 
266  unsigned int ridx;
267 
268  char *name;
269  char *text;
270  char *plural; /* Optional pluralized name */
271 
273 
274  int avg_hp; /* Average HP for this creature */
275 
276  int ac; /* Armour Class */
277 
278  int sleep; /* Inactive counter (base) */
279  int aaf; /* Area affect radius (1-100) */
280  int speed; /* Speed (normally 110) */
281 
282  int mexp; /* Exp value for kill */
283 
284  int freq_innate; /* Innate spell frequency */
285  int freq_spell; /* Other spell frequency */
286  int spell_power; /* Power of spells */
287 
288  bitflag flags[RF_SIZE]; /* Flags */
289  bitflag spell_flags[RSF_SIZE]; /* Spell flags */
290 
291  struct monster_blow *blow; /* Melee blows */
292 
293  int level; /* Level of creature */
294  int rarity; /* Rarity of creature */
295 
296  byte d_attr; /* Default monster attribute */
297  wchar_t d_char; /* Default monster character */
298 
299  byte max_num; /* Maximum population allowed per level */
300  int cur_num; /* Monster population on current level */
301 
303 
305 
307 
309 };
310 
311 
320 struct monster {
322  int midx;
323 
324  byte fy; /* Y location on map */
325  byte fx; /* X location on map */
326 
327  s16b hp; /* Current Hit points */
328  s16b maxhp; /* Max Hit points */
329 
330  s16b m_timed[MON_TMD_MAX]; /* Timed monster status effects */
331 
332  byte mspeed; /* Monster "speed" */
333  byte energy; /* Monster "energy" */
334 
335  byte cdis; /* Current dis from player */
336 
337  bitflag mflag[MFLAG_SIZE]; /* Temporary monster flags */
338 
339  struct object *mimicked_obj; /* Object this monster is mimicking */
340  struct object *held_obj; /* Object being held (if any) */
341 
342  byte attr; /* attr last used for drawing monster */
343 
344  struct player_state known_pstate; /* Known player state */
345 
348 
351 };
352 
355 extern s16b num_repro;
356 
357 extern struct monster_pain *pain_messages;
358 extern struct monster_spell *monster_spells;
359 extern struct monster_base *rb_info;
360 extern struct monster_race *r_info;
361 extern const struct monster_race *ref_race;
362 
363 #endif /* !MONSTER_MONSTER_H */
uint16_t u16b
Definition: h-basic.h:169
struct object * mimicked_obj
Definition: monster.h:339
Monster pain messages.
Definition: monster.h:157
Definition: monster.h:55
char * plural
Definition: monster.h:270
Definition: monster.h:52
unsigned int max
Definition: monster.h:214
Specified monster drops.
Definition: monster.h:208
char * name
Definition: monster.h:193
Monster "race" information, including racial memories.
Definition: monster.h:263
Definition: monster.h:49
char * message
Definition: monster.h:173
Low-level bit vector manipulation.
monster_flag_type
The monster flag types.
Definition: monster.h:46
char * name
Definition: monster.h:268
Monster information, for a specific monster.
Definition: monster.h:320
Definition: mon-blows.h:26
random_value dice
Definition: monster.h:150
Definition: monster.h:55
bitflag mflag[MFLAG_SIZE]
Definition: monster.h:337
byte lore_attr
Definition: monster.h:178
struct monster_spell * next
Definition: monster.h:169
Information about object kinds, including player knowledge.
Definition: object.h:157
Definition: monster.h:63
Definition: monster.h:51
Structures and functions for monster timed effects.
char * save_message
Definition: monster.h:176
Definition: monster.h:50
byte min_range
What is the closest we want to be? Not saved.
Definition: monster.h:349
struct monster_base * rb_info
Definition: mon-init.c:41
byte fy
Definition: monster.h:324
unsigned int percent_chance
Definition: monster.h:224
struct object_kind * kind
Definition: monster.h:210
unsigned int number_side
Definition: monster.h:226
char * blind_message
Definition: monster.h:174
Definition: monster.h:59
bitflag spell_flags[RSF_SIZE]
Definition: monster.h:289
struct monster_drop * drops
Definition: monster.h:302
int spell_power
Definition: monster.h:286
s16b num_repro
Variables.
Definition: mon-make.c:38
struct artifact * artifact
Definition: monster.h:211
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:225
List of monster spell flags.
byte d_attr
Definition: monster.h:296
struct monster_drop * next
Definition: monster.h:209
Definition: monster.h:60
struct monster_race * race
Definition: monster.h:223
Monster spell types.
Definition: monster.h:168
Monster friends (specific monster)
Definition: monster.h:220
s16b m_timed[MON_TMD_MAX]
Definition: monster.h:330
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:293
bitflag flags[RF_SIZE]
Definition: monster.h:288
Object information, for a specific object.
Definition: object.h:393
int aaf
Definition: monster.h:279
struct monster_mimic * next
Definition: monster.h:244
Definition: mon-blows.h:66
struct object * held_obj
Definition: monster.h:340
int freq_innate
Definition: monster.h:284
#define MFLAG_SIZE
Definition: monster.h:66
The lowest level header.
u16b type
Definition: monster.h:138
bitflag flags[RF_SIZE]
Definition: monster.h:196
wchar_t d_char
Definition: monster.h:199
int sleep
Definition: monster.h:278
byte cdis
Definition: monster.h:335
byte max_num
Definition: monster.h:299
struct monster_base * base
Definition: monster.h:272
struct monster_base * next
Definition: monster.h:191
Definition: monster.h:48
s16b hp
Definition: monster.h:327
struct monster_race * r_info
Definition: mon-init.c:42
struct monster_pain * next
Definition: monster.h:161
Base monster type.
Definition: monster.h:190
int speed
Definition: monster.h:280
struct blow_effect * effect
Definition: monster.h:149
int rarity
Definition: monster.h:294
struct monster_race * next
Definition: monster.h:264
char * name
Definition: monster.h:222
struct effect * effect
Definition: monster.h:182
int avg_hp
Definition: monster.h:274
byte attr
Definition: monster.h:342
byte bitflag
Definition: z-bitflag.h:27
byte fx
Definition: monster.h:325
unsigned int number_dice
Definition: monster.h:236
byte best_range
How close do we want to be? Not saved.
Definition: monster.h:350
int16_t s16b
Definition: h-basic.h:170
char * text
Definition: monster.h:194
byte lore_attr_immune
Definition: monster.h:180
struct player_state known_pstate
Definition: monster.h:344
byte ty
Monster target.
Definition: monster.h:346
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:212
struct monster_friends * next
Definition: monster.h:221
char * text
Definition: monster.h:269
int freq_spell
Definition: monster.h:285
u16b index
Definition: monster.h:137
Definition: monster.h:53
const char * messages[7]
Definition: monster.h:158
struct monster_friends * friends
Definition: monster.h:304
s16b maxhp
Definition: monster.h:328
struct monster_base * base
Definition: monster.h:234
unsigned int percent_chance
Definition: monster.h:235
Definition: monster.h:181
bitflag spell_flags[RSF_SIZE]
Definition: monster.h:197
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:233
Definition: monster.h:57
struct object_kind * kind
Definition: monster.h:245
int ac
Definition: monster.h:276
byte energy
Definition: monster.h:333
char * miss_message
Definition: monster.h:175
unsigned int min
Definition: monster.h:213
struct monster_spell * monster_spells
Definition: mon-init.c:40
struct monster_mimic * mimic_kinds
Definition: monster.h:308
unsigned int ridx
Definition: monster.h:266
struct blow_method * method
Definition: monster.h:148
Effect.
Definition: object.h:52
monster race flags
struct monster_blow * blow
Definition: monster.h:291
int hit
Definition: monster.h:181
Definition: monster.h:61
Definition: monster.h:54
byte lore_attr_resist
Definition: monster.h:179
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:306
random_value power
Definition: monster.h:183
Definition: monster.h:47
int cur_num
Definition: monster.h:300
byte mspeed
Definition: monster.h:332
struct monster_pain * pain_messages
Definition: mon-init.c:39
unsigned int number_side
Definition: monster.h:237
const struct monster_race * ref_race
Definition: mon-init.c:43
How monsters mimic.
Definition: monster.h:243
struct monster_race * race
Definition: monster.h:321
struct monster_pain * pain
Definition: monster.h:201
byte tx
Definition: monster.h:347
Information about artifacts.
Definition: object.h:238
wchar_t d_char
Definition: monster.h:297
Temporary monster flags.
#define RF_SIZE
Definition: monster.h:96
Monster friends (general type)
Definition: monster.h:232
Monster blows.
Definition: monster.h:145
u16b index
Definition: monster.h:171
int mexp
Definition: monster.h:282
int midx
Definition: monster.h:322
char * lore_desc
Definition: monster.h:177
A Random Number Generator for Angband.