Source:NetHack 3.6.0/include/youprop.h

From NetHackWiki
(Redirected from Youprop.h)
Jump to: navigation, search

Below is the full text to youprop.h from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/include/youprop.h#line123]], 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: 1433291407 2015/06/03 00:30:07 $  $NHDT-Branch: master $:$NHDT-Revision: 1.23 $ */
  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.  /* Those implemented solely as timeouts (we use just intrinsic) */
  79.  #define HStun u.uprops[STUNNED].intrinsic
  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.  #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)
  221.  
  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 */
  229.  
  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 */
  233.  
  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 */
  239.  
  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 */
  245.  
  246.  #define Breathless \
  247.      (HMagical_breathing || EMagical_breathing || breathless(youmonst.data))
  248.  
  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. */
  253.  
  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)
  257.  
  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 */
  262.  
  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)
  266.  
  267.  /*
  268.   * Physical damage
  269.   *
  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.
  280.   *
  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]
  307.   */
  308.  
  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)
  312.  
  313.  #define HRegeneration u.uprops[REGENERATION].intrinsic
  314.  #define ERegeneration u.uprops[REGENERATION].extrinsic
  315.  #define Regeneration (HRegeneration || ERegeneration)
  316.  
  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)
  320.  
  321.  #define HProtection u.uprops[PROTECTION].intrinsic
  322.  #define EProtection u.uprops[PROTECTION].extrinsic
  323.  #define Protection (HProtection || EProtection)
  324.  
  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)
  331.  
  332.  #define HPolymorph u.uprops[POLYMORPH].intrinsic
  333.  #define EPolymorph u.uprops[POLYMORPH].extrinsic
  334.  #define Polymorph (HPolymorph || EPolymorph)
  335.  
  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)
  339.  
  340.  #define HUnchanging u.uprops[UNCHANGING].intrinsic
  341.  #define EUnchanging u.uprops[UNCHANGING].extrinsic
  342.  #define Unchanging (HUnchanging || EUnchanging) /* KMH */
  343.  
  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)
  348.  
  349.  #define HReflecting u.uprops[REFLECTING].intrinsic
  350.  #define EReflecting u.uprops[REFLECTING].extrinsic
  351.  #define Reflecting (HReflecting || EReflecting)
  352.  
  353.  #define Free_action u.uprops[FREE_ACTION].extrinsic /* [Tom] */
  354.  
  355.  #define Fixed_abil u.uprops[FIXED_ABIL].extrinsic /* KMH */
  356.  
  357.  #define Lifesaved u.uprops[LIFESAVED].extrinsic
  358.  
  359.  /*
  360.   * Some pseudo-properties.
  361.   */
  362.  
  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()))
  366.  
  367.  #define Hate_silver (u.ulycn >= LOW_PM || hates_silver(youmonst.data))
  368.  
  369.  #endif /* YOUPROP_H */