From e23e6ef235d1c8a6bcb5162e746878a2b6a1d1a9 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 6 Dec 2024 11:09:23 +0200 Subject: [PATCH] Blessed scroll of destroy armor asks which armor to destroy via xNetHack with some slight modifications. --- doc/fixes3-7-0.txt | 1 + include/extern.h | 2 ++ src/do_wear.c | 27 +++++++++++++++++++++++++++ src/read.c | 15 +++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index d4214446c..77ed9ba7a 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1485,6 +1485,7 @@ digging in ice was handled inconsistently, particularly if done at the span spot in front of closed drawbridge angry god may remove an intrinsic blessed scroll of taming increases tameness of already tame creatures +blessed scroll of destroy armor asks which armor to destroy Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index 7de27aee2..c7ccd2856 100644 --- a/include/extern.h +++ b/include/extern.h @@ -732,6 +732,8 @@ extern int remarm_swapwep(void); extern int destroy_arm(struct obj *); extern void adj_abon(struct obj *, schar) NONNULLARG1; extern boolean inaccessible_equipment(struct obj *, const char *, boolean); +extern int any_worn_armor_ok(struct obj *); +extern int count_worn_armor(void); /* ### dog.c ### */ diff --git a/src/do_wear.c b/src/do_wear.c index 1b5b57dfd..289d7d743 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -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*/ diff --git a/src/read.c b/src/read.c index e489ea092..565ce90ea 100644 --- a/src/read.c +++ b/src/read.c @@ -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() */