]> granicus.if.org Git - nethack/commitdiff
breaking iron bars with weapon
authorPatR <rankin@nethack.org>
Sat, 4 Feb 2023 01:01:49 +0000 (17:01 -0800)
committerPatR <rankin@nethack.org>
Sat, 4 Feb 2023 01:01:49 +0000 (17:01 -0800)
For strength over 18, A_CURR(A_STR) can return up to 125, giving
the chance to break bars by hitting them with a warhammer a 50:50
chance.  Switch to acurrstr() which returns at most 25.

Allow heavy iron balls (wielded or thrown, regardless of whether
they're chained to hero) to have a chance to break bars too.  They
are slightly more complicated because they don't use obj->spe like
a weapon but are otherwise straightfoward.

src/mthrowu.c

index 1a40dc3a76730405b3437417fb2d1ec8e07dce33..0207d52e04a77670915c4bb2a6912be9d744bc42 100644 (file)
@@ -1259,8 +1259,17 @@ hit_bars(
         if (!(harmless_missile(otmp) || is_flimsy(otmp)))
             noise = 4 * 4;
 
-        if (your_fault && otmp->otyp == WAR_HAMMER) {
-            int chance = (melee_attk ? 40 : 60) - ACURR(A_STR) - otmp->spe;
+        if (your_fault && (otmp->otyp == WAR_HAMMER
+                           || otmp->otyp == HEAVY_IRON_BALL)) {
+            /* iron ball isn't a weapon or wep-tool so doesn't use obj->spe;
+               weight is normally 480 but can be increased by increments
+               of 160 (scrolls of punishment read while already punished) */
+            int spe = ((otmp->otyp == HEAVY_IRON_BALL) /* 3+ for iron ball */
+                       ? ((int) otmp->owt / IRON_BALL_W_INCR)
+                       : otmp->spe);
+            /* chance: used in saving throw for the bars; more likely to
+               break those when 'chance' is _lower_; acurrstr(): 3..25 */
+            int chance = (melee_attk ? 40 : 60) - acurrstr() - spe;
 
             if (!rn2(max(2, chance))) {
                 You("break the bars apart!");