Couple of extra nethack->anethack
[aNetHack.git] / include / youprop.h
blob1530ebedf63aaa389c5518cb31380453370f857e
1 /* aNetHack 0.0.1 youprop.h $ANH-Date: 1433291407 2015/06/03 00:30:07 $ $ANH-Branch: master $:$ANH-Revision: 1.23 $ */
2 /* Copyright (c) 1989 Mike Threepoint */
3 /* aNetHack may be freely redistributed. See license for details. */
5 #ifndef YOUPROP_H
6 #define YOUPROP_H
8 #include "prop.h"
9 #include "permonst.h"
10 #include "mondata.h"
11 #include "pm.h"
13 /* KMH, intrinsics patch.
14 * Reorganized and rewritten for >32-bit properties.
15 * HXxx refers to intrinsic bitfields while in human form.
16 * EXxx refers to extrinsic bitfields from worn objects.
17 * BXxx refers to the cause of the property being blocked.
18 * Xxx refers to any source, including polymorph forms.
19 * [Post-3.4.3: HXxx now includes a FROMFORM bit to handle
20 * intrinsic conferred by being polymorphed.]
23 #define maybe_polyd(if_so, if_not) (Upolyd ? (if_so) : (if_not))
25 /*** Resistances to troubles ***/
26 /* With intrinsics and extrinsics */
27 #define HFire_resistance u.uprops[FIRE_RES].intrinsic
28 #define EFire_resistance u.uprops[FIRE_RES].extrinsic
29 #define Fire_resistance (HFire_resistance || EFire_resistance)
31 #define HCold_resistance u.uprops[COLD_RES].intrinsic
32 #define ECold_resistance u.uprops[COLD_RES].extrinsic
33 #define Cold_resistance (HCold_resistance || ECold_resistance)
35 #define HSleep_resistance u.uprops[SLEEP_RES].intrinsic
36 #define ESleep_resistance u.uprops[SLEEP_RES].extrinsic
37 #define Sleep_resistance (HSleep_resistance || ESleep_resistance)
39 #define HDisint_resistance u.uprops[DISINT_RES].intrinsic
40 #define EDisint_resistance u.uprops[DISINT_RES].extrinsic
41 #define Disint_resistance (HDisint_resistance || EDisint_resistance)
43 #define HShock_resistance u.uprops[SHOCK_RES].intrinsic
44 #define EShock_resistance u.uprops[SHOCK_RES].extrinsic
45 #define Shock_resistance (HShock_resistance || EShock_resistance)
47 #define HPoison_resistance u.uprops[POISON_RES].intrinsic
48 #define EPoison_resistance u.uprops[POISON_RES].extrinsic
49 #define Poison_resistance (HPoison_resistance || EPoison_resistance)
51 #define HDrain_resistance u.uprops[DRAIN_RES].intrinsic
52 #define EDrain_resistance u.uprops[DRAIN_RES].extrinsic
53 #define Drain_resistance (HDrain_resistance || EDrain_resistance)
55 /* Hxxx due to FROMFORM only */
56 #define HAntimagic u.uprops[ANTIMAGIC].intrinsic
57 #define EAntimagic u.uprops[ANTIMAGIC].extrinsic
58 #define Antimagic (HAntimagic || EAntimagic)
60 #define HAcid_resistance u.uprops[ACID_RES].intrinsic
61 #define EAcid_resistance u.uprops[ACID_RES].extrinsic
62 #define Acid_resistance (HAcid_resistance || EAcid_resistance)
64 #define HStone_resistance u.uprops[STONE_RES].intrinsic
65 #define EStone_resistance u.uprops[STONE_RES].extrinsic
66 #define Stone_resistance (HStone_resistance || EStone_resistance)
68 /* Intrinsics only */
69 #define HSick_resistance u.uprops[SICK_RES].intrinsic
70 #define Sick_resistance (HSick_resistance || defends(AD_DISE, uwep))
72 #define Invulnerable u.uprops[INVULNERABLE].intrinsic /* [Tom] */
74 /*** Troubles ***/
75 /* Pseudo-property */
76 #define Punished (uball != 0)
78 /* Those implemented solely as timeouts (we use just intrinsic) */
79 #define HStun u.uprops[STUNNED].intrinsic
80 #define Stunned HStun
82 #define HConfusion u.uprops[CONFUSION].intrinsic
83 #define Confusion HConfusion
85 #define Blinded u.uprops[BLINDED].intrinsic
86 #define Blindfolded (ublindf && ublindf->otyp != LENSES)
87 /* ...means blind because of a cover */
88 #define Blind \
89 ((u.uroleplay.blind || Blinded || Blindfolded \
90 || !haseyes(youmonst.data)) \
91 && !(ublindf && ublindf->oartifact == ART_EYES_OF_THE_OVERWORLD))
92 /* ...the Eyes operate even when you really are blind
93 or don't have any eyes */
94 #define Blindfolded_only \
95 (Blindfolded && ublindf->oartifact != ART_EYES_OF_THE_OVERWORLD \
96 && !u.uroleplay.blind && !Blinded && haseyes(youmonst.data))
97 /* ...blind because of a blindfold, and *only* that */
99 #define Sick u.uprops[SICK].intrinsic
100 #define Stoned u.uprops[STONED].intrinsic
101 #define Strangled u.uprops[STRANGLED].intrinsic
102 #define Vomiting u.uprops[VOMITING].intrinsic
103 #define Glib u.uprops[GLIB].intrinsic
104 #define Slimed u.uprops[SLIMED].intrinsic /* [Tom] */
106 /* Hallucination is solely a timeout */
107 #define HHallucination u.uprops[HALLUC].intrinsic
108 #define HHalluc_resistance u.uprops[HALLUC_RES].intrinsic
109 #define EHalluc_resistance u.uprops[HALLUC_RES].extrinsic
110 #define Halluc_resistance (HHalluc_resistance || EHalluc_resistance)
111 #define Hallucination (HHallucination && !Halluc_resistance)
113 /* Timeout, plus a worn mask */
114 #define HDeaf u.uprops[DEAF].intrinsic
115 #define EDeaf u.uprops[DEAF].extrinsic
116 #define Deaf (HDeaf || EDeaf)
118 #define HFumbling u.uprops[FUMBLING].intrinsic
119 #define EFumbling u.uprops[FUMBLING].extrinsic
120 #define Fumbling (HFumbling || EFumbling)
122 #define HWounded_legs u.uprops[WOUNDED_LEGS].intrinsic
123 #define EWounded_legs u.uprops[WOUNDED_LEGS].extrinsic
124 #define Wounded_legs (HWounded_legs || EWounded_legs)
126 #define HSleepy u.uprops[SLEEPY].intrinsic
127 #define ESleepy u.uprops[SLEEPY].extrinsic
128 #define Sleepy (HSleepy || ESleepy)
130 #define HHunger u.uprops[HUNGER].intrinsic
131 #define EHunger u.uprops[HUNGER].extrinsic
132 #define Hunger (HHunger || EHunger)
134 /*** Vision and senses ***/
135 #define HSee_invisible u.uprops[SEE_INVIS].intrinsic
136 #define ESee_invisible u.uprops[SEE_INVIS].extrinsic
137 #define See_invisible (HSee_invisible || ESee_invisible)
139 #define HTelepat u.uprops[TELEPAT].intrinsic
140 #define ETelepat u.uprops[TELEPAT].extrinsic
141 #define Blind_telepat (HTelepat || ETelepat)
142 #define Unblind_telepat (ETelepat)
144 #define HWarning u.uprops[WARNING].intrinsic
145 #define EWarning u.uprops[WARNING].extrinsic
146 #define Warning (HWarning || EWarning)
148 /* Warning for a specific type of monster */
149 #define HWarn_of_mon u.uprops[WARN_OF_MON].intrinsic
150 #define EWarn_of_mon u.uprops[WARN_OF_MON].extrinsic
151 #define Warn_of_mon (HWarn_of_mon || EWarn_of_mon)
153 #define HUndead_warning u.uprops[WARN_UNDEAD].intrinsic
154 #define Undead_warning (HUndead_warning)
156 #define HSearching u.uprops[SEARCHING].intrinsic
157 #define ESearching u.uprops[SEARCHING].extrinsic
158 #define Searching (HSearching || ESearching)
160 #define HClairvoyant u.uprops[CLAIRVOYANT].intrinsic
161 #define EClairvoyant u.uprops[CLAIRVOYANT].extrinsic
162 #define BClairvoyant u.uprops[CLAIRVOYANT].blocked
163 #define Clairvoyant ((HClairvoyant || EClairvoyant) && !BClairvoyant)
165 #define HInfravision u.uprops[INFRAVISION].intrinsic
166 #define EInfravision u.uprops[INFRAVISION].extrinsic
167 #define Infravision (HInfravision || EInfravision)
169 #define HDetect_monsters u.uprops[DETECT_MONSTERS].intrinsic
170 #define EDetect_monsters u.uprops[DETECT_MONSTERS].extrinsic
171 #define Detect_monsters (HDetect_monsters || EDetect_monsters)
173 /*** Appearance and behavior ***/
174 #define Adornment u.uprops[ADORNED].extrinsic
176 #define HInvis u.uprops[INVIS].intrinsic
177 #define EInvis u.uprops[INVIS].extrinsic
178 #define BInvis u.uprops[INVIS].blocked
179 #define Invis ((HInvis || EInvis) && !BInvis)
180 #define Invisible (Invis && !See_invisible)
181 /* Note: invisibility also hides inventory and steed */
183 #define EDisplaced u.uprops[DISPLACED].extrinsic
184 #define Displaced EDisplaced
186 #define HStealth u.uprops[STEALTH].intrinsic
187 #define EStealth u.uprops[STEALTH].extrinsic
188 #define BStealth u.uprops[STEALTH].blocked
189 #define Stealth ((HStealth || EStealth) && !BStealth)
191 #define HAggravate_monster u.uprops[AGGRAVATE_MONSTER].intrinsic
192 #define EAggravate_monster u.uprops[AGGRAVATE_MONSTER].extrinsic
193 #define Aggravate_monster (HAggravate_monster || EAggravate_monster)
195 #define HConflict u.uprops[CONFLICT].intrinsic
196 #define EConflict u.uprops[CONFLICT].extrinsic
197 #define Conflict (HConflict || EConflict)
199 /*** Transportation ***/
200 #define HJumping u.uprops[JUMPING].intrinsic
201 #define EJumping u.uprops[JUMPING].extrinsic
202 #define Jumping (HJumping || EJumping)
204 #define HTeleportation u.uprops[TELEPORT].intrinsic
205 #define ETeleportation u.uprops[TELEPORT].extrinsic
206 #define Teleportation (HTeleportation || ETeleportation)
208 #define HTeleport_control u.uprops[TELEPORT_CONTROL].intrinsic
209 #define ETeleport_control u.uprops[TELEPORT_CONTROL].extrinsic
210 #define Teleport_control (HTeleport_control || ETeleport_control)
212 #define HLevitation u.uprops[LEVITATION].intrinsic
213 #define ELevitation u.uprops[LEVITATION].extrinsic
214 #define BLevitation u.uprops[LEVITATION].blocked
215 #define Levitation ((HLevitation || ELevitation) && !BLevitation)
216 /* Can't touch surface, can't go under water; overrides all others */
217 #define Lev_at_will \
218 (((HLevitation & I_SPECIAL) != 0L || (ELevitation & W_ARTI) != 0L) \
219 && (HLevitation & ~(I_SPECIAL | TIMEOUT)) == 0L \
220 && (ELevitation & ~W_ARTI) == 0L)
222 #define HFlying u.uprops[FLYING].intrinsic
223 #define EFlying u.uprops[FLYING].extrinsic
224 #define BFlying u.uprops[FLYING].blocked
225 #define Flying \
226 ((HFlying || EFlying || (u.usteed && is_flyer(u.usteed->data))) \
227 && !BFlying)
228 /* May touch surface; does not override any others */
230 #define Wwalking (u.uprops[WWALKING].extrinsic && !Is_waterlevel(&u.uz))
231 /* Don't get wet, can't go under water; overrides others except levitation */
232 /* Wwalking is meaningless on water level */
234 #define HSwimming u.uprops[SWIMMING].intrinsic
235 #define ESwimming u.uprops[SWIMMING].extrinsic /* [Tom] */
236 #define Swimming \
237 (HSwimming || ESwimming || (u.usteed && is_swimmer(u.usteed->data)))
238 /* Get wet, don't go under water unless if amphibious */
240 #define HMagical_breathing u.uprops[MAGICAL_BREATHING].intrinsic
241 #define EMagical_breathing u.uprops[MAGICAL_BREATHING].extrinsic
242 #define Amphibious \
243 (HMagical_breathing || EMagical_breathing || amphibious(youmonst.data))
244 /* Get wet, may go under surface */
246 #define Breathless \
247 (HMagical_breathing || EMagical_breathing || breathless(youmonst.data))
249 #define Underwater (u.uinwater)
250 /* Note that Underwater and u.uinwater are both used in code.
251 The latter form is for later implementation of other in-water
252 states, like swimming, wading, etc. */
254 #define HPasses_walls u.uprops[PASSES_WALLS].intrinsic
255 #define EPasses_walls u.uprops[PASSES_WALLS].extrinsic
256 #define Passes_walls (HPasses_walls || EPasses_walls)
258 /*** Physical attributes ***/
259 #define HSlow_digestion u.uprops[SLOW_DIGESTION].intrinsic
260 #define ESlow_digestion u.uprops[SLOW_DIGESTION].extrinsic
261 #define Slow_digestion (HSlow_digestion || ESlow_digestion) /* KMH */
263 #define HHalf_spell_damage u.uprops[HALF_SPDAM].intrinsic
264 #define EHalf_spell_damage u.uprops[HALF_SPDAM].extrinsic
265 #define Half_spell_damage (HHalf_spell_damage || EHalf_spell_damage)
268 * Physical damage
270 * Damage is NOT physical damage if (in order of priority):
271 * 1. it already qualifies for some other special category
272 * for which a special resistance already exists in the game
273 * including: cold, fire, shock, acid, and magic.
274 * Note that fire is extended to include all non-acid forms of
275 * burning, even boiling water since that is already dealt with
276 * by fire resistance, and in most or all cases is caused by fire.
277 * 2. it doesn't leave a mark. Marks include destruction of, or
278 * damage to, an internal organ (including the brain),
279 * lacerations, bruises, crushed body parts, bleeding.
281 * The following were evaluated and determined _NOT_ to be
282 * susceptible to Half_physical_damage protection:
283 * Being caught in a fireball [fire damage]
284 * Sitting in lava [lava damage]
285 * Thrown potion (acid) [acid damage]
286 * Splattered burning oil from thrown potion [fire damage]
287 * Mixing water and acid [acid damage]
288 * Molten lava (entering or being splashed) [lava damage]
289 * boiling water from a sink [fire damage]
290 * Fire traps [fire damage]
291 * Scrolls of fire (confused and otherwise) [fire damage]
292 * Alchemical explosion [not physical]
293 * System shock [shock damage]
294 * Bag of holding explosion [magical]
295 * Being undead-turned by your god [magical]
296 * Level-drain [magical]
297 * Magical explosion of a magic trap [magical]
298 * Sitting on a throne with a bad effect [magical]
299 * Contaminated water from a sink [poison/sickness]
300 * Contact-poisoned spellbooks [poison/sickness]
301 * Eating acidic/poisonous/mildly-old corpses [poison/sickness]
302 * Eating a poisoned weapon while polyselfed [poison/sickness]
303 * Engulfing a zombie or mummy (AT_ENGL in hmonas) [poison/sickness]
304 * Quaffed potions of sickness, lit oil, acid [poison/sickness]
305 * Pyrolisks' fiery gaze [fire damage]
306 * Any passive attack [most don't qualify]
309 #define HHalf_physical_damage u.uprops[HALF_PHDAM].intrinsic
310 #define EHalf_physical_damage u.uprops[HALF_PHDAM].extrinsic
311 #define Half_physical_damage (HHalf_physical_damage || EHalf_physical_damage)
313 #define HRegeneration u.uprops[REGENERATION].intrinsic
314 #define ERegeneration u.uprops[REGENERATION].extrinsic
315 #define Regeneration (HRegeneration || ERegeneration)
317 #define HEnergy_regeneration u.uprops[ENERGY_REGENERATION].intrinsic
318 #define EEnergy_regeneration u.uprops[ENERGY_REGENERATION].extrinsic
319 #define Energy_regeneration (HEnergy_regeneration || EEnergy_regeneration)
321 #define HProtection u.uprops[PROTECTION].intrinsic
322 #define EProtection u.uprops[PROTECTION].extrinsic
323 #define Protection (HProtection || EProtection)
325 #define HProtection_from_shape_changers \
326 u.uprops[PROT_FROM_SHAPE_CHANGERS].intrinsic
327 #define EProtection_from_shape_changers \
328 u.uprops[PROT_FROM_SHAPE_CHANGERS].extrinsic
329 #define Protection_from_shape_changers \
330 (HProtection_from_shape_changers || EProtection_from_shape_changers)
332 #define HPolymorph u.uprops[POLYMORPH].intrinsic
333 #define EPolymorph u.uprops[POLYMORPH].extrinsic
334 #define Polymorph (HPolymorph || EPolymorph)
336 #define HPolymorph_control u.uprops[POLYMORPH_CONTROL].intrinsic
337 #define EPolymorph_control u.uprops[POLYMORPH_CONTROL].extrinsic
338 #define Polymorph_control (HPolymorph_control || EPolymorph_control)
340 #define HUnchanging u.uprops[UNCHANGING].intrinsic
341 #define EUnchanging u.uprops[UNCHANGING].extrinsic
342 #define Unchanging (HUnchanging || EUnchanging) /* KMH */
344 #define HFast u.uprops[FAST].intrinsic
345 #define EFast u.uprops[FAST].extrinsic
346 #define Fast (HFast || EFast)
347 #define Very_fast ((HFast & ~INTRINSIC) || EFast)
349 #define HReflecting u.uprops[REFLECTING].intrinsic
350 #define EReflecting u.uprops[REFLECTING].extrinsic
351 #define Reflecting (HReflecting || EReflecting)
353 #define Free_action u.uprops[FREE_ACTION].extrinsic /* [Tom] */
355 #define Fixed_abil u.uprops[FIXED_ABIL].extrinsic /* KMH */
357 #define Lifesaved u.uprops[LIFESAVED].extrinsic
360 * Some pseudo-properties.
363 /* unconscious() includes u.usleep but not is_fainted(); the multi test is
364 redundant but allows the function calls to be skipped most of the time */
365 #define Unaware (multi < 0 && (unconscious() || is_fainted()))
367 #define Hate_silver (u.ulycn >= LOW_PM || hates_silver(youmonst.data))
369 #endif /* YOUPROP_H */