static void
attributes_enlightenment(int unused_mode UNUSED, int final)
{
- static NEARDATA const char if_surroundings_permitted[] =
- " if surroundings permitted";
+ static NEARDATA const char
+ if_surroundings_permitted[] = " if surroundings permitted";
int ltmp, armpro;
char buf[BUFSZ];
if (Fire_resistance)
you_are("fire resistant", from_what(FIRE_RES));
if (u_adtyp_resistance_obj(AD_FIRE))
- enl_msg("Your items ", "are", "were", " protected from fire", "");
+ enl_msg("Your items ", "are", "were", " protected from fire",
+ item_what(AD_FIRE));
if (Cold_resistance)
you_are("cold resistant", from_what(COLD_RES));
if (u_adtyp_resistance_obj(AD_COLD))
- enl_msg("Your items ", "are", "were", " protected from cold", "");
+ enl_msg("Your items ", "are", "were", " protected from cold",
+ item_what(AD_COLD));
if (Sleep_resistance)
you_are("sleep resistant", from_what(SLEEP_RES));
if (Disint_resistance)
you_are("disintegration-resistant", from_what(DISINT_RES));
if (u_adtyp_resistance_obj(AD_DISN))
- enl_msg("Your items ", "are", "were", " protected from disintegration", "");
+ enl_msg("Your items ", "are", "were",
+ " protected from disintegration", item_what(AD_DISN));
if (Shock_resistance)
you_are("shock resistant", from_what(SHOCK_RES));
if (u_adtyp_resistance_obj(AD_ELEC))
- enl_msg("Your items ", "are", "were", " protected from electric shocks", "");
+ enl_msg("Your items ", "are", "were",
+ " protected from electric shocks", item_what(AD_ELEC));
if (Poison_resistance)
you_are("poison resistant", from_what(POISON_RES));
- if (Acid_resistance)
- you_are("acid resistant", from_what(ACID_RES));
+ if (Acid_resistance) {
+ Sprintf(buf, "%.20s%.30s",
+ temp_resist(ACID_RES) ? "temporarily " : "",
+ "acid resistant");
+ you_are(buf, from_what(ACID_RES));
+ }
if (u_adtyp_resistance_obj(AD_ACID))
- enl_msg("Your items ", "are", "were", " protected from acid", "");
+ enl_msg("Your items ", "are", "were", " protected from acid",
+ item_what(AD_ACID));
if (Drain_resistance)
you_are("level-drain resistant", from_what(DRAIN_RES));
if (Sick_resistance)
you_are("immune to sickness", from_what(SICK_RES));
- if (Stone_resistance)
- you_are("petrification resistant", from_what(STONE_RES));
+ if (Stone_resistance) {
+ Sprintf(buf, "%.20s%.30s",
+ temp_resist(STONE_RES) ? "temporarily " : "",
+ "petrification resistant");
+ you_are(buf, from_what(STONE_RES));
+ }
if (Halluc_resistance)
enl_msg(You_, "resist", "resisted", " hallucinations",
from_what(HALLUC_RES));
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
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