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-blow-methods.h"
28 #include "mon-blow-effects.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 
44 #define MFLAG_SIZE FLAG_SIZE(MFLAG_MAX)
45 
46 #define mflag_has(f, flag) flag_has_dbg(f, MFLAG_SIZE, flag, #f, #flag)
47 #define mflag_next(f, flag) flag_next(f, MFLAG_SIZE, flag)
48 #define mflag_is_empty(f) flag_is_empty(f, MFLAG_SIZE)
49 #define mflag_is_full(f) flag_is_full(f, MFLAG_SIZE)
50 #define mflag_is_inter(f1, f2) flag_is_inter(f1, f2, MFLAG_SIZE)
51 #define mflag_is_subset(f1, f2) flag_is_subset(f1, f2, MFLAG_SIZE)
52 #define mflag_is_equal(f1, f2) flag_is_equal(f1, f2, MFLAG_SIZE)
53 #define mflag_on(f, flag) flag_on_dbg(f, MFLAG_SIZE, flag, #f, #flag)
54 #define mflag_off(f, flag) flag_off(f, MFLAG_SIZE, flag)
55 #define mflag_wipe(f) flag_wipe(f, MFLAG_SIZE)
56 #define mflag_setall(f) flag_setall(f, MFLAG_SIZE)
57 #define mflag_negate(f) flag_negate(f, MFLAG_SIZE)
58 #define mflag_copy(f1, f2) flag_copy(f1, f2, MFLAG_SIZE)
59 #define mflag_union(f1, f2) flag_union(f1, f2, MFLAG_SIZE)
60 #define mflag_comp_union(f1, f2) flag_comp_union(f1, f2, MFLAG_SIZE)
61 #define mflag_inter(f1, f2) flag_inter(f1, f2, MFLAG_SIZE)
62 #define mflag_diff(f1, f2) flag_diff(f1, f2, MFLAG_SIZE)
63 
67 enum
68 {
69  #define RF(a,b,c) RF_##a,
70  #include "list-mon-race-flags.h"
71  #undef RF
72  RF_MAX
73 };
74 
75 #define RF_SIZE FLAG_SIZE(RF_MAX)
76 
77 #define rf_has(f, flag) flag_has_dbg(f, RF_SIZE, flag, #f, #flag)
78 #define rf_next(f, flag) flag_next(f, RF_SIZE, flag)
79 #define rf_is_empty(f) flag_is_empty(f, RF_SIZE)
80 #define rf_is_full(f) flag_is_full(f, RF_SIZE)
81 #define rf_is_inter(f1, f2) flag_is_inter(f1, f2, RF_SIZE)
82 #define rf_is_subset(f1, f2) flag_is_subset(f1, f2, RF_SIZE)
83 #define rf_is_equal(f1, f2) flag_is_equal(f1, f2, RF_SIZE)
84 #define rf_on(f, flag) flag_on_dbg(f, RF_SIZE, flag, #f, #flag)
85 #define rf_off(f, flag) flag_off(f, RF_SIZE, flag)
86 #define rf_wipe(f) flag_wipe(f, RF_SIZE)
87 #define rf_setall(f) flag_setall(f, RF_SIZE)
88 #define rf_negate(f) flag_negate(f, RF_SIZE)
89 #define rf_copy(f1, f2) flag_copy(f1, f2, RF_SIZE)
90 #define rf_union(f1, f2) flag_union(f1, f2, RF_SIZE)
91 #define rf_comp_union(f1, f2) flag_comp_union(f1, f2, RF_SIZE)
92 #define rf_inter(f1, f2) flag_inter(f1, f2, RF_SIZE)
93 #define rf_diff(f1, f2) flag_diff(f1, f2, RF_SIZE)
94 
95 /* Some flags are obvious */
96 #define RF_OBVIOUS_MASK \
97  RF_UNIQUE, RF_QUESTOR, RF_MALE, RF_FEMALE, \
98  RF_GROUP_AI
99 
100 /* "race" flags */
101 #define RF_RACE_MASK \
102  RF_ORC, RF_TROLL, RF_GIANT, RF_DRAGON, RF_DEMON, \
103  RF_UNDEAD, RF_EVIL, RF_ANIMAL, RF_METAL, RF_NONLIVING
104 
105 /* Drop flags to be revealed on first kill */
106 #define RF_DROP_MASK \
107  RF_DROP_GOOD, \
108  RF_DROP_GREAT, \
109  RF_ONLY_ITEM, \
110  RF_ONLY_GOLD, \
111  RF_DROP_20, \
112  RF_DROP_40, \
113  RF_DROP_60, \
114  RF_DROP_4, \
115  RF_DROP_3, \
116  RF_DROP_2, \
117  RF_DROP_1
118 
119 
123 enum
124 {
125  #define RSF(a, b, c, d, e, f, g, h) RSF_##a,
126  #include "list-mon-spells.h"
127  #undef RSF
128 };
129 
130 #define RSF_SIZE FLAG_SIZE(RSF_MAX)
131 
132 
138 struct monster_blow {
139  struct monster_blow *next; /* Unused after parsing */
140 
141  int method; /* Method (RBM_*) */
142  int effect; /* Effect (RBE_*) */
143  random_value dice; /* Damage dice */
144  int times_seen; /* Sightings of the blow (lore only) */
145 };
146 
150 typedef struct monster_pain
151 {
152  const char *messages[7];
153  int pain_idx;
154 
156 } monster_pain;
157 
158 
165  u16b index; /* Numerical index (RSF_FOO) */
166  int hit; /* To-hit level for the attack */
167  struct effect *effect; /* Effect(s) of the spell */
168  random_value power; /* Relative power of the spell */
169 };
170 
171 
175 typedef struct monster_base
176 {
178 
179  char *name; /* Name for recognition in code */
180  char *text; /* In-game name */
181 
182  bitflag flags[RF_SIZE]; /* Flags */
183  bitflag spell_flags[RSF_SIZE]; /* Spell flags */
184 
185  wchar_t d_char; /* Default monster character */
186 
187  monster_pain *pain; /* Pain messages */
188 } monster_base;
189 
190 
194 struct monster_drop {
196  struct object_kind *kind;
198  unsigned int percent_chance;
199  unsigned int min;
200  unsigned int max;
201 };
202 
208  char *name;
210  unsigned int percent_chance;
211  unsigned int number_dice;
212  unsigned int number_side;
213 };
214 
221  unsigned int percent_chance;
222  unsigned int number_dice;
223  unsigned int number_side;
224 };
225 
231  struct object_kind *kind;
232 };
233 
249 typedef struct monster_race
250 {
252 
253  unsigned int ridx;
254 
255  char *name;
256  char *text;
257  char *plural; /* Optional pluralized name */
258 
260 
261  int avg_hp; /* Average HP for this creature */
262 
263  int ac; /* Armour Class */
264 
265  int sleep; /* Inactive counter (base) */
266  int aaf; /* Area affect radius (1-100) */
267  int speed; /* Speed (normally 110) */
268 
269  int mexp; /* Exp value for kill */
270 
271  long power; /* Monster power */
272  long scaled_power; /* Monster power scaled by level */
273 
274  int freq_innate; /* Innate spell frequency */
275  int freq_spell; /* Other spell frequency */
276 
277  bitflag flags[RF_SIZE]; /* Flags */
278  bitflag spell_flags[RSF_SIZE]; /* Spell flags */
279 
280  struct monster_blow *blow; /* Melee blows */
281 
282  int level; /* Level of creature */
283  int rarity; /* Rarity of creature */
284 
285  byte d_attr; /* Default monster attribute */
286  wchar_t d_char; /* Default monster character */
287 
288  byte max_num; /* Maximum population allowed per level */
289  int cur_num; /* Monster population on current level */
290 
292 
294 
296 
298 } monster_race;
299 
300 
309 typedef struct monster
310 {
312  int midx;
313 
314  byte fy; /* Y location on map */
315  byte fx; /* X location on map */
316 
317  s16b hp; /* Current Hit points */
318  s16b maxhp; /* Max Hit points */
319 
320  s16b m_timed[MON_TMD_MAX]; /* Timed monster status effects */
321 
322  byte mspeed; /* Monster "speed" */
323  byte energy; /* Monster "energy" */
324 
325  byte cdis; /* Current dis from player */
326 
327  bitflag mflag[MFLAG_SIZE]; /* Temporary monster flags */
328 
329  struct object *mimicked_obj; /* Object this monster is mimicking */
330  struct object *held_obj; /* Object being held (if any) */
331 
332  byte attr; /* attr last used for drawing monster */
333 
334  player_state known_pstate; /* Known player state */
335 
338 
341 } monster_type;
342 
345 extern s16b num_repro;
346 
348 extern struct monster_spell *monster_spells;
349 extern monster_base *rb_info;
350 extern monster_race *r_info;
351 extern const monster_race *ref_race;
352 
353 #endif /* !MONSTER_MONSTER_H */