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

@@ -49,6 +49,7 @@ staticfn void ia_addmenu(winid, int, char, const char *);
staticfn void itemactions_pushkeys(struct obj *, int);
staticfn int itemactions(struct obj *);
staticfn int dispinv_with_action(char *, boolean, const char *);
staticfn struct obj *carrying_cockatrice_corpse(void);
/* enum and structs are defined in wintype.h */
static win_request_info wri_info;
@@ -1231,7 +1232,7 @@ hold_another_object(
obj = addinv_core0(obj, (struct obj *) 0, FALSE);
goto drop_it;
} else if (obj->otyp == CORPSE
&& !u_safe_from_fatal_corpse(obj)
&& !u_safe_from_fatal_corpse(obj, 0xF)
&& obj->wishedfor) {
obj->wishedfor = 0;
obj = addinv_core0(obj, (struct obj *) 0, FALSE);
@@ -1480,6 +1481,18 @@ carrying(int type)
return otmp;
}
/* return inventory object of type that will petrify on touch */
struct obj *
carrying_stoning_corpse(void)
{
struct obj *otmp;
for (otmp = gi.invent; otmp; otmp = otmp->nobj)
if (otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm]))
break;
return otmp;
}
/* Fictional and not-so-fictional currencies.
* http://concord.wikia.com/wiki/List_of_Fictional_Currencies
*/