From d32ab55b8489d37b67b7ed314dfb55f36a8f54b8 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 26 Nov 2024 20:57:11 -0800 Subject: [PATCH] new property: BLND_RES Add enlightenment feedback for Sunsword's blocking of becoming blind from light flashes. It uses an extra property so that wizard mode can report the reason. EDITLEVEL is being incremented, so existing save and bones files are invalidated. --- include/patchlevel.h | 2 +- include/prop.h | 63 ++++++++++++++++++++++---------------------- include/youprop.h | 4 +++ src/artifact.c | 16 ++++++++++- src/attrib.c | 8 +++--- src/insight.c | 3 +++ src/mondata.c | 10 ++++++- src/polyself.c | 2 ++ src/timeout.c | 1 + 9 files changed, 72 insertions(+), 37 deletions(-) diff --git a/include/patchlevel.h b/include/patchlevel.h index 4d107d941..3f1d88e81 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -17,7 +17,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 109 +#define EDITLEVEL 110 /* * Development status possibilities. diff --git a/include/prop.h b/include/prop.h index 9824d892b..16b7efd50 100644 --- a/include/prop.h +++ b/include/prop.h @@ -55,41 +55,42 @@ enum prop_types { CLAIRVOYANT = 35, INFRAVISION = 36, DETECT_MONSTERS = 37, + BLND_RES = 38, /* Appearance and behavior */ - ADORNED = 38, - INVIS = 39, - DISPLACED = 40, - STEALTH = 41, - AGGRAVATE_MONSTER = 42, - CONFLICT = 43, + ADORNED = 39, + INVIS = 40, + DISPLACED = 41, + STEALTH = 42, + AGGRAVATE_MONSTER = 43, + CONFLICT = 44, /* Transportation */ - JUMPING = 44, - TELEPORT = 45, - TELEPORT_CONTROL = 46, - LEVITATION = 47, - FLYING = 48, - WWALKING = 49, - SWIMMING = 50, - MAGICAL_BREATHING = 51, - PASSES_WALLS = 52, + JUMPING = 45, + TELEPORT = 46, + TELEPORT_CONTROL = 47, + LEVITATION = 48, + FLYING = 49, + WWALKING = 50, + SWIMMING = 51, + MAGICAL_BREATHING = 52, + PASSES_WALLS = 53, /* Physical attributes */ - SLOW_DIGESTION = 53, - HALF_SPDAM = 54, - HALF_PHDAM = 55, - REGENERATION = 56, - ENERGY_REGENERATION = 57, - PROTECTION = 58, - PROT_FROM_SHAPE_CHANGERS = 59, - POLYMORPH = 60, - POLYMORPH_CONTROL = 61, - UNCHANGING = 62, - FAST = 63, - REFLECTING = 64, - FREE_ACTION = 65, - FIXED_ABIL = 66, - LIFESAVED = 67 + SLOW_DIGESTION = 54, + HALF_SPDAM = 55, + HALF_PHDAM = 56, + REGENERATION = 57, + ENERGY_REGENERATION = 58, + PROTECTION = 59, + PROT_FROM_SHAPE_CHANGERS = 60, + POLYMORPH = 61, + POLYMORPH_CONTROL = 62, + UNCHANGING = 63, + FAST = 64, + REFLECTING = 65, + FREE_ACTION = 66, + FIXED_ABIL = 67, + LIFESAVED = 68, + LAST_PROP = LIFESAVED }; -#define LAST_PROP (LIFESAVED) /*** Where the properties come from ***/ /* Definitions were moved here from obj.h and you.h */ diff --git a/include/youprop.h b/include/youprop.h index 331d6ede1..f2c166606 100644 --- a/include/youprop.h +++ b/include/youprop.h @@ -156,6 +156,10 @@ #define Blind_telepat (HTelepat || ETelepat) #define Unblind_telepat (ETelepat) +#define HBlnd_resist u.uprops[BLND_RES].intrinsic /* from form */ +#define EBlnd_resist u.uprops[BLND_RES].extrinsic /* wielding Sunsword */ +#define Blnd_resist (HBlnd_resist || EBlnd_resist) + #define HWarning u.uprops[WARNING].intrinsic #define EWarning u.uprops[WARNING].extrinsic #define Warning (HWarning || EWarning) diff --git a/src/artifact.c b/src/artifact.c index 009dd3406..f31ec5a98 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -629,7 +629,10 @@ protects(struct obj *otmp, boolean being_worn) * unworn/unwielded/dropped. Pickup/drop only set/reset the W_ART mask. */ void -set_artifact_intrinsic(struct obj *otmp, boolean on, long wp_mask) +set_artifact_intrinsic( + struct obj *otmp, + boolean on, + long wp_mask) { long *mask = 0; const struct artifact *art, *oart = get_artifact(otmp); @@ -796,6 +799,13 @@ set_artifact_intrinsic(struct obj *otmp, boolean on, long wp_mask) && (u.uprops[oart->inv_prop].extrinsic & W_ARTI)) (void) arti_invoke(otmp); } + + if (wp_mask == W_WEP && is_art(otmp, ART_SUNSWORD)) { + if (on) + EBlnd_resist |= wp_mask; + else + EBlnd_resist &= ~wp_mask; + } } /* touch_artifact()'s return value isn't sufficient to tell whether it @@ -2210,6 +2220,10 @@ what_gives(long *abil) if ((art->spfx & spfx) == spfx && obj->owornmask) return obj; } + if (obj == uwep && abil == &EBlnd_resist + && (*abil & W_WEP) != 0L) { + return obj; /* Sunsword */ + } } } else { if (wornbits && wornbits == (wornmask & obj->owornmask)) diff --git a/src/attrib.c b/src/attrib.c index 859b5b44a..36dd9ea91 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -889,7 +889,8 @@ is_innate(int propidx) ignore innateness if equipment is going to claim responsibility */ && !u.uprops[propidx].extrinsic) return FROM_ROLE; - if (propidx == BLINDED && !haseyes(gy.youmonst.data)) + if ((propidx == BLINDED && !haseyes(gy.youmonst.data)) + || (propidx == BLND_RES && (HBlnd_resist & FROMFORM) != 0)) return FROM_FORM; return FROM_NONE; } @@ -897,7 +898,8 @@ is_innate(int propidx) DISABLE_WARNING_FORMAT_NONLITERAL char * -from_what(int propidx) /* special cases can have negative values */ +from_what( + int propidx) /* special cases can have negative values */ { static char buf[BUFSZ]; @@ -939,7 +941,7 @@ from_what(int propidx) /* special cases can have negative values */ else if (innateness == FROM_LYCN) Strcpy(buf, " due to your lycanthropy"); else if (innateness == FROM_FORM) - Strcpy(buf, " from current creature form"); + Strcpy(buf, " from your creature form"); else if (propidx == FAST && Very_fast) Sprintf(buf, because_of, ((HFast & TIMEOUT) != 0L) ? "a potion or spell" diff --git a/src/insight.c b/src/insight.c index 08fd80b6b..2b8bd27b7 100644 --- a/src/insight.c +++ b/src/insight.c @@ -1533,6 +1533,9 @@ attributes_enlightenment( /*** Vision and senses ***/ if ((HBlinded || EBlinded) && BBlinded) /* blind w/ blindness blocked */ you_can("see", from_what(-BLINDED)); /* Eyes of the Overworld */ + if (Blnd_resist && !Blind) /* skip if no eyes or blindfolded */ + you_are("not subject to light-induced blindness", + from_what(BLND_RES)); if (See_invisible) { if (!Blind) enl_msg(You_, "see", "saw", " invisible", from_what(SEE_INVIS)); diff --git a/src/mondata.c b/src/mondata.c index 28da3358a..49a887a80 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -187,7 +187,15 @@ resists_blnd(struct monst *mon) if (dmgtype_fromattack(ptr, AD_BLND, AT_EXPL) || dmgtype_fromattack(ptr, AD_BLND, AT_GAZE)) return TRUE; - return resists_blnd_by_arti(mon); + /* Sunsword */ + if (resists_blnd_by_arti(mon)) + return TRUE; + /* catchall */ + if (is_you && Blnd_resist) { + impossible("'Blnd_resist' but not resists_blnd()?"); + return TRUE; + } + return FALSE; } /* True iff monster is resistant to light-induced blindness due to worn diff --git a/src/polyself.c b/src/polyself.c index 55da8a8d5..9d619f6bb 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -103,6 +103,8 @@ set_uasmon(void) PROPSET(REGENERATION, regenerates(mdat)); PROPSET(REFLECTING, (mdat == &mons[PM_SILVER_DRAGON])); PROPSET(BLINDED, !haseyes(mdat)); + PROPSET(BLND_RES, (dmgtype_fromattack(mdat, AD_BLND, AT_EXPL) + || dmgtype_fromattack(mdat, AD_BLND, AT_GAZE))); #undef PROPSET /* whether the player is flying/floating depends on their steed, diff --git a/src/timeout.c b/src/timeout.c index 13ebb0d4e..8553320bb 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -79,6 +79,7 @@ static const struct propname { { SICK_RES, "sickness resistance" }, { ANTIMAGIC, "magic resistance" }, { HALLUC_RES, "hallucination resistance" }, + { BLND_RES, "light-induced blindness resistance" }, { FUMBLING, "fumbling" }, { HUNGER, "voracious hunger" }, { TELEPAT, "telepathic" },