Blessed scroll of destroy armor asks which armor to destroy

via xNetHack with some slight modifications.
This commit is contained in:
Pasi Kallinen
2024-12-06 11:09:23 +02:00
parent 9b4f38eebe
commit e23e6ef235
4 changed files with 45 additions and 0 deletions

View File

@@ -3367,4 +3367,31 @@ takeoff_ok(struct obj *obj)
return equip_ok(obj, TRUE, FALSE);
}
/* getobj callback for blessed destroy armor.
suggest any worn armor, even if covered by other armor */
int
any_worn_armor_ok(struct obj *obj)
{
if (obj && (obj->owornmask & W_ARMOR))
return GETOBJ_SUGGEST;
return GETOBJ_EXCLUDE;
}
/* number of armor pieces worn by hero */
int
count_worn_armor(void)
{
int ret = 0;
if (uarm) ret++;
if (uarmc) ret++;
if (uarmh) ret++;
if (uarms) ret++;
if (uarmg) ret++;
if (uarmf) ret++;
if (uarmu) ret++;
return ret;
}
/*do_wear.c*/

View File

@@ -1279,6 +1279,21 @@ seffect_destroy_armor(struct obj **sobjp)
return;
}
if (!scursed || !otmp || !otmp->cursed) {
boolean gets_choice = (otmp && sobj && sobj->blessed
&& count_worn_armor() > 1);
if (gets_choice) {
struct obj *atmp;
if (!objects[sobj->otyp].oc_name_known)
pline("This is %s!", an(actualoname(sobj)));
gk.known = TRUE;
atmp = getobj("destroy", any_worn_armor_ok, GETOBJ_PROMPT);
/* check the return value, if user picked non-valid obj */
if (any_worn_armor_ok(atmp) == GETOBJ_SUGGEST)
otmp = atmp;
}
if (!destroy_arm(otmp)) {
strange_feeling(sobj, "Your skin itches.");
*sobjp = 0; /* useup() in strange_feeling() */