]> granicus.if.org Git - nethack/commitdiff
Tiny chance of breaking iron bars with war hammer
authorPasi Kallinen <paxed@alt.org>
Thu, 26 Jan 2023 16:21:50 +0000 (18:21 +0200)
committerPasi Kallinen <paxed@alt.org>
Thu, 26 Jan 2023 16:21:53 +0000 (18:21 +0200)
Also add some different sounds to hitting the iron bars,
and make it noisy.

doc/fixes3-7-0.txt
include/extern.h
include/hack.h
src/dothrow.c
src/hack.c
src/mthrowu.c

index 167e34fbc37ca1a0dfe24bad07b406425197ef30..1915cd325c5f040863aae7e52c590efebef89794 100644 (file)
@@ -1100,6 +1100,7 @@ kicking a headstone might summon a ghoul
 eating garlic makes nearby monsters flee
 giants occasionally get a battle axe or a two-handed sword
 give gremlin the property it stole, if possible
+'F'orcefighting with a war hammer has a small chance of breaking iron bars
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index bfa8e36171951a16da0b49f8f6465d9748b9c98b..b954e4662c1853c0ba46392582e26e243c56e6c2 100644 (file)
@@ -643,6 +643,7 @@ extern void endmultishot(boolean);
 extern void hitfloor(struct obj *, boolean);
 extern void hurtle(int, int, int, boolean);
 extern void mhurtle(struct monst *, int, int, int);
+extern boolean harmless_missile(struct obj *);
 extern boolean throwing_weapon(struct obj *);
 extern void throwit(struct obj *, long, boolean, struct obj *);
 extern int omon_adj(struct monst *, struct obj *, boolean);
index bc86fc616853c9616f672a9f7bad36ac1acf35ca..327849ac5513de2eca0cfe69e8c53983d67c4674 100644 (file)
@@ -595,11 +595,12 @@ enum bodypart_types {
 /* flags for hero_breaks() and hits_bars(); BRK_KNOWN* let callers who have
    already called breaktest() prevent it from being called again since it
    has a random factor which makes it be non-deterministic */
-#define BRK_BY_HERO        1
-#define BRK_FROM_INV       2
-#define BRK_KNOWN2BREAK    4
-#define BRK_KNOWN2NOTBREAK 8
+#define BRK_BY_HERO        0x01
+#define BRK_FROM_INV       0x02
+#define BRK_KNOWN2BREAK    0x04
+#define BRK_KNOWN2NOTBREAK 0x08
 #define BRK_KNOWN_OUTCOME  (BRK_KNOWN2BREAK | BRK_KNOWN2NOTBREAK)
+#define BRK_MELEE          0x10
 
 /* extended command return values */
 #define ECMD_OK     0x00 /* cmd done successfully */
index 84b16e09973255df7cc7d22d216ac26ff309b226..528db90396091f352d01f2d7c34d464e22f5dd03 100644 (file)
@@ -13,7 +13,6 @@ static int throw_ok(struct obj *);
 static void autoquiver(void);
 static struct obj *find_launcher(struct obj *);
 static int gem_accept(struct monst *, struct obj *);
-static boolean harmless_missile(struct obj *);
 static boolean toss_up(struct obj *, boolean);
 static void sho_obj_return_to_u(struct obj * obj);
 static struct obj *return_throw_to_inv(struct obj *, long, boolean,
@@ -1184,7 +1183,7 @@ check_shop_obj(struct obj *obj, coordxy x, coordxy y, boolean broken)
 /* Will 'obj' cause damage if it falls on hero's head when thrown upward?
    Not used to handle things which break when they hit.
    Stone missile hitting hero w/ Passes_walls attribute handled separately. */
-static boolean
+boolean
 harmless_missile(struct obj *obj)
 {
     int otyp = obj->otyp;
index 30cd2f7ec49528f3a4e7c032b364a40303eda9c5..bdf85aea1ac3308b534ebae6e2f326eaf31b7773 100644 (file)
@@ -1755,7 +1755,7 @@ domove_fight_ironbars(coordxy x, coordxy y)
 {
     if (gc.context.forcefight && levl[x][y].typ == IRONBARS && uwep) {
         struct obj *obj = uwep;
-        unsigned breakflags = (BRK_BY_HERO | BRK_FROM_INV);
+        unsigned breakflags = (BRK_BY_HERO | BRK_FROM_INV | BRK_MELEE);
 
         if (breaktest(obj)) {
             if (obj->quan > 1L)
index 2f664b8691ff67191f8de3ac53c77d4be528ae5c..a5f745b4e258e4fe4959d0400b3d2ff3966035f2 100644 (file)
@@ -1213,7 +1213,9 @@ hit_bars(
     struct obj *otmp = *objp;
     int obj_type = otmp->otyp;
     boolean nodissolve = (levl[barsx][barsy].wall_info & W_NONDIGGABLE) != 0,
-            your_fault = (breakflags & BRK_BY_HERO) != 0;
+            your_fault = (breakflags & BRK_BY_HERO) != 0,
+            melee_attk = (breakflags & BRK_MELEE) != 0;
+    int noise = 0;
 
     if (your_fault
         ? hero_breaks(otmp, objx, objy, breakflags)
@@ -1235,11 +1237,29 @@ hit_bars(
         if (!Deaf)
             pline("%s!", (obj_type == BOULDER || obj_type == HEAVY_IRON_BALL)
                          ? "Whang"
+                         : harmless_missile(otmp) ? "Whap"
+                         : is_flimsy(otmp) ? "Flapp"
                          : (otmp->oclass == COIN_CLASS
                             || objects[obj_type].oc_material == GOLD
                             || objects[obj_type].oc_material == SILVER)
                            ? "Clink"
                            : "Clonk");
+
+        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 (!rn2(max(2, chance))) {
+                You("break the bars apart!");
+                dissolve_bars(barsx, barsy);
+                noise = noise * 2;
+            }
+        }
+
+        if (noise)
+            wake_nearto(barsx, barsy, noise);
     }
 }