follow-up related to #1320

This is additional groundwork related to
https://github.com/NetHack/NetHack/issues/1320

This additional groundwork just puts some safeguards
in place to make it rather tough to end up with an
instant death from handling a cockatrice corpse in
your inventory without appropriate protection.

At this point, still no actual petrification will occur.
This commit is contained in:
nhmall
2024-11-09 23:49:10 -05:00
parent a40d85a430
commit 5cc529efc8
6 changed files with 74 additions and 8 deletions

View File

@@ -52,6 +52,7 @@ staticfn int takeoff_ok(struct obj *);
/* maybe_destroy_armor() may return NULL */
staticfn struct obj *maybe_destroy_armor(struct obj *, struct obj *,
boolean *) NONNULLARG3;
staticfn boolean better_not_take_that_off(struct obj *) NONNULLARG1;
/* plural "fingers" or optionally "gloves" */
const char *
@@ -2641,6 +2642,8 @@ select_off(struct obj *otmp)
gloves_simple_name(uarmg));
return 0;
}
if (better_not_take_that_off(otmp))
return 0;
}
/* special boot checks */
if (otmp == uarmf) {
@@ -2886,6 +2889,26 @@ take_off(void)
return 1; /* get busy */
}
staticfn boolean
better_not_take_that_off(struct obj *otmp)
{
struct obj *corpse = carrying_stoning_corpse();
char buf[BUFSZ];
/* u_safe_from_fatal_corpse() with 0x4e instead of 0x6
would also check for no stoning resistance before
bothering to prompt, but losing stoning resistance
later, without the gloves on could prove dangerous,
so we won't factor that in */
if (corpse && !u_safe_from_fatal_corpse(corpse, 0x6)) {
Snprintf(buf, sizeof buf,
"Take off your %s despite carrying a dead %s?",
gloves_simple_name(otmp), obj_pmname(corpse));
return (paranoid_ynq(TRUE, buf, FALSE) != 'y');
}
return FALSE;
}
/* clear saved context to avoid inappropriate resumption of interrupted 'A' */
void
reset_remarm(void)