Source:NetHack 5.0.0/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 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/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 5.0	youprop.h	$NHDT-Date: 1725653018 2024/09/06 20:03:38 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.45 $ */
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. 
12. /* KMH, intrinsics patch.
13.  * Reorganized and rewritten for >32-bit properties.
14.  * HXxx refers to intrinsic bitfields while in human form.
15.  * EXxx refers to extrinsic bitfields from worn objects.
16.  * BXxx refers to the cause of the property being blocked.
17.  * Xxx refers to any source, including polymorph forms.
18.  * [Post-3.4.3: HXxx now includes a FROMFORM bit to handle
19.  * intrinsic conferred by being polymorphed.]
20.  */
21. 
22. #define maybe_polyd(if_so, if_not) (Upolyd ? (if_so) : (if_not))
23. 
24. /*** Resistances to troubles ***/
25. /* With intrinsics and extrinsics */
26. #define HFire_resistance u.uprops[FIRE_RES].intrinsic
27. #define EFire_resistance u.uprops[FIRE_RES].extrinsic
28. #define Fire_resistance (HFire_resistance || EFire_resistance)
29. 
30. #define HCold_resistance u.uprops[COLD_RES].intrinsic
31. #define ECold_resistance u.uprops[COLD_RES].extrinsic
32. #define Cold_resistance (HCold_resistance || ECold_resistance)
33. 
34. #define HSleep_resistance u.uprops[SLEEP_RES].intrinsic
35. #define ESleep_resistance u.uprops[SLEEP_RES].extrinsic
36. #define Sleep_resistance (HSleep_resistance || ESleep_resistance)
37. 
38. #define HDisint_resistance u.uprops[DISINT_RES].intrinsic
39. #define EDisint_resistance u.uprops[DISINT_RES].extrinsic
40. #define Disint_resistance (HDisint_resistance || EDisint_resistance)
41. 
42. #define HShock_resistance u.uprops[SHOCK_RES].intrinsic
43. #define EShock_resistance u.uprops[SHOCK_RES].extrinsic
44. #define Shock_resistance (HShock_resistance || EShock_resistance)
45. 
46. #define HPoison_resistance u.uprops[POISON_RES].intrinsic
47. #define EPoison_resistance u.uprops[POISON_RES].extrinsic
48. #define Poison_resistance (HPoison_resistance || EPoison_resistance)
49. 
50. #define HDrain_resistance u.uprops[DRAIN_RES].intrinsic
51. #define EDrain_resistance u.uprops[DRAIN_RES].extrinsic
52. #define Drain_resistance (HDrain_resistance || EDrain_resistance)
53. 
54. /* Hxxx due to FROMFORM only */
55. #define HAntimagic u.uprops[ANTIMAGIC].intrinsic
56. #define EAntimagic u.uprops[ANTIMAGIC].extrinsic
57. #define Antimagic (HAntimagic || EAntimagic)
58. 
59. #define HAcid_resistance u.uprops[ACID_RES].intrinsic
60. #define EAcid_resistance u.uprops[ACID_RES].extrinsic
61. #define Acid_resistance (HAcid_resistance || EAcid_resistance)
62. 
63. #define HStone_resistance u.uprops[STONE_RES].intrinsic
64. #define EStone_resistance u.uprops[STONE_RES].extrinsic
65. #define Stone_resistance (HStone_resistance || EStone_resistance)
66. 
67. #define HSick_resistance u.uprops[SICK_RES].intrinsic
68. #define ESick_resistance u.uprops[SICK_RES].extrinsic
69. #define Sick_resistance (HSick_resistance || ESick_resistance \
70.                          || defended(&gy.youmonst, AD_DISE))
71. 
72. /* Intrinsics only */
73. #define Invulnerable u.uprops[INVULNERABLE].intrinsic /* [Tom] */
74. 
75. /*** Troubles ***/
76. /* Pseudo-property */
77. #define Punished (uball != 0)
78. 
79. /* Many are implemented solely as timeouts (we use just intrinsic) */
80. #define HStun u.uprops[STUNNED].intrinsic /* timed or FROMFORM */
81. #define Stunned HStun
82. 
83. #define HConfusion u.uprops[CONFUSION].intrinsic
84. #define Confusion HConfusion
85. 
86. /* Blindness is more complex than other properties */
87. #define HBlinded u.uprops[BLINDED].intrinsic /* TIMEOUT|FROMOUTSIDE|FROMFORM */
88. #define EBlinded u.uprops[BLINDED].extrinsic /* W_TOOL */
89.         /* wearing the Eyes of the Overworld overrides blindness */
90. #define BBlinded u.uprops[BLINDED].blocked   /* W_TOOL */
91.         /* non-blindfold: timed effect | u.uroleplay.blind | !haseyes() */
92. #define Blinded (HBlinded && !BBlinded)
93. #define BlindedTimeout (HBlinded & TIMEOUT)
94. #define PermaBlind ((HBlinded & FROMOUTSIDE) != 0L) /* OPTIONS:blind */
95.         /* worn blindfold (or towel; lenses don't set [BLINDED].extrinsic) */
96. #define Blindfolded EBlinded
97. #define Blindfolded_only (Blindfolded && !Blinded)
98.         /* '#define Blind (Blinded || Blindfolded)' would work, but only
99.            because BBlinded (conferred by artifact lenses) and Blindfolded
100.            are mutually exclusive; explicitly applying !BBlinded to both
101.            internal and external blindness should be more robust in case
102.            of future changes */
103. #define Blind ((HBlinded || EBlinded) && !BBlinded)
104. 
105. /*
106.  * Maladies
107.  */
108. #define Sick u.uprops[SICK].intrinsic
109. #define Stoned u.uprops[STONED].intrinsic
110. #define Strangled u.uprops[STRANGLED].intrinsic
111. #define Vomiting u.uprops[VOMITING].intrinsic
112. #define Glib u.uprops[GLIB].intrinsic
113. #define Slimed u.uprops[SLIMED].intrinsic /* [Tom] */
114. 
115. /* Hallucination is solely a timeout */
116. #define HHallucination u.uprops[HALLUC].intrinsic
117. #define HHalluc_resistance u.uprops[HALLUC_RES].intrinsic
118. #define EHalluc_resistance u.uprops[HALLUC_RES].extrinsic
119. #define Halluc_resistance (HHalluc_resistance || EHalluc_resistance)
120. #define Hallucination (HHallucination && !Halluc_resistance)
121. 
122. /* Timeout, plus a worn mask */
123. #define HDeaf u.uprops[DEAF].intrinsic
124. #define EDeaf u.uprops[DEAF].extrinsic
125. #define Deaf (HDeaf || EDeaf || u.uroleplay.deaf)
126. 
127. #define HFumbling u.uprops[FUMBLING].intrinsic
128. #define EFumbling u.uprops[FUMBLING].extrinsic
129. #define Fumbling (HFumbling || EFumbling)
130. 
131. /* HWounded_legs indicates whether wounded leg(s) condition exists and
132.    holds the timeout for recovery; EWounded_legs uses the worn-ring bits
133.    to track left vs right vs both and is meaningless when HWounded_legs
134.    is zero except when timeout has just decremented that to 0 and calls
135.    heal_legs(); both values apply to steed rather than to hero when riding */
136. #define HWounded_legs u.uprops[WOUNDED_LEGS].intrinsic
137. #define EWounded_legs u.uprops[WOUNDED_LEGS].extrinsic
138. #define Wounded_legs (HWounded_legs || EWounded_legs)
139. 
140. /* Sleepy: prone to falling asleep periodically; not necessarily asleep now */
141. #define HSleepy u.uprops[SLEEPY].intrinsic
142. #define ESleepy u.uprops[SLEEPY].extrinsic
143. #define Sleepy (HSleepy || ESleepy)
144. 
145. #define HHunger u.uprops[HUNGER].intrinsic
146. #define EHunger u.uprops[HUNGER].extrinsic
147. #define Hunger (HHunger || EHunger)
148. 
149. /*** Vision and senses ***/
150. #define HSee_invisible u.uprops[SEE_INVIS].intrinsic
151. #define ESee_invisible u.uprops[SEE_INVIS].extrinsic
152. #define See_invisible (HSee_invisible || ESee_invisible)
153. 
154. #define HTelepat u.uprops[TELEPAT].intrinsic
155. #define ETelepat u.uprops[TELEPAT].extrinsic
156. #define Blind_telepat (HTelepat || ETelepat)
157. #define Unblind_telepat (ETelepat)
158. 
159. #define HBlnd_resist u.uprops[BLND_RES].intrinsic /* from form */
160. #define EBlnd_resist u.uprops[BLND_RES].extrinsic /* wielding Sunsword */
161. #define Blnd_resist (HBlnd_resist || EBlnd_resist)
162. 
163. #define HWarning u.uprops[WARNING].intrinsic
164. #define EWarning u.uprops[WARNING].extrinsic
165. #define Warning (HWarning || EWarning)
166. 
167. /* Warning for a specific type of monster */
168. #define HWarn_of_mon u.uprops[WARN_OF_MON].intrinsic
169. #define EWarn_of_mon u.uprops[WARN_OF_MON].extrinsic
170. #define Warn_of_mon (HWarn_of_mon || EWarn_of_mon)
171. 
172. #define HUndead_warning u.uprops[WARN_UNDEAD].intrinsic
173. #define Undead_warning (HUndead_warning)
174. 
175. #define HSearching u.uprops[SEARCHING].intrinsic
176. #define ESearching u.uprops[SEARCHING].extrinsic
177. #define Searching (HSearching || ESearching)
178. 
179. #define HClairvoyant u.uprops[CLAIRVOYANT].intrinsic
180. #define EClairvoyant u.uprops[CLAIRVOYANT].extrinsic
181. #define BClairvoyant u.uprops[CLAIRVOYANT].blocked
182. #define Clairvoyant ((HClairvoyant || EClairvoyant) && !BClairvoyant)
183. 
184. #define HInfravision u.uprops[INFRAVISION].intrinsic
185. #define EInfravision u.uprops[INFRAVISION].extrinsic
186. #define Infravision (HInfravision || EInfravision)
187. 
188. #define HDetect_monsters u.uprops[DETECT_MONSTERS].intrinsic
189. #define EDetect_monsters u.uprops[DETECT_MONSTERS].extrinsic
190. #define Detect_monsters (HDetect_monsters || EDetect_monsters)
191. 
192. /*** Appearance and behavior ***/
193. #define Adornment u.uprops[ADORNED].extrinsic
194. 
195. #define HInvis u.uprops[INVIS].intrinsic
196. #define EInvis u.uprops[INVIS].extrinsic
197. #define BInvis u.uprops[INVIS].blocked
198. #define Invis ((HInvis || EInvis) && !BInvis)
199. #define Invisible (Invis && !See_invisible)
200. /* Note: invisibility also hides inventory and steed */
201. 
202. #define HDisplaced u.uprops[DISPLACED].intrinsic /* timed from corpse */
203. #define EDisplaced u.uprops[DISPLACED].extrinsic /* worn cloak */
204. #define Displaced (HDisplaced || EDisplaced)
205. 
206. #define HStealth u.uprops[STEALTH].intrinsic
207. #define EStealth u.uprops[STEALTH].extrinsic
208. /* BStealth has FROMOUTSIDE set if mounted on non-flying steed */
209. #define BStealth u.uprops[STEALTH].blocked
210. #define Stealth ((HStealth || EStealth) && !BStealth)
211. 
212. #define HAggravate_monster u.uprops[AGGRAVATE_MONSTER].intrinsic
213. #define EAggravate_monster u.uprops[AGGRAVATE_MONSTER].extrinsic
214. #define Aggravate_monster (HAggravate_monster || EAggravate_monster)
215. 
216. #define HConflict u.uprops[CONFLICT].intrinsic
217. #define EConflict u.uprops[CONFLICT].extrinsic
218. #define Conflict (HConflict || EConflict)
219. 
220. /*** Transportation ***/
221. #define HJumping u.uprops[JUMPING].intrinsic
222. #define EJumping u.uprops[JUMPING].extrinsic
223. #define Jumping (HJumping || EJumping)
224. 
225. #define HTeleportation u.uprops[TELEPORT].intrinsic
226. #define ETeleportation u.uprops[TELEPORT].extrinsic
227. #define Teleportation (HTeleportation || ETeleportation)
228. 
229. #define HTeleport_control u.uprops[TELEPORT_CONTROL].intrinsic
230. #define ETeleport_control u.uprops[TELEPORT_CONTROL].extrinsic
231. #define Teleport_control (HTeleport_control || ETeleport_control)
232. 
233. /* HLevitation has I_SPECIAL set if levitating due to blessed potion
234.    which allows player to use the '>' command to end levitation early */
235. #define HLevitation u.uprops[LEVITATION].intrinsic
236. #define ELevitation u.uprops[LEVITATION].extrinsic
237. /* BLevitation has I_SPECIAL set if trapped in the floor,
238.    FROMOUTSIDE set if inside solid rock (or in water on Plane of Water) */
239. #define BLevitation u.uprops[LEVITATION].blocked
240. #define Levitation ((HLevitation || ELevitation) && !BLevitation)
241. /* Can't touch surface, can't go under water; overrides all others */
242. #define Lev_at_will                                                    \
243.     (((HLevitation & I_SPECIAL) != 0L || (ELevitation & W_ARTI) != 0L) \
244.      && (HLevitation & ~(I_SPECIAL | TIMEOUT)) == 0L                   \
245.      && (ELevitation & ~W_ARTI) == 0L)
246. 
247. /* Flying is overridden by Levitation */
248. #define HFlying u.uprops[FLYING].intrinsic
249. #define EFlying u.uprops[FLYING].extrinsic
250. /* BFlying has I_SPECIAL set if levitating or trapped in the floor or both,
251.    FROMOUTSIDE set if inside solid rock (or in water on Plane of Water) */
252. #define BFlying u.uprops[FLYING].blocked
253. #define Flying                                                      \
254.     ((HFlying || EFlying || (u.usteed && is_flyer(u.usteed->data))) \
255.      && !BFlying)
256. /* May touch surface; does not override any others */
257. 
258. #define HWwalking u.uprops[WWALKING].intrinsic /* see lava_effects() */
259. #define EWwalking u.uprops[WWALKING].extrinsic
260. #define Wwalking ((HWwalking || EWwalking) && !Is_waterlevel(&u.uz))
261. /* Don't get wet, can't go under water; overrides others except levitation */
262. /* Wwalking is meaningless on water level */
263. 
264. #define HSwimming u.uprops[SWIMMING].intrinsic
265. #define ESwimming u.uprops[SWIMMING].extrinsic /* [Tom] */
266. #define Swimming \
267.     (HSwimming || ESwimming || (u.usteed && is_swimmer(u.usteed->data)))
268. /* Get wet, don't go under water unless if amphibious */
269. 
270. #define HMagical_breathing u.uprops[MAGICAL_BREATHING].intrinsic
271. #define EMagical_breathing u.uprops[MAGICAL_BREATHING].extrinsic
272. #define Amphibious \
273.     (HMagical_breathing || EMagical_breathing || amphibious(gy.youmonst.data))
274. /* Get wet, may go under surface */
275. 
276. #define Breathless \
277.     (HMagical_breathing || EMagical_breathing || breathless(gy.youmonst.data))
278. 
279. #define Underwater (u.uinwater)
280. /* Note that Underwater and u.uinwater are both used in code.
281.    The latter form is for later implementation of other in-water
282.    states, like swimming, wading, etc. */
283. 
284. #define HPasses_walls u.uprops[PASSES_WALLS].intrinsic
285. #define EPasses_walls u.uprops[PASSES_WALLS].extrinsic
286. #define Passes_walls (HPasses_walls || EPasses_walls)
287. 
288. /*** Physical attributes ***/
289. #define HSlow_digestion u.uprops[SLOW_DIGESTION].intrinsic
290. #define ESlow_digestion u.uprops[SLOW_DIGESTION].extrinsic
291. #define Slow_digestion (HSlow_digestion || ESlow_digestion) /* KMH */
292. 
293. #define HHalf_spell_damage u.uprops[HALF_SPDAM].intrinsic
294. #define EHalf_spell_damage u.uprops[HALF_SPDAM].extrinsic
295. #define Half_spell_damage (HHalf_spell_damage || EHalf_spell_damage)
296. 
297. /*
298.  * Physical damage
299.  *
300.  * Damage is NOT physical damage if (in order of priority):
301.  * 1. it already qualifies for some other special category
302.  *    for which a special resistance already exists in the game
303.  *    including: cold, fire, shock, acid, and magic.
304.  *    Note that fire is extended to include all non-acid forms of
305.  *    burning, even boiling water since that is already dealt with
306.  *    by fire resistance, and in most or all cases is caused by fire.
307.  * 2. it doesn't leave a mark. Marks include destruction of, or
308.  *    damage to, an internal organ (including the brain),
309.  *    lacerations, bruises, crushed body parts, bleeding.
310.  *
311.  * The following were evaluated and determined _NOT_ to be
312.  * susceptible to Half_physical_damage protection:
313.  *   Being caught in a fireball                      [fire damage]
314.  *   Sitting in lava                                 [lava damage]
315.  *   Thrown potion (acid)                            [acid damage]
316.  *   Splattered burning oil from thrown potion       [fire damage]
317.  *   Mixing water and acid                           [acid damage]
318.  *   Molten lava (entering or being splashed)        [lava damage]
319.  *   boiling water from a sink                       [fire damage]
320.  *   Fire traps                                      [fire damage]
321.  *   Scrolls of fire (confused and otherwise)        [fire damage]
322.  *   Alchemical explosion                            [not physical]
323.  *   System shock                                    [shock damage]
324.  *   Bag of holding explosion                        [magical]
325.  *   Being undead-turned by your god                 [magical]
326.  *   Level-drain                                     [magical]
327.  *   Magical explosion of a magic trap               [magical]
328.  *   Sitting on a throne with a bad effect           [magical]
329.  *   Contaminated water from a sink                  [poison/sickness]
330.  *   Contact-poisoned spellbooks                     [poison/sickness]
331.  *   Eating acidic/poisonous/mildly-old corpses      [poison/sickness]
332.  *   Eating a poisoned weapon while polyselfed       [poison/sickness]
333.  *   Engulfing a zombie or mummy (AT_ENGL in hmonas) [poison/sickness]
334.  *   Quaffed potions of sickness, lit oil, acid      [poison/sickness]
335.  *   Pyrolisks' fiery gaze                           [fire damage]
336.  *   Any passive attack                              [most don't qualify]
337.  */
338. 
339. #define HHalf_physical_damage u.uprops[HALF_PHDAM].intrinsic
340. #define EHalf_physical_damage u.uprops[HALF_PHDAM].extrinsic
341. #define Half_physical_damage (HHalf_physical_damage || EHalf_physical_damage)
342. 
343. #define HRegeneration u.uprops[REGENERATION].intrinsic
344. #define ERegeneration u.uprops[REGENERATION].extrinsic
345. #define Regeneration (HRegeneration || ERegeneration)
346. 
347. #define HEnergy_regeneration u.uprops[ENERGY_REGENERATION].intrinsic
348. #define EEnergy_regeneration u.uprops[ENERGY_REGENERATION].extrinsic
349. #define Energy_regeneration (HEnergy_regeneration || EEnergy_regeneration)
350. 
351. #define HProtection u.uprops[PROTECTION].intrinsic
352. #define EProtection u.uprops[PROTECTION].extrinsic
353. #define Protection (HProtection || EProtection)
354. 
355. #define HProtection_from_shape_changers \
356.     u.uprops[PROT_FROM_SHAPE_CHANGERS].intrinsic
357. #define EProtection_from_shape_changers \
358.     u.uprops[PROT_FROM_SHAPE_CHANGERS].extrinsic
359. #define Protection_from_shape_changers \
360.     (HProtection_from_shape_changers || EProtection_from_shape_changers)
361. 
362. #define HPolymorph u.uprops[POLYMORPH].intrinsic
363. #define EPolymorph u.uprops[POLYMORPH].extrinsic
364. #define Polymorph (HPolymorph || EPolymorph)
365. 
366. #define HPolymorph_control u.uprops[POLYMORPH_CONTROL].intrinsic
367. #define EPolymorph_control u.uprops[POLYMORPH_CONTROL].extrinsic
368. #define Polymorph_control (HPolymorph_control || EPolymorph_control)
369. 
370. #define HUnchanging u.uprops[UNCHANGING].intrinsic
371. #define EUnchanging u.uprops[UNCHANGING].extrinsic
372. #define Unchanging (HUnchanging || EUnchanging) /* KMH */
373. 
374. #define HFast u.uprops[FAST].intrinsic
375. #define EFast u.uprops[FAST].extrinsic
376. #define Fast (HFast || EFast)
377. #define Very_fast ((HFast & ~INTRINSIC) || EFast)
378. 
379. #define HReflecting u.uprops[REFLECTING].intrinsic
380. #define EReflecting u.uprops[REFLECTING].extrinsic
381. #define Reflecting (HReflecting || EReflecting)
382. 
383. #define Free_action u.uprops[FREE_ACTION].extrinsic /* [Tom] */
384. 
385. #define Fixed_abil u.uprops[FIXED_ABIL].extrinsic /* KMH */
386. 
387. #define Lifesaved u.uprops[LIFESAVED].extrinsic
388. 
389. /*
390.  * Some pseudo-properties.
391.  */
392. 
393. /* the code will needs lots of updating to use this so leave it commented
394. #define Riding (u.usteed != NULL)
395. */
396. 
397. /* unconscious() includes u.usleep but not is_fainted(); the multi test is
398.    redundant but allows the function calls to be skipped most of the time */
399. #define Unaware (gm.multi < 0 && (unconscious() || is_fainted()))
400. 
401. #define Hate_silver (u.ulycn >= LOW_PM || hates_silver(gy.youmonst.data))
402. 
403. /* _The_Hitchhikers_Guide_to_the_Galaxy_ on uses for 'towel': "wrap it round
404.    your head to ward off noxious fumes" [we require it to be damp or wet] */
405. #define Half_gas_damage \
406.     (ublindf && ublindf->otyp == TOWEL && ublindf->spe > 0)
407. 
408. #endif /* YOUPROP_H */