enlightenment about temp resist and item resist

For timed acid resistance and timed stoning resistance, report
"You {are,were} temporarily {acid,petrification} resistant."

For items being protected by worn equipment, add "by your {armor,&c}"
similar to the existing feeback about you being protected "because
<some-reason>".  Wizard mode only.
This commit is contained in:
PatR
2022-03-28 10:38:04 -07:00
parent e96d4ea9ef
commit 0b42404ad6
3 changed files with 83 additions and 17 deletions

View File

@@ -5014,13 +5014,20 @@ static int
adtyp_to_prop(int dmgtyp)
{
switch (dmgtyp) {
case AD_COLD: return COLD_RES;
case AD_FIRE: return FIRE_RES;
case AD_ELEC: return SHOCK_RES;
case AD_ACID: return ACID_RES;
case AD_DISN: return DISINT_RES;
default: return 0; /* prop_types start at 1 */
case AD_COLD:
return COLD_RES;
case AD_FIRE:
return FIRE_RES;
case AD_ELEC:
return SHOCK_RES;
case AD_ACID:
return ACID_RES;
case AD_DISN:
return DISINT_RES;
default:
break;
}
return 0; /* prop_types start at 1 */
}
/* is hero wearing or wielding an object with resistance
@@ -5039,6 +5046,51 @@ u_adtyp_resistance_obj(int dmgtyp)
return FALSE;
}
/* for enlightenment; currently only useful in wizard mode; cf from_what() */
char *
item_what(int dmgtyp)
{
static char whatbuf[50];
const char *what = 0;
int prop = adtyp_to_prop(dmgtyp);
long xtrinsic = u.uprops[prop].extrinsic;
whatbuf[0] = '\0';
if (wizard) {
if (!prop || !xtrinsic) {
; /* 'what' stays Null */
} else if (xtrinsic & W_ARMC) {
what = cloak_simple_name(uarmc);
} else if (xtrinsic & W_ARM) {
what = suit_simple_name(uarm); /* "dragon {scales,mail}" */
} else if (xtrinsic & W_ARMU) {
what = shirt_simple_name(uarmu);
} else if (xtrinsic & W_ARMH) {
what = helm_simple_name(uarmh);
} else if (xtrinsic & W_ARMG) {
what = gloves_simple_name(uarmg);
} else if (xtrinsic & W_ARMF) {
what = boots_simple_name(uarmf);
} else if (xtrinsic & W_ARMS) {
what = shield_simple_name(uarms);
} else if (xtrinsic & (W_AMUL | W_TOOL)) {
what = simpleonames((xtrinsic & W_AMUL) ? uamul : ublindf);
} else if (xtrinsic & W_RING) {
if ((xtrinsic & W_RING) == W_RING) /* both */
what = "rings";
else
what = simpleonames((xtrinsic & W_RINGL) ? uleft : uright);
} else if (xtrinsic & W_WEP) {
what = simpleonames(uwep);
}
/* format the output to be ready for enl_msg() to append it to
"Your items {are,were} protected against <damage-type>" */
if (what) /* strlen(what) will be less than 30 */
Sprintf(whatbuf, " by your %.40s", what);
}
return whatbuf;
}
/*
* destroy_strings[dindx][0:singular,1:plural,2:killer_reason]
* [0] freezing potion