Source:NetHack 3.6.3/include/youprop.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to youprop.h from the source code of NetHack 3.6.3. To link to a particular line, write [[Source:NetHack 3.6.3/include/youprop.h#line12]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1. /* NetHack 3.6	youprop.h	$NHDT-Date: 1568831820 2019/09/18 18:37:00 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.27 $ */
2. /* Copyright (c) 1989 Mike Threepoint				  */
3. /* NetHack may be freely redistributed.  See license for details. */
4. 
5. #ifndef YOUPROP_H
6. #define YOUPROP_H
7. 
8. #include "prop.h"
9. #include "permonst.h"
10. #include "mondata.h"
11. #include "pm.h"
12. 
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.]
21.  */
22. 
23. #define maybe_polyd(if_so, if_not) (Upolyd ? (if_so) : (if_not))
24. 
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)
30. 
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)
34. 
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)
38. 
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)
42. 
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)
46. 
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)
50. 
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)
54. 
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)
59. 
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)
63. 
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)
67. 
68. /* Intrinsics only */
69. #define HSick_resistance u.uprops[SICK_RES].intrinsic
70. #define Sick_resistance (HSick_resistance || defends(AD_DISE, uwep))
71. 
72. #define Invulnerable u.uprops[INVULNERABLE].intrinsic /* [Tom] */
73. 
74. /*** Troubles ***/
75. /* Pseudo-property */
76. #define Punished (uball != 0)
77. 
78. /* Many are implemented solely as timeouts (we use just intrinsic) */
79. #define HStun u.uprops[STUNNED].intrinsic /* timed or FROMFORM */
80. #define Stunned HStun
81. 
82. #define HConfusion u.uprops[CONFUSION].intrinsic
83. #define Confusion HConfusion
84. 
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 */
98. 
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] */
105. 
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)
112. 
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)
117. 
118. #define HFumbling u.uprops[FUMBLING].intrinsic
119. #define EFumbling u.uprops[FUMBLING].extrinsic
120. #define Fumbling (HFumbling || EFumbling)
121. 
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)
125. 
126. #define HSleepy u.uprops[SLEEPY].intrinsic
127. #define ESleepy u.uprops[SLEEPY].extrinsic
128. #define Sleepy (HSleepy || ESleepy)
129. 
130. #define HHunger u.uprops[HUNGER].intrinsic
131. #define EHunger u.uprops[HUNGER].extrinsic
132. #define Hunger (HHunger || EHunger)
133. 
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)
138. 
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)
143. 
144. #define HWarning u.uprops[WARNING].intrinsic
145. #define EWarning u.uprops[WARNING].extrinsic
146. #define Warning (HWarning || EWarning)
147. 
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)
152. 
153. #define HUndead_warning u.uprops[WARN_UNDEAD].intrinsic
154. #define Undead_warning (HUndead_warning)
155. 
156. #define HSearching u.uprops[SEARCHING].intrinsic
157. #define ESearching u.uprops[SEARCHING].extrinsic
158. #define Searching (HSearching || ESearching)
159. 
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)
164. 
165. #define HInfravision u.uprops[INFRAVISION].intrinsic
166. #define EInfravision u.uprops[INFRAVISION].extrinsic
167. #define Infravision (HInfravision || EInfravision)
168. 
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)
172. 
173. /*** Appearance and behavior ***/
174. #define Adornment u.uprops[ADORNED].extrinsic
175. 
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 */
182. 
183. #define EDisplaced u.uprops[DISPLACED].extrinsic
184. #define Displaced EDisplaced
185. 
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)
190. 
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)
194. 
195. #define HConflict u.uprops[CONFLICT].intrinsic
196. #define EConflict u.uprops[CONFLICT].extrinsic
197. #define Conflict (HConflict || EConflict)
198. 
199. /*** Transportation ***/
200. #define HJumping u.uprops[JUMPING].intrinsic
201. #define EJumping u.uprops[JUMPING].extrinsic
202. #define Jumping (HJumping || EJumping)
203. 
204. #define HTeleportation u.uprops[TELEPORT].intrinsic
205. #define ETeleportation u.uprops[TELEPORT].extrinsic
206. #define Teleportation (HTeleportation || ETeleportation)
207. 
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)
211. 
212. /* HLevitation has I_SPECIAL set if levitating due to blessed potion
213.    which allows player to use the '>' command to end levitation early */
214. #define HLevitation u.uprops[LEVITATION].intrinsic
215. #define ELevitation u.uprops[LEVITATION].extrinsic
216. /* BLevitation has I_SPECIAL set if trapped in the floor,
217.    FROMOUTSIDE set if inside solid rock (or in water on Plane of Water) */
218. #define BLevitation u.uprops[LEVITATION].blocked
219. #define Levitation ((HLevitation || ELevitation) && !BLevitation)
220. /* Can't touch surface, can't go under water; overrides all others */
221. #define Lev_at_will                                                    \
222.     (((HLevitation & I_SPECIAL) != 0L || (ELevitation & W_ARTI) != 0L) \
223.      && (HLevitation & ~(I_SPECIAL | TIMEOUT)) == 0L                   \
224.      && (ELevitation & ~W_ARTI) == 0L)
225. 
226. /* Flying is overridden by Levitation */
227. #define HFlying u.uprops[FLYING].intrinsic
228. #define EFlying u.uprops[FLYING].extrinsic
229. /* BFlying has I_SPECIAL set if levitating or trapped in the floor or both,
230.    FROMOUTSIDE set if inside solid rock (or in water on Plane of Water) */
231. #define BFlying u.uprops[FLYING].blocked
232. #define Flying                                                      \
233.     ((HFlying || EFlying || (u.usteed && is_flyer(u.usteed->data))) \
234.      && !BFlying)
235. /* May touch surface; does not override any others */
236. 
237. #define EWwalking u.uprops[WWALKING].extrinsic
238. #define Wwalking (EWwalking && !Is_waterlevel(&u.uz))
239. /* Don't get wet, can't go under water; overrides others except levitation */
240. /* Wwalking is meaningless on water level */
241. 
242. #define HSwimming u.uprops[SWIMMING].intrinsic
243. #define ESwimming u.uprops[SWIMMING].extrinsic /* [Tom] */
244. #define Swimming \
245.     (HSwimming || ESwimming || (u.usteed && is_swimmer(u.usteed->data)))
246. /* Get wet, don't go under water unless if amphibious */
247. 
248. #define HMagical_breathing u.uprops[MAGICAL_BREATHING].intrinsic
249. #define EMagical_breathing u.uprops[MAGICAL_BREATHING].extrinsic
250. #define Amphibious \
251.     (HMagical_breathing || EMagical_breathing || amphibious(youmonst.data))
252. /* Get wet, may go under surface */
253. 
254. #define Breathless \
255.     (HMagical_breathing || EMagical_breathing || breathless(youmonst.data))
256. 
257. #define Underwater (u.uinwater)
258. /* Note that Underwater and u.uinwater are both used in code.
259.    The latter form is for later implementation of other in-water
260.    states, like swimming, wading, etc. */
261. 
262. #define HPasses_walls u.uprops[PASSES_WALLS].intrinsic
263. #define EPasses_walls u.uprops[PASSES_WALLS].extrinsic
264. #define Passes_walls (HPasses_walls || EPasses_walls)
265. 
266. /*** Physical attributes ***/
267. #define HSlow_digestion u.uprops[SLOW_DIGESTION].intrinsic
268. #define ESlow_digestion u.uprops[SLOW_DIGESTION].extrinsic
269. #define Slow_digestion (HSlow_digestion || ESlow_digestion) /* KMH */
270. 
271. #define HHalf_spell_damage u.uprops[HALF_SPDAM].intrinsic
272. #define EHalf_spell_damage u.uprops[HALF_SPDAM].extrinsic
273. #define Half_spell_damage (HHalf_spell_damage || EHalf_spell_damage)
274. 
275. /*
276.  * Physical damage
277.  *
278.  * Damage is NOT physical damage if (in order of priority):
279.  * 1. it already qualifies for some other special category
280.  *    for which a special resistance already exists in the game
281.  *    including: cold, fire, shock, acid, and magic.
282.  *    Note that fire is extended to include all non-acid forms of
283.  *    burning, even boiling water since that is already dealt with
284.  *    by fire resistance, and in most or all cases is caused by fire.
285.  * 2. it doesn't leave a mark. Marks include destruction of, or
286.  *    damage to, an internal organ (including the brain),
287.  *    lacerations, bruises, crushed body parts, bleeding.
288.  *
289.  * The following were evaluated and determined _NOT_ to be
290.  * susceptible to Half_physical_damage protection:
291.  *   Being caught in a fireball                      [fire damage]
292.  *   Sitting in lava                                 [lava damage]
293.  *   Thrown potion (acid)                            [acid damage]
294.  *   Splattered burning oil from thrown potion       [fire damage]
295.  *   Mixing water and acid                           [acid damage]
296.  *   Molten lava (entering or being splashed)        [lava damage]
297.  *   boiling water from a sink                       [fire damage]
298.  *   Fire traps                                      [fire damage]
299.  *   Scrolls of fire (confused and otherwise)        [fire damage]
300.  *   Alchemical explosion                            [not physical]
301.  *   System shock                                    [shock damage]
302.  *   Bag of holding explosion                        [magical]
303.  *   Being undead-turned by your god                 [magical]
304.  *   Level-drain                                     [magical]
305.  *   Magical explosion of a magic trap               [magical]
306.  *   Sitting on a throne with a bad effect           [magical]
307.  *   Contaminated water from a sink                  [poison/sickness]
308.  *   Contact-poisoned spellbooks                     [poison/sickness]
309.  *   Eating acidic/poisonous/mildly-old corpses      [poison/sickness]
310.  *   Eating a poisoned weapon while polyselfed       [poison/sickness]
311.  *   Engulfing a zombie or mummy (AT_ENGL in hmonas) [poison/sickness]
312.  *   Quaffed potions of sickness, lit oil, acid      [poison/sickness]
313.  *   Pyrolisks' fiery gaze                           [fire damage]
314.  *   Any passive attack                              [most don't qualify]
315.  */
316. 
317. #define HHalf_physical_damage u.uprops[HALF_PHDAM].intrinsic
318. #define EHalf_physical_damage u.uprops[HALF_PHDAM].extrinsic
319. #define Half_physical_damage (HHalf_physical_damage || EHalf_physical_damage)
320. 
321. #define HRegeneration u.uprops[REGENERATION].intrinsic
322. #define ERegeneration u.uprops[REGENERATION].extrinsic
323. #define Regeneration (HRegeneration || ERegeneration)
324. 
325. #define HEnergy_regeneration u.uprops[ENERGY_REGENERATION].intrinsic
326. #define EEnergy_regeneration u.uprops[ENERGY_REGENERATION].extrinsic
327. #define Energy_regeneration (HEnergy_regeneration || EEnergy_regeneration)
328. 
329. #define HProtection u.uprops[PROTECTION].intrinsic
330. #define EProtection u.uprops[PROTECTION].extrinsic
331. #define Protection (HProtection || EProtection)
332. 
333. #define HProtection_from_shape_changers \
334.     u.uprops[PROT_FROM_SHAPE_CHANGERS].intrinsic
335. #define EProtection_from_shape_changers \
336.     u.uprops[PROT_FROM_SHAPE_CHANGERS].extrinsic
337. #define Protection_from_shape_changers \
338.     (HProtection_from_shape_changers || EProtection_from_shape_changers)
339. 
340. #define HPolymorph u.uprops[POLYMORPH].intrinsic
341. #define EPolymorph u.uprops[POLYMORPH].extrinsic
342. #define Polymorph (HPolymorph || EPolymorph)
343. 
344. #define HPolymorph_control u.uprops[POLYMORPH_CONTROL].intrinsic
345. #define EPolymorph_control u.uprops[POLYMORPH_CONTROL].extrinsic
346. #define Polymorph_control (HPolymorph_control || EPolymorph_control)
347. 
348. #define HUnchanging u.uprops[UNCHANGING].intrinsic
349. #define EUnchanging u.uprops[UNCHANGING].extrinsic
350. #define Unchanging (HUnchanging || EUnchanging) /* KMH */
351. 
352. #define HFast u.uprops[FAST].intrinsic
353. #define EFast u.uprops[FAST].extrinsic
354. #define Fast (HFast || EFast)
355. #define Very_fast ((HFast & ~INTRINSIC) || EFast)
356. 
357. #define HReflecting u.uprops[REFLECTING].intrinsic
358. #define EReflecting u.uprops[REFLECTING].extrinsic
359. #define Reflecting (HReflecting || EReflecting)
360. 
361. #define Free_action u.uprops[FREE_ACTION].extrinsic /* [Tom] */
362. 
363. #define Fixed_abil u.uprops[FIXED_ABIL].extrinsic /* KMH */
364. 
365. #define Lifesaved u.uprops[LIFESAVED].extrinsic
366. 
367. /*
368.  * Some pseudo-properties.
369.  */
370. 
371. /* unconscious() includes u.usleep but not is_fainted(); the multi test is
372.    redundant but allows the function calls to be skipped most of the time */
373. #define Unaware (multi < 0 && (unconscious() || is_fainted()))
374. 
375. #define Hate_silver (u.ulycn >= LOW_PM || hates_silver(youmonst.data))
376. 
377. #endif /* YOUPROP_H */