youprop.h

Go to the documentation of this file.
00001 /*      SCCS Id: @(#)youprop.h  3.4     1999/07/02      */
00002 /* Copyright (c) 1989 Mike Threepoint                             */
00003 /* NetHack may be freely redistributed.  See license for details. */
00004 
00005 #ifndef YOUPROP_H
00006 #define YOUPROP_H
00007 
00008 #include "prop.h"
00009 #include "permonst.h"
00010 #include "mondata.h"
00011 #include "pm.h"
00012 
00013 
00014 /* KMH, intrinsics patch.
00015  * Reorganized and rewritten for >32-bit properties.
00016  * HXxx refers to intrinsic bitfields while in human form.
00017  * EXxx refers to extrinsic bitfields from worn objects.
00018  * BXxx refers to the cause of the property being blocked.
00019  * Xxx refers to any source, including polymorph forms.
00020  */
00021 
00022 
00023 #define maybe_polyd(if_so,if_not)       (Upolyd ? (if_so) : (if_not))
00024 
00025 
00026 /*** Resistances to troubles ***/
00027 /* With intrinsics and extrinsics */
00028 #define HFire_resistance        u.uprops[FIRE_RES].intrinsic
00029 #define EFire_resistance        u.uprops[FIRE_RES].extrinsic
00030 #define Fire_resistance         (HFire_resistance || EFire_resistance || \
00031                                  resists_fire(&youmonst))
00032 
00033 #define HCold_resistance        u.uprops[COLD_RES].intrinsic
00034 #define ECold_resistance        u.uprops[COLD_RES].extrinsic
00035 #define Cold_resistance         (HCold_resistance || ECold_resistance || \
00036                                  resists_cold(&youmonst))
00037 
00038 #define HSleep_resistance       u.uprops[SLEEP_RES].intrinsic
00039 #define ESleep_resistance       u.uprops[SLEEP_RES].extrinsic
00040 #define Sleep_resistance        (HSleep_resistance || ESleep_resistance || \
00041                                  resists_sleep(&youmonst))
00042 
00043 #define HDisint_resistance      u.uprops[DISINT_RES].intrinsic
00044 #define EDisint_resistance      u.uprops[DISINT_RES].extrinsic
00045 #define Disint_resistance       (HDisint_resistance || EDisint_resistance || \
00046                                  resists_disint(&youmonst))
00047 
00048 #define HShock_resistance       u.uprops[SHOCK_RES].intrinsic
00049 #define EShock_resistance       u.uprops[SHOCK_RES].extrinsic
00050 #define Shock_resistance        (HShock_resistance || EShock_resistance || \
00051                                  resists_elec(&youmonst))
00052 
00053 #define HPoison_resistance      u.uprops[POISON_RES].intrinsic
00054 #define EPoison_resistance      u.uprops[POISON_RES].extrinsic
00055 #define Poison_resistance       (HPoison_resistance || EPoison_resistance || \
00056                                  resists_poison(&youmonst))
00057 
00058 #define HDrain_resistance       u.uprops[DRAIN_RES].intrinsic
00059 #define EDrain_resistance       u.uprops[DRAIN_RES].extrinsic
00060 #define Drain_resistance        (HDrain_resistance || EDrain_resistance || \
00061                                  resists_drli(&youmonst))
00062 
00063 /* Intrinsics only */
00064 #define HSick_resistance        u.uprops[SICK_RES].intrinsic
00065 #define Sick_resistance         (HSick_resistance || \
00066                                  youmonst.data->mlet == S_FUNGUS || \
00067                                  youmonst.data == &mons[PM_GHOUL] || \
00068                                  defends(AD_DISE,uwep))
00069 #define Invulnerable            u.uprops[INVULNERABLE].intrinsic    /* [Tom] */
00070 
00071 /* Extrinsics only */
00072 #define EAntimagic              u.uprops[ANTIMAGIC].extrinsic
00073 #define Antimagic               (EAntimagic || \
00074                                  (Upolyd && resists_magm(&youmonst)))
00075 
00076 #define EAcid_resistance        u.uprops[ACID_RES].extrinsic
00077 #define Acid_resistance         (EAcid_resistance || resists_acid(&youmonst))
00078 
00079 #define EStone_resistance       u.uprops[STONE_RES].extrinsic
00080 #define Stone_resistance        (EStone_resistance || resists_ston(&youmonst))
00081 
00082 
00083 /*** Troubles ***/
00084 /* Pseudo-property */
00085 #define Punished                (uball)
00086 
00087 /* Those implemented solely as timeouts (we use just intrinsic) */
00088 #define HStun                   u.uprops[STUNNED].intrinsic
00089 #define Stunned                 (HStun || u.umonnum == PM_STALKER || \
00090                                  youmonst.data->mlet == S_BAT)
00091                 /* Note: birds will also be stunned */
00092 
00093 #define HConfusion              u.uprops[CONFUSION].intrinsic
00094 #define Confusion               HConfusion
00095 
00096 #define Blinded                 u.uprops[BLINDED].intrinsic
00097 #define Blindfolded             (ublindf && ublindf->otyp != LENSES)
00098                 /* ...means blind because of a cover */
00099 #define Blind   ((Blinded || Blindfolded || !haseyes(youmonst.data)) && \
00100                  !(ublindf && ublindf->oartifact == ART_EYES_OF_THE_OVERWORLD))
00101                 /* ...the Eyes operate even when you really are blind
00102                     or don't have any eyes */
00103 
00104 #define Sick                    u.uprops[SICK].intrinsic
00105 #define Stoned                  u.uprops[STONED].intrinsic
00106 #define Strangled               u.uprops[STRANGLED].intrinsic
00107 #define Vomiting                u.uprops[VOMITING].intrinsic
00108 #define Glib                    u.uprops[GLIB].intrinsic
00109 #define Slimed                  u.uprops[SLIMED].intrinsic      /* [Tom] */
00110 
00111 /* Hallucination is solely a timeout; its resistance is extrinsic */
00112 #define HHallucination          u.uprops[HALLUC].intrinsic
00113 #define EHalluc_resistance      u.uprops[HALLUC_RES].extrinsic
00114 #define Halluc_resistance       (EHalluc_resistance || \
00115                                  (Upolyd && dmgtype(youmonst.data, AD_HALU)))
00116 #define Hallucination           (HHallucination && !Halluc_resistance)
00117 
00118 /* Timeout, plus a worn mask */
00119 #define HFumbling               u.uprops[FUMBLING].intrinsic
00120 #define EFumbling               u.uprops[FUMBLING].extrinsic
00121 #define Fumbling                (HFumbling || EFumbling)
00122 
00123 #define HWounded_legs           u.uprops[WOUNDED_LEGS].intrinsic
00124 #define EWounded_legs           u.uprops[WOUNDED_LEGS].extrinsic
00125 #define Wounded_legs            (HWounded_legs || EWounded_legs)
00126 
00127 #define HSleeping               u.uprops[SLEEPING].intrinsic
00128 #define ESleeping               u.uprops[SLEEPING].extrinsic
00129 #define Sleeping                (HSleeping || ESleeping)
00130 
00131 #define HHunger                 u.uprops[HUNGER].intrinsic
00132 #define EHunger                 u.uprops[HUNGER].extrinsic
00133 #define Hunger                  (HHunger || EHunger)
00134 
00135 
00136 /*** Vision and senses ***/
00137 #define HSee_invisible          u.uprops[SEE_INVIS].intrinsic
00138 #define ESee_invisible          u.uprops[SEE_INVIS].extrinsic
00139 #define See_invisible           (HSee_invisible || ESee_invisible || \
00140                                  perceives(youmonst.data))
00141 
00142 #define HTelepat                u.uprops[TELEPAT].intrinsic
00143 #define ETelepat                u.uprops[TELEPAT].extrinsic
00144 #define BTelepat                u.uprops[TELEPAT].blocked
00145 #define Blind_telepat           ((HTelepat || ETelepat || \
00146                                  telepathic(youmonst.data)) \
00147                                  && !BTelepat)
00148 #define Unblind_telepat         (ETelepat && !BTelepat)
00149 
00150 #define HWarning                u.uprops[WARNING].intrinsic
00151 #define EWarning                u.uprops[WARNING].extrinsic
00152 #define Warning                 (HWarning || EWarning)
00153 
00154 /* Warning for a specific type of monster */
00155 #define HWarn_of_mon            u.uprops[WARN_OF_MON].intrinsic
00156 #define EWarn_of_mon            u.uprops[WARN_OF_MON].extrinsic
00157 #define Warn_of_mon             (HWarn_of_mon || EWarn_of_mon)
00158 
00159 #define HUndead_warning         u.uprops[WARN_UNDEAD].intrinsic
00160 #define Undead_warning          (HUndead_warning)
00161 
00162 #define HSearching              u.uprops[SEARCHING].intrinsic
00163 #define ESearching              u.uprops[SEARCHING].extrinsic
00164 #define Searching               (HSearching || ESearching)
00165 
00166 #define HClairvoyant            u.uprops[CLAIRVOYANT].intrinsic
00167 #define EClairvoyant            u.uprops[CLAIRVOYANT].extrinsic
00168 #define BClairvoyant            u.uprops[CLAIRVOYANT].blocked
00169 #define Clairvoyant             ((HClairvoyant || EClairvoyant) &&\
00170                                  !BClairvoyant)
00171 
00172 #define HInfravision            u.uprops[INFRAVISION].intrinsic
00173 #define EInfravision            u.uprops[INFRAVISION].extrinsic
00174 #define Infravision             (HInfravision || EInfravision || \
00175                                   infravision(youmonst.data))
00176 
00177 #define HDetect_monsters        u.uprops[DETECT_MONSTERS].intrinsic
00178 #define EDetect_monsters        u.uprops[DETECT_MONSTERS].extrinsic
00179 #define Detect_monsters         (HDetect_monsters || EDetect_monsters)
00180 
00181 
00182 /*** Appearance and behavior ***/
00183 #define Adornment               u.uprops[ADORNED].extrinsic
00184 
00185 #define HInvis                  u.uprops[INVIS].intrinsic
00186 #define EInvis                  u.uprops[INVIS].extrinsic
00187 #define BInvis                  u.uprops[INVIS].blocked
00188 #define Invis                   ((HInvis || EInvis || \
00189                                  pm_invisible(youmonst.data)) && !BInvis)
00190 #define Invisible               (Invis && !See_invisible)
00191                 /* Note: invisibility also hides inventory and steed */
00192 
00193 #define EDisplaced              u.uprops[DISPLACED].extrinsic
00194 #define Displaced               EDisplaced
00195 
00196 #define HStealth                u.uprops[STEALTH].intrinsic
00197 #define EStealth                u.uprops[STEALTH].extrinsic
00198 #define BStealth                u.uprops[STEALTH].blocked
00199 #define Stealth                 ((HStealth || EStealth) && !BStealth)
00200 
00201 #define HAggravate_monster      u.uprops[AGGRAVATE_MONSTER].intrinsic
00202 #define EAggravate_monster      u.uprops[AGGRAVATE_MONSTER].extrinsic
00203 #define Aggravate_monster       (HAggravate_monster || EAggravate_monster)
00204 
00205 #define HConflict               u.uprops[CONFLICT].intrinsic
00206 #define EConflict               u.uprops[CONFLICT].extrinsic
00207 #define Conflict                (HConflict || EConflict)
00208 
00209 
00210 /*** Transportation ***/
00211 #define HJumping                u.uprops[JUMPING].intrinsic
00212 #define EJumping                u.uprops[JUMPING].extrinsic
00213 #define Jumping                 (HJumping || EJumping)
00214 
00215 #define HTeleportation          u.uprops[TELEPORT].intrinsic
00216 #define ETeleportation          u.uprops[TELEPORT].extrinsic
00217 #define Teleportation           (HTeleportation || ETeleportation || \
00218                                  can_teleport(youmonst.data))
00219 
00220 #define HTeleport_control       u.uprops[TELEPORT_CONTROL].intrinsic
00221 #define ETeleport_control       u.uprops[TELEPORT_CONTROL].extrinsic
00222 #define Teleport_control        (HTeleport_control || ETeleport_control || \
00223                                  control_teleport(youmonst.data))
00224 
00225 #define HLevitation             u.uprops[LEVITATION].intrinsic
00226 #define ELevitation             u.uprops[LEVITATION].extrinsic
00227 #define Levitation              (HLevitation || ELevitation || \
00228                                  is_floater(youmonst.data))
00229         /* Can't touch surface, can't go under water; overrides all others */
00230 #define Lev_at_will             (((HLevitation & I_SPECIAL) != 0L || \
00231                                  (ELevitation & W_ARTI) != 0L) && \
00232                                  (HLevitation & ~(I_SPECIAL|TIMEOUT)) == 0L && \
00233                                  (ELevitation & ~W_ARTI) == 0L && \
00234                                  !is_floater(youmonst.data))
00235 
00236 #define EFlying                 u.uprops[FLYING].extrinsic
00237 #ifdef STEED
00238 # define Flying                 (EFlying || is_flyer(youmonst.data) || \
00239                                  (u.usteed && is_flyer(u.usteed->data)))
00240 #else
00241 # define Flying                 (EFlying || is_flyer(youmonst.data))
00242 #endif
00243         /* May touch surface; does not override any others */
00244 
00245 #define Wwalking                (u.uprops[WWALKING].extrinsic && \
00246                                  !Is_waterlevel(&u.uz))
00247         /* Don't get wet, can't go under water; overrides others except levitation */
00248         /* Wwalking is meaningless on water level */
00249 
00250 #define HSwimming               u.uprops[SWIMMING].intrinsic
00251 #define ESwimming               u.uprops[SWIMMING].extrinsic    /* [Tom] */
00252 #ifdef STEED
00253 # define Swimming               (HSwimming || ESwimming || \
00254                                  is_swimmer(youmonst.data) || \
00255                                  (u.usteed && is_swimmer(u.usteed->data)))
00256 #else
00257 # define Swimming               (HSwimming || ESwimming || \
00258                                  is_swimmer(youmonst.data))
00259 #endif
00260         /* Get wet, don't go under water unless if amphibious */
00261 
00262 #define HMagical_breathing      u.uprops[MAGICAL_BREATHING].intrinsic
00263 #define EMagical_breathing      u.uprops[MAGICAL_BREATHING].extrinsic
00264 #define Amphibious              (HMagical_breathing || EMagical_breathing || \
00265                                  amphibious(youmonst.data))
00266         /* Get wet, may go under surface */
00267 
00268 #define Breathless              (HMagical_breathing || EMagical_breathing || \
00269                                  breathless(youmonst.data))
00270 
00271 #define Underwater              (u.uinwater)
00272 /* Note that Underwater and u.uinwater are both used in code.
00273    The latter form is for later implementation of other in-water
00274    states, like swimming, wading, etc. */
00275 
00276 #define HPasses_walls           u.uprops[PASSES_WALLS].intrinsic
00277 #define EPasses_walls           u.uprops[PASSES_WALLS].extrinsic
00278 #define Passes_walls            (HPasses_walls || EPasses_walls || \
00279                                  passes_walls(youmonst.data))
00280 
00281 
00282 /*** Physical attributes ***/
00283 #define HSlow_digestion         u.uprops[SLOW_DIGESTION].intrinsic
00284 #define ESlow_digestion         u.uprops[SLOW_DIGESTION].extrinsic
00285 #define Slow_digestion          (HSlow_digestion || ESlow_digestion)  /* KMH */
00286 
00287 #define HHalf_spell_damage      u.uprops[HALF_SPDAM].intrinsic
00288 #define EHalf_spell_damage      u.uprops[HALF_SPDAM].extrinsic
00289 #define Half_spell_damage       (HHalf_spell_damage || EHalf_spell_damage)
00290 
00291 #define HHalf_physical_damage   u.uprops[HALF_PHDAM].intrinsic
00292 #define EHalf_physical_damage   u.uprops[HALF_PHDAM].extrinsic
00293 #define Half_physical_damage    (HHalf_physical_damage || EHalf_physical_damage)
00294 
00295 #define HRegeneration           u.uprops[REGENERATION].intrinsic
00296 #define ERegeneration           u.uprops[REGENERATION].extrinsic
00297 #define Regeneration            (HRegeneration || ERegeneration || \
00298                                  regenerates(youmonst.data))
00299 
00300 #define HEnergy_regeneration    u.uprops[ENERGY_REGENERATION].intrinsic
00301 #define EEnergy_regeneration    u.uprops[ENERGY_REGENERATION].extrinsic
00302 #define Energy_regeneration     (HEnergy_regeneration || EEnergy_regeneration)
00303 
00304 #define HProtection             u.uprops[PROTECTION].intrinsic
00305 #define EProtection             u.uprops[PROTECTION].extrinsic
00306 #define Protection              (HProtection || EProtection)
00307 
00308 #define HProtection_from_shape_changers \
00309                                 u.uprops[PROT_FROM_SHAPE_CHANGERS].intrinsic
00310 #define EProtection_from_shape_changers \
00311                                 u.uprops[PROT_FROM_SHAPE_CHANGERS].extrinsic
00312 #define Protection_from_shape_changers \
00313                                 (HProtection_from_shape_changers || \
00314                                  EProtection_from_shape_changers)
00315 
00316 #define HPolymorph              u.uprops[POLYMORPH].intrinsic
00317 #define EPolymorph              u.uprops[POLYMORPH].extrinsic
00318 #define Polymorph               (HPolymorph || EPolymorph)
00319 
00320 #define HPolymorph_control      u.uprops[POLYMORPH_CONTROL].intrinsic
00321 #define EPolymorph_control      u.uprops[POLYMORPH_CONTROL].extrinsic
00322 #define Polymorph_control       (HPolymorph_control || EPolymorph_control)
00323 
00324 #define HUnchanging             u.uprops[UNCHANGING].intrinsic
00325 #define EUnchanging             u.uprops[UNCHANGING].extrinsic
00326 #define Unchanging              (HUnchanging || EUnchanging)    /* KMH */
00327 
00328 #define HFast                   u.uprops[FAST].intrinsic
00329 #define EFast                   u.uprops[FAST].extrinsic
00330 #define Fast                    (HFast || EFast)
00331 #define Very_fast               ((HFast & ~INTRINSIC) || EFast)
00332 
00333 #define EReflecting             u.uprops[REFLECTING].extrinsic
00334 #define Reflecting              (EReflecting || \
00335                                  (youmonst.data == &mons[PM_SILVER_DRAGON]))
00336 
00337 #define Free_action             u.uprops[FREE_ACTION].extrinsic /* [Tom] */
00338 
00339 #define Fixed_abil              u.uprops[FIXED_ABIL].extrinsic  /* KMH */
00340 
00341 #define Lifesaved               u.uprops[LIFESAVED].extrinsic
00342 
00343 
00344 #endif /* YOUPROP_H */