miscellaneous formatting
[aNetHack.git] / include / mondata.h
blobcdb2990073be495552620095c135afdeccd9a36f
1 /* NetHack 3.6 mondata.h $NHDT-Date: 1432512776 2015/05/25 00:12:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.26 $ */
2 /* Copyright (c) 1989 Mike Threepoint */
3 /* NetHack may be freely redistributed. See license for details. */
5 #ifndef MONDATA_H
6 #define MONDATA_H
8 #define verysmall(ptr) ((ptr)->msize < MZ_SMALL)
9 #define bigmonst(ptr) ((ptr)->msize >= MZ_LARGE)
11 #define pm_resistance(ptr, typ) (((ptr)->mresists & (typ)) != 0)
13 #define resists_fire(mon) (((mon)->mintrinsics & MR_FIRE) != 0)
14 #define resists_cold(mon) (((mon)->mintrinsics & MR_COLD) != 0)
15 #define resists_sleep(mon) (((mon)->mintrinsics & MR_SLEEP) != 0)
16 #define resists_disint(mon) (((mon)->mintrinsics & MR_DISINT) != 0)
17 #define resists_elec(mon) (((mon)->mintrinsics & MR_ELEC) != 0)
18 #define resists_poison(mon) (((mon)->mintrinsics & MR_POISON) != 0)
19 #define resists_acid(mon) (((mon)->mintrinsics & MR_ACID) != 0)
20 #define resists_ston(mon) (((mon)->mintrinsics & MR_STONE) != 0)
22 #define is_lminion(mon) \
23 (is_minion((mon)->data) && mon_aligntyp(mon) == A_LAWFUL)
24 #define is_flyer(ptr) (((ptr)->mflags1 & M1_FLY) != 0L)
25 #define is_floater(ptr) ((ptr)->mlet == S_EYE || (ptr)->mlet == S_LIGHT)
26 #define is_clinger(ptr) (((ptr)->mflags1 & M1_CLING) != 0L)
27 #define is_swimmer(ptr) (((ptr)->mflags1 & M1_SWIM) != 0L)
28 #define breathless(ptr) (((ptr)->mflags1 & M1_BREATHLESS) != 0L)
29 #define amphibious(ptr) \
30 (((ptr)->mflags1 & (M1_AMPHIBIOUS | M1_BREATHLESS)) != 0L)
31 #define passes_walls(ptr) (((ptr)->mflags1 & M1_WALLWALK) != 0L)
32 #define amorphous(ptr) (((ptr)->mflags1 & M1_AMORPHOUS) != 0L)
33 #define noncorporeal(ptr) ((ptr)->mlet == S_GHOST)
34 #define tunnels(ptr) (((ptr)->mflags1 & M1_TUNNEL) != 0L)
35 #define needspick(ptr) (((ptr)->mflags1 & M1_NEEDPICK) != 0L)
36 #define hides_under(ptr) (((ptr)->mflags1 & M1_CONCEAL) != 0L)
37 #define is_hider(ptr) (((ptr)->mflags1 & M1_HIDE) != 0L)
38 #define haseyes(ptr) (((ptr)->mflags1 & M1_NOEYES) == 0L)
39 #define eyecount(ptr) \
40 (!haseyes(ptr) ? 0 : ((ptr) == &mons[PM_CYCLOPS] \
41 || (ptr) == &mons[PM_FLOATING_EYE]) \
42 ? 1 \
43 : 2)
44 #define nohands(ptr) (((ptr)->mflags1 & M1_NOHANDS) != 0L)
45 #define nolimbs(ptr) (((ptr)->mflags1 & M1_NOLIMBS) == M1_NOLIMBS)
46 #define notake(ptr) (((ptr)->mflags1 & M1_NOTAKE) != 0L)
47 #define has_head(ptr) (((ptr)->mflags1 & M1_NOHEAD) == 0L)
48 #define has_horns(ptr) (num_horns(ptr) > 0)
49 #define is_whirly(ptr) \
50 ((ptr)->mlet == S_VORTEX || (ptr) == &mons[PM_AIR_ELEMENTAL])
51 #define flaming(ptr) \
52 ((ptr) == &mons[PM_FIRE_VORTEX] || (ptr) == &mons[PM_FLAMING_SPHERE] \
53 || (ptr) == &mons[PM_FIRE_ELEMENTAL] || (ptr) == &mons[PM_SALAMANDER])
54 #define is_silent(ptr) ((ptr)->msound == MS_SILENT)
55 #define unsolid(ptr) (((ptr)->mflags1 & M1_UNSOLID) != 0L)
56 #define mindless(ptr) (((ptr)->mflags1 & M1_MINDLESS) != 0L)
57 #define humanoid(ptr) (((ptr)->mflags1 & M1_HUMANOID) != 0L)
58 #define is_animal(ptr) (((ptr)->mflags1 & M1_ANIMAL) != 0L)
59 #define slithy(ptr) (((ptr)->mflags1 & M1_SLITHY) != 0L)
60 #define is_wooden(ptr) ((ptr) == &mons[PM_WOOD_GOLEM])
61 #define thick_skinned(ptr) (((ptr)->mflags1 & M1_THICK_HIDE) != 0L)
62 #define slimeproof(ptr) \
63 ((ptr) == &mons[PM_GREEN_SLIME] || flaming(ptr) || noncorporeal(ptr))
64 #define lays_eggs(ptr) (((ptr)->mflags1 & M1_OVIPAROUS) != 0L)
65 #define regenerates(ptr) (((ptr)->mflags1 & M1_REGEN) != 0L)
66 #define perceives(ptr) (((ptr)->mflags1 & M1_SEE_INVIS) != 0L)
67 #define can_teleport(ptr) (((ptr)->mflags1 & M1_TPORT) != 0L)
68 #define control_teleport(ptr) (((ptr)->mflags1 & M1_TPORT_CNTRL) != 0L)
69 #define telepathic(ptr) \
70 ((ptr) == &mons[PM_FLOATING_EYE] || (ptr) == &mons[PM_MIND_FLAYER] \
71 || (ptr) == &mons[PM_MASTER_MIND_FLAYER])
72 #define is_armed(ptr) attacktype(ptr, AT_WEAP)
73 #define acidic(ptr) (((ptr)->mflags1 & M1_ACID) != 0L)
74 #define poisonous(ptr) (((ptr)->mflags1 & M1_POIS) != 0L)
75 #define carnivorous(ptr) (((ptr)->mflags1 & M1_CARNIVORE) != 0L)
76 #define herbivorous(ptr) (((ptr)->mflags1 & M1_HERBIVORE) != 0L)
77 #define metallivorous(ptr) (((ptr)->mflags1 & M1_METALLIVORE) != 0L)
78 #define polyok(ptr) (((ptr)->mflags2 & M2_NOPOLY) == 0L)
79 #define is_shapeshifter(ptr) (((ptr)->mflags2 & M2_SHAPESHIFTER) != 0L)
80 #define is_undead(ptr) (((ptr)->mflags2 & M2_UNDEAD) != 0L)
81 #define is_were(ptr) (((ptr)->mflags2 & M2_WERE) != 0L)
82 #define is_elf(ptr) (((ptr)->mflags2 & M2_ELF) != 0L)
83 #define is_dwarf(ptr) (((ptr)->mflags2 & M2_DWARF) != 0L)
84 #define is_gnome(ptr) (((ptr)->mflags2 & M2_GNOME) != 0L)
85 #define is_orc(ptr) (((ptr)->mflags2 & M2_ORC) != 0L)
86 #define is_human(ptr) (((ptr)->mflags2 & M2_HUMAN) != 0L)
87 #define your_race(ptr) (((ptr)->mflags2 & urace.selfmask) != 0L)
88 #define is_bat(ptr) \
89 ((ptr) == &mons[PM_BAT] || (ptr) == &mons[PM_GIANT_BAT] \
90 || (ptr) == &mons[PM_VAMPIRE_BAT])
91 #define is_bird(ptr) ((ptr)->mlet == S_BAT && !is_bat(ptr))
92 #define is_giant(ptr) (((ptr)->mflags2 & M2_GIANT) != 0L)
93 #define is_golem(ptr) ((ptr)->mlet == S_GOLEM)
94 #define is_domestic(ptr) (((ptr)->mflags2 & M2_DOMESTIC) != 0L)
95 #define is_demon(ptr) (((ptr)->mflags2 & M2_DEMON) != 0L)
96 #define is_mercenary(ptr) (((ptr)->mflags2 & M2_MERC) != 0L)
97 #define is_male(ptr) (((ptr)->mflags2 & M2_MALE) != 0L)
98 #define is_female(ptr) (((ptr)->mflags2 & M2_FEMALE) != 0L)
99 #define is_neuter(ptr) (((ptr)->mflags2 & M2_NEUTER) != 0L)
100 #define is_wanderer(ptr) (((ptr)->mflags2 & M2_WANDER) != 0L)
101 #define always_hostile(ptr) (((ptr)->mflags2 & M2_HOSTILE) != 0L)
102 #define always_peaceful(ptr) (((ptr)->mflags2 & M2_PEACEFUL) != 0L)
103 #define race_hostile(ptr) (((ptr)->mflags2 & urace.hatemask) != 0L)
104 #define race_peaceful(ptr) (((ptr)->mflags2 & urace.lovemask) != 0L)
105 #define extra_nasty(ptr) (((ptr)->mflags2 & M2_NASTY) != 0L)
106 #define strongmonst(ptr) (((ptr)->mflags2 & M2_STRONG) != 0L)
107 #define can_breathe(ptr) attacktype(ptr, AT_BREA)
108 #define cantwield(ptr) (nohands(ptr) || verysmall(ptr))
109 #define could_twoweap(ptr) ((ptr)->mattk[1].aatyp == AT_WEAP)
110 #define cantweararm(ptr) (breakarm(ptr) || sliparm(ptr))
111 #define throws_rocks(ptr) (((ptr)->mflags2 & M2_ROCKTHROW) != 0L)
112 #define type_is_pname(ptr) (((ptr)->mflags2 & M2_PNAME) != 0L)
113 #define is_lord(ptr) (((ptr)->mflags2 & M2_LORD) != 0L)
114 #define is_prince(ptr) (((ptr)->mflags2 & M2_PRINCE) != 0L)
115 #define is_ndemon(ptr) \
116 (is_demon(ptr) && (((ptr)->mflags2 & (M2_LORD | M2_PRINCE)) == 0L))
117 #define is_dlord(ptr) (is_demon(ptr) && is_lord(ptr))
118 #define is_dprince(ptr) (is_demon(ptr) && is_prince(ptr))
119 #define is_minion(ptr) (((ptr)->mflags2 & M2_MINION) != 0L)
120 #define likes_gold(ptr) (((ptr)->mflags2 & M2_GREEDY) != 0L)
121 #define likes_gems(ptr) (((ptr)->mflags2 & M2_JEWELS) != 0L)
122 #define likes_objs(ptr) (((ptr)->mflags2 & M2_COLLECT) != 0L || is_armed(ptr))
123 #define likes_magic(ptr) (((ptr)->mflags2 & M2_MAGIC) != 0L)
124 #define webmaker(ptr) \
125 ((ptr) == &mons[PM_CAVE_SPIDER] || (ptr) == &mons[PM_GIANT_SPIDER])
126 #define is_unicorn(ptr) ((ptr)->mlet == S_UNICORN && likes_gems(ptr))
127 #define is_longworm(ptr) \
128 (((ptr) == &mons[PM_BABY_LONG_WORM]) || ((ptr) == &mons[PM_LONG_WORM]) \
129 || ((ptr) == &mons[PM_LONG_WORM_TAIL]))
130 #define is_covetous(ptr) ((ptr->mflags3 & M3_COVETOUS))
131 #define infravision(ptr) ((ptr->mflags3 & M3_INFRAVISION))
132 #define infravisible(ptr) ((ptr->mflags3 & M3_INFRAVISIBLE))
133 #define is_displacer(ptr) (((ptr)->mflags3 & M3_DISPLACES) != 0L)
134 #define is_mplayer(ptr) \
135 (((ptr) >= &mons[PM_ARCHEOLOGIST]) && ((ptr) <= &mons[PM_WIZARD]))
136 #define is_watch(ptr) \
137 ((ptr) == &mons[PM_WATCHMAN] || (ptr) == &mons[PM_WATCH_CAPTAIN])
138 #define is_rider(ptr) \
139 ((ptr) == &mons[PM_DEATH] || (ptr) == &mons[PM_FAMINE] \
140 || (ptr) == &mons[PM_PESTILENCE])
141 #define is_placeholder(ptr) \
142 ((ptr) == &mons[PM_ORC] || (ptr) == &mons[PM_GIANT] \
143 || (ptr) == &mons[PM_ELF] || (ptr) == &mons[PM_HUMAN])
144 /* return TRUE if the monster tends to revive */
145 #define is_reviver(ptr) (is_rider(ptr) || (ptr)->mlet == S_TROLL)
146 /* monsters whose corpses and statues need special handling;
147 note that high priests and the Wizard of Yendor are flagged
148 as unique even though they really aren't; that's ok here */
149 #define unique_corpstat(ptr) (((ptr)->geno & G_UNIQ) != 0)
151 /* this returns the light's range, or 0 if none; if we add more light emitting
152 monsters, we'll likely have to add a new light range field to mons[] */
153 #define emits_light(ptr) \
154 (((ptr)->mlet == S_LIGHT || (ptr) == &mons[PM_FLAMING_SPHERE] \
155 || (ptr) == &mons[PM_SHOCKING_SPHERE] \
156 || (ptr) == &mons[PM_FIRE_VORTEX]) \
157 ? 1 \
158 : ((ptr) == &mons[PM_FIRE_ELEMENTAL]) ? 1 : 0)
159 /* [note: the light ranges above were reduced to 1 for performance...] */
160 #define likes_lava(ptr) \
161 (ptr == &mons[PM_FIRE_ELEMENTAL] || ptr == &mons[PM_SALAMANDER])
162 #define pm_invisible(ptr) \
163 ((ptr) == &mons[PM_STALKER] || (ptr) == &mons[PM_BLACK_LIGHT])
165 /* could probably add more */
166 #define likes_fire(ptr) \
167 ((ptr) == &mons[PM_FIRE_VORTEX] || (ptr) == &mons[PM_FLAMING_SPHERE] \
168 || likes_lava(ptr))
170 #define touch_petrifies(ptr) \
171 ((ptr) == &mons[PM_COCKATRICE] || (ptr) == &mons[PM_CHICKATRICE])
173 #define is_mind_flayer(ptr) \
174 ((ptr) == &mons[PM_MIND_FLAYER] || (ptr) == &mons[PM_MASTER_MIND_FLAYER])
176 #define is_vampire(ptr) ((ptr)->mlet == S_VAMPIRE)
178 #define nonliving(ptr) \
179 (is_golem(ptr) || is_undead(ptr) || (ptr)->mlet == S_VORTEX \
180 || (ptr) == &mons[PM_MANES])
182 /* Used for conduct with corpses, tins, and digestion attacks */
183 /* G_NOCORPSE monsters might still be swallowed as a purple worm */
184 /* Maybe someday this could be in mflags... */
185 #define vegan(ptr) \
186 ((ptr)->mlet == S_BLOB || (ptr)->mlet == S_JELLY \
187 || (ptr)->mlet == S_FUNGUS || (ptr)->mlet == S_VORTEX \
188 || (ptr)->mlet == S_LIGHT \
189 || ((ptr)->mlet == S_ELEMENTAL && (ptr) != &mons[PM_STALKER]) \
190 || ((ptr)->mlet == S_GOLEM && (ptr) != &mons[PM_FLESH_GOLEM] \
191 && (ptr) != &mons[PM_LEATHER_GOLEM]) || noncorporeal(ptr))
192 #define vegetarian(ptr) \
193 (vegan(ptr) \
194 || ((ptr)->mlet == S_PUDDING && (ptr) != &mons[PM_BLACK_PUDDING]))
196 /* monkeys are tameable via bananas but not pacifiable via food,
197 otherwise their theft attack could be nullified too easily;
198 dogs and cats can be tamed by anything they like to eat and are
199 pacified by any other food;
200 horses can be tamed by always-veggy food or lichen corpses but
201 not tamed or pacified by other corpses or tins of veggy critters */
202 #define befriend_with_obj(ptr, obj) \
203 (((ptr) == &mons[PM_MONKEY] || (ptr) == &mons[PM_APE]) \
204 ? (obj)->otyp == BANANA \
205 : (is_domestic(ptr) && (obj)->oclass == FOOD_CLASS \
206 && ((ptr)->mlet != S_UNICORN \
207 || objects[(obj)->otyp].oc_material == VEGGY \
208 || ((obj)->otyp == CORPSE && (obj)->corpsenm == PM_LICHEN))))
210 #endif /* MONDATA_H */